Skip to content

Commit

Permalink
Early return, use constexpr
Browse files Browse the repository at this point in the history
  • Loading branch information
pembem22 committed Jan 13, 2025
1 parent bd987c3 commit 2c01aad
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/sensors/softfusion/softfusionsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,19 @@ class SoftFusionSensor : public Sensor {

void checkSensorTimeout() {
uint32_t now = micros();
if (m_lastRotationUpdate + 2_000_000 < now) {
working = false;
m_status = SensorStatus::SENSOR_ERROR;
m_Logger.error(
"Sensor timeout I2C Address 0x%02x delaytime: %d ms",
addr,
now - m_lastRotationUpdate
);
networkConnection.sendSensorError(this->sensorId, 1);
constexpr uint32_t sensorTimeoutMicros = 2e6; // 2 seconds
if (m_lastRotationUpdate + sensorTimeoutMicros > now) {
return;
}

working = false;
m_status = SensorStatus::SENSOR_ERROR;
m_Logger.error(
"Sensor timeout I2C Address 0x%02x delaytime: %d ms",
addr,
now - m_lastRotationUpdate
);
networkConnection.sendSensorError(this->sensorId, 1);
}

void motionLoop() override final {
Expand Down

0 comments on commit 2c01aad

Please sign in to comment.