Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scd4x 3x issue #658

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ build_flags = -DARDUINO_METRO_ESP32S3 -DBOARD_HAS_PSRAM
board_build.partitions = tinyuf2-partitions-16MB.csv
extra_scripts = pre:rename_usb_config.py

; Adafruit Metro ESP32-S3
[env:adafruit_metro_esp32s3_debug]
extends = common:esp32
board = adafruit_metro_esp32s3
build_type = debug
build_flags = -DARDUINO_METRO_ESP32S3 -DBOARD_HAS_PSRAM -DCFG_TUSB_DEBUG=1 -DDEBUG=1 -DESP_LOG_LEVEL=ESP_LOG_VERBOSE -DARDUINO_CORE_DEBUG_LEVEL=5 -DCORE_DEBUG_LEVEL=5 -DARDUHAL_LOG_LEVEL=5 -DARDUINO_USB_CDC_ON_BOOT=1
;set partition to tinyuf2-partitions-16MB.csv as of idf 5.1
board_build.partitions = tinyuf2-partitions-16MB.csv
extra_scripts = pre:rename_usb_config.py

; Adafruit Funhouse ESP32-S2
[env:adafruit_funhouse_esp32s2]
extends = common:esp32
Expand Down
10 changes: 6 additions & 4 deletions src/components/i2c/WipperSnapper_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
WS_DEBUG_PRINTLN("VEML7700 Initialized Successfully!");
} else if (strcmp("scd40", msgDeviceInitReq->i2c_device_name) == 0) {
_scd40 = new WipperSnapper_I2C_Driver_SCD4X(this->_i2c, i2cAddress);
if (!_scd40->begin()) {
if (!_scd40->begin(
msgDeviceInitReq->i2c_device_properties[0].sensor_period)) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize SCD4x!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
Expand Down Expand Up @@ -1328,16 +1329,17 @@ void WipperSnapper_Component_I2C::sensorEventRead(
unsigned long curTime, wippersnapper_signal_v1_I2CResponse *msgi2cResponse,
bool (WipperSnapper_I2C_Driver::*getEventFunc)(sensors_event_t *),
long (WipperSnapper_I2C_Driver::*getPeriodFunc)(),
long (WipperSnapper_I2C_Driver::*getPeriodPrvFunc)(),
void (WipperSnapper_I2C_Driver::*setPeriodPrvFunc)(long),
ulong (WipperSnapper_I2C_Driver::*getPeriodPrvFunc)(),
void (WipperSnapper_I2C_Driver::*setPeriodPrvFunc)(ulong),
wippersnapper_i2c_v1_SensorType sensorType, const char *sensorName,
const char *unit, sensors_event_t event,
float sensors_event_t::*valueMember, bool &sensorsReturningFalse,
int &retries) {
// sensorName used for prefix + error message, units is value suffix
curTime = millis();
if (((*iter)->*getPeriodFunc)() != 0L &&
curTime - ((*iter)->*getPeriodPrvFunc)() > ((*iter)->*getPeriodFunc)()) {
curTime - ((*iter)->*getPeriodPrvFunc)() >
(ulong)((*iter)->*getPeriodFunc)()) {
// within the period, read the sensor
if (((*iter)->*getEventFunc)(&event)) {
float value;
Expand Down
4 changes: 2 additions & 2 deletions src/components/i2c/WipperSnapper_I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class WipperSnapper_Component_I2C {
wippersnapper_signal_v1_I2CResponse *msgi2cResponse,
bool (WipperSnapper_I2C_Driver::*getEventFunc)(sensors_event_t *),
long (WipperSnapper_I2C_Driver::*getPeriodFunc)(),
long (WipperSnapper_I2C_Driver::*getPeriodPrvFunc)(),
void (WipperSnapper_I2C_Driver::*setPeriodPrvFunc)(long),
ulong (WipperSnapper_I2C_Driver::*getPeriodPrvFunc)(),
void (WipperSnapper_I2C_Driver::*setPeriodPrvFunc)(ulong),
wippersnapper_i2c_v1_SensorType sensorType, const char *sensorName,
const char *unit, sensors_event_t event,
float sensors_event_t::*valueMember, bool &sensorsReturningFalse,
Expand Down
Loading