Skip to content

Commit 059ef8e

Browse files
committed
define value before if branches
1 parent e0fd181 commit 059ef8e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/i2c/WipperSnapper_I2C.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,11 +1251,12 @@ void WipperSnapper_Component_I2C::sensorEventRead(
12511251
curTime - ((*iter)->*getPeriodPrvFunc)() > ((*iter)->*getPeriodFunc)()) {
12521252
// within the period, read the sensor
12531253
if (((*iter)->*getEventFunc)(&event)) {
1254+
float value;
12541255
if (sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RAW ||
12551256
sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PROXIMITY) {
1256-
float value = event.data[0];
1257+
value = event.data[0];
12571258
} else {
1258-
float value = event.*valueMember;
1259+
value = event.*valueMember;
12591260
}
12601261
WS_DEBUG_PRINT("Sensor 0x");
12611262
WS_DEBUG_PRINTHEX((*iter)->getI2CAddress());

0 commit comments

Comments
 (0)