aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpetermans <tibcmhhm@gmail.com>2017-04-29 09:22:40 -0700
committerjpetermans <tibcmhhm@gmail.com>2017-04-29 09:22:40 -0700
commitff6beeb7a313953c589defb6af1f9ae461cba03a (patch)
tree3047fc71b6899480363c5260597d8f496b1d7079
parentb3945c103cfa4c8f30a656d626dba75ad7f0af85 (diff)
downloadqmk_firmware-ff6beeb7a313953c589defb6af1f9ae461cba03a.tar.gz
qmk_firmware-ff6beeb7a313953c589defb6af1f9ae461cba03a.zip
simplified lock led function
-rw-r--r--keyboards/infinity60/led_controller.c57
-rw-r--r--keyboards/infinity60/led_controller.h2
2 files changed, 17 insertions, 42 deletions
diff --git a/keyboards/infinity60/led_controller.c b/keyboards/infinity60/led_controller.c
index 4dc9b9234..707b4e0df 100644
--- a/keyboards/infinity60/led_controller.c
+++ b/keyboards/infinity60/led_controller.c
@@ -262,10 +262,10 @@ page_status = 0; //start frame 0 (all off/on)
262 262
263 //maintain lock leds 263 //maintain lock leds
264 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { 264 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) {
265 set_lock_leds(USB_LED_NUM_LOCK, 1); 265 set_lock_leds(NUM_LOCK_LED_ADDRESS, 1);
266 } 266 }
267 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { 267 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
268 set_lock_leds(USB_LED_CAPS_LOCK, 1); 268 set_lock_leds(CAPS_LOCK_LED_ADDRESS, 1);
269 } 269 }
270 270
271 page_status=0; 271 page_status=0;
@@ -308,28 +308,28 @@ page_status = 0; //start frame 0 (all off/on)
308 308
309 //maintain lock leds 309 //maintain lock leds
310 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { 310 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) {
311 set_lock_leds(USB_LED_NUM_LOCK, 1); 311 set_lock_leds(NUM_LOCK_LED_ADDRESS, 1);
312 } 312 }
313 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { 313 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
314 set_lock_leds(USB_LED_CAPS_LOCK, 1); 314 set_lock_leds(CAPS_LOCK_LED_ADDRESS, 1);
315 } 315 }
316 break; 316 break;
317 317
318 case TOGGLE_NUM_LOCK: 318 case TOGGLE_NUM_LOCK:
319 //msg_led = 0 or 1, off/on 319 //msg_led = 0 or 1, off/on
320 set_lock_leds(USB_LED_NUM_LOCK, msg_led); 320 set_lock_leds(NUM_LOCK_LED_ADDRESS, msg_led);
321 break; 321 break;
322 322
323 case TOGGLE_CAPS_LOCK: 323 case TOGGLE_CAPS_LOCK:
324 //msg_led = 0 or 1, off/on 324 //msg_led = 0 or 1, off/on
325 set_lock_leds(USB_LED_CAPS_LOCK, msg_led); 325 set_lock_leds(CAPS_LOCK_LED_ADDRESS, msg_led);
326 break; 326 break;
327 327
328 //TODO: MODE_BREATH 328 //TODO: MODE_BREATH
329 case MODE_BREATH: 329 case MODE_BREATH:
330 break; 330 break;
331 case STEP_BRIGHTNESS: 331 case STEP_BRIGHTNESS:
332 xprintf("TOGGLE_BACKLIGHT\n"); 332 xprintf("STEP_BACKLIGHT\n");
333 chThdSleepMilliseconds(10); 333 chThdSleepMilliseconds(10);
334 //led_msg = step pwm up or down 334 //led_msg = step pwm up or down
335 switch (msg_led) { 335 switch (msg_led) {
@@ -458,45 +458,20 @@ void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint
458 led_control_reg[1] = column_byte; 458 led_control_reg[1] = column_byte;
459} 459}
460 460
461void set_lock_leds(uint8_t lock_type, uint8_t led_on) { 461void set_lock_leds(uint8_t led_addr, uint8_t led_action) {
462 uint8_t page, led_addr, start, temp; 462 uint8_t page, temp;
463 uint8_t led_control_word[2] = {0}; 463 uint8_t led_control_word[2] = {0};
464 //TODO: this function call could send led address vs lock_type. 464 //TODO: this function call could send led address vs lock_type.
465 //however, the switch/case allows for additional steps, like audio, depending on type 465 //however, the switch/case allows for additional steps, like audio, depending on type
466 466
467 led_addr = 0;
468 switch(lock_type) {
469 case USB_LED_NUM_LOCK:
470 led_addr = NUM_LOCK_LED_ADDRESS;
471 break;
472 case USB_LED_CAPS_LOCK:
473 led_addr = CAPS_LOCK_LED_ADDRESS;
474 break;
475 #ifdef SCROLL_LOCK_LED_ADDRESS
476 case USB_LED_SCROLL_LOCK:
477 led_addr = SCROLL_LOCK_LED_ADDRESS;
478 break;
479 #endif
480 #ifdef COMPOSE_LED_ADDRESS
481 case USB_LED_COMPOSE:
482 led_addr = COMPOSE_LED_ADDRESS;
483 break;
484 #endif
485 #ifdef SCROLL_LOCK_LED_ADDRESS
486 case USB_LED_KANA:
487 led_addr = KANA_LED_ADDRESS;
488 break;
489 #endif
490 }
491
492 //ignore frame0 if all leds are on or if option set in led_controller.h 467 //ignore frame0 if all leds are on or if option set in led_controller.h
493 //TODO: blink of all leds are on, clear blink register if not 468 //TODO: blink of all leds are on, clear blink register if not
494 is31_read_register(0, 0x00, &temp); 469 //is31_read_register(0, 0x00, &temp);
495 led_addr += temp == 0 ? 0 : 0x12;//send bit to blink register instead 470 //led_addr += temp == 0 ? 0 : 0x12;//send bit to blink register instead
496 start = BACKLIGHT_OFF_LOCK_LED_OFF ? 1 : 0; 471 //start = BACKLIGHT_OFF_LOCK_LED_OFF ? 1 : 0;
497 472
498 for(page=start; page<8; page++) { 473 for(page=0; page<8; page++) {
499 set_led_bit(page,led_control_word,led_addr,led_on); 474 set_led_bit(page,led_control_word,led_addr,led_action);
500 is31_write_data(page, led_control_word, 0x02); 475 is31_write_data(page, led_control_word, 0x02);
501 } 476 }
502} 477}
@@ -558,8 +533,8 @@ void led_controller_init(void) {
558 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL2, IS31_REG_BREATHCTRL2_ENABLE|3); 533 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL2, IS31_REG_BREATHCTRL2_ENABLE|3);
559 534
560 // clean up the lock LEDs 535 // clean up the lock LEDs
561 set_lock_leds(USB_LED_NUM_LOCK, 0); 536 set_lock_leds(NUM_LOCK_LED_ADDRESS, 0);
562 set_lock_leds(USB_LED_CAPS_LOCK, 0); 537 set_lock_leds(CAPS_LOCK_LED_ADDRESS, 0);
563 538
564 /* more time consuming LED processing should be offloaded into 539 /* more time consuming LED processing should be offloaded into
565 * a thread, with asynchronous messaging. */ 540 * a thread, with asynchronous messaging. */
diff --git a/keyboards/infinity60/led_controller.h b/keyboards/infinity60/led_controller.h
index b06113b07..7a8a1a109 100644
--- a/keyboards/infinity60/led_controller.h
+++ b/keyboards/infinity60/led_controller.h
@@ -93,7 +93,7 @@ void led_controller_init(void);
93extern mailbox_t led_mailbox; 93extern mailbox_t led_mailbox;
94 94
95void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint8_t action); 95void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint8_t action);
96void set_lock_leds (uint8_t lock_type, uint8_t led_on); 96void set_lock_leds (uint8_t lock_addr, uint8_t led_action);
97void write_led_page (uint8_t page, uint8_t *led_array, uint8_t led_count); 97void write_led_page (uint8_t page, uint8_t *led_array, uint8_t led_count);
98 98
99// constants for signaling the LED controller thread 99// constants for signaling the LED controller thread