summaryrefslogtreecommitdiff
path: root/quantum/rgblight
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgblight')
-rw-r--r--quantum/rgblight/rgblight.c33
-rw-r--r--quantum/rgblight/rgblight.h20
2 files changed, 29 insertions, 24 deletions
diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c
index 19d80e0097..ea28801a40 100644
--- a/quantum/rgblight/rgblight.c
+++ b/quantum/rgblight/rgblight.c
@@ -21,6 +21,7 @@
#include "rgblight.h"
#include "color.h"
#include "debug.h"
+#include "util.h"
#include "led_tables.h"
#include <lib/lib8tion/lib8tion.h>
#ifdef EEPROM_ENABLE
@@ -30,13 +31,6 @@
# include "velocikey.h"
#endif
-#ifndef MIN
-# define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#endif
-#ifndef MAX
-# define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#endif
-
#ifdef RGBLIGHT_SPLIT
/* for split keyboard */
# define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE
@@ -183,18 +177,19 @@ void rgblight_check_config(void) {
}
}
-uint32_t eeconfig_read_rgblight(void) {
+uint64_t eeconfig_read_rgblight(void) {
#ifdef EEPROM_ENABLE
- return eeprom_read_dword(EECONFIG_RGBLIGHT);
+ return (uint64_t)((eeprom_read_dword(EECONFIG_RGBLIGHT)) | ((uint64_t)eeprom_read_byte(EECONFIG_RGBLIGHT_EXTENDED) << 32));
#else
return 0;
#endif
}
-void eeconfig_update_rgblight(uint32_t val) {
+void eeconfig_update_rgblight(uint64_t val) {
#ifdef EEPROM_ENABLE
rgblight_check_config();
- eeprom_update_dword(EECONFIG_RGBLIGHT, val);
+ eeprom_update_dword(EECONFIG_RGBLIGHT, val & 0xFFFFFFFF);
+ eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, (val >> 32) & 0xFF);
#endif
}
@@ -269,13 +264,13 @@ void rgblight_reload_from_eeprom(void) {
}
}
-uint32_t rgblight_read_dword(void) {
+uint64_t rgblight_read_qword(void) {
return rgblight_config.raw;
}
-void rgblight_update_dword(uint32_t dword) {
+void rgblight_update_qword(uint64_t qword) {
RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS;
- rgblight_config.raw = dword;
+ rgblight_config.raw = qword;
if (rgblight_config.enable)
rgblight_mode_noeeprom(rgblight_config.mode);
else {
@@ -422,6 +417,10 @@ void rgblight_disable_noeeprom(void) {
rgblight_set();
}
+void rgblight_enabled_noeeprom(bool state) {
+ state ? rgblight_enable_noeeprom() : rgblight_disable_noeeprom();
+}
+
bool rgblight_is_enabled(void) {
return rgblight_config.enable;
}
@@ -491,7 +490,7 @@ void rgblight_increase_speed_helper(bool write_to_eeprom) {
if (rgblight_config.speed < 3) rgblight_config.speed++;
// RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?
if (write_to_eeprom) {
- eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
+ eeconfig_update_rgblight(rgblight_config.raw);
}
}
void rgblight_increase_speed(void) {
@@ -505,7 +504,7 @@ void rgblight_decrease_speed_helper(bool write_to_eeprom) {
if (rgblight_config.speed > 0) rgblight_config.speed--;
// RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED??
if (write_to_eeprom) {
- eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
+ eeconfig_update_rgblight(rgblight_config.raw);
}
}
void rgblight_decrease_speed(void) {
@@ -614,7 +613,7 @@ uint8_t rgblight_get_speed(void) {
void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) {
rgblight_config.speed = speed;
if (write_to_eeprom) {
- eeconfig_update_rgblight(rgblight_config.raw); // EECONFIG needs to be increased to support this
+ eeconfig_update_rgblight(rgblight_config.raw);
dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed);
} else {
dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed);
diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h
index 7693888462..001058f962 100644
--- a/quantum/rgblight/rgblight.h
+++ b/quantum/rgblight/rgblight.h
@@ -174,6 +174,10 @@ typedef struct {
uint8_t val;
} rgblight_segment_t;
+// rgblight_set_layer_state doesn't take effect until the next time
+// rgblight_task runs, so timers must be enabled for layers to work.
+# define RGBLIGHT_USE_TIMER
+
# define RGBLIGHT_END_SEGMENT_INDEX (255)
# define RGBLIGHT_END_SEGMENTS \
{ RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 }
@@ -240,19 +244,20 @@ extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM;
extern const uint8_t RGBLED_TWINKLE_INTERVALS[3] PROGMEM;
extern bool is_rgblight_initialized;
-// Should stay in sycn with rgb matrix config as we reuse eeprom storage for both (for now)
typedef union {
- uint32_t raw;
+ uint64_t raw;
struct {
bool enable : 1;
uint8_t mode : 7;
uint8_t hue : 8;
uint8_t sat : 8;
uint8_t val : 8;
- uint8_t speed : 8; // EECONFIG needs to be increased to support this
+ uint8_t speed : 8;
};
} rgblight_config_t;
+_Static_assert(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec.");
+
typedef struct _rgblight_status_t {
uint8_t base_mode;
bool timer_enabled;
@@ -321,6 +326,7 @@ void rgblight_enable(void);
void rgblight_enable_noeeprom(void);
void rgblight_disable(void);
void rgblight_disable_noeeprom(void);
+void rgblight_enabled_noeeprom(bool state);
/* hue, sat, val change */
void rgblight_increase_hue(void);
@@ -362,10 +368,10 @@ HSV rgblight_get_hsv(void);
void rgblight_init(void);
void rgblight_suspend(void);
void rgblight_wakeup(void);
-uint32_t rgblight_read_dword(void);
-void rgblight_update_dword(uint32_t dword);
-uint32_t eeconfig_read_rgblight(void);
-void eeconfig_update_rgblight(uint32_t val);
+uint64_t rgblight_read_qword(void);
+void rgblight_update_qword(uint64_t qword);
+uint64_t eeconfig_read_rgblight(void);
+void eeconfig_update_rgblight(uint64_t val);
void eeconfig_update_rgblight_current(void);
void eeconfig_update_rgblight_default(void);
void eeconfig_debug_rgblight(void);