43 #include "dev/button-sensor.h"
45 #include "hal/micro/micro-common.h"
53 static struct timer debouncetimer;
59 uint8_t button_flags = 0;
61 #define BUTTON_ACTIVE_FLG 0x01
62 #define BUTTON_PRESSED_FLG 0x02
64 #define BUTTON_HAS_BEEN_PRESSED() (button_flags & BUTTON_PRESSED_FLG)
65 #define BUTTON_HAS_BEEN_RELEASED() (!(button_flags & BUTTON_PRESSED_FLG))
66 #define BUTTON_SET_PRESSED() (button_flags |= BUTTON_PRESSED_FLG)
67 #define BUTTON_SET_RELEASED() (button_flags &= ~BUTTON_PRESSED_FLG)
85 button_flags |= BUTTON_ACTIVE_FLG;
91 button_flags &= ~BUTTON_ACTIVE_FLG;
97 return (button_flags & BUTTON_ACTIVE_FLG)? 1 : 0;
114 if(BUTTON_HAS_BEEN_RELEASED()){
115 sensors_changed(&button_sensor);
117 BUTTON_SET_PRESSED();
122 BUTTON_SET_RELEASED();
131 sensors_changed(&button_sensor);
142 configure(
int type,
int value)
145 case SENSORS_HW_INIT:
175 ENERGEST_ON(ENERGEST_TYPE_IRQ);
184 sensors_changed(&button_sensor);
187 sensors_changed(&button_sensor);
194 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
198 SENSORS_SENSOR(button_sensor, BUTTON_SENSOR,
199 value, configure, status);