]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Adding rgb matrix speed into eeprom storage. (#5965)
authorXScorpion2 <rcalt2vt@gmail.com>
Tue, 16 Jul 2019 07:40:43 +0000 (02:40 -0500)
committerskullydazed <skullydazed@users.noreply.github.com>
Tue, 16 Jul 2019 07:40:43 +0000 (00:40 -0700)
Zeroing out spd in eeconfig_init_quantum

Switched to block read & update

Update tmk_core/common/eeconfig.h

Co-Authored-By: Drashna Jaelre <drashna@live.com>
Fixing init compile error

Update eeconfig.c

Dead / Missing API cleanup

alignment

quantum/rgb_matrix.c
quantum/rgb_matrix.h
tmk_core/common/eeconfig.c
tmk_core/common/eeconfig.h
users/xulkal/process_records.c

index d20daf5e45cb3684f14f2e10f5807399cdbbc12a..f170cfc1b7504fa15d94a932c6f5dafa760c2241 100644 (file)
   #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) {
index 96a8b766271cb1a95b3f9ba08fb377217209d201..749926822a8f528794abc19e19a8a00bda1604a4 100644 (file)
 
 #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 {
index 30dc7a48d4c711032ddee08812b33d0b9dc0b83b..4f440abc9c2006bc100e8dbe882c44012dfe355a 100644 (file)
@@ -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();
 }
index 0ac3dff07925ae6c14204beb317421fb760eb7cb..3100041b4e90a3e9a6eb548492449766e5003061 100644 (file)
@@ -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)
index 115623caa44a7dbf6631f90010cf0264b024148e..2c5d2a4e751d58e344ef45848af5295e4b21ffb0 100644 (file)
@@ -2,10 +2,6 @@
 #include "custom_keycodes.h"
 #include "timer_utils.h"
 
-#if defined(RGB_MATRIX_ENABLE)
-extern void eeconfig_update_rgb_matrix_default(void);
-#endif
-
 #ifdef TRILAYER_ENABLED
 uint32_t layer_state_set_user(uint32_t state)
 {