summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-06-14 16:53:15 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-06-14 16:53:15 +0800
commitb0323b1b23ce955fd1d65cc6f7625ff6ca65fc5f (patch)
tree0868100b9067b6d7b37af2b4f106cd580167bf06
parentf2d99e2576997a2c975948c2b1feef59021821f7 (diff)
downloadfpm-door-lock-b0323b1b23ce955fd1d65cc6f7625ff6ca65fc5f.tar.gz
Fix FPM touch reset problem.
-rw-r--r--main.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/main.c b/main.c
index 913b559..d2366fc 100644
--- a/main.c
+++ b/main.c
@@ -89,6 +89,16 @@ uint16_t getvcc(void)
return vcc;
}
+static inline void flash(void)
+{
+ for (int i = 0; i < 4; i++) {
+ LED_PORT |= (1 << LED_PIN);
+ _delay_ms(70);
+ LED_PORT &= ~(1 << LED_PIN);
+ _delay_ms(70);
+ }
+}
+
int main(void)
{
uint16_t id;
@@ -104,13 +114,6 @@ int main(void)
LED_DDR |= (1 << LED_PIN);
LED_PORT &= ~(1 << LED_PIN);
- for (int i = 0; i < 4; i++) {
- LED_PORT |= (1 << LED_PIN);
- _delay_ms(70);
- LED_PORT &= ~(1 << LED_PIN);
- _delay_ms(70);
- }
-
/* init input ports */
INPUT_DDR &= ~((1 << BACK_LOCK_PIN) | (1 << BACK_UNLOCK_PIN) |
(1 << FRONT_LOCK_PIN) | (1 << FRONT_UNLOCK_PIN) |
@@ -135,6 +138,7 @@ int main(void)
SERVO_DDR |= (1 << SERVO_PIN);
fpm_init();
+ flash();
for (;;) {
cli();
@@ -157,6 +161,7 @@ int main(void)
break;
case BUNLOCK:
unlock();
+ fpm_led(FLASH, BLUE, 1);
break;
case ENROLL:
id = fpm_match();
@@ -173,10 +178,7 @@ int main(void)
break;
}
- cmd = 0;
-
- if (getvcc() < VCC_MIN)
- LED_PORT |= (1 << LED_PIN);
+ cmd = NONE;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
@@ -201,7 +203,8 @@ static inline int is_pressed(uint8_t btn)
ISR(FPM_INT_VEC)
{
cli();
- cmd = FUNLOCK;
+ if (is_pressed(FRONT_UNLOCK_PIN))
+ cmd = FUNLOCK;
sei();
}