#define MANUAL_OPEN_PIN 12 // keys for manual open and close
#define MANUAL_CLOSE_PIN 13 //
-#define DEBOUNCE_DELAY 625 // * 16us = 10ms
+#define DEBOUNCE_DELAY 6250 // * 16us = 100ms
#define DEBOUNCE_IDLE 0 // currently no debouncing
#define DEBOUNCE_OPEN 1 // debouncing open key
#define DEBOUNCE_CLOSE 2 // debouncing close key
debounce_cnt = DEBOUNCE_DELAY;
TCCR0A = 0; // no prescaler, WGM = 0 (normal)
- TCCR0B = 1<<WGM01; //
+ TCCR0B = 1<<CS00; //
OCR0A = 255; // 1+255 = 256 -> 16us @ 16 MHz
TCNT0 = 0; // reseting timer
TIMSK0 = 1<<OCF0A; // enable Interrupt
ISR(TIMER0_COMPA_vect)
{
- if((debounce_state & DEBOUNCE_OPEN && manual_open_pressed()) ||
- (debounce_state & DEBOUNCE_CLOSE && manual_close_pressed())) {
+ if(((debounce_state & DEBOUNCE_OPEN) && manual_open_pressed()) ||
+ ((debounce_state & DEBOUNCE_CLOSE) && manual_close_pressed())) {
if(debounce_cnt) {
debounce_cnt--;
return;
return true;
}
}
- else {
+ else if(debounce_state & DEBOUNCE_OPEN) {
stop_debounce_timer();
debounce_state = DEBOUNCE_IDLE;
}
return true;
}
}
- else {
+ else if(debounce_state & DEBOUNCE_CLOSE) {
stop_debounce_timer();
debounce_state = DEBOUNCE_IDLE;
}