Skip to content

Commit bb31f5e

Browse files
committed
Fix getAmbientTempF(), get raw event for AHT20 test
1 parent aa8ef67 commit bb31f5e

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/components/i2c/drivers/drvBase.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#ifndef DRV_BASE_H
1717
#define DRV_BASE_H
18-
18+
#include "Wippersnapper_V2.h"
1919
#include <Adafruit_Sensor.h>
2020
#include <Arduino.h>
2121
#include <protos/i2c.pb.h>
@@ -473,8 +473,9 @@ class drvBase {
473473
/*******************************************************************************/
474474
virtual bool getEventAmbientTempF(sensors_event_t *AmbientTempFEvent) {
475475
// obtain ambient temp. in °C
476-
if (!getEventAmbientTemp(AmbientTempFEvent))
476+
if (!getEventAmbientTemp(AmbientTempFEvent)) {
477477
return false;
478+
}
478479
// convert event from °C to °F
479480
AmbientTempFEvent->temperature =
480481
(AmbientTempFEvent->temperature * 9.0) / 5.0 + 32;

src/components/i2c/model.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,18 @@ float GetValueFromSensorsEvent(wippersnapper_sensor_SensorType sensor_type,
160160
case wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE:
161161
value = event->temperature;
162162
break;
163+
case wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT:
164+
value = event->temperature;
165+
break;
163166
case wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE:
164167
value = event->temperature;
165168
break;
169+
case wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT:
170+
value = event->temperature;
171+
break;
172+
case wippersnapper_sensor_SensorType_SENSOR_TYPE_RAW:
173+
value = event->data[0];
174+
break;
166175
case wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY:
167176
value = event->relative_humidity;
168177
break;

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ void ws_sdcard::CheckIn(uint8_t max_digital_pins, uint8_t max_analog_pins,
208208
WsV2.analogio_controller->SetRefVoltage(ref_voltage);
209209
}
210210

211-
// TODO: This could be a switch/map/or something mucccch cleaner...
212211
/**************************************************************************/
213212
/*!
214213
@brief Parses a sensor type from the JSON configuration file.
@@ -226,16 +225,12 @@ ws_sdcard::ParseSensorType(const char *sensor_type) {
226225
} else if (strcmp(sensor_type, "current") == 0) {
227226
return wippersnapper_sensor_SensorType_SENSOR_TYPE_CURRENT;
228227
} else if (strcmp(sensor_type, "object-temp-fahrenheit") == 0) {
229-
WS_DEBUG_PRINTLN("Found object-temp-fahrenheit");
230228
return wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT;
231229
} else if (strcmp(sensor_type, "object-temp") == 0) {
232-
WS_DEBUG_PRINTLN("Found object-temp");
233230
return wippersnapper_sensor_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE;
234231
} else if (strcmp(sensor_type, "ambient-temp") == 0) {
235-
WS_DEBUG_PRINTLN("Found ambient temp");
236232
return wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE;
237233
} else if (strcmp(sensor_type, "ambient-temp-fahrenheit") == 0) {
238-
WS_DEBUG_PRINTLN("Found ambient temp fahrenheit");
239234
return wippersnapper_sensor_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT;
240235
} else if (strcmp(sensor_type, "accelerometer") == 0) {
241236
return wippersnapper_sensor_SensorType_SENSOR_TYPE_ACCELEROMETER;
@@ -252,13 +247,10 @@ ws_sdcard::ParseSensorType(const char *sensor_type) {
252247
} else if (strcmp(sensor_type, "rotation-vector") == 0) {
253248
return wippersnapper_sensor_SensorType_SENSOR_TYPE_ROTATION_VECTOR;
254249
} else if (strcmp(sensor_type, "altitude") == 0) {
255-
WS_DEBUG_PRINTLN("Found altitude");
256250
return wippersnapper_sensor_SensorType_SENSOR_TYPE_ALTITUDE;
257-
} else if (strcmp(sensor_type, "humidity") == 0) {
258-
WS_DEBUG_PRINTLN("Found humidity");
251+
} else if (strcmp(sensor_type, "relative-humidity") == 0) {
259252
return wippersnapper_sensor_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY;
260253
} else if (strcmp(sensor_type, "pressure") == 0) {
261-
WS_DEBUG_PRINTLN("Found pressure");
262254
return wippersnapper_sensor_SensorType_SENSOR_TYPE_PRESSURE;
263255
} else if (strcmp(sensor_type, "light") == 0) {
264256
return wippersnapper_sensor_SensorType_SENSOR_TYPE_LIGHT;

0 commit comments

Comments
 (0)