diff options
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/protocol/arm_atsam/md_rgb_matrix.c | 60 | ||||
-rw-r--r-- | tmk_core/protocol/arm_atsam/md_rgb_matrix.h | 55 |
2 files changed, 84 insertions, 31 deletions
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c index 43d9f2ee6..074158443 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.c +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.c | |||
@@ -15,6 +15,10 @@ You should have received a copy of the GNU General Public License | |||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #define FLUSH_TIMEOUT 5000 | ||
19 | #define EECONFIG_MD_LED ((uint8_t*)(EECONFIG_SIZE + 64)) | ||
20 | #define MD_LED_CONFIG_VERSION 1 | ||
21 | |||
18 | #ifdef RGB_MATRIX_ENABLE | 22 | #ifdef RGB_MATRIX_ENABLE |
19 | # include "arm_atsam_protocol.h" | 23 | # include "arm_atsam_protocol.h" |
20 | # include "led.h" | 24 | # include "led.h" |
@@ -23,8 +27,41 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
23 | # include <math.h> | 27 | # include <math.h> |
24 | 28 | ||
25 | # ifdef USE_MASSDROP_CONFIGURATOR | 29 | # ifdef USE_MASSDROP_CONFIGURATOR |
30 | // TODO?: wire these up to keymap.c | ||
31 | md_led_config_t md_led_config = {0}; | ||
32 | |||
33 | EECONFIG_DEBOUNCE_HELPER(md_led, EECONFIG_MD_LED, md_led_config); | ||
34 | |||
35 | void eeconfig_update_md_led_default(void) { | ||
36 | md_led_config.ver = MD_LED_CONFIG_VERSION; | ||
37 | |||
38 | gcr_desired = LED_GCR_MAX; | ||
39 | led_animation_orientation = 0; | ||
40 | led_animation_direction = 0; | ||
41 | led_animation_breathing = 0; | ||
42 | led_animation_id = 0; | ||
43 | led_animation_speed = 4.0f; | ||
44 | led_lighting_mode = LED_MODE_NORMAL; | ||
45 | led_enabled = 1; | ||
46 | led_animation_breathe_cur = BREATHE_MIN_STEP; | ||
47 | breathe_dir = 1; | ||
48 | led_animation_circular = 0; | ||
49 | led_edge_brightness = 1.0f; | ||
50 | led_ratio_brightness = 1.0f; | ||
51 | led_edge_mode = LED_EDGE_MODE_ALL; | ||
52 | |||
53 | eeconfig_flush_md_led(true); | ||
54 | } | ||
55 | |||
56 | void md_led_changed(void) { eeconfig_flag_md_led(true); } | ||
57 | |||
58 | // todo: use real task rather than this bodge | ||
59 | void housekeeping_task_kb(void) { eeconfig_flush_md_led_task(FLUSH_TIMEOUT); } | ||
60 | |||
26 | __attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}}; | 61 | __attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}}; |
27 | static void md_rgb_matrix_config_override(int i); | 62 | static void md_rgb_matrix_config_override(int i); |
63 | # else | ||
64 | uint8_t gcr_desired; | ||
28 | # endif // USE_MASSDROP_CONFIGURATOR | 65 | # endif // USE_MASSDROP_CONFIGURATOR |
29 | 66 | ||
30 | void SERCOM1_0_Handler(void) { | 67 | void SERCOM1_0_Handler(void) { |
@@ -56,7 +93,6 @@ issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; | |||
56 | issi3733_led_t led_map[ISSI3733_LED_COUNT] = ISSI3733_LED_MAP; | 93 | issi3733_led_t led_map[ISSI3733_LED_COUNT] = ISSI3733_LED_MAP; |
57 | RGB led_buffer[ISSI3733_LED_COUNT]; | 94 | RGB led_buffer[ISSI3733_LED_COUNT]; |
58 | 95 | ||
59 | uint8_t gcr_desired; | ||
60 | uint8_t gcr_actual; | 96 | uint8_t gcr_actual; |
61 | uint8_t gcr_actual_last; | 97 | uint8_t gcr_actual_last; |
62 | # ifdef USE_MASSDROP_CONFIGURATOR | 98 | # ifdef USE_MASSDROP_CONFIGURATOR |
@@ -218,6 +254,13 @@ static void led_set_all(uint8_t r, uint8_t g, uint8_t b) { | |||
218 | static void init(void) { | 254 | static void init(void) { |
219 | DBGC(DC_LED_MATRIX_INIT_BEGIN); | 255 | DBGC(DC_LED_MATRIX_INIT_BEGIN); |
220 | 256 | ||
257 | # ifdef USE_MASSDROP_CONFIGURATOR | ||
258 | eeconfig_init_md_led(); | ||
259 | if (md_led_config.ver != MD_LED_CONFIG_VERSION) { | ||
260 | eeconfig_update_md_led_default(); | ||
261 | } | ||
262 | # endif | ||
263 | |||
221 | issi3733_prepare_arrays(); | 264 | issi3733_prepare_arrays(); |
222 | 265 | ||
223 | md_rgb_matrix_prepare(); | 266 | md_rgb_matrix_prepare(); |
@@ -331,21 +374,6 @@ const rgb_matrix_driver_t rgb_matrix_driver = {.init = init, .flush = flush, .se | |||
331 | # ifdef USE_MASSDROP_CONFIGURATOR | 374 | # ifdef USE_MASSDROP_CONFIGURATOR |
332 | // Ported from Massdrop QMK GitHub Repo | 375 | // Ported from Massdrop QMK GitHub Repo |
333 | 376 | ||
334 | // TODO?: wire these up to keymap.c | ||
335 | uint8_t led_animation_orientation = 0; | ||
336 | uint8_t led_animation_direction = 0; | ||
337 | uint8_t led_animation_breathing = 0; | ||
338 | uint8_t led_animation_id = 0; | ||
339 | float led_animation_speed = 4.0f; | ||
340 | uint8_t led_lighting_mode = LED_MODE_NORMAL; | ||
341 | uint8_t led_enabled = 1; | ||
342 | uint8_t led_animation_breathe_cur = BREATHE_MIN_STEP; | ||
343 | uint8_t breathe_dir = 1; | ||
344 | uint8_t led_animation_circular = 0; | ||
345 | float led_edge_brightness = 1.0f; | ||
346 | float led_ratio_brightness = 1.0f; | ||
347 | uint8_t led_edge_mode = LED_EDGE_MODE_ALL; | ||
348 | |||
349 | static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) { | 377 | static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) { |
350 | float po; | 378 | float po; |
351 | 379 | ||
diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h index f72dca298..deea12b88 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix.h +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix.h | |||
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
19 | #define _LED_MATRIX_H_ | 19 | #define _LED_MATRIX_H_ |
20 | 20 | ||
21 | #include "quantum.h" | 21 | #include "quantum.h" |
22 | #include "eeprom.h" | ||
22 | 23 | ||
23 | // From keyboard | 24 | // From keyboard |
24 | #include "config_led.h" | 25 | #include "config_led.h" |
@@ -79,7 +80,6 @@ typedef struct issi3733_led_s { | |||
79 | 80 | ||
80 | extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; | 81 | extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; |
81 | 82 | ||
82 | extern uint8_t gcr_desired; | ||
83 | extern uint8_t gcr_breathe; | 83 | extern uint8_t gcr_breathe; |
84 | extern uint8_t gcr_actual; | 84 | extern uint8_t gcr_actual; |
85 | extern uint8_t gcr_actual_last; | 85 | extern uint8_t gcr_actual_last; |
@@ -140,19 +140,43 @@ typedef struct led_instruction_s { | |||
140 | 140 | ||
141 | extern led_instruction_t led_instructions[]; | 141 | extern led_instruction_t led_instructions[]; |
142 | 142 | ||
143 | extern uint8_t led_animation_breathing; | 143 | typedef struct led_config_s { |
144 | extern uint8_t led_animation_id; | 144 | uint8_t ver; // assumed to be zero on eeprom reset |
145 | extern float led_animation_speed; | 145 | |
146 | extern uint8_t led_lighting_mode; | 146 | uint8_t desired_gcr; |
147 | extern uint8_t led_enabled; | 147 | uint8_t animation_breathing; |
148 | extern uint8_t led_animation_breathe_cur; | 148 | uint8_t animation_id; |
149 | extern uint8_t led_animation_direction; | 149 | float animation_speed; |
150 | extern uint8_t breathe_dir; | 150 | uint8_t lighting_mode; |
151 | extern uint8_t led_animation_orientation; | 151 | uint8_t enabled; |
152 | extern uint8_t led_animation_circular; | 152 | uint8_t animation_breathe_cur; |
153 | extern float led_edge_brightness; | 153 | uint8_t animation_direction; |
154 | extern float led_ratio_brightness; | 154 | uint8_t animation_breathe_dir; |
155 | extern uint8_t led_edge_mode; | 155 | uint8_t animation_orientation; |
156 | uint8_t animation_circular; | ||
157 | float edge_brightness; | ||
158 | float ratio_brightness; | ||
159 | uint8_t edge_mode; | ||
160 | } md_led_config_t; | ||
161 | |||
162 | extern md_led_config_t md_led_config; | ||
163 | |||
164 | void md_led_changed(void); | ||
165 | |||
166 | # define gcr_desired md_led_config.desired_gcr | ||
167 | # define led_animation_breathing md_led_config.animation_breathing | ||
168 | # define led_animation_id md_led_config.animation_id | ||
169 | # define led_animation_speed md_led_config.animation_speed | ||
170 | # define led_lighting_mode md_led_config.lighting_mode | ||
171 | # define led_enabled md_led_config.enabled | ||
172 | # define led_animation_breathe_cur md_led_config.animation_breathe_cur | ||
173 | # define led_animation_direction md_led_config.animation_direction | ||
174 | # define breathe_dir md_led_config.animation_breathe_dir | ||
175 | # define led_animation_orientation md_led_config.animation_orientation | ||
176 | # define led_animation_circular md_led_config.animation_circular | ||
177 | # define led_edge_brightness md_led_config.edge_brightness | ||
178 | # define led_ratio_brightness md_led_config.ratio_brightness | ||
179 | # define led_edge_mode md_led_config.edge_mode | ||
156 | 180 | ||
157 | # define LED_MODE_NORMAL 0 // Must be 0 | 181 | # define LED_MODE_NORMAL 0 // Must be 0 |
158 | # define LED_MODE_KEYS_ONLY 1 | 182 | # define LED_MODE_KEYS_ONLY 1 |
@@ -173,7 +197,8 @@ extern uint8_t led_edge_mode; | |||
173 | # define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED | 197 | # define LED_IS_EDGE(scan) (scan >= LED_EDGE_MIN_SCAN) // Return true if an LED's scan value indicates an edge LED |
174 | # define LED_IS_EDGE_ALT(scan) (scan == LED_EDGE_ALT_MODE) // Return true if an LED's scan value indicates an alternate edge mode LED | 198 | # define LED_IS_EDGE_ALT(scan) (scan == LED_EDGE_ALT_MODE) // Return true if an LED's scan value indicates an alternate edge mode LED |
175 | # define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator | 199 | # define LED_IS_INDICATOR(scan) (scan == LED_INDICATOR_SCAN) // Return true if an LED's scan value indicates it is a dedicated Indicator |
176 | 200 | #else | |
201 | extern uint8_t gcr_desired; | ||
177 | #endif // USE_MASSDROP_CONFIGURATOR | 202 | #endif // USE_MASSDROP_CONFIGURATOR |
178 | 203 | ||
179 | #endif //_LED_MATRIX_H_ | 204 | #endif //_LED_MATRIX_H_ |