]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
rgblight split transfer non-eeprom config (#5396)
authorLen Trigg <lenbok@gmail.com>
Fri, 15 Mar 2019 20:46:49 +0000 (09:46 +1300)
committerDrashna Jaelre <drashna@live.com>
Fri, 15 Mar 2019 20:46:49 +0000 (13:46 -0700)
* Make rgblight_update_dword not update eeprom (we already have
eeconfig_update_rgblight for that).

Make split i2c keyboards transfer active rgblight config rather than
eeprom saved version of rgblight config, enabling runtime changes
that aren't persisted to eeprom.

* prev_level and prev_rgb only store successfully transmitted values

quantum/api.c
quantum/rgblight.c
quantum/rgblight.h
quantum/split_common/transport.c

index 52dfe23e17648593b479152abee235cd393806de..233f99636de4a9dd16cee230602f463003c688c8 100644 (file)
@@ -67,7 +67,7 @@ void process_api(uint16_t length, uint8_t * data) {
                 case DT_RGBLIGHT: {
                     #ifdef RGBLIGHT_ENABLE
                         uint32_t rgblight = bytes_to_dword(data, 2);
-                        rgblight_update_dword(rgblight);
+                        eeconfig_update_rgblight(rgblight);
                     #endif
                     break;
                 }
index 52e0be8ba01604e7a63ef8b3fa33eaedd3d29031..119ca1b9eeeb4392cb6914b5b675744ef6284cef 100644 (file)
@@ -225,11 +225,14 @@ void rgblight_init(void) {
 
 }
 
+uint32_t rgblight_read_dword(void) {
+  return rgblight_config.raw;
+}
+
 void rgblight_update_dword(uint32_t dword) {
   rgblight_config.raw = dword;
-  eeconfig_update_rgblight(rgblight_config.raw);
   if (rgblight_config.enable)
-    rgblight_mode(rgblight_config.mode);
+    rgblight_mode_noeeprom(rgblight_config.mode);
   else {
 #ifdef RGBLIGHT_USE_TIMER
       rgblight_timer_disable();
index f92388c96104285698eb9652412a3bb69096223f..36e436b899b490188881a4b714983b22296c5acd 100644 (file)
@@ -174,6 +174,7 @@ void rgblight_step_reverse(void);
 uint8_t rgblight_get_mode(void);
 void rgblight_mode(uint8_t mode);
 void rgblight_set(void);
+uint32_t rgblight_read_dword(void);
 void rgblight_update_dword(uint32_t dword);
 void rgblight_increase_hue(void);
 void rgblight_decrease_hue(void);
index b16852bc161e07c7c787a3ad3dab9c76f12803b9..3696a2abaa74ac8604aa7ce4c6a2bf35d24724ce 100644 (file)
@@ -39,17 +39,19 @@ bool transport_master(matrix_row_t matrix[]) {
   static uint8_t prev_level = ~0;
   uint8_t        level      = get_backlight_level();
   if (level != prev_level) {
-    i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIT_START, (void *)&level, sizeof(level), TIMEOUT);
-    prev_level = level;
+    if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) {
+      prev_level = level;
+    }
   }
 #  endif
 
 #  ifdef RGBLIGHT_ENABLE
   static uint32_t prev_rgb = ~0;
-  uint32_t        rgb      = eeconfig_read_rgblight();
+  uint32_t        rgb      = rgblight_read_dword();
   if (rgb != prev_rgb) {
-    i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START, (void *)&rgb, sizeof(rgb), TIMEOUT);
-    prev_rgb = rgb;
+    if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START, (void *)&rgb, sizeof(rgb), TIMEOUT) >= 0) {
+      prev_rgb = rgb;
+    }
   }
 #  endif