summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018/manual.c
diff options
context:
space:
mode:
Diffstat (limited to 'usb-i2c-sl018/manual.c')
-rw-r--r--usb-i2c-sl018/manual.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/usb-i2c-sl018/manual.c b/usb-i2c-sl018/manual.c
index 3333a80..36f1a6c 100644
--- a/usb-i2c-sl018/manual.c
+++ b/usb-i2c-sl018/manual.c
@@ -30,6 +30,8 @@
#define MANUAL_DDR DDRF
#define MANUAL_BIT 0
+#define MANUAL_LP_MAX 255
+
void init_manual(void)
{
MANUAL_DDR = MANUAL_DDR & ~(1<<MANUAL_BIT);
@@ -39,9 +41,18 @@ void init_manual(void)
void manual_task(void)
{
static uint8_t last_state = 0;
+ static uint8_t lp_cnt = 0;
+
uint8_t state = MANUAL_PIN & (1<<MANUAL_BIT);
- if(state && state != last_state)
- eventqueue_push(btn_toggle);
+ if(state != last_state)
+ lp_cnt++;
+ else
+ lp_cnt += lp_cnt ? -1 : 0;
- last_state = state;
+ if(lp_cnt >= MANUAL_LP_MAX) {
+ if(state)
+ eventqueue_push(btn_toggle);
+ last_state = state;
+ lp_cnt = 0;
+ }
}