diff options
| author | jpetermans <tibcmhhm@gmail.com> | 2017-05-30 21:52:44 -0700 |
|---|---|---|
| committer | jpetermans <tibcmhhm@gmail.com> | 2017-05-30 21:52:44 -0700 |
| commit | 9af272e4bb685faabd1d879231f2718f0c00b32d (patch) | |
| tree | eaedc9316db429a838066a42ed46114d24333880 | |
| parent | ac97870801a684b228cb7a667ea423d0ec381b1e (diff) | |
| download | qmk_firmware-9af272e4bb685faabd1d879231f2718f0c00b32d.tar.gz qmk_firmware-9af272e4bb685faabd1d879231f2718f0c00b32d.zip | |
Update lock led processing and remove debug msgs
| -rw-r--r-- | keyboards/infinity60/keymaps/jpetermans/keymap.c | 1 | ||||
| -rw-r--r-- | keyboards/infinity60/led_controller.c | 32 | ||||
| -rw-r--r-- | keyboards/infinity60/led_controller.h | 3 | ||||
| -rw-r--r-- | keyboards/infinity60/rules.mk | 2 |
4 files changed, 10 insertions, 28 deletions
diff --git a/keyboards/infinity60/keymaps/jpetermans/keymap.c b/keyboards/infinity60/keymaps/jpetermans/keymap.c index cc4633b1b..59249ff72 100644 --- a/keyboards/infinity60/keymaps/jpetermans/keymap.c +++ b/keyboards/infinity60/keymaps/jpetermans/keymap.c | |||
| @@ -247,7 +247,6 @@ bool process_record_user (uint16_t keycode, keyrecord_t *record) { | |||
| 247 | 247 | ||
| 248 | // Runs just one time when the keyboard initializes. | 248 | // Runs just one time when the keyboard initializes. |
| 249 | void matrix_init_user(void) { | 249 | void matrix_init_user(void) { |
| 250 | xprintf("init start"); | ||
| 251 | 250 | ||
| 252 | led_controller_init(); | 251 | led_controller_init(); |
| 253 | 252 | ||
diff --git a/keyboards/infinity60/led_controller.c b/keyboards/infinity60/led_controller.c index 5c177d26b..21f95a9c1 100644 --- a/keyboards/infinity60/led_controller.c +++ b/keyboards/infinity60/led_controller.c | |||
| @@ -135,7 +135,6 @@ msg_t is31_read_register(uint8_t page, uint8_t reg, uint8_t *result) { | |||
| 135 | * initialise the IS31 chip | 135 | * initialise the IS31 chip |
| 136 | * ======================== */ | 136 | * ======================== */ |
| 137 | void is31_init(void) { | 137 | void is31_init(void) { |
| 138 | xprintf("_is31_init\n"); | ||
| 139 | // just to be sure that it's all zeroes | 138 | // just to be sure that it's all zeroes |
| 140 | __builtin_memset(full_page,0,0xB4+1); | 139 | __builtin_memset(full_page,0,0xB4+1); |
| 141 | // zero function page, all registers (assuming full_page is all zeroes) | 140 | // zero function page, all registers (assuming full_page is all zeroes) |
| @@ -200,41 +199,33 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 200 | msg_args[1] = (msg >> 16) & 0XFF; | 199 | msg_args[1] = (msg >> 16) & 0XFF; |
| 201 | msg_args[2] = (msg >> 24) & 0xFF; | 200 | msg_args[2] = (msg >> 24) & 0xFF; |
| 202 | 201 | ||
| 203 | xprintf("msg_type: %d-%d-%d\n", msg_type, msg_args[0], msg_args[1]); | ||
| 204 | 202 | ||
| 205 | switch (msg_type){ | 203 | switch (msg_type){ |
| 206 | case SET_FULL_ROW: | 204 | case SET_FULL_ROW: |
| 207 | xprintf("FULL ROW: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 208 | //write full byte to pin address, msg_args[1] = pin #, msg_args[0] = 8 bits to write | 205 | //write full byte to pin address, msg_args[1] = pin #, msg_args[0] = 8 bits to write |
| 209 | //writes only to currently displayed page | 206 | //writes only to currently displayed page |
| 210 | write_led_byte(page_status, msg_args[1], msg_args[0]); | 207 | write_led_byte(page_status, msg_args[1], msg_args[0]); |
| 211 | break; | 208 | break; |
| 212 | 209 | ||
| 213 | case OFF_LED: | 210 | case OFF_LED: |
| 214 | xprintf("OFF: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 215 | //on/off/toggle single led, msg_args[0] = row/col of led, msg_args[1] = page | 211 | //on/off/toggle single led, msg_args[0] = row/col of led, msg_args[1] = page |
| 216 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 0); | 212 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 0); |
| 217 | break; | 213 | break; |
| 218 | case ON_LED: | 214 | case ON_LED: |
| 219 | xprintf("ON: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 220 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 1); | 215 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 1); |
| 221 | break; | 216 | break; |
| 222 | case TOGGLE_LED: | 217 | case TOGGLE_LED: |
| 223 | xprintf("TOGGLE: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 224 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 2); | 218 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 2); |
| 225 | break; | 219 | break; |
| 226 | 220 | ||
| 227 | case BLINK_OFF_LED: | 221 | case BLINK_OFF_LED: |
| 228 | xprintf("B_on: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 229 | //on/off/toggle single led, msg_args[0] = row/col of led | 222 | //on/off/toggle single led, msg_args[0] = row/col of led |
| 230 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 4); | 223 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 4); |
| 231 | break; | 224 | break; |
| 232 | case BLINK_ON_LED: | 225 | case BLINK_ON_LED: |
| 233 | xprintf("B_off: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 234 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 5); | 226 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 5); |
| 235 | break; | 227 | break; |
| 236 | case BLINK_TOGGLE_LED: | 228 | case BLINK_TOGGLE_LED: |
| 237 | xprintf("B_togg: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 238 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 6); | 229 | set_led_bit(msg_args[1], control_register_word, msg_args[0], 6); |
| 239 | break; | 230 | break; |
| 240 | 231 | ||
| @@ -244,12 +235,10 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 244 | chThdSleepMilliseconds(5); | 235 | chThdSleepMilliseconds(5); |
| 245 | is31_read_register(0, 0x00, &temp); | 236 | is31_read_register(0, 0x00, &temp); |
| 246 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | 237 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); |
| 247 | xprintf("TOGGLE_ALL: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 248 | xprintf("temp: %d\n", temp); | ||
| 249 | 238 | ||
| 250 | led_control_reg[0] = 0; | 239 | led_control_reg[0] = 0; |
| 251 | 240 | ||
| 252 | //if first leds are already on, toggle frame 0 off | 241 | //toggle led mask based on current state (temp) |
| 253 | if (temp==0 || page_status > 0) { | 242 | if (temp==0 || page_status > 0) { |
| 254 | __builtin_memcpy(led_control_reg+1, all_on_leds_mask, 0x12); | 243 | __builtin_memcpy(led_control_reg+1, all_on_leds_mask, 0x12); |
| 255 | } else { | 244 | } else { |
| @@ -262,13 +251,14 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 262 | 251 | ||
| 263 | page_status=0; | 252 | page_status=0; |
| 264 | 253 | ||
| 265 | //maintain lock leds | 254 | //maintain lock leds, reset to off and force recheck to blink of all leds toggled on |
| 255 | numlock_status = 0; | ||
| 256 | capslock_status = 0; | ||
| 266 | led_set(host_keyboard_leds()); | 257 | led_set(host_keyboard_leds()); |
| 267 | } | 258 | } |
| 268 | break; | 259 | break; |
| 269 | 260 | ||
| 270 | case TOGGLE_BACKLIGHT: | 261 | case TOGGLE_BACKLIGHT: |
| 271 | xprintf("TOGGLE_BKLT: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 272 | //msg_args[0] = on/off | 262 | //msg_args[0] = on/off |
| 273 | 263 | ||
| 274 | //populate 9 byte rows to be written to each pin, first byte is register (pin) address | 264 | //populate 9 byte rows to be written to each pin, first byte is register (pin) address |
| @@ -287,12 +277,13 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 287 | 277 | ||
| 288 | case DISPLAY_PAGE: | 278 | case DISPLAY_PAGE: |
| 289 | //msg_args[0] = page to toggle on | 279 | //msg_args[0] = page to toggle on |
| 290 | xprintf("DSPY_PG: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 291 | if (page_status != msg_args[0]) { | 280 | if (page_status != msg_args[0]) { |
| 292 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_PICTDISP, msg_args[0]); | 281 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_PICTDISP, msg_args[0]); |
| 293 | page_status = msg_args[0]; | 282 | page_status = msg_args[0]; |
| 294 | 283 | ||
| 295 | //maintain lock leds | 284 | //maintain lock leds, reset to off and force recheck for new page |
| 285 | numlock_status = 0; | ||
| 286 | capslock_status = 0; | ||
| 296 | led_set(host_keyboard_leds()); | 287 | led_set(host_keyboard_leds()); |
| 297 | } | 288 | } |
| 298 | break; | 289 | break; |
| @@ -309,7 +300,6 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 309 | break; | 300 | break; |
| 310 | 301 | ||
| 311 | case TOGGLE_NUM_LOCK: | 302 | case TOGGLE_NUM_LOCK: |
| 312 | xprintf("NMLK: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 313 | //msg_args[0] = 0 or 1, off/on | 303 | //msg_args[0] = 0 or 1, off/on |
| 314 | if (numlock_status != msg_args[0]) { | 304 | if (numlock_status != msg_args[0]) { |
| 315 | set_lock_leds(NUM_LOCK_LED_ADDRESS, msg_args[0], page_status); | 305 | set_lock_leds(NUM_LOCK_LED_ADDRESS, msg_args[0], page_status); |
| @@ -317,7 +307,6 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 317 | } | 307 | } |
| 318 | break; | 308 | break; |
| 319 | case TOGGLE_CAPS_LOCK: | 309 | case TOGGLE_CAPS_LOCK: |
| 320 | xprintf("CPLK: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 321 | //msg_args[0] = 0 or 1, off/on | 310 | //msg_args[0] = 0 or 1, off/on |
| 322 | if (capslock_status != msg_args[0]) { | 311 | if (capslock_status != msg_args[0]) { |
| 323 | set_lock_leds(CAPS_LOCK_LED_ADDRESS, msg_args[0], page_status); | 312 | set_lock_leds(CAPS_LOCK_LED_ADDRESS, msg_args[0], page_status); |
| @@ -326,7 +315,6 @@ static THD_FUNCTION(LEDthread, arg) { | |||
| 326 | break; | 315 | break; |
| 327 | 316 | ||
| 328 | case STEP_BRIGHTNESS: | 317 | case STEP_BRIGHTNESS: |
| 329 | xprintf("Step: %d-%d\n", msg_args[0], msg_args[1]); | ||
| 330 | //led_args[0] = step up (1) or down (0) | 318 | //led_args[0] = step up (1) or down (0) |
| 331 | switch (msg_args[0]) { | 319 | switch (msg_args[0]) { |
| 332 | case 0: | 320 | case 0: |
| @@ -373,7 +361,6 @@ void set_led_bit (uint8_t page, uint8_t *led_control_word, uint8_t led_addr, uin | |||
| 373 | if (led_addr < 0 || led_addr > 87 || led_addr % 10 > 8) { | 361 | if (led_addr < 0 || led_addr > 87 || led_addr % 10 > 8) { |
| 374 | return; | 362 | return; |
| 375 | } | 363 | } |
| 376 | xprintf("_set action-led: %x-%d\n", action, led_addr); | ||
| 377 | 364 | ||
| 378 | blink_bit = action>>2;//check for blink bit | 365 | blink_bit = action>>2;//check for blink bit |
| 379 | action &= ~(1<<2); //strip blink bit | 366 | action &= ~(1<<2); //strip blink bit |
| @@ -381,17 +368,14 @@ void set_led_bit (uint8_t page, uint8_t *led_control_word, uint8_t led_addr, uin | |||
| 381 | //led_addr tens column is pin#, ones column is bit position in 8-bit mask | 368 | //led_addr tens column is pin#, ones column is bit position in 8-bit mask |
| 382 | control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte | 369 | control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte |
| 383 | control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register | 370 | control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register |
| 384 | xprintf("_set control address: %x\n", control_reg_addr); | ||
| 385 | 371 | ||
| 386 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); | 372 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON); |
| 387 | chThdSleepMilliseconds(5); | 373 | chThdSleepMilliseconds(5); |
| 388 | is31_read_register(page, control_reg_addr, &temp);//maintain status of leds on this byte | 374 | is31_read_register(page, control_reg_addr, &temp);//maintain status of leds on this byte |
| 389 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); | 375 | is31_write_register(IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF); |
| 390 | xprintf("_set temp_byte_mask: %x\n", temp); | ||
| 391 | 376 | ||
| 392 | column_bit = 1<<(led_addr % 10 - 1); | 377 | column_bit = 1<<(led_addr % 10 - 1); |
| 393 | column_byte = temp; | 378 | column_byte = temp; |
| 394 | xprintf("_set col_byte_mask: %x\n", column_byte); | ||
| 395 | 379 | ||
| 396 | switch(action) { | 380 | switch(action) { |
| 397 | case 0: | 381 | case 0: |
| @@ -451,7 +435,6 @@ void set_lock_leds(uint8_t led_addr, uint8_t led_action, uint8_t page) { | |||
| 451 | led_action |= (1<<2); //set blink bit | 435 | led_action |= (1<<2); //set blink bit |
| 452 | } | 436 | } |
| 453 | } | 437 | } |
| 454 | xprintf("_lock action: %d\n", led_action); | ||
| 455 | 438 | ||
| 456 | set_led_bit(page,led_control_word,led_addr,led_action); | 439 | set_led_bit(page,led_control_word,led_addr,led_action); |
| 457 | } | 440 | } |
| @@ -462,7 +445,6 @@ void set_lock_leds(uint8_t led_addr, uint8_t led_action, uint8_t page) { | |||
| 462 | void led_controller_init(void) { | 445 | void led_controller_init(void) { |
| 463 | uint8_t i; | 446 | uint8_t i; |
| 464 | 447 | ||
| 465 | xprintf("led_init\n"); | ||
| 466 | /* initialise I2C */ | 448 | /* initialise I2C */ |
| 467 | /* I2C pins */ | 449 | /* I2C pins */ |
| 468 | palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL | 450 | palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL |
diff --git a/keyboards/infinity60/led_controller.h b/keyboards/infinity60/led_controller.h index 457b21a92..eb6060f26 100644 --- a/keyboards/infinity60/led_controller.h +++ b/keyboards/infinity60/led_controller.h | |||
| @@ -75,7 +75,8 @@ void led_controller_init(void); | |||
| 75 | // D2:D0 extinguish time (3.5ms*2^i) | 75 | // D2:D0 extinguish time (3.5ms*2^i) |
| 76 | 76 | ||
| 77 | #define IS31_REG_SHUTDOWN 0x0A | 77 | #define IS31_REG_SHUTDOWN 0x0A |
| 78 | #define IS31_REG_SHUTDOWN_ON 0x1 | 78 | #define IS31_REG_SHUTDOWN_OFF 0x1 |
| 79 | #define IS31_REG_SHUTDOWN_ON 0x0 | ||
| 79 | 80 | ||
| 80 | #define IS31_REG_AGCCTRL 0x0B | 81 | #define IS31_REG_AGCCTRL 0x0B |
| 81 | #define IS31_REG_ADCRATE 0x0C | 82 | #define IS31_REG_ADCRATE 0x0C |
diff --git a/keyboards/infinity60/rules.mk b/keyboards/infinity60/rules.mk index f58bb2642..c19f62401 100644 --- a/keyboards/infinity60/rules.mk +++ b/keyboards/infinity60/rules.mk | |||
| @@ -56,7 +56,7 @@ OPT_DEFS = -DCORTEX_VTOR_INIT=0x00001000 | |||
| 56 | # Build Options | 56 | # Build Options |
| 57 | # comment out to disable the options. | 57 | # comment out to disable the options. |
| 58 | # | 58 | # |
| 59 | BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration | 59 | BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration |
| 60 | ## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.) | 60 | ## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.) |
| 61 | MOUSEKEY_ENABLE ?= yes # Mouse keys | 61 | MOUSEKEY_ENABLE ?= yes # Mouse keys |
| 62 | EXTRAKEY_ENABLE ?= yes # Audio control and System control | 62 | EXTRAKEY_ENABLE ?= yes # Audio control and System control |
