diff --git a/examples/04_Dual_I2C_SingleShot/i2c_interface_soft.h b/examples/04_Dual_I2C_SingleShot/i2c_interface_soft.h index 07e63d1..7fa4449 100644 --- a/examples/04_Dual_I2C_SingleShot/i2c_interface_soft.h +++ b/examples/04_Dual_I2C_SingleShot/i2c_interface_soft.h @@ -77,8 +77,9 @@ ENS220::Result I2cInterface::write(const ENS220::RegisterAddress& address, uint8 if( softI2C->i2c_start((slaveAddress<<1)|I2C_WRITE) ) { + int size_int = (int)size; softI2C->i2c_write((uint8_t)address); // send desired register to device - for( int i=0; ii2c_write(data[i]); // send data } diff --git a/examples/05_Event_Detection/05_Event_Detection.ino b/examples/05_Event_Detection/05_Event_Detection.ino index 36f7755..033f6b7 100644 --- a/examples/05_Event_Detection/05_Event_Detection.ino +++ b/examples/05_Event_Detection/05_Event_Detection.ino @@ -135,10 +135,6 @@ void detect_events(float p, float t, float m, float d, float alpha) { } } - - - - void setup() { pinMode(OPTIONAL_LED_PIN, OUTPUT); @@ -160,7 +156,7 @@ void setup() result = ens220.update(); } first_pressure_Pa = ens220.getPressurePascal(); - state = {.first_event_detected = 1, .norm=1, .mean_absolute_deviation=2.0, .p_1=first_pressure_Pa, .t_1=relative_time_ms/1000.}; + state = {.event_detected=0, .first_event_lower_than_threshold=0, .first_event_detected=1, .norm=1, .average = 0, .mean_absolute_deviation=2.0, .p_1=first_pressure_Pa, .t_1=relative_time_ms/1000.}; } @@ -201,12 +197,10 @@ void ens220_setup() ens220.startContinuousMeasure(ENS220::Sensor::Pressure); } - - void loop() { - while ((millis()-last_readout_time_ms) >= (target_sampling_interval_ms)) { + while ((((int)millis())-last_readout_time_ms) >= (target_sampling_interval_ms)) { // Check the DATA_STAT from the sensor. Read data, if available relative_time_ms = millis(); diff --git a/examples/06_Fall_Detection/06_Fall_Detection.ino b/examples/06_Fall_Detection/06_Fall_Detection.ino index c5dfb86..43d18a8 100644 --- a/examples/06_Fall_Detection/06_Fall_Detection.ino +++ b/examples/06_Fall_Detection/06_Fall_Detection.ino @@ -42,7 +42,7 @@ AlgorithmConstants algorithm_constants; // Algorithm constants struct // Global variables float latestPressure = 0; float latestTemp = 0; -uint32_t maximum_fall_pressure_peak_raw = 0; +int32_t maximum_fall_pressure_peak_raw = 0; float conversion_pa_to_m = 0; unsigned long current_ms = 0; @@ -101,7 +101,7 @@ void loop() { ContinuousModeWithFIFO_loop(meas_buffer); - uint32_t measured_drop_height_raw = 0; + int32_t measured_drop_height_raw = 0; unsigned long data_collection_finished = millis(); unsigned long curr_time = data_collection_finished - (ENS220_BUFFERSIZE-1) * t_individual_meas_ms; diff --git a/examples/06_Fall_Detection/DropAlgorithm.h b/examples/06_Fall_Detection/DropAlgorithm.h index c741b67..46900c8 100644 --- a/examples/06_Fall_Detection/DropAlgorithm.h +++ b/examples/06_Fall_Detection/DropAlgorithm.h @@ -17,7 +17,7 @@ typedef struct { int32_t index_window; int32_t drop_count; double last_baseline_update; - double spike_height; + int32_t spike_height; double spike_duration; } DropDetectionState;