We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 76824e5 commit 12f78b8Copy full SHA for 12f78b8
src/firmware/application/io/analog/Filter.h
@@ -54,20 +54,28 @@ namespace io
54
// avoid filtering in this case for faster response
55
if (descriptor.type == Analog::type_t::BUTTON)
56
{
57
+ bool newValue = _lastStableValue[index];
58
+
59
if (descriptor.value < _adcConfig.DIGITAL_VALUE_THRESHOLD_OFF)
60
- descriptor.value = 1;
61
+ newValue = true;
62
}
63
else if (descriptor.value > _adcConfig.DIGITAL_VALUE_THRESHOLD_ON)
64
- descriptor.value = 0;
65
+ newValue = false;
66
67
else
68
69
+ return false;
70
+ }
71
72
+ if (newValue != _lastStableValue[index])
73
+ {
74
+ _lastStableValue[index] = newValue;
75
+ return true;
76
77
- return true;
78
79
80
81
const bool FAST_FILTER = (core::mcu::timing::ms() - _lastStableMovementTime[index]) < FAST_FILTER_ENABLE_AFTER_MS;
0 commit comments