From da1a49f0e9be05fc243e79fdb0953f26fae06339 Mon Sep 17 00:00:00 2001 From: unlogisch04 <98281608+unlogisch04@users.noreply.github.com> Date: Sun, 12 Nov 2023 02:45:41 +0100 Subject: [PATCH] Fix ICM20948 PacketBundling and LastData The delay in sendData() makes at somepoint that the packetbundling does not work correctly. The ICM works without delay on ESP8266, ESP32-C3, ESP32-S2 Also added the LastData Flag for get info --- src/sensors/icm20948sensor.cpp | 6 +++--- src/sensors/icm20948sensor.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sensors/icm20948sensor.cpp b/src/sensors/icm20948sensor.cpp index 9e60914d8..83c42db90 100644 --- a/src/sensors/icm20948sensor.cpp +++ b/src/sensors/icm20948sensor.cpp @@ -79,7 +79,7 @@ void ICM20948Sensor::motionLoop() cntbuf = 0; cntrounds = 0; } -*/ +*/ } void ICM20948Sensor::readFIFOToEnd() @@ -104,9 +104,8 @@ void ICM20948Sensor::readFIFOToEnd() void ICM20948Sensor::sendData() { - if(newFusedRotation && lastDataSent + 7 < millis()) + if(newFusedRotation) { - lastDataSent = millis(); newFusedRotation = false; #if(USE_6_AXIS) @@ -320,6 +319,7 @@ void ICM20948Sensor::startMotionLoop() { lastData = millis(); working = true; + hadData = true; } void ICM20948Sensor::checkSensorTimeout() diff --git a/src/sensors/icm20948sensor.h b/src/sensors/icm20948sensor.h index ca116ba21..f422db06c 100644 --- a/src/sensors/icm20948sensor.h +++ b/src/sensors/icm20948sensor.h @@ -45,7 +45,6 @@ class ICM20948Sensor : public Sensor private: void calculateAccelerationWithoutGravity(Quat *quaternion); unsigned long lastData = 0; - unsigned long lastDataSent = 0; int bias_save_counter = 0; bool hasdata = false; // Performance test