enum btnStat_t{
high,
low,
rising,
falling,
};
enum btnStat_t doDebounce(uint8_t *state, volatile bool value) {
uint8_t old = *state & 0x7F;
bool flag = (*state & 0x80)? true : false;
enum btnStat_t btnStd = (true == flag)? low : high;
// Digital filter part, value = (old * .75) + (new * .25)
old -= (old >> 2); // 1 - (1/4) = .75
old += value? 0x1F : 0x00; // if bit set, add .25
// Software schmitt trigger
// Newly detected rising edge
if ( (true == flag) && (old > 0x70) ) {
flag = false;
btnStd = rising;
}
// Newly detected falling edge
else if ( (false == flag) && (old < 0x07) ){
flag = true;
btnStd = falling;
}
// Update the state variable
*state = (old & 0x7F) | ((flag & 0x01) << 7);
// Return the state
return btnStd;
}
enum btnStat_t btnStd = (true == flag)? low : high;
y tampoco entiendo por qué la función es definida como un enumerador de la forma en que está con argumento.