diff options
Diffstat (limited to 'lock/util.c')
| -rw-r--r-- | lock/util.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lock/util.c b/lock/util.c index ebcf9fe..5a22ef1 100644 --- a/lock/util.c +++ b/lock/util.c @@ -4,6 +4,12 @@ #include "util.h" +#define LOCK_LED PC3 +#define UNLOCK_LED PC4 +#define BATLOW_LED PC5 +#define LED_DDR DDRC +#define LED_PORT PORTC + int is_btn_pressed(uint8_t pin, uint8_t btn) { if (!((pin >> btn) & 0x01)) { @@ -44,3 +50,40 @@ uint16_t getvcc(void) ADCSRA &= ~(1 << ADEN); return vcc; } + +void led_init(void) +{ + LED_DDR |= (1 << LOCK_LED) | (1 << UNLOCK_LED); + LED_DDR |= (1 << BATLOW_LED); + + LED_PORT &= ~(1 << LOCK_LED); + LED_PORT &= ~(1 << UNLOCK_LED); + LED_PORT &= ~(1 << BATLOW_LED); +} + +void led_locked(void) +{ + LED_PORT |= (1 << LOCK_LED); + _delay_ms(70); + LED_PORT &= ~(1 << LOCK_LED); + _delay_ms(70); + LED_PORT |= (1 << LOCK_LED); + _delay_ms(70); + LED_PORT &= ~(1 << LOCK_LED); +} + +void led_unlocked(void) +{ + LED_PORT |= (1 << UNLOCK_LED); + _delay_ms(70); + LED_PORT &= ~(1 << UNLOCK_LED); + _delay_ms(70); + LED_PORT |= (1 << UNLOCK_LED); + _delay_ms(70); + LED_PORT &= ~(1 << UNLOCK_LED); +} + +void led_bat(void) +{ + LED_PORT ^= (1 << BATLOW_LED); +} |
