From a154ddbda5477a9b5a66333b8777fd6d1ee99d39 Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Sat, 21 Oct 2017 06:51:27 -0600 Subject: Moved indicator_led() from Anduril into FSM. Made it auto-set indicator level based on ramp level. Made Anduril configure voltage fudge and indicator LED functions based on driver type. Removed "ticks_spent_awake" thing since it's redundant. EV_tick arg does the same thing in fewer bytes. Rearranged some clauses in off_state to put events in a more coherent order. --- spaghetti-monster/fsm-misc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'spaghetti-monster/fsm-misc.c') diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 1b8f864..acef28c 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -109,4 +109,32 @@ uint8_t blink_num(uint8_t num) { } #endif +#ifdef USE_INDICATOR_LED +void indicator_led(uint8_t lvl) { + switch (lvl) { + case 0: // indicator off + DDRB &= 0xff ^ (1 << AUXLED_PIN); + PORTB &= 0xff ^ (1 << AUXLED_PIN); + break; + case 1: // indicator low + DDRB &= 0xff ^ (1 << AUXLED_PIN); + PORTB |= (1 << AUXLED_PIN); + break; + default: // indicator high + DDRB |= (1 << AUXLED_PIN); + PORTB |= (1 << AUXLED_PIN); + break; + } +} + +/* +void indicator_led_auto() { + if (actual_level > MAX_1x7135) indicator_led(2); + else if (actual_level > 0) indicator_led(1); + else indicator_led(0); +} +*/ +#endif // USE_INDICATOR_LED + + #endif -- cgit v1.2.3