1
0
Fork 0
forked from forks/qmk_firmware

led_update_kb -> led_update_ports where appropriate (#18716)

Following #14452, less boilerplate is needed to customize indicator led
control.
This commit is contained in:
Jouke Witteveen 2022-10-15 21:09:03 +02:00 committed by GitHub
parent ad8630bd72
commit 2ee573fc5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 49 additions and 101 deletions

View file

@ -44,14 +44,10 @@ void led_init_ports(void) {
setPinOutput(F0); setPinOutput(F0);
} }
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
if (led_update_user(led_state)) {
if (led_state.caps_lock) { if (led_state.caps_lock) {
dk60_caps_led_on(); dk60_caps_led_on();
} else { } else {
dk60_caps_led_off(); dk60_caps_led_off();
} }
} }
return true;
}

View file

@ -80,15 +80,11 @@ void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds)
indicator_write(start_led + (RGBLED_NUM - RGB_INDICATOR_NUM), RGB_INDICATOR_NUM); indicator_write(start_led + (RGBLED_NUM - RGB_INDICATOR_NUM), RGB_INDICATOR_NUM);
} }
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
rgblight_set_layer_state(0, led_state.caps_lock); rgblight_set_layer_state(0, led_state.caps_lock);
rgblight_set_layer_state(1, led_state.scroll_lock); rgblight_set_layer_state(1, led_state.scroll_lock);
rgblight_set_layer_state(2, led_state.num_lock); rgblight_set_layer_state(2, led_state.num_lock);
} }
return res;
}
layer_state_t layer_state_set_kb(layer_state_t state) { layer_state_t layer_state_set_kb(layer_state_t state) {
state = layer_state_set_user(state); state = layer_state_set_user(state);

View file

@ -29,12 +29,8 @@ void matrix_scan_kb(void) {
/* update LED driver with usb led_state /* update LED driver with usb led_state
*/ */
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
set_fallacy_led(2, led_state.caps_lock); /* caps */ set_fallacy_led(2, led_state.caps_lock); /* caps */
set_fallacy_led(1, led_state.num_lock); /* num lock */ set_fallacy_led(1, led_state.num_lock); /* num lock */
set_fallacy_led(0, led_state.scroll_lock); /* scroll lock */ set_fallacy_led(0, led_state.scroll_lock); /* scroll lock */
} }
return res;
}

View file

@ -18,8 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "iron180.h" #include "iron180.h"
#ifdef CAPSLOCK_BACKLIGHT #ifdef CAPSLOCK_BACKLIGHT
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if (!led_state.caps_lock){ if (!led_state.caps_lock){
if (is_backlight_breathing()) breathing_disable(); if (is_backlight_breathing()) breathing_disable();
backlight_disable(); backlight_disable();
@ -28,6 +27,5 @@ bool led_update_kb(led_t led_state) {
if (is_backlight_breathing()) breathing_enable(); if (is_backlight_breathing()) breathing_enable();
backlight_enable(); backlight_enable();
} }
return res;
} }
#endif #endif

View file

@ -1,13 +1,9 @@
#include "kc60.h" #include "kc60.h"
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
if (led_update_user(led_state)) {
if (led_state.caps_lock) { if (led_state.caps_lock) {
setPinOutput(B2); setPinOutput(B2);
} else { } else {
setPinInput(B2); setPinInput(B2);
} }
} }
return true;
}

View file

@ -16,17 +16,13 @@
#include "timberwolf.h" #include "timberwolf.h"
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool runDefault = led_update_user(led_state);
if(runDefault) {
if (led_state.caps_lock) { if (led_state.caps_lock) {
backlight_level_noeeprom(get_backlight_level()); backlight_level_noeeprom(get_backlight_level());
} else { } else {
backlight_set(0); backlight_set(0);
} }
} }
return runDefault;
}
bool encoder_update_kb(uint8_t index, bool clockwise) { bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) return false; if (!encoder_update_user(index, clockwise)) return false;

View file

