aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorFredric Silberberg <frsilb@microsoft.com>2018-12-13 18:05:50 -0800
committerDrashna Jaelre <drashna@live.com>2018-12-13 18:30:15 -0800
commit9e6ee4777995a1ac3dfd7aa4454b0a4ed825d663 (patch)
tree2454e09fb278a5da9fd8afbafb1a551a386c70e8 /quantum
parente8f730595c37a508ad86cc46fa39c7fae4d36800 (diff)
downloadqmk_firmware-9e6ee4777995a1ac3dfd7aa4454b0a4ed825d663.tar.gz
qmk_firmware-9e6ee4777995a1ac3dfd7aa4454b0a4ed825d663.zip
Added noeeprom versions of set hue, sat, val, and step
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 a2d6fe7a0..ae5dca188 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -205,21 +205,33 @@ void rgblight_decrease(void) {
205 } 205 }
206 rgblight_mode(mode); 206 rgblight_mode(mode);
207} 207}
208void rgblight_step(void) { 208void rgblight_step_helper(bool write_to_eeprom) {
209 uint8_t mode = 0; 209 uint8_t mode = 0;
210 mode = rgblight_config.mode + 1; 210 mode = rgblight_config.mode + 1;
211 if (mode > RGBLIGHT_MODES) { 211 if (mode > RGBLIGHT_MODES) {
212 mode = 1; 212 mode = 1;
213 } 213 }
214 rgblight_mode(mode); 214 rgblight_mode_eeprom_helper(mode, write_to_eeprom);
215} 215}
216void rgblight_step_reverse(void) { 216void rgblight_step_noeeprom(void) {
217 rgblight_step_helper(false);
218}
219void rgblight_step(void) {
220 rgblight_step_helper(true);
221}
222void rgblight_step_reverse_helper(bool write_to_eeprom) {
217 uint8_t mode = 0; 223 uint8_t mode = 0;
218 mode = rgblight_config.mode - 1; 224 mode = rgblight_config.mode - 1;
219 if (mode < 1) { 225 if (mode < 1) {
220 mode = RGBLIGHT_MODES; 226 mode = RGBLIGHT_MODES;
221 } 227 }
222 rgblight_mode(mode); 228 rgblight_mode_eeprom_helper(mode, write_to_eeprom);
229}
230void rgblight_step_reverse_noeeprom(void) {
231 rgblight_step_reverse_helper(false);
232}
233void rgblight_step_reverse(void) {
234 rgblight_step_reverse_helper(true);
223} 235}
224 236
225uint32_t rgblight_get_mode(void) { 237uint32_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
337 return MIN( MAX( new_value, min ), max ); 349 return MIN( MAX( new_value, min ), max );
338} 350}
339 351
340void rgblight_increase_hue(void) { 352void rgblight_increase_hue_helper(bool write_to_eeprom) {
341 uint16_t hue; 353 uint16_t hue;
342 hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360; 354 hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360;
343 rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); 355 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
344} 356}
345void rgblight_decrease_hue(void) { 357void rgblight_increase_hue_noeeprom(void) {
358 rgblight_increase_hue_helper(false);
359}
360void rgblight_increase_hue(void) {
361 rgblight_increase_hue_helper(true);
362}
363void rgblight_decrease_hue_helper(bool write_to_eeprom) {
346 uint16_t hue; 364 uint16_t hue;
347 if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) { 365 if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) {
348 hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360; 366 hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360;
349 } else { 367 } else {
350 hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360; 368 hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360;
351 } 369 }
352 rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); 370 rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
353} 371}
354void rgblight_increase_sat(void) { 372void rgblight_decrease_hue_noeeprom(void) {
373 rgblight_decrease_hue_helper(false);
374}
375void rgblight_decrease_hue(void) {
376 rgblight_decrease_hue_helper(true);
377}
378void rgblight_increase_sat_helper(bool write_to_eeprom) {
355 uint8_t sat; 379 uint8_t sat;
356 if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) { 380 if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) {
357 sat = 255; 381 sat = 255;
358 } else { 382 } else {
359 sat = rgblight_config.sat + RGBLIGHT_SAT_STEP; 383 sat = rgblight_config.sat + RGBLIGHT_SAT_STEP;
360 } 384 }
361 rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); 385 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
362} 386}
363void rgblight_decrease_sat(void) { 387void rgblight_increase_sat_noeeprom(void) {
388 rgblight_increase_sat_helper(false);
389}
390void rgblight_increase_sat(void) {
391 rgblight_increase_sat_helper(true);
392}
393void rgblight_decrease_sat_helper(bool write_to_eeprom) {
364 uint8_t sat; 394 uint8_t sat;
365 if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) { 395 if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) {
366 sat = 0; 396 sat = 0;
367 } else { 397 } else {
368 sat = rgblight_config.sat - RGBLIGHT_SAT_STEP; 398 sat = rgblight_config.sat - RGBLIGHT_SAT_STEP;
369 } 399 }
370 rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); 400 rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom);
371} 401}
372void rgblight_increase_val(void) { 402void rgblight_decrease_sat_noeeprom(void) {
403 rgblight_decrease_sat_helper(false);
404}
405void rgblight_decrease_sat(void) {
406 rgblight_decrease_sat_helper(true);
407}
408void rgblight_increase_val_helper(bool write_to_eeprom) {
373 uint8_t val; 409 uint8_t val;
374 if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) { 410 if (rgblight_config.val + RGBLIGHT_VAL_STEP > RGBLIGHT_LIMIT_VAL) {
375 val = RGBLIGHT_LIMIT_VAL; 411 val = RGBLIGHT_LIMIT_VAL;
376 } else { 412 } else {
377 val = rgblight_config.val + RGBLIGHT_VAL_STEP; 413 val = rgblight_config.val + RGBLIGHT_VAL_STEP;
378 } 414 }
379 rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); 415 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
380} 416}
381void rgblight_decrease_val(void) { 417void rgblight_increase_val_noeeprom(void) {
418 rgblight_increase_val_helper(false);
419}
420void rgblight_increase_val(void) {
421 rgblight_increase_val_helper(true);
422}
423void rgblight_decrease_val_helper(bool write_to_eeprom) {
382 uint8_t val; 424 uint8_t val;
383 if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) { 425 if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) {
384 val = 0; 426 val = 0;
385 } else { 427 } else {
386 val = rgblight_config.val - RGBLIGHT_VAL_STEP; 428 val = rgblight_config.val - RGBLIGHT_VAL_STEP;
387 } 429 }
388 rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); 430 rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom);
431}
432void rgblight_decrease_val_noeeprom(void) {
433 rgblight_decrease_val_helper(false);
434}
435void rgblight_decrease_val(void) {
436 rgblight_decrease_val_helper(true);
389} 437}
390void rgblight_increase_speed(void) { 438void rgblight_increase_speed(void) {
391 rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 ); 439 rgblight_config.speed = increment( rgblight_config.speed, 1, 0, 3 );
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 33b279f08..99ede43c5 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -203,6 +203,14 @@ void rgblight_mode_noeeprom(uint8_t mode);
203void rgblight_toggle_noeeprom(void); 203void rgblight_toggle_noeeprom(void);
204void rgblight_enable_noeeprom(void); 204void rgblight_enable_noeeprom(void);
205void rgblight_disable_noeeprom(void); 205void rgblight_disable_noeeprom(void);
206void rgblight_step_noeeprom(void);
207void rgblight_step_reverse_noeeprom(void);
208void rgblight_increase_hue_noeeprom(void);
209void rgblight_decrease_hue_noeeprom(void);
210void rgblight_increase_sat_noeeprom(void);
211void rgblight_decrease_sat_noeeprom(void);
212void rgblight_increase_val_noeeprom(void);
213void rgblight_decrease_val_noeeprom(void);
206 214
207void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); 215void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom);
208void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); 216void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom);