aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjpetermans <tibcmhhm@gmail.com>2017-04-06 16:27:51 -0700
committerjpetermans <tibcmhhm@gmail.com>2017-04-06 16:27:51 -0700
commitaf13e9a12d64f74873e5bf429fdedcda37b3036a (patch)
tree5836346f81d5dc6fbf4ed354f968a3a02c921b54
parent56be3007570a3b6b2e2f78f500cea4fb22430459 (diff)
downloadqmk_firmware-af13e9a12d64f74873e5bf429fdedcda37b3036a.tar.gz
qmk_firmware-af13e9a12d64f74873e5bf429fdedcda37b3036a.zip
Moved led page arrays to keymap.c and added keymap header to define
individual led addresses
-rw-r--r--keyboards/infinity60/keymaps/jpetermans/keymap.c80
-rw-r--r--keyboards/infinity60/keymaps/jpetermans/keymap_jpetermans.h78
-rw-r--r--keyboards/infinity60/led_controller.c51
3 files changed, 152 insertions, 57 deletions
diff --git a/keyboards/infinity60/keymaps/jpetermans/keymap.c b/keyboards/infinity60/keymaps/jpetermans/keymap.c
index 2c38068fe..7b90bc8ed 100644
--- a/keyboards/infinity60/keymaps/jpetermans/keymap.c
+++ b/keyboards/infinity60/keymaps/jpetermans/keymap.c
@@ -1,5 +1,6 @@
1#include "infinity60.h" 1#include "infinity60.h"
2#include "led_controller.h" 2#include "led_controller.h"
3#include "keymap_jpetermans.h"
3 4
4//Helpful Defines 5//Helpful Defines
5#define _______ KC_TRNS 6#define _______ KC_TRNS
@@ -86,6 +87,66 @@ enum function_id {
86enum macro_id { 87enum macro_id {
87 ACTION_LEDS_ALL, 88 ACTION_LEDS_ALL,
88 ACTION_LEDS_GAME 89 ACTION_LEDS_GAME
90//TODO: ACTION_LED_LAYER which reads current layer and turns on appropriate LED
91};
92
93/*
94 Configuring led control can be done
95 1. full keyboard at a time - define led array, or
96 2. individual - send specific led address (defined in keymap.h)
97
98 The arrays relate to the mcu's LED pages (8 available) desribed in led_controller.c
99 0x24 (pcb row 1) is first byte of PWM portion of LED page
100 0x34 (pcb row 2) is 17th byte of PWM portion of LED page
101 array translates to row and column positions
102
103
104 Infinity60 LED MAP
105 11 12 13 14 15 16 17 18 21 22 23 24 25 26 27*
106 28 31 32 33 34 35 36 37 38 41 42 43 44 45
107 46 47 48 51 52 53 54 55 56 57 58 61 62
108 63 64 65 66 67 68 71 72 73 74 75 76 77*
109 78 81 82 83 84 85 86 87
110*Unused in Alphabet Layout
111*/
112
113//"WASD"
114const uint8_t led_game[72] = {
115 0x24,
116 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
117 0x34,
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x44,
120 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121 0x54,
122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
123 0x64,
124 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
125 0x74,
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
127 0x84,
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
129 0x94,
130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
131};
132
133const uint8_t led_all[72] = {
134 0x24,
135 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
136 0x34,
137 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
138 0x44,
139 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
140 0x54,
141 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
142 0x64,
143 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
144 0x74,
145 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
146 0x84,
147 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
148 0x94,
149 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
89}; 150};
90 151
91const uint16_t fn_actions[] = { 152const uint16_t fn_actions[] = {
@@ -94,13 +155,6 @@ const uint16_t fn_actions[] = {
94 [2] = ACTION_FUNCTION(ACTION_LEDS_ALL), 155 [2] = ACTION_FUNCTION(ACTION_LEDS_ALL),
95 [3] = ACTION_FUNCTION(ACTION_LEDS_GAME) 156 [3] = ACTION_FUNCTION(ACTION_LEDS_GAME)
96 157
97/* [1] = ACTION_FUNCTION(ACTION_LEDS_GAME),
98
99 [4] = ACTION_USAGE_CONSUMER(0x1B4),
100 [5] = ACTION_USAGE_CONSUMER(0x196),
101 [6] = ACTION_USAGE_CONSUMER(0x1A6),
102 [7] = ACTION_USAGE_CONSUMER(0x1A0)
103*/
104}; 158};
105 159
106/* custom action function */ 160/* custom action function */
@@ -140,7 +194,19 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
140 194
141// Runs just one time when the keyboard initializes. 195// Runs just one time when the keyboard initializes.
142void matrix_init_user(void) { 196void matrix_init_user(void) {
197 uint8_t j;
198
143 led_controller_init(); 199 led_controller_init();
200
201//TODO: do pages need to be written at init or ok on demand?
202 /* Write pages */
203 for(j=0; j<8; j++) {
204 is31_write_data(1,(uint8_t *)(led_game+(9*j)),9);
205 chThdSleepMilliseconds(5);
206 is31_write_data(2,(uint8_t *)(led_all+(9*j)),9);
207 chThdSleepMilliseconds(5);
208 }
209
144}; 210};
145 211
146// Runs constantly in the background, in a loop. 212// Runs constantly in the background, in a loop.
diff --git a/keyboards/infinity60/keymaps/jpetermans/keymap_jpetermans.h b/keyboards/infinity60/keymaps/jpetermans/keymap_jpetermans.h
new file mode 100644
index 000000000..240374423
--- /dev/null
+++ b/keyboards/infinity60/keymaps/jpetermans/keymap_jpetermans.h
@@ -0,0 +1,78 @@
1/* LED layout mainly based on default Standard configuration
2 * ,-----------------------------------------------------------.
3 * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ | ` |
4 * |-----------------------------------------------------------|
5 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Bksp|
6 * |-----------------------------------------------------------|
7 * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter |
8 * |-----------------------------------------------------------|
9 * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
10 * |-----------------------------------------------------------'
11 * | LCtl|LGui|LAlt | Space | RAlt|RGui|RMenu|RCtl|
12 * `-----------------------------------------------------------'
13*/
14
15
16#define ADDR_LED_ESC 0x24
17#define ADDR_LED_1 0x25
18#define ADDR_LED_2 0x26
19#define ADDR_LED_3 0x27
20#define ADDR_LED_4 0x28
21#define ADDR_LED_5 0x29
22#define ADDR_LED_6 0x2A
23#define ADDR_LED_7 0x2B
24#define ADDR_LED_8 0x34
25#define ADDR_LED_9 0x35
26#define ADDR_LED_0 0x36
27#define ADDR_LED_MINS 0x37
28#define ADDR_LED_EQL 0x38
29#define ADDR_LED_BSLS 0x39
30//#define ADDR_LED_GRV 0x3A //not used by Alphabet layout
31#define ADDR_LED_TAB 0x3B
32#define ADDR_LED_Q 0x44
33#define ADDR_LED_W 0x45
34#define ADDR_LED_E 0x46
35#define ADDR_LED_R 0x47
36#define ADDR_LED_T 0x48
37#define ADDR_LED_Y 0x49
38#define ADDR_LED_U 0x4A
39#define ADDR_LED_I 0x4B
40#define ADDR_LED_O 0x54
41#define ADDR_LED_P 0x55
42#define ADDR_LED_LBRC 0x56
43#define ADDR_LED_RBRC 0x57
44#define ADDR_LED_BSPC 0x58
45#define ADDR_LED_CAPS 0x59
46#define ADDR_LED_A 0x5A
47#define ADDR_LED_S 0x5B
48#define ADDR_LED_D 0x64
49#define ADDR_LED_F 0x65
50#define ADDR_LED_G 0x66
51#define ADDR_LED_H 0x67
52#define ADDR_LED_J 0x68
53#define ADDR_LED_K 0x69
54#define ADDR_LED_L 0x6A
55#define ADDR_LED_SCLN 0x6B
56#define ADDR_LED_QUOT 0x74
57#define ADDR_LED_ENT 0x75
58#define ADDR_LED_LSFT 0x76
59#define ADDR_LED_Z 0x77
60#define ADDR_LED_X 0x78
61#define ADDR_LED_C 0x79
62#define ADDR_LED_V 0x7A
63#define ADDR_LED_B 0x7B
64#define ADDR_LED_N 0x84
65#define ADDR_LED_M 0x85
66#define ADDR_LED_COMM 0x86
67#define ADDR_LED_DOT 0x87
68#define ADDR_LED_SLSH 0x88
69#define ADDR_LED_RSFT 0x89
70//#define ADDR_LED_FN0 0x8A //not used by Alphabet layout
71#define ADDR_LED_LCTL 0x8B
72#define ADDR_LED_LGUI 0x94
73#define ADDR_LED_LALT 0x95
74#define ADDR_LED_SPC 0x96
75#define ADDR_LED_RALT 0x97
76#define ADDR_LED_RGUI 0x98
77#define ADDR_LED_MENU 0x99
78#define ADDR_LED_RCTL 0x9A
diff --git a/keyboards/infinity60/led_controller.c b/keyboards/infinity60/led_controller.c
index c5303a3e7..9579bc08b 100644
--- a/keyboards/infinity60/led_controller.c
+++ b/keyboards/infinity60/led_controller.c
@@ -171,6 +171,7 @@ static THD_FUNCTION(LEDthread, arg) {
171 171
172 // process 'msg' here 172 // process 'msg' here
173 switch(msg) { 173 switch(msg) {
174//TODO: make this generic and able to turn on/off any address and loop through all(or current) pages
174 case LED_MSG_CAPS_ON: 175 case LED_MSG_CAPS_ON:
175 // turn caps on on pages 1 and 2 176 // turn caps on on pages 1 and 2
176 is31_write_register(0, CAPS_LOCK_LED_ADDRESS, 0xFF); 177 is31_write_register(0, CAPS_LOCK_LED_ADDRESS, 0xFF);
@@ -238,48 +239,6 @@ static THD_FUNCTION(LEDthread, arg) {
238 } 239 }
239} 240}
240 241
241//These relate to the LED map above, row and column
242//0x24 = first byte (CA1) of PWM page, 0x34 is 17th byte (CA2)
243/* LED game mode */
244const uint8_t led_game[72] = {
245 0x24,
246 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
247 0x34,
248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
249 0x44,
250 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251 0x54,
252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
253 0x64,
254 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
255 0x74,
256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257 0x84,
258 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
259 0x94,
260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
261};
262
263/* ALL LEDs */
264const uint8_t led_all[72] = {
265 0x24,
266 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
267 0x34,
268 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
2690x44,
270 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
271 0x54,
272 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
273 0x64,
274 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
275 0x74,
276 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
277 0x84,
278 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
279 0x94,
280 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
281};
282
283/* ============= 242/* =============
284 * hook into TMK 243 * hook into TMK
285 * ============= */ 244 * ============= */
@@ -315,14 +274,6 @@ void led_controller_init(void) {
315 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL1, (3<<4)|3); 274 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL1, (3<<4)|3);
316 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL2, IS31_REG_BREATHCTRL2_ENABLE|3); 275 is31_write_register(IS31_FUNCTIONREG, IS31_REG_BREATHCTRL2, IS31_REG_BREATHCTRL2_ENABLE|3);
317 276
318 /* Write pages */
319 for(i=0; i<8; i++) {
320 is31_write_data(1,(uint8_t *)(led_game+(9*i)),9);
321 chThdSleepMilliseconds(5);
322 is31_write_data(2,(uint8_t *)(led_all+(9*i)),9);
323 chThdSleepMilliseconds(5);
324 }
325
326 // clean up the capslock LED 277 // clean up the capslock LED
327 is31_write_register(1, CAPS_LOCK_LED_ADDRESS, 0); 278 is31_write_register(1, CAPS_LOCK_LED_ADDRESS, 0);
328 is31_write_register(2, CAPS_LOCK_LED_ADDRESS, 0); 279 is31_write_register(2, CAPS_LOCK_LED_ADDRESS, 0);