1
0
Fork 0

Indicator LEDs as config (#10816)

* First pass

* Add config options to docs

* Update some wording

* Slight tidy up of backlight caps logic

* Init pin to correct state

* Move init location

* Reverse default state
This commit is contained in:
Joel Challis 2020-11-08 22:31:16 +00:00 committed by GitHub
parent 9cd3ffa5ba
commit 1ff5ee255f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 264 additions and 174 deletions

View file

@ -23,7 +23,6 @@
#ifdef BACKLIGHT_ENABLE
# include "backlight.h"
extern backlight_config_t backlight_config;
#endif
#ifdef FAUXCLICKY_ENABLE
@ -602,6 +601,10 @@ void matrix_init_quantum() {
if (!eeconfig_is_enabled()) {
eeconfig_init();
}
#if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN)
// TODO: remove calls to led_init_ports from keyboards and remove ifdef
led_init_ports();
#endif
#ifdef BACKLIGHT_ENABLE
# ifdef LED_MATRIX_ENABLE
led_matrix_init();
@ -725,55 +728,6 @@ void api_send_unicode(uint32_t unicode) {
#endif
}
/** \brief Lock LED set callback - keymap/user level
*
* \deprecated Use led_update_user() instead.
*/
__attribute__((weak)) void led_set_user(uint8_t usb_led) {}
/** \brief Lock LED set callback - keyboard level
*
* \deprecated Use led_update_kb() instead.
*/
__attribute__((weak)) void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); }
/** \brief Lock LED update callback - keymap/user level
*
* \return True if led_update_kb() should run its own code, false otherwise.
*/
__attribute__((weak)) bool led_update_user(led_t led_state) { return true; }
/** \brief Lock LED update callback - keyboard level
*
* \return Ignored for now.
*/
__attribute__((weak)) bool led_update_kb(led_t led_state) { return led_update_user(led_state); }
__attribute__((weak)) void led_init_ports(void) {}
__attribute__((weak)) void led_set(uint8_t usb_led) {
#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_update_kb((led_t)usb_led);
}
//------------------------------------------------------------------------------
// Override these functions in your keymap file to play different tunes on
// different events such as startup and bootloader jump
@ -781,5 +735,3 @@ __attribute__((weak)) void led_set(uint8_t usb_led) {
__attribute__((weak)) void startup_user() {}
__attribute__((weak)) void shutdown_user() {}
//------------------------------------------------------------------------------