aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.c60
-rw-r--r--tmk_core/protocol/arm_atsam/md_rgb_matrix.h55
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
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along 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
31md_led_config_t md_led_config = {0};
32
33EECONFIG_DEBOUNCE_HELPER(md_led, EECONFIG_MD_LED, md_led_config);
34
35void 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
56void md_led_changed(void) { eeconfig_flag_md_led(true); }
57
58// todo: use real task rather than this bodge
59void 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}};
27static void md_rgb_matrix_config_override(int i); 62static void md_rgb_matrix_config_override(int i);
63# else
64uint8_t gcr_desired;
28# endif // USE_MASSDROP_CONFIGURATOR 65# endif // USE_MASSDROP_CONFIGURATOR
29 66
30void SERCOM1_0_Handler(void) { 67void SERCOM1_0_Handler(void) {
@@ -56,7 +93,6 @@ issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT];
56issi3733_led_t led_map[ISSI3733_LED_COUNT] = ISSI3733_LED_MAP; 93issi3733_led_t led_map[ISSI3733_LED_COUNT] = ISSI3733_LED_MAP;
57RGB led_buffer[ISSI3733_LED_COUNT]; 94RGB led_buffer[ISSI3733_LED_COUNT];
58 95
59uint8_t gcr_desired;
60uint8_t gcr_actual; 96uint8_t gcr_actual;
61uint8_t gcr_actual_last; 97uint8_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) {
218static void init(void) { 254static 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
335uint8_t led_animation_orientation = 0;
336uint8_t led_animation_direction = 0;
337uint8_t led_animation_breathing = 0;
338uint8_t led_animation_id = 0;
339float led_animation_speed = 4.0f;
340uint8_t led_lighting_mode = LED_MODE_NORMAL;
341uint8_t led_enabled = 1;
342uint8_t led_animation_breathe_cur = BREATHE_MIN_STEP;
343uint8_t breathe_dir = 1;
344uint8_t led_animation_circular = 0;
345float led_edge_brightness = 1.0f;
346float led_ratio_brightness = 1.0f;
347uint8_t led_edge_mode = LED_EDGE_MODE_ALL;
348
349static void led_run_pattern(led_setup_t* f, float* ro, float* go, float* bo, float pos) { 377static 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
80extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT]; 81extern issi3733_driver_t issidrv[ISSI3733_DRIVER_COUNT];
81 82
82extern uint8_t gcr_desired;
83extern uint8_t gcr_breathe; 83extern uint8_t gcr_breathe;
84extern uint8_t gcr_actual; 84extern uint8_t gcr_actual;
85extern uint8_t gcr_actual_last; 85extern uint8_t gcr_actual_last;
@@ -140,19 +140,43 @@ typedef struct led_instruction_s {
140 140
141extern led_instruction_t led_instructions[]; 141extern led_instruction_t led_instructions[];
142 142
143extern uint8_t led_animation_breathing; 143typedef struct led_config_s {
144extern uint8_t led_animation_id; 144 uint8_t ver; // assumed to be zero on eeprom reset
145extern float led_animation_speed; 145
146extern uint8_t led_lighting_mode; 146 uint8_t desired_gcr;
147extern uint8_t led_enabled; 147 uint8_t animation_breathing;
148extern uint8_t led_animation_breathe_cur; 148 uint8_t animation_id;
149extern uint8_t led_animation_direction; 149 float animation_speed;
150extern uint8_t breathe_dir; 150 uint8_t lighting_mode;
151extern uint8_t led_animation_orientation; 151 uint8_t enabled;
152extern uint8_t led_animation_circular; 152 uint8_t animation_breathe_cur;
153extern float led_edge_brightness; 153 uint8_t animation_direction;
154extern float led_ratio_brightness; 154 uint8_t animation_breathe_dir;
155extern 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
162extern md_led_config_t md_led_config;
163
164void 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
201extern 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_