@ -370,13 +370,9 @@ const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_moonlander(
#endif #endif
#ifdef CAPS_LOCK_STATUS #ifdef CAPS_LOCK_STATUS
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
ML_LED_6(led_state.caps_lock); ML_LED_6(led_state.caps_lock);
} }
return res;
}
#endif #endif
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) {

View file

@ -25,17 +25,13 @@
* Middle LED is blue and red. LED driver 2 RGB 6 Red and Blue channel * Middle LED is blue and red. LED driver 2 RGB 6 Red and Blue channel
* Bottom LED is red only LED driver 2 RGB 6 Green channel. * Bottom LED is red only LED driver 2 RGB 6 Green channel.
*/ */
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
if (led_state.caps_lock) { if (led_state.caps_lock) {
IS31FL3733_set_color( 7+64-1, 0, 255, 0 ); IS31FL3733_set_color( 7+64-1, 0, 255, 0 );
} else { } else {
IS31FL3733_set_color( 7+64-1, 0, 0, 0 ); IS31FL3733_set_color( 7+64-1, 0, 0, 0 );
} }
} }
return res;
}
__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
uint8_t R = 0; uint8_t R = 0;

View file

@ -16,10 +16,6 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
// Use Bit-C LED to show CAPS LOCK status // Use Bit-C LED to show CAPS LOCK status
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
set_bitc_LED(led_state.caps_lock ? LED_DIM : LED_OFF); set_bitc_LED(led_state.caps_lock ? LED_DIM : LED_OFF);
} }
return res;
}

View file

@ -103,13 +103,9 @@ bool encoder_update_kb(uint8_t index, bool clockwise) {
} }
// Use Bit-C LED to show NUM LOCK status // Use Bit-C LED to show NUM LOCK status
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF); set_bitc_LED(led_state.num_lock ? LED_DIM : LED_OFF);
} }
return res;
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) { bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
process_record_remote_kb(keycode, record); process_record_remote_kb(keycode, record);

View file

@ -23,14 +23,10 @@ uint8_t caps_color[3] = {0xFF,0xFF,0xFF};
uint8_t num_color[3] = {0xFF,0xFF,0xFF}; uint8_t num_color[3] = {0xFF,0xFF,0xFF};
uint8_t layer_color[3] = {0xFF,0xFF,0xFF}; uint8_t layer_color[3] = {0xFF,0xFF,0xFF};
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
led_state.caps_lock ? rgblight_setrgb_at(caps_color[0], caps_color[1], caps_color[2], 2) : rgblight_setrgb_at(0x00,0x00,0x00,2); led_state.caps_lock ? rgblight_setrgb_at(caps_color[0], caps_color[1], caps_color[2], 2) : rgblight_setrgb_at(0x00,0x00,0x00,2);
led_state.num_lock ? rgblight_setrgb_at(num_color[0], num_color[1], num_color[2], 3) : rgblight_setrgb_at(0x00,0x00,0x00,3); led_state.num_lock ? rgblight_setrgb_at(num_color[0], num_color[1], num_color[2], 3) : rgblight_setrgb_at(0x00,0x00,0x00,3);
} }
return res;
}
layer_state_t layer_state_set_kb(layer_state_t state) { layer_state_t layer_state_set_kb(layer_state_t state) {
switch (get_highest_layer(state)) { switch (get_highest_layer(state)) {

View file

@ -16,16 +16,10 @@
#include "ls_60.h" #include "ls_60.h"
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if (res) {
if(led_state.caps_lock){ if(led_state.caps_lock){
rgblight_setrgb_at(192, 192, 192, 0); rgblight_setrgb_at(192, 192, 192, 0);
} else { } else {
rgblight_setrgb_at(0, 0, 0, 0); rgblight_setrgb_at(0, 0, 0, 0);
} }
} }
return res;
}

View file

@ -20,9 +20,7 @@
uint8_t send_data = 0x00; uint8_t send_data = 0x00;
bool led_update_kb(led_t led_state) { void led_update_ports(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
if (led_state.caps_lock){ if (led_state.caps_lock){
send_data |= 1 << 5; send_data |= 1 << 5;
} else { } else {
@ -30,8 +28,6 @@ bool led_update_kb(led_t led_state) {
} }
i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x0A, &send_data, 1, 20); i2c_writeReg((PORT_EXPANDER_ADDRESS << 1), 0x0A, &send_data, 1, 20);
} }
return res;
}
__attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) { __attribute__((weak)) layer_state_t layer_state_set_user(layer_state_t state) {
if (IS_LAYER_ON_STATE(state, 1)) { if (IS_LAYER_ON_STATE(state, 1)) {