mirror of
https://github.com/qmk/qmk_firmware
synced 2024-11-18 18:04:57 +00:00
Backlight - New option : BACKLIGHT_CAPS_LOCK (#4769)
* [BACKLIGHT_CAPS_LOCK_INDICATOR] Use backlight toggling as Caps Lock LED I've implemented this feature because S65-X doesn't have LED indicators and the existing led_set_kb(usb_led) function try to use backlight as indicator but that creates an inconsistency with backlight_config state. - define `BACKLIGHT_CAPS_LOCK_INDICATOR` to enable Caps Lock indicator using backlight (for keyboards without dedicated LED) - Don't turn off LED indicators when suspend because backlight is already turned off. Else led_set(0) will turn back on backlight. - Documentation has been updated * [BACKLIGHT_CAPS_LOCK_INDICATOR] Turn off all LED indicators except Caps Lock if BACKLIGHT_CAPS_LOCK_INDICATOR * [BACKLIGHT_CAPS_LOCK] Rename BACKLIGHT_CAPS_LOCK_INDICATOR * [BACKLIGHT_CAPS_LOCK] Use new IS_LED_ON method
This commit is contained in:
parent
0f507f0169
commit
df251d7a13
3 changed files with 50 additions and 24 deletions
|
@ -40,6 +40,7 @@ To change the behaviour of the backlighting, `#define` these in your `config.h`:
|
||||||
|---------------------|-------------|-------------------------------------------------------------------------------------------------------------|
|
|---------------------|-------------|-------------------------------------------------------------------------------------------------------------|
|
||||||
|`BACKLIGHT_PIN` |`B7` |The pin that controls the LEDs. Unless you are designing your own keyboard, you shouldn't need to change this|
|
|`BACKLIGHT_PIN` |`B7` |The pin that controls the LEDs. Unless you are designing your own keyboard, you shouldn't need to change this|
|
||||||
|`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 15 excluding off) |
|
|`BACKLIGHT_LEVELS` |`3` |The number of brightness levels (maximum 15 excluding off) |
|
||||||
|
|`BACKLIGHT_CAPS_LOCK`|*Not defined*|Enable Caps Lock indicator using backlight (for keyboards without dedicated LED) |
|
||||||
|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if hardware PWM is used |
|
|`BACKLIGHT_BREATHING`|*Not defined*|Enable backlight breathing, if hardware PWM is used |
|
||||||
|`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds |
|
|`BREATHING_PERIOD` |`6` |The length of one backlight "breath" in seconds |
|
||||||
|
|
||||||
|
|
|
@ -1448,6 +1448,24 @@ void led_set(uint8_t usb_led)
|
||||||
// PORTE &= ~(1<<6);
|
// PORTE &= ~(1<<6);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
|
||||||
|
// Use backlight as Caps Lock indicator
|
||||||
|
uint8_t bl_toggle_lvl = 0;
|
||||||
|
|
||||||
|
if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK) && !backlight_config.enable) {
|
||||||
|
// Turning Caps Lock ON and backlight is disabled in config
|
||||||
|
// Toggling backlight to the brightest level
|
||||||
|
bl_toggle_lvl = BACKLIGHT_LEVELS;
|
||||||
|
} else if (IS_LED_OFF(usb_led, USB_LED_CAPS_LOCK) && backlight_config.enable) {
|
||||||
|
// Turning Caps Lock OFF and backlight is enabled in config
|
||||||
|
// Toggling backlight and restoring config level
|
||||||
|
bl_toggle_lvl = backlight_config.level;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set level without modify backlight_config to keep ability to restore state
|
||||||
|
backlight_set(bl_toggle_lvl);
|
||||||
|
#endif
|
||||||
|
|
||||||
led_set_kb(usb_led);
|
led_set_kb(usb_led);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,19 @@ static void power_down(uint8_t wdto) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Turn off LED indicators
|
// Turn off LED indicators
|
||||||
led_set(0);
|
uint8_t leds_off = 0;
|
||||||
|
#if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
|
||||||
|
if (is_backlight_enabled()) {
|
||||||
|
// Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
|
||||||
|
leds_off |= (1<<USB_LED_CAPS_LOCK);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
led_set(leds_off);
|
||||||
|
|
||||||
#ifdef AUDIO_ENABLE
|
#ifdef AUDIO_ENABLE
|
||||||
// This sometimes disables the start-up noise, so it's been disabled
|
// This sometimes disables the start-up noise, so it's been disabled
|
||||||
// stop_all_notes();
|
// stop_all_notes();
|
||||||
#endif /* AUDIO_ENABLE */
|
#endif /* AUDIO_ENABLE */
|
||||||
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
#if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
|
||||||
#ifdef RGBLIGHT_ANIMATIONS
|
#ifdef RGBLIGHT_ANIMATIONS
|
||||||
rgblight_timer_disable();
|
rgblight_timer_disable();
|
||||||
|
|
Loading…
Reference in a new issue