From 7851656847738192e0e12cfe77861ba58d98cf6f Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 6 Sep 2019 04:38:00 -0600 Subject: 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) --- spaghetti-monster/fsm-misc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'spaghetti-monster/fsm-misc.c') 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 -- cgit v1.2.3