Get rid of USB_LED_NUM_LOCK (#21424)
This commit is contained in:
parent
7ff80a57cb
commit
9ab16e62f7
25 changed files with 91 additions and 133 deletions
|
|
@ -26,29 +26,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
* both regular threads and ISRs, unlocked (during resume-from-sleep).
|
||||
* In particular, I2C functions (interrupt-driven) should NOT be called from here.
|
||||
*/
|
||||
void led_set(uint8_t usb_led) {
|
||||
msg_t msg;
|
||||
bool led_update_kb(led_t led_state) {
|
||||
bool res = led_update_user(led_state);
|
||||
if (res) {
|
||||
msg_t msg;
|
||||
|
||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
||||
chSysUnconditionalLock();
|
||||
msg=(1 << 8) | TOGGLE_NUM_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
} else {
|
||||
chSysUnconditionalLock();
|
||||
msg=(0 << 8) | TOGGLE_NUM_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
}
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
chSysUnconditionalLock();
|
||||
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
} else {
|
||||
chSysUnconditionalLock();
|
||||
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
if (led_state.num_lock) {
|
||||
chSysUnconditionalLock();
|
||||
msg=(1 << 8) | TOGGLE_NUM_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
} else {
|
||||
chSysUnconditionalLock();
|
||||
msg=(0 << 8) | TOGGLE_NUM_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
}
|
||||
if (led_state.caps_lock) {
|
||||
chSysUnconditionalLock();
|
||||
msg=(1 << 8) | TOGGLE_CAPS_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
} else {
|
||||
chSysUnconditionalLock();
|
||||
msg=(0 << 8) | TOGGLE_CAPS_LOCK;
|
||||
chMBPostI(&led_mailbox, msg);
|
||||
chSysUnconditionalUnlock();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,8 +187,9 @@ static THD_FUNCTION(LEDthread, arg) {
|
|||
// initialize persistent variables
|
||||
pwm_step_status = 4; //full brightness
|
||||
page_status = 0; //start frame 0 (all off/on)
|
||||
numlock_status = (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) ? 1 : 0;
|
||||
capslock_status = (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) ? 1 : 0;
|
||||
led_t led_state = host_keyboard_led_state();
|
||||
numlock_status = led_state.num_lock ? 1 : 0;
|
||||
capslock_status = led_state.caps_lock ? 1 : 0;
|
||||
|
||||
while(true) {
|
||||
// wait for a message (asynchronous)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue