summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quantum/rgb_matrix.c48
-rw-r--r--quantum/rgb_matrix.h39
-rw-r--r--tmk_core/common/eeconfig.c3
-rw-r--r--tmk_core/common/eeconfig.h6
4 files changed, 35 insertions, 61 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c
index d20daf5e45..f170cfc1b7 100644
--- a/quantum/rgb_matrix.c
+++ b/quantum/rgb_matrix.c
@@ -66,10 +66,6 @@
#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
@@ -116,12 +112,12 @@ uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}};
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) {
@@ -130,7 +126,7 @@ void eeconfig_update_rgb_matrix_default(void) {
rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
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) {
@@ -431,12 +427,10 @@ void rgb_matrix_init(void) {
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
}
@@ -448,12 +442,12 @@ void rgb_matrix_set_suspend_state(bool state) {
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) {
@@ -464,7 +458,7 @@ 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) {
@@ -478,7 +472,7 @@ void rgb_matrix_step(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) {
@@ -486,49 +480,49 @@ 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.hsv.h += RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_hue(void) {
rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_sat(void) {
rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_sat(void) {
rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_increase_val(void) {
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(rgb_matrix_config.raw);
+ eeconfig_update_rgb_matrix();
}
void rgb_matrix_decrease_val(void) {
rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
- eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
+ 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) {
@@ -542,7 +536,7 @@ void rgb_matrix_set_flags(led_flags_t flags) {
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) {
@@ -555,7 +549,7 @@ uint8_t rgb_matrix_get_mode(void) {
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) {
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index 96a8b76627..749926822a 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -56,12 +56,6 @@
#define RGB_MATRIX_TEST_LED_FLAGS() if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue
-typedef struct
-{
- HSV color;
- uint8_t index;
-} rgb_indicator;
-
enum rgb_matrix_effects {
RGB_MATRIX_NONE = 0,
@@ -87,11 +81,18 @@ enum rgb_matrix_effects {
RGB_MATRIX_EFFECT_MAX
};
+void eeconfig_update_rgb_matrix_default(void);
+
+uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i);
uint8_t rgb_matrix_map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i);
void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
+bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
+
+void rgb_matrix_task(void);
+
// This runs after another backlight effect and replaces
// colors already set
void rgb_matrix_indicators(void);
@@ -99,37 +100,14 @@ void rgb_matrix_indicators_kb(void);
void rgb_matrix_indicators_user(void);
void rgb_matrix_init(void);
-void rgb_matrix_setup_drivers(void);
void rgb_matrix_set_suspend_state(bool state);
-void rgb_matrix_set_indicator_state(uint8_t state);
-
-
-void rgb_matrix_task(void);
-
-// This should not be called from an interrupt
-// (eg. from a timer interrupt).
-// Call this while idle (in between matrix scans).
-// If the buffer is dirty, it will update the driver with the buffer.
-void rgb_matrix_update_pwm_buffers(void);
-
-bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
-
-void rgb_matrix_increase(void);
-void rgb_matrix_decrease(void);
-
-// void *backlight_get_key_color_eeprom_address(uint8_t led);
-// void backlight_get_key_color( uint8_t led, HSV *hsv );
-// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
-
void rgb_matrix_toggle(void);
void rgb_matrix_enable(void);
void rgb_matrix_enable_noeeprom(void);
void rgb_matrix_disable(void);
void rgb_matrix_disable_noeeprom(void);
void rgb_matrix_step(void);
-void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
-void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
void rgb_matrix_step_reverse(void);
void rgb_matrix_increase_hue(void);
void rgb_matrix_decrease_hue(void);
@@ -144,6 +122,8 @@ void rgb_matrix_set_flags(led_flags_t flags);
void rgb_matrix_mode(uint8_t mode);
void rgb_matrix_mode_noeeprom(uint8_t mode);
uint8_t rgb_matrix_get_mode(void);
+void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
+void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
#ifndef RGBLIGHT_ENABLE
#define rgblight_toggle() rgb_matrix_toggle()
@@ -166,7 +146,6 @@ uint8_t rgb_matrix_get_mode(void);
#define rgblight_mode(mode) rgb_matrix_mode(mode)
#define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode)
#define rgblight_get_mode() rgb_matrix_get_mode()
-
#endif
typedef struct {
diff --git a/tmk_core/common/eeconfig.c b/tmk_core/common/eeconfig.c
index 30dc7a48d4..4f440abc9c 100644
--- a/tmk_core/common/eeconfig.c
+++ b/tmk_core/common/eeconfig.c
@@ -47,9 +47,8 @@ void eeconfig_init_quantum(void) {
eeprom_update_byte(EECONFIG_STENOMODE, 0);
eeprom_update_dword(EECONFIG_HAPTIC, 0);
eeprom_update_byte(EECONFIG_VELOCIKEY, 0);
-#ifdef EECONFIG_RGB_MATRIX
eeprom_update_dword(EECONFIG_RGB_MATRIX, 0);
-#endif
+ eeprom_update_byte(EECONFIG_RGB_MATRIX_SPEED, 0);
eeconfig_init_kb();
}
diff --git a/tmk_core/common/eeconfig.h b/tmk_core/common/eeconfig.h
index 0ac3dff079..3100041b4e 100644
--- a/tmk_core/common/eeconfig.h
+++ b/tmk_core/common/eeconfig.h
@@ -37,12 +37,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EECONFIG_UNICODEMODE (uint8_t *)12
#define EECONFIG_STENOMODE (uint8_t *)13
// EEHANDS for two handed boards
-#define EECONFIG_HANDEDNESS (uint8_t *)14
+#define EECONFIG_HANDEDNESS (uint8_t *)14
#define EECONFIG_KEYBOARD (uint32_t *)15
#define EECONFIG_USER (uint32_t *)19
#define EECONFIG_VELOCIKEY (uint8_t *)23
-#define EECONFIG_HAPTIC (uint32_t*)24
+#define EECONFIG_HAPTIC (uint32_t *)24
+#define EECONFIG_RGB_MATRIX (uint32_t *)28
+#define EECONFIG_RGB_MATRIX_SPEED (uint8_t *)32
/* debug bit */
#define EECONFIG_DEBUG_ENABLE (1<<0)