Antiglitch, try 3

This commit is contained in:
Gregor Riepl 2021-02-08 16:50:57 +01:00
parent 4fa0b9e1b0
commit b0d91e6290

View file

@ -62,8 +62,11 @@ static uint16_t get_status() {
static uint16_t graded_status() { static uint16_t graded_status() {
uint16_t status = get_status(); uint16_t status = get_status();
// combine the bits of the last 3 states into one: "3 successive ones" // report a one bit if the majority of the last states had a one
uint16_t graded = status_hysteresis[0] & status_hysteresis[1] & status; uint16_t graded =
(status_hysteresis[0] & status_hysteresis[1]) |
(status_hysteresis[1] & status) |
(status_hysteresis[0] & status);
status_hysteresis[0] = status_hysteresis[1]; status_hysteresis[0] = status_hysteresis[1];
status_hysteresis[1] = status; status_hysteresis[1] = status;
@ -113,7 +116,7 @@ static void loop() {
} }
} }
_delay_us(100); _delay_ms(200);
} }
int main() { int main() {