const point_t k_rgb_matrix_center = RGB_MATRIX_CENTER;
#endif
+// Generic effect runners
+#include "rgb_matrix_runners/effect_runner_dx_dy_dist.h"
+#include "rgb_matrix_runners/effect_runner_dx_dy.h"
+#include "rgb_matrix_runners/effect_runner_i.h"
+#include "rgb_matrix_runners/effect_runner_sin_cos_i.h"
+#include "rgb_matrix_runners/effect_runner_reactive.h"
+#include "rgb_matrix_runners/effect_runner_reactive_splash.h"
+
// ------------------------------------------
// -----Begin rgb effect includes macros-----
#define RGB_MATRIX_EFFECT(name)
#define RGB_DISABLE_WHEN_USB_SUSPENDED false
#endif
-#ifndef EECONFIG_RGB_MATRIX
- #define EECONFIG_RGB_MATRIX EECONFIG_RGBLIGHT
-#endif
-
#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
#undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
#define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
static last_hit_t last_hit_buffer;
#endif // RGB_MATRIX_KEYREACTIVE_ENABLED
-uint32_t eeconfig_read_rgb_matrix(void) {
- return eeprom_read_dword(EECONFIG_RGB_MATRIX);
+void eeconfig_read_rgb_matrix(void) {
+ eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config));
}
-void eeconfig_update_rgb_matrix(uint32_t val) {
- eeprom_update_dword(EECONFIG_RGB_MATRIX, val);
+void eeconfig_update_rgb_matrix(void) {
+ eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config));
}
void eeconfig_update_rgb_matrix_default(void) {
dprintf("eeconfig_update_rgb_matrix_default\n");
rgb_matrix_config.enable = 1;
rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
- rgb_matrix_config.hue = 0;
- rgb_matrix_config.sat = UINT8_MAX;
- rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
+ rgb_matrix_config.hsv = (HSV){ 0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS };
rgb_matrix_config.speed = UINT8_MAX / 2;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void eeconfig_debug_rgb_matrix(void) {
dprintf("rgb_matrix_config eprom\n");
dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable);
dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode);
- dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue);
- dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat);
- dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val);
+ dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h);
+ dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
+ dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
}
eeconfig_update_rgb_matrix_default();
}
- rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
- rgb_matrix_config.speed = UINT8_MAX / 2; //EECONFIG needs to be increased to support this
+ eeconfig_read_rgb_matrix();
if (!rgb_matrix_config.mode) {
dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n");
eeconfig_update_rgb_matrix_default();
- rgb_matrix_config.raw = eeconfig_read_rgb_matrix();
}
eeconfig_debug_rgb_matrix(); // display current eeprom values
}
void rgb_matrix_toggle(void) {
rgb_matrix_config.enable ^= 1;
rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_enable(void) {
rgb_matrix_enable_noeeprom();
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_enable_noeeprom(void) {
void rgb_matrix_disable(void) {
rgb_matrix_disable_noeeprom();
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_disable_noeeprom(void) {
if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX)
rgb_matrix_config.mode = 1;
rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_step_reverse(void) {
if (rgb_matrix_config.mode < 1)
rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1;
rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_hue(void) {
- rgb_matrix_config.hue += RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_hue(void) {
- rgb_matrix_config.hue -= RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_sat(void) {
- rgb_matrix_config.sat = qadd8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_sat(void) {
- rgb_matrix_config.sat = qsub8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_val(void) {
- rgb_matrix_config.val = qadd8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
- if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
- rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
+ if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
+ rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_val(void) {
- rgb_matrix_config.val = qsub8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_speed(void) {
rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_speed(void) {
rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this
+ eeconfig_update_rgb_matrix();
}
led_flags_t rgb_matrix_get_flags(void) {
void rgb_matrix_mode(uint8_t mode) {
rgb_matrix_config.mode = mode;
rgb_task_state = STARTING;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_mode_noeeprom(uint8_t mode) {
void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
rgb_matrix_sethsv_noeeprom(hue, sat, val);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
- rgb_matrix_config.hue = hue;
- rgb_matrix_config.sat = sat;
- rgb_matrix_config.val = val;
- if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
- rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
+ rgb_matrix_config.hsv.h = hue;
+ rgb_matrix_config.hsv.s = sat;
+ rgb_matrix_config.hsv.v = val;
+ if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
+ rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
}