summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/rgblight.c80
-rw-r--r--quantum/rgblight.h8
2 files changed, 72 insertions, 16 deletions
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index a2d6fe7a07..ae5dca1884 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -205,21 +205,33 @@ void rgblight_decrease(void) {
}
rgblight_mode(mode);
}
-void rgblight_step(void) {
+void rgblight_step_helper(bool write_to_eeprom) {
uint8_t mode = 0;
mode = rgblight_config.mode + 1;
if (mode > RGBLIGHT_MODES) {
mode = 1;
}
- rgblight_mode(mode);
+ rgblight_mode_eeprom_helper(mode, write_to_eeprom);
}
-void rgblight_step_reverse(void) {
+void rgblight_step_noeeprom(void) {
+ rgblight_step_helper(false);
+}
+void rgblight_step(void) {
+ rgblight_step_helper(true);
+}
+void rgblight_step_reverse_helper(bool write_to_eeprom) {
uint8_t mode = 0;
mode = rgblight_config.mode - 1;
if (mode < 1) {
mode = RGBLIGHT_MODES;
}
- rgblight_mode(mode);
+ rgblight_mode_eeprom_helper(mode, write_to_eeprom);
+}
+void rgblight_step_reverse_noeeprom(void) {
+ rgblight_step_reverse_helper(false);
+}
+void rgblight_step_reverse(void) {
+ rgblight_step_reverse_helper(true);
}
uint32_t rgblight_get_mode(void) {
@@ -337,55 +349,91 @@ static uint8_t decrement( uint8_t value, uint8_t step, uint8_t min, uint8_t max
return MIN( MAX( new_value, min ), max );
}
-void rgblight_increase_hue(void) {
+void rgblight_increase_hue_helper(bool write_to_eeprom) {
uint16_t hue;
hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360;
- rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
+ rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
-void rgblight_decrease_hue(void) {
+void rgblight_increase_hue_noeeprom(void) {
+ rgblight_increase_hue_helper(false);
+}
+void rgblight_increase_hue(void) {
+ rgblight_increase_hue_helper(true);
+}
+void rgblight_decrease_hue_helper(bool write_to_eeprom) {
uint16_t hue;
if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) {
hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360;
} else {
hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360;
}
- rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
+ rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
}
-void rgblight_increase_sat(void) {
+void rgblight_decrease_hue_noeeprom(void) {
+ rgblight_decrease_hue_helper(false);
+}
+void rgblight_decrease_hue(void) {
+ rgblight_decrease_hue_helper(true);
+}
+void rgblight_increase_sat_helper(bool write_to_eeprom) {
uint8_t sat;
if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) {
sat = 255;
} else {
sat = rgblight_config.sat + RGBLIGHT_SAT_STEP;
}
- rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
-void rgblight_decrease_sat(void) {
+void rgblight_increase_sat_noeeprom(void) {
+ rgblight_increase_sat_helper(false);
+}
+void rgblight_increase_sat(void) {
+ rgblight_increase_sat_helper(true);
+}
+void rgblight_decrease_sat_helper(bool write_to_eeprom) {
uint8_t sat;
if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) {
sat = 0;
} else {
sat = rgblight_config.sat - RGBLIGHT_SAT_STEP;
}
- rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
}
-void rgblight_increase_val(void) {
+void rgblight_decrease_sat_noeeprom(void) {
+ rgblight_decrease_sat_helper(false);
+}
+void rgblight_decrease_sat(void) {
+ rgblight_decrease_sat_helper(true);
+}
+void rgblight_increase_val_helper(bool write_to_eeprom) {
uint8_t val;
if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) {
val = RGBLIGHT_LIMIT_VAL;
} else {
val = rgblight_config.val + RGBLIGHT_VAL_STEP;
}
- rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
}
-void rgblight_decrease_val(void) {
+void rgblight_increase_val_noeeprom(void) {
+ rgblight_increase_val_helper(false);
+}
+void rgblight_increase_val(void) {
+ rgblight_increase_val_helper(true);
+}
+void rgblight_decrease_val_helper(bool write_to_eeprom) {
uint8_t val;
if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) {
val = 0;
} else {
val = rgblight_config.val - RGBLIGHT_VAL_STEP;
}
- rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
+ rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
+}
+void rgblight_decrease_val_noeeprom(void) {
+ rgblight_decrease_val_helper(false);
+}
+void rgblight_decrease_val(void) {
+ rgblight_decrease_val_helper(true);
}
void rgblight_increase_speed(void) {
rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 );
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 33b279f08c..99ede43c5b 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -203,6 +203,14 @@ void rgblight_mode_noeeprom(uint8_t mode);
void rgblight_toggle_noeeprom(void);
void rgblight_enable_noeeprom(void);
void rgblight_disable_noeeprom(void);
+void rgblight_step_noeeprom(void);
+void rgblight_step_reverse_noeeprom(void);
+void rgblight_increase_hue_noeeprom(void);
+void rgblight_decrease_hue_noeeprom(void);
+void rgblight_increase_sat_noeeprom(void);
+void rgblight_decrease_sat_noeeprom(void);
+void rgblight_increase_val_noeeprom(void);
+void rgblight_decrease_val_noeeprom(void);
void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom);
void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom);