diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2025-06-14 16:53:15 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2025-06-14 16:53:15 +0800 |
| commit | b0323b1b23ce955fd1d65cc6f7625ff6ca65fc5f (patch) | |
| tree | 0868100b9067b6d7b37af2b4f106cd580167bf06 | |
| parent | f2d99e2576997a2c975948c2b1feef59021821f7 (diff) | |
| download | fpm-door-lock-b0323b1b23ce955fd1d65cc6f7625ff6ca65fc5f.tar.gz | |
Fix FPM touch reset problem.
| -rw-r--r-- | main.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -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(); } |
