summaryrefslogtreecommitdiffstats
path: root/lock/util.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-04-15 18:43:49 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-04-15 20:46:46 +0800
commit065594d8b1344ed8110f7e7e1ff4b7281e8eb291 (patch)
tree45b520ad2a8219fbf313e403a0a592fdf7af83d9 /lock/util.c
parent18502ba0f60906d6fc886d85096d8c2eef9ca4a9 (diff)
downloadsmart-home-065594d8b1344ed8110f7e7e1ff4b7281e8eb291.tar.gz
Backend btns and debounce logic.
Diffstat (limited to 'lock/util.c')
-rw-r--r--lock/util.c11
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;