diff options
| author | Fredric Silberberg <frsilb@microsoft.com> | 2018-12-13 18:05:50 -0800 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-12-13 18:30:15 -0800 |
| commit | 9e6ee4777995a1ac3dfd7aa4454b0a4ed825d663 (patch) | |
| tree | 2454e09fb278a5da9fd8afbafb1a551a386c70e8 /quantum | |
| parent | e8f730595c37a508ad86cc46fa39c7fae4d36800 (diff) | |
| download | qmk_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.c | 80 | ||||
| -rw-r--r-- | quantum/rgblight.h | 8 |
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 | } |
| 208 | void rgblight_step(void) { | 208 | void 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 | } |
| 216 | void rgblight_step_reverse(void) { | 216 | void rgblight_step_noeeprom(void) { |
| 217 | rgblight_step_helper(false); | ||
| 218 | } | ||
| 219 | void rgblight_step(void) { | ||
| 220 | rgblight_step_helper(true); | ||
| 221 | } | ||
| 222 | void 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 | } | ||
| 230 | void rgblight_step_reverse_noeeprom(void) { | ||
| 231 | rgblight_step_reverse_helper(false); | ||
| 232 | } | ||
| 233 | void rgblight_step_reverse(void) { | ||
| 234 | rgblight_step_reverse_helper(true); | ||
| 223 | } | 235 | } |
| 224 | 236 | ||
| 225 | uint32_t rgblight_get_mode(void) { | 237 | 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 | |||
| 337 | return MIN( MAX( new_value, min ), max ); | 349 | return MIN( MAX( new_value, min ), max ); |
| 338 | } | 350 | } |
| 339 | 351 | ||
| 340 | void rgblight_increase_hue(void) { | 352 | void 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 | } |
| 345 | void rgblight_decrease_hue(void) { | 357 | void rgblight_increase_hue_noeeprom(void) { |
| 358 | rgblight_increase_hue_helper(false); | ||
| 359 | } | ||
| 360 | void rgblight_increase_hue(void) { | ||
| 361 | rgblight_increase_hue_helper(true); | ||
| 362 | } | ||
| 363 | void 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 | } |
| 354 | void rgblight_increase_sat(void) { | 372 | void rgblight_decrease_hue_noeeprom(void) { |
| 373 | rgblight_decrease_hue_helper(false); | ||
| 374 | } | ||
| 375 | void rgblight_decrease_hue(void) { | ||
| 376 | rgblight_decrease_hue_helper(true); | ||
| 377 | } | ||
| 378 | void 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 | } |
| 363 | void rgblight_decrease_sat(void) { | 387 | void rgblight_increase_sat_noeeprom(void) { |
| 388 | rgblight_increase_sat_helper(false); | ||
| 389 | } | ||
| 390 | void rgblight_increase_sat(void) { | ||
| 391 | rgblight_increase_sat_helper(true); | ||
| 392 | } | ||
| 393 | void 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 | } |
| 372 | void rgblight_increase_val(void) { | 402 | void rgblight_decrease_sat_noeeprom(void) { |
| 403 | rgblight_decrease_sat_helper(false); | ||
| 404 | } | ||
| 405 | void rgblight_decrease_sat(void) { | ||
| 406 | rgblight_decrease_sat_helper(true); | ||
| 407 | } | ||
| 408 | void 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 | } |
| 381 | void rgblight_decrease_val(void) { | 417 | void rgblight_increase_val_noeeprom(void) { |
| 418 | rgblight_increase_val_helper(false); | ||
| 419 | } | ||
| 420 | void rgblight_increase_val(void) { | ||
| 421 | rgblight_increase_val_helper(true); | ||
| 422 | } | ||
| 423 | void 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 | } | ||
| 432 | void rgblight_decrease_val_noeeprom(void) { | ||
| 433 | rgblight_decrease_val_helper(false); | ||
| 434 | } | ||
| 435 | void rgblight_decrease_val(void) { | ||
| 436 | rgblight_decrease_val_helper(true); | ||
| 389 | } | 437 | } |
| 390 | void rgblight_increase_speed(void) { | 438 | void 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); | |||
| 203 | void rgblight_toggle_noeeprom(void); | 203 | void rgblight_toggle_noeeprom(void); |
| 204 | void rgblight_enable_noeeprom(void); | 204 | void rgblight_enable_noeeprom(void); |
| 205 | void rgblight_disable_noeeprom(void); | 205 | void rgblight_disable_noeeprom(void); |
| 206 | void rgblight_step_noeeprom(void); | ||
| 207 | void rgblight_step_reverse_noeeprom(void); | ||
| 208 | void rgblight_increase_hue_noeeprom(void); | ||
| 209 | void rgblight_decrease_hue_noeeprom(void); | ||
| 210 | void rgblight_increase_sat_noeeprom(void); | ||
| 211 | void rgblight_decrease_sat_noeeprom(void); | ||
| 212 | void rgblight_increase_val_noeeprom(void); | ||
| 213 | void rgblight_decrease_val_noeeprom(void); | ||
| 206 | 214 | ||
| 207 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); | 215 | void rgblight_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); |
| 208 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); | 216 | void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); |
