Skip to content

Commit

Permalink
Cleanup + log thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Oct 21, 2024
1 parent cce8fa0 commit 5383f98
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/components/analogIO/Wippersnapper_AnalogIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/analogIO/Wippersnapper_AnalogIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5383f98

Please sign in to comment.