Skip to content

Commit

Permalink
Use millis instead of micros
Browse files Browse the repository at this point in the history
  • Loading branch information
pembem22 committed Jan 19, 2025
1 parent 6a535a6 commit a1b55a5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/sensors/softfusion/softfusionsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ class SoftFusionSensor : public Sensor {
~SoftFusionSensor() {}

void checkSensorTimeout() {
uint32_t now = micros();
constexpr uint32_t sensorTimeoutMicros = 2e6; // 2 seconds
if (m_lastRotationUpdate + sensorTimeoutMicros > now) {
uint32_t now = millis();
constexpr uint32_t sensorTimeoutMillis = 2e3; // 2 seconds
if (m_lastRotationUpdateMillis + sensorTimeoutMillis > now) {
return;
}

Expand All @@ -211,7 +211,7 @@ class SoftFusionSensor : public Sensor {
m_Logger.error(
"Sensor timeout I2C Address 0x%02x delaytime: %d ms",
addr,
now - m_lastRotationUpdate
now - m_lastRotationUpdateMillis
);
networkConnection.sendSensorError(
this->sensorId,
Expand Down Expand Up @@ -242,7 +242,7 @@ class SoftFusionSensor : public Sensor {
return;
}
hadData = true;
m_lastRotationUpdate = now;
m_lastRotationUpdateMillis = millis();
m_fusion.clearUpdated();
}

Expand Down Expand Up @@ -637,7 +637,7 @@ class SoftFusionSensor : public Sensor {

SensorStatus m_status = SensorStatus::SENSOR_OFFLINE;
uint32_t m_lastPollTime = micros();
uint32_t m_lastRotationUpdate = 0;
uint32_t m_lastRotationUpdateMillis = 0;
uint32_t m_lastRotationPacketSent = 0;
uint32_t m_lastTemperaturePacketSent = 0;
};
Expand Down

0 comments on commit a1b55a5

Please sign in to comment.