diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-15 18:43:49 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-04-15 20:46:46 +0800 |
| commit | 065594d8b1344ed8110f7e7e1ff4b7281e8eb291 (patch) | |
| tree | 45b520ad2a8219fbf313e403a0a592fdf7af83d9 /lock/util.c | |
| parent | 18502ba0f60906d6fc886d85096d8c2eef9ca4a9 (diff) | |
| download | smart-home-065594d8b1344ed8110f7e7e1ff4b7281e8eb291.tar.gz | |
Backend btns and debounce logic.
Diffstat (limited to 'lock/util.c')
| -rw-r--r-- | lock/util.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lock/util.c b/lock/util.c index 32a1fcf..683faa2 100644 --- a/lock/util.c +++ b/lock/util.c @@ -1,9 +1,18 @@ #include <avr/io.h> #include <avr/interrupt.h> -#include <avr/wdt.h> +#include <util/delay.h> #include "util.h" +int is_btn_pressed(uint8_t pin, uint8_t btn) +{ + if (!((pin >> btn) & 0x01)) { + _delay_us(2000); + return !((pin >> btn) & 0x01); + } + return 0; +} + void xor(const char *k, const char *s, char *d, uint8_t n) { int i; |
