Skip to content

Commit

Permalink
Refactor sensorsReturningFalse to existing no events block
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Jun 12, 2024
1 parent d73d034 commit 1af3128
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to get ambient temperature sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorAmbientTempPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1049,7 +1048,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to obtain ambient temp. (°F)) sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorAmbientTempFPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1078,7 +1076,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to get object temperature sensor (°C) reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorObjectTempPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1107,7 +1104,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to get object temperature sensor (°F) reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorObjectTempFPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1159,7 +1155,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorPressurePeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get Pressure sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorPressurePeriodPrv(curTime);
}
Expand All @@ -1184,7 +1179,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorCO2PeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain CO2 sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorCO2PeriodPrv(curTime);
}
Expand All @@ -1209,7 +1203,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorECO2PeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain eCO2 sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorECO2PeriodPrv(curTime);
}
Expand All @@ -1234,7 +1227,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorTVOCPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain TVOC sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorTVOCPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1262,7 +1254,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorAltitudePeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get altitude sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorAltitudePeriodPrv(curTime);
}
Expand All @@ -1289,7 +1280,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorLightPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get light sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorLightPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1317,7 +1307,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorPM10_STDPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get PM1.0 sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorPM10_STDPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1345,7 +1334,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorPM25_STDPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get PM2.5 sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorPM25_STDPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1373,7 +1361,6 @@ void WipperSnapper_Component_I2C::update() {
curTime); // try again in curTime seconds
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get PM10.0 sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorPM100_STDPeriodPrv(curTime);
}
Expand All @@ -1400,7 +1387,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorVoltagePeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get voltage sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorVoltagePeriodPrv(curTime);
}
Expand All @@ -1427,7 +1413,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorCurrentPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get Current sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorCurrentPeriodPrv(curTime);
}
Expand Down Expand Up @@ -1456,7 +1441,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to get unitless percent sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorUnitlessPercentPeriodPrv(curTime);
}
Expand All @@ -1480,7 +1464,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorRawPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain Raw sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorRawPeriodPrv(curTime);
}
Expand All @@ -1507,7 +1490,6 @@ void WipperSnapper_Component_I2C::update() {
} else {
WS_DEBUG_PRINTLN(
"ERROR: Failed to obtain gas resistance sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorGasResistancePeriodPrv(curTime);
}
Expand All @@ -1532,7 +1514,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorNOxIndexPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain NOx index sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorNOxIndexPeriodPrv(curTime);
}
Expand All @@ -1557,7 +1538,6 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorVOCIndexPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to obtain VOC index sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorVOCIndexPeriodPrv(curTime);
}
Expand All @@ -1584,16 +1564,18 @@ void WipperSnapper_Component_I2C::update() {
(*iter)->setSensorProximityPeriodPrv(curTime);
} else {
WS_DEBUG_PRINTLN("ERROR: Failed to get proximity sensor reading!");
sensorsReturningFalse = true;
if (retries == 1) {
(*iter)->setSensorProximityPeriodPrv(curTime);
}
}
}

// Did this driver obtain data from sensors?
if (msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count == 0)
if (msgi2cResponse.payload.resp_i2c_device_event.sensor_event_count ==
0) {
sensorsReturningFalse = true;
continue;
}

displayDeviceEventMessage(&msgi2cResponse, (*iter)->getI2CAddress());

Expand Down

0 comments on commit 1af3128

Please sign in to comment.