From fd12dcccf081df1c8115e0b8ed0f06c9323f0339 Mon Sep 17 00:00:00 2001 From: Harald Pichler Date: Fri, 16 Sep 2016 14:31:38 +0200 Subject: [PATCH] bugfix minimal push button time --- cpu/avr/dev/button-sensor.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cpu/avr/dev/button-sensor.c b/cpu/avr/dev/button-sensor.c index 14b959d2e..68569ec4f 100644 --- a/cpu/avr/dev/button-sensor.c +++ b/cpu/avr/dev/button-sensor.c @@ -12,6 +12,7 @@ static struct timer debouncetimer; static int status(int type); static int enabled = 0; volatile static int bstate; +volatile static int bstatei; struct sensors_sensor *sensors[1]; unsigned char sensors_flags[1]; @@ -22,18 +23,18 @@ unsigned char sensors_flags[1]; /*---------------------------------------------------------------------------*/ ISR(INT4_vect) { - -// leds_toggle(LEDS_RED); if(BUTTON_CHECK_IRQ()) { + bstatei = (PINE & _BV(PE4) ? 0 : 1); if(timer_expired(&debouncetimer)) { - // led1_on(); - timer_set(&debouncetimer, CLOCK_SECOND / 8); +// led1_on(); + timer_set(&debouncetimer, CLOCK_SECOND / 16); bstate = (PINE & _BV(PE4) ? 0 : 1); - sensors_changed(&button_sensor); + if(bstate == bstatei){ + sensors_changed(&button_sensor); + } // led1_off(); } } - } /*---------------------------------------------------------------------------*/