diff options
| author | Selene ToyKeeper | 2019-09-06 04:38:00 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2019-09-06 04:38:00 -0600 |
| commit | 7851656847738192e0e12cfe77861ba58d98cf6f (patch) | |
| tree | abe34d61f48402f93fd954fb4759a6d9cd231a01 /spaghetti-monster/fsm-misc.c | |
| parent | fixed attiny13 builds (diff) | |
| download | anduril-7851656847738192e0e12cfe77861ba58d98cf6f.tar.gz anduril-7851656847738192e0e12cfe77861ba58d98cf6f.tar.bz2 anduril-7851656847738192e0e12cfe77861ba58d98cf6f.zip | |
added button LED support to D4v2
(in a way which doesn't break backward compatibility...
... but it really needs some refactoring to reduce code duplication)
Diffstat (limited to 'spaghetti-monster/fsm-misc.c')
| -rw-r--r-- | spaghetti-monster/fsm-misc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 8e88cbd..18dc7c5 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -147,6 +147,29 @@ void indicator_led_auto() { */ #endif // USE_INDICATOR_LED +#ifdef USE_BUTTON_LED +// TODO: Refactor this and RGB LED function to merge code and save space +void button_led_set(uint8_t lvl) { + switch (lvl) { + case 0: // LED off + BUTTON_LED_DDR &= 0xff ^ (1 << BUTTON_LED_PIN); + BUTTON_LED_PUE &= 0xff ^ (1 << BUTTON_LED_PIN); + BUTTON_LED_PORT &= 0xff ^ (1 << BUTTON_LED_PIN); + break; + case 1: // LED low + BUTTON_LED_DDR &= 0xff ^ (1 << BUTTON_LED_PIN); + BUTTON_LED_PUE |= (1 << BUTTON_LED_PIN); + BUTTON_LED_PORT |= (1 << BUTTON_LED_PIN); + break; + default: // LED high + BUTTON_LED_DDR |= (1 << BUTTON_LED_PIN); + BUTTON_LED_PUE |= (1 << BUTTON_LED_PIN); + BUTTON_LED_PORT |= (1 << BUTTON_LED_PIN); + break; + } +} +#endif + #ifdef USE_AUX_RGB_LEDS void rgb_led_set(uint8_t value) { // value: 0b00BBGGRR |
