Better antiglitch

This commit is contained in:
Gregor Riepl 2021-02-08 16:28:38 +01:00
parent 016e37e009
commit 4fa0b9e1b0

View file

@ -62,11 +62,8 @@ static uint16_t get_status() {
static uint16_t graded_status() {
uint16_t status = get_status();
// combine the bits of the last 3 states into one: "at least 2 of 3"
uint16_t graded01 = status_hysteresis[0] & status_hysteresis[1];
uint16_t graded1n = status_hysteresis[1] & status;
uint16_t gradedn0 = status & status_hysteresis[0];
uint16_t graded = graded01 | graded1n | gradedn0;
// combine the bits of the last 3 states into one: "3 successive ones"
uint16_t graded = status_hysteresis[0] & status_hysteresis[1] & status;
status_hysteresis[0] = status_hysteresis[1];
status_hysteresis[1] = status;