diff options
| -rw-r--r-- | keyboards/infinity60/keymaps/jpetermans/readme.md | 69 | ||||
| -rw-r--r-- | keyboards/infinity60/led_controller.c | 6 |
2 files changed, 41 insertions, 34 deletions
diff --git a/keyboards/infinity60/keymaps/jpetermans/readme.md b/keyboards/infinity60/keymaps/jpetermans/readme.md index 9c5b89173..fcad4b140 100644 --- a/keyboards/infinity60/keymaps/jpetermans/readme.md +++ b/keyboards/infinity60/keymaps/jpetermans/readme.md | |||
| @@ -3,10 +3,10 @@ Backlight for Infinity60 | |||
| 3 | 3 | ||
| 4 | ## Led Controller Specs | 4 | ## Led Controller Specs |
| 5 | 5 | ||
| 6 | The Infinity60 pcb uses the IS31FL3731C matrix LED driver from ISSI [datasheet](http://www.issi.com/WW/pdf/31FL3731C.pdf). The IS31 has the ability to control two led matrices (A & B), each matrix controlling 9 pins, each pin controlling 8 leds. The Infinity only utilizes matrix A. | 6 | The Infinity60 (revision 1.1a) pcb uses the IS31FL3731C matrix LED driver from ISSI [(datasheet)](http://www.issi.com/WW/pdf/31FL3731C.pdf). The IS31 has the ability to control two led matrices (A & B), each matrix controlling 9 pins, each pin controlling 8 leds. The Infinity only utilizes matrix A. |
| 7 | 7 | ||
| 8 | Infinity60 LED MAP: | 8 | Infinity60 LED Map: |
| 9 | digits mean "row" and "col", i.e. 45 means C4-5 in the IS31 datasheet, matrix A | 9 | digits mean "row" and "col", i.e. 45 means pin 4, column 5 in the IS31 datasheet |
| 10 | ```c | 10 | ```c |
| 11 | 11 12 13 14 15 16 17 18 21 22 23 24 25 26 27* | 11 | 11 12 13 14 15 16 17 18 21 22 23 24 25 26 27* |
| 12 | 28 31 32 33 34 35 36 37 38 41 42 43 44 45 | 12 | 28 31 32 33 34 35 36 37 38 41 42 43 44 45 |
| @@ -17,19 +17,26 @@ digits mean "row" and "col", i.e. 45 means C4-5 in the IS31 datasheet, matrix A | |||
| 17 | *Unused in Alphabet Layout | 17 | *Unused in Alphabet Layout |
| 18 | 18 | ||
| 19 | The IS31 includes 8 pages (or frames) 0-7 and each page consists of 0xB4 (144) bytes | 19 | The IS31 includes 8 pages (or frames) 0-7 and each page consists of 0xB4 (144) bytes |
| 20 | - **0 - 17** LED control (on/off). 18 pins which alternate between A and B matrices (CA1, CB1, CA2, CB2, ..). Each byte controls the 8 leds on that pin with bits (8 to 1). | 20 | - **0 - 17** |
| 21 | - **18 - 35** Blink control. Same as LED control above, but sets blink on/off. | 21 | * LED control (on/off). |
| 22 | - **36 - 143** PWM control. One byte per LED, sets PWM from 0 to 255. Same as above, the register alternates bytes between the A & B matrices. | 22 | * 18 pins which alternate between A and B matrices (CA1, CB1, CA2, CB2, ..). |
| 23 | * Each byte controls the 8 leds on that pin with bits (8 to 1). | ||
| 24 | - **18 - 35** | ||
| 25 | * Blink control. | ||
| 26 | * Same as LED control above, but sets blink on/off. | ||
| 27 | - **36 - 143** | ||
| 28 | * PWM control. One byte per LED, sets PWM from 0 to 255. | ||
| 29 | * Same as above, the register alternates, every 8 *bytes* (not bits) between the A & B matrices. | ||
| 23 | 30 | ||
| 24 | ## Led Controller Code | 31 | ## Led Controller Code |
| 25 | led_controller.c sets up ability to write led layers at startup or control leds on demand as part of fn_actions. By default led_controller.c assumes page 0 will be used for full on/off and page 7 for controlling individual leds. The remaining 6 pages (1-6) are free to preset led maps at init or on demand. Communication with the IS31 is primarily done through the led_mailbox using chMBPost described further below under "Sending messages in Keymap.c" | 32 | In the Infinity60 project folder, led_controller.c sets up ability to write led layers at startup or control leds on demand as part of fn_actions. By default led_controller.c assumes page 0 will be used for full on/off and page 7 for controlling individual leds. The remaining 6 pages (1-6) are free to preset led maps at init or on demand. Communication with the IS31 is primarily done through the led_mailbox using chMBPost described further below under "Sending messages in Keymap.c" |
| 26 | 33 | ||
| 27 | One function is available to directly control leds: | 34 | One function is available to directly set leds without the mailbox: |
| 28 | ``` | 35 | ``` |
| 29 | write_led_page(page#, array of leds by address, # of leds in array) | 36 | write_led_page(page#, array of leds by address, # of leds in array) |
| 30 | ``` | 37 | ``` |
| 31 | This function saves a full page using a supplied array of led locations such as: | 38 | This function saves a full page using a supplied array of led locations such as: |
| 32 | ``` | 39 | ```c |
| 33 | uint8_t led_numpad[16] = { | 40 | uint8_t led_numpad[16] = { |
| 34 | 18,21,22,23, | 41 | 18,21,22,23, |
| 35 | 37,38,41,42, | 42 | 37,38,41,42, |
| @@ -39,24 +46,24 @@ uint8_t led_numpad[16] = { | |||
| 39 | write_led_page(5, led_numpad, 16); | 46 | write_led_page(5, led_numpad, 16); |
| 40 | ``` | 47 | ``` |
| 41 | 48 | ||
| 42 | Remaining led control is done through the led mailbox using these message types. | 49 | Remaining led control is done through the led mailbox using these message types: |
| 43 | - **SET_FULL_ROW** - 3 bytes: row#, message type, 8-bit mask. Sets all leds on one pin per the bit mask. | 50 | - **SET_FULL_ROW** (3 bytes) - row#, message type, 8-bit mask. Sets all leds on one pin per the bit mask. |
| 44 | - **OFF_LED** - 2 bytes: message type, led address. Turn off specific led. | 51 | - **OFF_LED** (2 bytes) - message type, led address. Turn off specific led. |
| 45 | - **ON_LED** - 2 bytes: message type, led address. Turn on specific led. | 52 | - **ON_LED** (2 bytes) - message type, led address. Turn on specific led. |
| 46 | - **TOGGLE_LED** - 2 bytes: message type, led address. Toggle specific led on/off. | 53 | - **TOGGLE_LED** (2 bytes) - message type, led address. Toggle specific led on/off. |
| 47 | - **BLINK_OFF_LED** - 2 bytes: message type, led address. Set blink off for specific led. | 54 | - **BLINK_OFF_LED** (2 bytes) - message type, led address. Set blink off for specific led. |
| 48 | - **BLINK_ON_LED** - 2 bytes: message type, led address. Set blink on for specific led. | 55 | - **BLINK_ON_LED** (2 bytes) - message type, led address. Set blink on for specific led. |
| 49 | - **BLINK_TOGGLE_LED** - 2 bytes: message type, led address. Toggle blink for specific led. | 56 | - **BLINK_TOGGLE_LED** (2 bytes) - message type, led address. Toggle blink for specific led. |
| 50 | - **TOGGLE_ALL** - 2 bytes: message type, not used. Turn on/off full backlight. | 57 | - **TOGGLE_ALL** (2 bytes) - message type, not used. Turn on/off full backlight. |
| 51 | - **TOGGLE_BACKLIGHT** - 2 bytes: message type, on/off. Sets backlight completely off, no leds will display. | 58 | - **TOGGLE_BACKLIGHT** (2 bytes) - message type, on/off. Sets backlight completely off, no leds will display. |
| 52 | - **DISPLAY_PAGE** - 2 bytes: message type, page to display. Switch to specific pre-set page. | 59 | - **DISPLAY_PAGE** (2 bytes) - message type, page to display. Switch to specific pre-set page. |
| 53 | - **RESET_PAGE** - 2 bytes: message type, page to reset. Reset/erase specific page. | 60 | - **RESET_PAGE** (2 bytes) - message type, page to reset. Reset/erase specific page. |
| 54 | - **TOGGLE_NUM_LOCK** - 2 bytes: message type, on/off (NUM_LOCK_LED_ADDRESS). Toggle numlock on/off. Usually run with the `set_leds` function to check state of numlock or capslock. If all leds are on (e.i. TOGGLE_ALL) then this sets numlock to blink instead (this is still a little buggy if toggling on/off quickly). | 61 | - **TOGGLE_NUM_LOCK** (2 bytes) - message type, on/off (NUM_LOCK_LED_ADDRESS). Toggle numlock on/off. Usually run with the `set_leds` function to check state of numlock or capslock. If all leds are on (e.i. TOGGLE_ALL) then this sets numlock to blink instead (this is still a little buggy if toggling on/off quickly). |
| 55 | - **TOGGLE_CAPS_LOCK** - 2 bytes: message type, on/off (CAPS_LOCK_LED_ADDRESS). Same as numlock. | 62 | - **TOGGLE_CAPS_LOCK** (2 bytes) - message type, on/off (CAPS_LOCK_LED_ADDRESS). Same as numlock. |
| 56 | - **STEP_BRIGHTNESS** - 2 bytes: message type, and step up (1) or step down (0). Increase or decrease led brightness. | 63 | - **STEP_BRIGHTNESS** (2 bytes) - message type, and step up (1) or step down (0). Increase or decrease led brightness. |
| 57 | 64 | ||
| 58 | ## Sending messages in Keymap.c | 65 | ## Sending messages in Keymap.c |
| 59 | Sending an action to the led mailbox is done using chMBPost with the following form. | 66 | Sending an action to the led mailbox is done using chMBPost: |
| 60 | ``` | 67 | ``` |
| 61 | chMBPost(&led_mailbox, message, timeout); | 68 | chMBPost(&led_mailbox, message, timeout); |
| 62 | ``` | 69 | ``` |
| @@ -66,14 +73,14 @@ chMBPost(&led_mailbox, message, timeout); | |||
| 66 | 73 | ||
| 67 | An example: | 74 | An example: |
| 68 | 1. set the message to be sent. First byte (LSB) is the led address, and second is the message type | 75 | 1. set the message to be sent. First byte (LSB) is the led address, and second is the message type |
| 69 | `msg=(ON_LED << 8) | 42;` | 76 | *`msg=(ON_LED << 8) | 42;` |
| 70 | 2. send msg to the led mailbox | 77 | 2. send msg to the led mailbox |
| 71 | `chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` | 78 | *`chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` |
| 72 | 79 | ||
| 73 | Another: | 80 | Another: |
| 74 | `msg=(BLINK_TOGGLE_LED << 8) | 46;` | 81 | *`msg=(BLINK_TOGGLE_LED << 8) | 46;` |
| 75 | `chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` | 82 | *`chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` |
| 76 | 83 | ||
| 77 | Finally, SET_FULL_ROW requires an extra byte with row information in the message so sending this message looks like: | 84 | Finally, SET_FULL_ROW requires an extra byte with row information in the message so sending this message looks like: |
| 78 | `msg=(row<<16) | (SET_FULL_ROW << 8) | (led_pin_byte);` | 85 | *`msg=(row<<16) | (SET_FULL_ROW << 8) | (led_pin_byte);` |
| 79 | `chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` | 86 | *`chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);` |
diff --git a/keyboards/infinity60/led_controller.c b/keyboards/infinity60/led_controller.c index d4ad0559b..d776b4fcf 100644 --- a/keyboards/infinity60/led_controller.c +++ b/keyboards/infinity60/led_controller.c | |||
| @@ -186,7 +186,7 @@ page_status = 0; //start frame 0 (all off/on) | |||
| 186 | while(true) { | 186 | while(true) { |
| 187 | // wait for a message (asynchronous) | 187 | // wait for a message (asynchronous) |
| 188 | // (messages are queued (up to LED_MAILBOX_NUM_MSGS) if they can't | 188 | // (messages are queued (up to LED_MAILBOX_NUM_MSGS) if they can't |
| 189 | // be processed right away) | 189 | // be processed right away |
| 190 | chMBFetch(&led_mailbox, &msg, TIME_INFINITE); | 190 | chMBFetch(&led_mailbox, &msg, TIME_INFINITE); |
| 191 | msg_col = (msg >> 24) & 0xFF;//if needed | 191 | msg_col = (msg >> 24) & 0xFF;//if needed |
| 192 | msg_pin = (msg >> 16) & 0XFF;//if needed (e.g. SET_FULL_ROW) | 192 | msg_pin = (msg >> 16) & 0XFF;//if needed (e.g. SET_FULL_ROW) |
| @@ -229,7 +229,7 @@ page_status = 0; //start frame 0 (all off/on) | |||
| 229 | break; | 229 | break; |
| 230 | 230 | ||
| 231 | case TOGGLE_ALL: | 231 | case TOGGLE_ALL: |
| 232 | //msg_led = unused | 232 | //msg_led = unused |
| 233 | is31_read_register(0, 0x00, &temp); | 233 | is31_read_register(0, 0x00, &temp); |
| 234 | led_control_reg[0] = 0; | 234 | led_control_reg[0] = 0; |
| 235 | 235 | ||
| @@ -315,7 +315,7 @@ page_status = 0; //start frame 0 (all off/on) | |||
| 315 | break; | 315 | break; |
| 316 | } | 316 | } |
| 317 | 317 | ||
| 318 | //populate 8 byte rows to write on each pin | 318 | //populate 8 byte arrays to write on each pin |
| 319 | //first byte is register address, every 0x10 9 bytes are A-register pwm pins | 319 | //first byte is register address, every 0x10 9 bytes are A-register pwm pins |
| 320 | __builtin_memset(pwm_register_array+1, pwm_levels[pwm_step_status], 8); | 320 | __builtin_memset(pwm_register_array+1, pwm_levels[pwm_step_status], 8); |
| 321 | 321 | ||
