From a4a7ca818a23fcbceceed202aa51d254552ae33e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 7 Feb 2013 02:37:44 +0000 Subject: fixed manual pin polarity limit switches now low pass filtered git-svn-id: https://svn.spreadspace.org/avr/trunk@168 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- usb-i2c-sl018/limits.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- usb-i2c-sl018/manual.c | 2 +- 2 files changed, 44 insertions(+), 4 deletions(-) (limited to 'usb-i2c-sl018') diff --git a/usb-i2c-sl018/limits.c b/usb-i2c-sl018/limits.c index b65fe28..5807151 100644 --- a/usb-i2c-sl018/limits.c +++ b/usb-i2c-sl018/limits.c @@ -30,22 +30,62 @@ #define LIMITS_OPEN 6 #define LIMITS_CLOSE 7 +#define LIMITS_LP_MAX 255 + void init_limits(void) { LIMITS_DDR = LIMITS_DDR & ~(1<= LIMITS_LP_MAX) { + last_state = state; + lp_cnt = 0; + } + + return last_state; +} + +uint8_t limits_get_open(uint8_t pin) +{ + static uint8_t last_state = 0; + static uint8_t lp_cnt = 0; + + uint8_t state = pin & (1<= LIMITS_LP_MAX) { + last_state = state; + lp_cnt = 0; + } + + return last_state; +} + limits_t limits_get(void) { uint8_t tmp = LIMITS_PIN & (1<= MANUAL_LP_MAX) { - if(state) + if(!state) eventqueue_push(btn_toggle); last_state = state; lp_cnt = 0; -- cgit v1.2.3