@@ -1206,7 +1206,7 @@ void WipperSnapper_Component_I2C::update() {
1206
1206
wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_VOC_INDEX,
1207
1207
" VOC Index" , " " , event, &sensors_event_t ::voc_index, sensorsReturningFalse, retries);
1208
1208
1209
- // Proximity sensor
1209
+ // Proximity sensor -- sends using event.data[0] same as raw sensor_type
1210
1210
sensorEventRead (iter, curTime, &msgi2cResponse,
1211
1211
&WipperSnapper_I2C_Driver::getEventProximity,
1212
1212
&WipperSnapper_I2C_Driver::sensorProximityPeriod,
@@ -1249,23 +1249,25 @@ void WipperSnapper_Component_I2C::sensorEventRead(
1249
1249
curTime = millis ();
1250
1250
if (((*iter)->*getPeriodFunc)() != 0L &&
1251
1251
curTime - ((*iter)->*getPeriodPrvFunc)() > ((*iter)->*getPeriodFunc)()) {
1252
+ // within the period, read the sensor
1252
1253
if (((*iter)->*getEventFunc)(&event)) {
1254
+ if (sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RAW ||
1255
+ sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PROXIMITY) {
1256
+ float value = event.data [0 ];
1257
+ } else {
1258
+ float value = event.*valueMember;
1259
+ }
1253
1260
WS_DEBUG_PRINT (" Sensor 0x" );
1254
1261
WS_DEBUG_PRINTHEX ((*iter)->getI2CAddress ());
1255
1262
WS_DEBUG_PRINTLN (" " );
1256
1263
WS_DEBUG_PRINT (" \t " );
1257
1264
WS_DEBUG_PRINT (sensorName);
1258
1265
WS_DEBUG_PRINT (" : " );
1259
- WS_DEBUG_PRINT (event.*valueMember );
1266
+ WS_DEBUG_PRINT (value );
1260
1267
WS_DEBUG_PRINTLN (unit);
1261
1268
1262
1269
// pack event data into msg
1263
- if (sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RAW ||
1264
- sensorType == wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PROXIMITY) {
1265
- fillEventMessage (msgi2cResponse, event.data [0 ], sensorType);
1266
- } else {
1267
- fillEventMessage (msgi2cResponse, event.*valueMember, sensorType);
1268
- }
1270
+ fillEventMessage (msgi2cResponse, value, sensorType);
1269
1271
1270
1272
((*iter)->*setPeriodPrvFunc)(curTime);
1271
1273
} else {
0 commit comments