aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpetermans <tibcmhhm@gmail.com>2017-05-24 11:20:50 -0700
committerjpetermans <tibcmhhm@gmail.com>2017-05-24 11:20:50 -0700
commitf54b4771eb23027be1bd66a6fe1300713b593d58 (patch)
treeff1b2d2aa2eb5fea37dd112346a4e99348937530
parent164a6c994b797b66634f7a1c12fcaffd0ffd7506 (diff)
downloadqmk_firmware-f54b4771eb23027be1bd66a6fe1300713b593d58.tar.gz
qmk_firmware-f54b4771eb23027be1bd66a6fe1300713b593d58.zip
keymap example update and tweak to set_led_bit function
-rw-r--r--keyboards/infinity60/keymaps/jpetermans/keymap.c6
-rw-r--r--keyboards/infinity60/keymaps/jpetermans/readme.md12
-rw-r--r--keyboards/infinity60/led_controller.c27
3 files changed, 21 insertions, 24 deletions
diff --git a/keyboards/infinity60/keymaps/jpetermans/keymap.c b/keyboards/infinity60/keymaps/jpetermans/keymap.c
index 8d19834b2..cc4633b1b 100644
--- a/keyboards/infinity60/keymaps/jpetermans/keymap.c
+++ b/keyboards/infinity60/keymaps/jpetermans/keymap.c
@@ -59,7 +59,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
59 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \ 59 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \
60 TT(_FNAV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT, \ 60 TT(_FNAV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT, \
61 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,F(TILDE),KC_NO, \ 61 KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,F(TILDE),KC_NO, \
62 KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,TG(_NUMPAD),MO(_MEDIA), KC_RCTL \ 62 KC_LCTL, KC_LGUI,KC_LALT, LT(_FNAV, KC_SPC), KC_RALT,TG(_NUMPAD),MO(_MEDIA), KC_RCTL \
63 ), 63 ),
64 64
65 /* numpad */ 65 /* numpad */
@@ -68,7 +68,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
68 _______,_______,_______,_______,_______,_______,_______, KC_P4, KC_P5, KC_P6, KC_PAST, _______,_______,_______, \ 68 _______,_______,_______,_______,_______,_______,_______, KC_P4, KC_P5, KC_P6, KC_PAST, _______,_______,_______, \
69 MO(_FNAV),_______,_______,_______,_______,_______,_______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______,_______, \ 69 MO(_FNAV),_______,_______,_______,_______,_______,_______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______,_______, \
70 _______,_______,_______,_______,_______,_______,_______, KC_P0,KC_COMM,KC_PDOT,KC_PPLS, _______,KC_NO, \ 70 _______,_______,_______,_______,_______,_______,_______, KC_P0,KC_COMM,KC_PDOT,KC_PPLS, _______,KC_NO, \
71 _______,_______,_______, MO(_BASE), _______,_______,_______,_______ \ 71 _______,_______,_______, TO(_BASE), _______,_______,_______,_______ \
72 ), 72 ),
73 73
74 /* F-, arrow, and media keys */ 74 /* F-, arrow, and media keys */
@@ -290,7 +290,7 @@ void matrix_scan_user(void) {
290 led_pin_byte = layer_state & 0xFF; 290 led_pin_byte = layer_state & 0xFF;
291 msg=(7 << 8) | DISPLAY_PAGE; 291 msg=(7 << 8) | DISPLAY_PAGE;
292 chMBPost(&led_mailbox, msg, TIME_IMMEDIATE); 292 chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
293 msg=(1<<16) | (led_pin_byte << 8) | SET_FULL_ROW; 293 msg=(1 << 16) | (led_pin_byte << 8) | SET_FULL_ROW;
294 chMBPost(&led_mailbox, msg, TIME_IMMEDIATE); 294 chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
295 break; 295 break;
296 296
diff --git a/keyboards/infinity60/keymaps/jpetermans/readme.md b/keyboards/infinity60/keymaps/jpetermans/readme.md
index 63fd88ec2..b83057ea7 100644
--- a/keyboards/infinity60/keymaps/jpetermans/readme.md
+++ b/keyboards/infinity60/keymaps/jpetermans/readme.md
@@ -16,9 +16,9 @@ digits mean "row" and "col", i.e. 45 means pin 4, column 5 in the IS31 datasheet
16``` 16```
17*Unused in Alphabet Layout 17*Unused in Alphabet Layout
18 18
19The IS31 includes 8 pages (or frames) 0-7 and each page consists of 144 bytes 19The IS31 includes 8 led pages (or frames) 0-7 than can be displayed, and each page consists of 144 bytes.
20- **bytes 0 - 17** - LED control (on/off). 20- **bytes 0 - 17** - LED control (on/off).
21 * 18 pins which alternate between A and B matrices (CA1, CB1, CA2, CB2, ..). 21 * 18 pins which alternate between A and B matrices (A1, B1, A2, B2, ..).
22 * Each byte controls the 8 leds on that pin with bits (8 to 1). 22 * Each byte controls the 8 leds on that pin with bits (8 to 1).
23- **bytes 8 - 35** - Blink control. 23- **bytes 8 - 35** - Blink control.
24 * Same as LED control above, but sets blink on/off. 24 * Same as LED control above, but sets blink on/off.
@@ -31,7 +31,7 @@ In the Infinity60 project folder, led_controller.c sets up ability to write led
31 31
32One function is available to directly set leds without the mailbox: 32One function is available to directly set leds without the mailbox:
33``` 33```
34write_led_page(page#, array of leds by address, # of leds in array) 34write_led_page(page#, array of leds by address, # of addresses in array)
35``` 35```
36This function saves a full page to the controller using a supplied array of led locations such as: 36This function saves a full page to the controller using a supplied array of led locations such as:
37```c 37```c
@@ -45,7 +45,7 @@ write_led_page(5, led_numpad, 16);
45``` 45```
46 46
47Remaining led control is done through the led mailbox using these message types: 47Remaining led control is done through the led mailbox using these message types:
48- **SET_FULL_ROW** (3 bytes) - row#, message type, 8-bit mask. Sets all leds on one pin per the bit mask. 48- **SET_FULL_ROW** (3 bytes) - message type, 8-bit mask, and row#. Sets all leds on one pin per the bit mask.
49- **OFF_LED, ON_LED, TOGGLE_LED** (3 bytes) - message type, led address, and page#. Off/on/toggle specific led. 49- **OFF_LED, ON_LED, TOGGLE_LED** (3 bytes) - message type, led address, and page#. Off/on/toggle specific led.
50- **BLINK_OFF_LED, BLINK_ON_LED, BLINK_OFF_LED** (3 bytes) - message type, led address, and page#. Set blink Off/on/toggle for specific led. 50- **BLINK_OFF_LED, BLINK_ON_LED, BLINK_OFF_LED** (3 bytes) - message type, led address, and page#. Set blink Off/on/toggle for specific led.
51- **TOGGLE_ALL** (1 byte) - Turn on/off full backlight. 51- **TOGGLE_ALL** (1 byte) - Turn on/off full backlight.
@@ -68,7 +68,7 @@ chMBPost(&led_mailbox, message, timeout);
68An example: 68An example:
69```c 69```c
70//set the message to be sent. First byte (LSB) is the led address, and second is the message type 70//set the message to be sent. First byte (LSB) is the led address, and second is the message type
71msg=(42 << 8) | ON_LED 71msg=(42 << 8) | ON_LED;
72 72
73//send msg to the led mailbox 73//send msg to the led mailbox
74chMBPost(&led_mailbox, msg, TIME_IMMEDIATE); 74chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
@@ -76,7 +76,7 @@ chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
76 76
77Another: 77Another:
78```c 78```c
79msg=(46 << 8) | BLINK_TOGGLE_LED 79msg=(46 << 8) | BLINK_TOGGLE_LED;
80chMBPost(&led_mailbox, msg, TIME_IMMEDIATE); 80chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
81``` 81```
82 82
diff --git a/keyboards/infinity60/led_controller.c b/keyboards/infinity60/led_controller.c
index a66edb927..04793cc01 100644
--- a/keyboards/infinity60/led_controller.c
+++ b/keyboards/infinity60/led_controller.c
@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
25#include "hal.h" 25#include "hal.h"
26#include "print.h" 26#include "print.h"
27#include "led.h" 27#include "led.h"
28#include "action_layer.h"
29#include "host.h" 28#include "host.h"
30 29
31#include "led_controller.h" 30#include "led_controller.h"
@@ -199,31 +198,25 @@ static THD_FUNCTION(LEDthread, arg) {
199 break; 198 break;
200 199
201 case OFF_LED: 200 case OFF_LED:
202 //on/off/toggle single led, msg_args[0] = row/col of led 201 //on/off/toggle single led, msg_args[0] = row/col of led, msg_args[1] = page
203 set_led_bit(msg_args[1], control_register_word, msg_args[0], 0); 202 set_led_bit(msg_args[1], control_register_word, msg_args[0], 0);
204 is31_write_data (msg_args[1], control_register_word, 0x02);
205 break; 203 break;
206 case ON_LED: 204 case ON_LED:
207 set_led_bit(msg_args[1], control_register_word, msg_args[0], 1); 205 set_led_bit(msg_args[1], control_register_word, msg_args[0], 1);
208 is31_write_data (msg_args[1], control_register_word, 0x02);
209 break; 206 break;
210 case TOGGLE_LED: 207 case TOGGLE_LED:
211 set_led_bit(msg_args[1], control_register_word, msg_args[0], 2); 208 set_led_bit(msg_args[1], control_register_word, msg_args[0], 2);
212 is31_write_data (msg_args[1], control_register_word, 0x02);
213 break; 209 break;
214 210
215 case BLINK_OFF_LED: 211 case BLINK_OFF_LED:
216 //on/off/toggle single led, msg_args[0] = row/col of led 212 //on/off/toggle single led, msg_args[0] = row/col of led
217 set_led_bit(msg_args[1], control_register_word, msg_args[0], 4); 213 set_led_bit(msg_args[1], control_register_word, msg_args[0], 4);
218 is31_write_data (msg_args[1], control_register_word, 0x02);
219 break; 214 break;
220 case BLINK_ON_LED: 215 case BLINK_ON_LED:
221 set_led_bit(msg_args[1], control_register_word, msg_args[0], 5); 216 set_led_bit(msg_args[1], control_register_word, msg_args[0], 5);
222 is31_write_data (msg_args[1], control_register_word, 0x02);
223 break; 217 break;
224 case BLINK_TOGGLE_LED: 218 case BLINK_TOGGLE_LED:
225 set_led_bit(msg_args[1], control_register_word, msg_args[0], 6); 219 set_led_bit(msg_args[1], control_register_word, msg_args[0], 6);
226 is31_write_data (msg_args[1], control_register_word, 0x02);
227 break; 220 break;
228 221
229 case TOGGLE_ALL: 222 case TOGGLE_ALL:
@@ -282,6 +275,10 @@ static THD_FUNCTION(LEDthread, arg) {
282 led_control_reg[0] = 0; 275 led_control_reg[0] = 0;
283 __builtin_memset(led_control_reg+1, 0, 0x12); 276 __builtin_memset(led_control_reg+1, 0, 0x12);
284 is31_write_data(msg_args[0], led_control_reg, 0x13); 277 is31_write_data(msg_args[0], led_control_reg, 0x13);
278
279 //repeat for blink register
280 led_control_reg[0] = 0x12;
281 is31_write_data(msg_args[0], led_control_reg, 0x13);
285 break; 282 break;
286 283
287 case TOGGLE_NUM_LOCK: 284 case TOGGLE_NUM_LOCK:
@@ -330,7 +327,7 @@ static THD_FUNCTION(LEDthread, arg) {
330 * led processing functions 327 * led processing functions
331 * ============================== */ 328 * ============================== */
332 329
333void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint8_t action) { 330void set_led_bit (uint8_t page, uint8_t *led_control_word, uint8_t led_addr, uint8_t action) {
334 //returns 2 bytes: led control register address and byte to write 331 //returns 2 bytes: led control register address and byte to write
335 //action: 0 - off, 1 - on, 2 - toggle, 4 - blink on, 5 - blink off, 6 - toggle blink 332 //action: 0 - off, 1 - on, 2 - toggle, 4 - blink on, 5 - blink off, 6 - toggle blink
336 333
@@ -341,11 +338,9 @@ void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint
341 return; 338 return;
342 } 339 }
343 340
344 //check for blink bit 341 blink_bit = action>>2;//check for blink bit
345 blink_bit = action>>2;
346 action &= ~(1<<2); //strip blink bit 342 action &= ~(1<<2); //strip blink bit
347 343
348 //first byte is led control register address 0x00
349 //led_addr tens column is pin#, ones column is bit position in 8-bit mask 344 //led_addr tens column is pin#, ones column is bit position in 8-bit mask
350 control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte 345 control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte
351 control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register 346 control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register
@@ -367,8 +362,9 @@ void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint
367 } 362 }
368 363
369 //return word to be written in register 364 //return word to be written in register
370 led_control_reg[0] = control_reg_addr; 365 led_control_word[0] = control_reg_addr;
371 led_control_reg[1] = column_byte; 366 led_control_word[1] = column_byte;
367 is31_write_data (page, led_control_word, 0x02);
372} 368}
373 369
374void write_led_byte (uint8_t page, uint8_t row, uint8_t led_byte) { 370void write_led_byte (uint8_t page, uint8_t row, uint8_t led_byte) {
@@ -403,13 +399,14 @@ void set_lock_leds(uint8_t led_addr, uint8_t led_action, uint8_t page) {
403 //blink if all leds are on 399 //blink if all leds are on
404 if (page == 0) { 400 if (page == 0) {
405 is31_read_register(0, 0x00, &temp); 401 is31_read_register(0, 0x00, &temp);
402 chThdSleepMilliseconds(10);
403
406 if (temp == 0xFF) { 404 if (temp == 0xFF) {
407 led_action |= (1<<2); //set blink bit 405 led_action |= (1<<2); //set blink bit
408 } 406 }
409 } 407 }
410 408
411 set_led_bit(page,led_control_word,led_addr,led_action); 409 set_led_bit(page,led_control_word,led_addr,led_action);
412 is31_write_data(page, led_control_word, 0x02);
413} 410}
414 411
415/* ===================== 412/* =====================