From 973d2e3e25329e838088241c17c2880021960479 Mon Sep 17 00:00:00 2001 From: tyeth Date: Fri, 18 Oct 2024 18:25:16 +0100 Subject: [PATCH] Cleanup + log thresholds --- src/components/analogIO/Wippersnapper_AnalogIO.cpp | 14 ++++++++++---- src/components/analogIO/Wippersnapper_AnalogIO.h | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/analogIO/Wippersnapper_AnalogIO.cpp b/src/components/analogIO/Wippersnapper_AnalogIO.cpp index a7e072c9..86de51aa 100644 --- a/src/components/analogIO/Wippersnapper_AnalogIO.cpp +++ b/src/components/analogIO/Wippersnapper_AnalogIO.cpp @@ -424,12 +424,18 @@ void Wippersnapper_AnalogIO::update() { uint16_t pinValRaw = getPinValue(_analog_input_pins[i].pinName); // check if pin value has changed enough - uint16_t _pinValThreshHi, _pinValThreshLow; - calculateHysteresis(_analog_input_pins[i], pinValRaw, _pinValThreshHi, - _pinValThreshLow); + uint16_t pinValThreshHi, pinValThreshLow; + calculateHysteresis(_analog_input_pins[i], pinValRaw, pinValThreshHi, + pinValThreshLow); + WS_DEBUG_PRINT("Returned pinValThreshHi: "); + WS_DEBUG_PRINTLN(pinValThreshHi); + WS_DEBUG_PRINT("Returned pinValThreshLow: "); + WS_DEBUG_PRINTLN(pinValThreshLow); + WS_DEBUG_PRINT("Current pinValRaw: "); + WS_DEBUG_PRINTLN(pinValRaw); if (_analog_input_pins[i].prvPeriod == 0 || - pinValRaw > _pinValThreshHi || pinValRaw < _pinValThreshLow) { + pinValRaw > pinValThreshHi || pinValRaw < pinValThreshLow) { // Perform voltage conversion if we need to if (_analog_input_pins[i].readMode == wippersnapper_pin_v1_ConfigurePinRequest_AnalogReadMode_ANALOG_READ_MODE_PIN_VOLTAGE) { diff --git a/src/components/analogIO/Wippersnapper_AnalogIO.h b/src/components/analogIO/Wippersnapper_AnalogIO.h index 659e3e57..8ad0e31d 100644 --- a/src/components/analogIO/Wippersnapper_AnalogIO.h +++ b/src/components/analogIO/Wippersnapper_AnalogIO.h @@ -58,7 +58,7 @@ class Wippersnapper_AnalogIO { void disableAnalogInPin(int pin); void calculateHysteresis(analogInputPin pin, uint16_t pinValRaw, - uint16_t &_pinValThreshHi, uint16_t &_pinValThreshLow); + uint16_t pinValThreshHi, uint16_t pinValThreshLow); uint16_t getPinValue(int pin); float getPinValueVolts(int pin);