Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align location of some host led logic #15954

Merged
merged 6 commits into from
Jan 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Align location of host led logic
  • Loading branch information
zvecr committed Jan 20, 2022
commit c6f82b4840d4555ccff9825a55bd30c35c79bb7d
2 changes: 1 addition & 1 deletion keyboards/converter/usb_usb/custom_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ extern "C"
// restore LED state when keyboard comes up
if (usb_state == USB_STATE_RUNNING) {
dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low");
keyboard_set_leds(host_keyboard_leds());
led_set(host_keyboard_leds());
}
}
matrix_scan_quantum();
Expand Down
2 changes: 1 addition & 1 deletion keyboards/sirius/unigo66/custom_matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ extern "C"
// restore LED state when keyboard comes up
if (usb_state == USB_STATE_RUNNING) {
dprintf("speed: %s\n", usb_host.getVbusState()==FSHOST ? "full" : "low");
keyboard_set_leds(host_keyboard_leds());
led_set(host_keyboard_leds());
}
}
return 1;
Expand Down
26 changes: 0 additions & 26 deletions quantum/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,32 +350,6 @@ void keyboard_init(void) {
keyboard_post_init_kb(); /* Always keep this last */
}

/** \brief keyboard set leds
*
* FIXME: needs doc
*/
void keyboard_set_leds(uint8_t leds) {
if (debug_keyboard) {
debug("keyboard_set_led: ");
debug_hex8(leds);
debug("\n");
}
led_set(leds);
}

/** \brief set host led state
*
* Only sets state if change detected
*/
void led_task(void) {
static uint8_t led_status = 0;
// update LED
if (led_status != host_keyboard_leds()) {
led_status = host_keyboard_leds();
keyboard_set_leds(led_status);
}
}

/** \brief key_event_task
*
* This function is responsible for calling into other systems when they need to respond to electrical switch press events.
Expand Down
2 changes: 0 additions & 2 deletions quantum/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ void keyboard_setup(void);
void keyboard_init(void);
/* it runs repeatedly in main loop */
void keyboard_task(void);
/* it runs when host LED status is updated */
void keyboard_set_leds(uint8_t leds);
/* it runs whenever code has to behave differently on a slave */
bool is_keyboard_master(void);
/* it runs whenever code has to behave differently on left vs right split */
Expand Down
21 changes: 21 additions & 0 deletions quantum/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,24 @@ __attribute__((weak)) void led_set(uint8_t usb_led) {
led_set_kb(usb_led);
led_update_kb((led_t)usb_led);
}

/** \brief set host led state
*
* Only sets state if change detected
*/
void led_task(void) {
static uint8_t last_led_status = 0;

// update LED
uint8_t led_status = host_keyboard_leds();
if (last_led_status != led_status) {
last_led_status = led_status;

if (debug_keyboard) {
debug("led_task: ");
debug_hex8(leds);
debug("\n");
}
led_set(led_status);
}
}
2 changes: 2 additions & 0 deletions quantum/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ void led_set(uint8_t usb_led);

void led_init_ports(void);

void led_task(void);

#ifdef __cplusplus
}
#endif