Skip to content

Commit 50cfba4

Browse files
committed
WIP: tweak log10 logic
1 parent f837709 commit 50cfba4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,15 @@ void Wippersnapper_AnalogIO::update() {
392392
// pin value
393393
uint16_t pinValRaw = getPinValue(_analog_input_pins[i].pinName);
394394
WS_DEBUG_PRINT(F("PinValRaw: "));
395-
WS_DEBUG_PRINTLN(pinValRaw);
395+
WS_DEBUG_PRINT(pinValRaw);
396396

397-
double currentLogValue = log10(pinValRaw + 1); // +1 to avoid log(0)
397+
// +1 to avoid log(0), 0-8 is fluctuation about 0, log(8) = 0.9, hysterisys=0.04
398+
double currentLogValue = log10(pinValRaw + 10);
398399
double lastLogValue =
399-
log10(_analog_input_pins[i].prvPinVal + 1); // +1 to avoid log(0)
400-
WS_DEBUG_PRINT(F("CurrentLogValue: "));
401-
WS_DEBUG_PRINTLN(currentLogValue);
402-
WS_DEBUG_PRINT(F("LastLogValue: "));
400+
log10(_analog_input_pins[i].prvPinVal + 10); // +1 to avoid log(0)
401+
WS_DEBUG_PRINT(F("\tCurrentLogValue: "));
402+
WS_DEBUG_PRINT(currentLogValue);
403+
WS_DEBUG_PRINT(F("\tLastLogValue: "));
403404
WS_DEBUG_PRINTLN(lastLogValue);
404405
bool passed_hysterisys = false;
405406
// Check if the logarithmic change exceeds the threshold

0 commit comments

Comments
 (0)