diff options
author | XScorpion2 <rcalt2vt@gmail.com> | 2019-07-16 02:40:43 -0500 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-07-16 00:40:43 -0700 |
commit | e2dfb787da2a2ba88e0e074b396a2b988e10eccf (patch) | |
tree | 28a4cb615cdec55697f054be9c8f7bb59db67e50 /quantum/rgb_matrix.c | |
parent | 72df7b4c191399c7835527b730647e079b6683ff (diff) | |
download | qmk_firmware-e2dfb787da2a2ba88e0e074b396a2b988e10eccf.tar.gz qmk_firmware-e2dfb787da2a2ba88e0e074b396a2b988e10eccf.zip |
Adding rgb matrix speed into eeprom storage. (#5965)
Zeroing out spd in eeconfig_init_quantum
Switched to block read & update
Update tmk_core/common/eeconfig.h
Co-Authored-By: Drashna Jaelre <drashna@live.com>
Fixing init compile error
Update eeconfig.c
Dead / Missing API cleanup
alignment
Diffstat (limited to 'quantum/rgb_matrix.c')
-rw-r--r-- | quantum/rgb_matrix.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index d20daf5e4..f170cfc1b 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -66,10 +66,6 @@ | |||
66 | #define RGB_DISABLE_WHEN_USB_SUSPENDED false | 66 | #define RGB_DISABLE_WHEN_USB_SUSPENDED false |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #ifndef EECONFIG_RGB_MATRIX | ||
70 | #define EECONFIG_RGB_MATRIX EECONFIG_RGBLIGHT | ||
71 | #endif | ||
72 | |||
73 | #if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX | 69 | #if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX |
74 | #undef RGB_MATRIX_MAXIMUM_BRIGHTNESS | 70 | #undef RGB_MATRIX_MAXIMUM_BRIGHTNESS |
75 | #define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX | 71 | #define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX |
@@ -116,12 +112,12 @@ uint8_t rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; | |||
116 | static last_hit_t last_hit_buffer; | 112 | static last_hit_t last_hit_buffer; |
117 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED | 113 | #endif // RGB_MATRIX_KEYREACTIVE_ENABLED |
118 | 114 | ||
119 | uint32_t eeconfig_read_rgb_matrix(void) { | 115 | void eeconfig_read_rgb_matrix(void) { |
120 | return eeprom_read_dword(EECONFIG_RGB_MATRIX); | 116 | eeprom_read_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); |
121 | } | 117 | } |
122 | 118 | ||
123 | void eeconfig_update_rgb_matrix(uint32_t val) { | 119 | void eeconfig_update_rgb_matrix(void) { |
124 | eeprom_update_dword(EECONFIG_RGB_MATRIX, val); | 120 | eeprom_update_block(&rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_matrix_config)); |
125 | } | 121 | } |
126 | 122 | ||
127 | void eeconfig_update_rgb_matrix_default(void) { | 123 | void eeconfig_update_rgb_matrix_default(void) { |
@@ -130,7 +126,7 @@ void eeconfig_update_rgb_matrix_default(void) { | |||
130 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; | 126 | rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE; |
131 | rgb_matrix_config.hsv = (HSV){ 0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS }; | 127 | rgb_matrix_config.hsv = (HSV){ 0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS }; |
132 | rgb_matrix_config.speed = UINT8_MAX / 2; | 128 | rgb_matrix_config.speed = UINT8_MAX / 2; |
133 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 129 | eeconfig_update_rgb_matrix(); |
134 | } | 130 | } |
135 | 131 | ||
136 | void eeconfig_debug_rgb_matrix(void) { | 132 | void eeconfig_debug_rgb_matrix(void) { |
@@ -431,12 +427,10 @@ void rgb_matrix_init(void) { | |||
431 | eeconfig_update_rgb_matrix_default(); | 427 | eeconfig_update_rgb_matrix_default(); |
432 | } | 428 | } |
433 | 429 | ||
434 | rgb_matrix_config.raw = eeconfig_read_rgb_matrix(); | 430 | eeconfig_read_rgb_matrix(); |
435 | rgb_matrix_config.speed = UINT8_MAX / 2; //EECONFIG needs to be increased to support this | ||
436 | if (!rgb_matrix_config.mode) { | 431 | if (!rgb_matrix_config.mode) { |
437 | dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); | 432 | dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); |
438 | eeconfig_update_rgb_matrix_default(); | 433 | eeconfig_update_rgb_matrix_default(); |
439 | rgb_matrix_config.raw = eeconfig_read_rgb_matrix(); | ||
440 | } | 434 | } |
441 | eeconfig_debug_rgb_matrix(); // display current eeprom values | 435 | eeconfig_debug_rgb_matrix(); // display current eeprom values |
442 | } | 436 | } |
@@ -448,12 +442,12 @@ void rgb_matrix_set_suspend_state(bool state) { | |||
448 | void rgb_matrix_toggle(void) { | 442 | void rgb_matrix_toggle(void) { |
449 | rgb_matrix_config.enable ^= 1; | 443 | rgb_matrix_config.enable ^= 1; |
450 | rgb_task_state = STARTING; | 444 | rgb_task_state = STARTING; |
451 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 445 | eeconfig_update_rgb_matrix(); |
452 | } | 446 | } |
453 | 447 | ||
454 | void rgb_matrix_enable(void) { | 448 | void rgb_matrix_enable(void) { |
455 | rgb_matrix_enable_noeeprom(); | 449 | rgb_matrix_enable_noeeprom(); |
456 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 450 | eeconfig_update_rgb_matrix(); |
457 | } | 451 | } |
458 | 452 | ||
459 | void rgb_matrix_enable_noeeprom(void) { | 453 | void rgb_matrix_enable_noeeprom(void) { |
@@ -464,7 +458,7 @@ void rgb_matrix_enable_noeeprom(void) { | |||
464 | 458 | ||
465 | void rgb_matrix_disable(void) { | 459 | void rgb_matrix_disable(void) { |
466 | rgb_matrix_disable_noeeprom(); | 460 | rgb_matrix_disable_noeeprom(); |
467 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 461 | eeconfig_update_rgb_matrix(); |
468 | } | 462 | } |
469 | 463 | ||
470 | void rgb_matrix_disable_noeeprom(void) { | 464 | void rgb_matrix_disable_noeeprom(void) { |
@@ -478,7 +472,7 @@ void rgb_matrix_step(void) { | |||
478 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) | 472 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) |
479 | rgb_matrix_config.mode = 1; | 473 | rgb_matrix_config.mode = 1; |
480 | rgb_task_state = STARTING; | 474 | rgb_task_state = STARTING; |
481 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 475 | eeconfig_update_rgb_matrix(); |
482 | } | 476 | } |
483 | 477 | ||
484 | void rgb_matrix_step_reverse(void) { | 478 | void rgb_matrix_step_reverse(void) { |
@@ -486,49 +480,49 @@ void rgb_matrix_step_reverse(void) { | |||
486 | if (rgb_matrix_config.mode < 1) | 480 | if (rgb_matrix_config.mode < 1) |
487 | rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; | 481 | rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; |
488 | rgb_task_state = STARTING; | 482 | rgb_task_state = STARTING; |
489 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 483 | eeconfig_update_rgb_matrix(); |
490 | } | 484 | } |
491 | 485 | ||
492 | void rgb_matrix_increase_hue(void) { | 486 | void rgb_matrix_increase_hue(void) { |
493 | rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP; | 487 | rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP; |
494 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 488 | eeconfig_update_rgb_matrix(); |
495 | } | 489 | } |
496 | 490 | ||
497 | void rgb_matrix_decrease_hue(void) { | 491 | void rgb_matrix_decrease_hue(void) { |
498 | rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP; | 492 | rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP; |
499 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 493 | eeconfig_update_rgb_matrix(); |
500 | } | 494 | } |
501 | 495 | ||
502 | void rgb_matrix_increase_sat(void) { | 496 | void rgb_matrix_increase_sat(void) { |
503 | rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); | 497 | rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); |
504 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 498 | eeconfig_update_rgb_matrix(); |
505 | } | 499 | } |
506 | 500 | ||
507 | void rgb_matrix_decrease_sat(void) { | 501 | void rgb_matrix_decrease_sat(void) { |
508 | rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); | 502 | rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP); |
509 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 503 | eeconfig_update_rgb_matrix(); |
510 | } | 504 | } |
511 | 505 | ||
512 | void rgb_matrix_increase_val(void) { | 506 | void rgb_matrix_increase_val(void) { |
513 | rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); | 507 | rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); |
514 | if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) | 508 | if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) |
515 | rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; | 509 | rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; |
516 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 510 | eeconfig_update_rgb_matrix(); |
517 | } | 511 | } |
518 | 512 | ||
519 | void rgb_matrix_decrease_val(void) { | 513 | void rgb_matrix_decrease_val(void) { |
520 | rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); | 514 | rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP); |
521 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 515 | eeconfig_update_rgb_matrix(); |
522 | } | 516 | } |
523 | 517 | ||
524 | void rgb_matrix_increase_speed(void) { | 518 | void rgb_matrix_increase_speed(void) { |
525 | rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); | 519 | rgb_matrix_config.speed = qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); |
526 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | 520 | eeconfig_update_rgb_matrix(); |
527 | } | 521 | } |
528 | 522 | ||
529 | void rgb_matrix_decrease_speed(void) { | 523 | void rgb_matrix_decrease_speed(void) { |
530 | rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); | 524 | rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); |
531 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this | 525 | eeconfig_update_rgb_matrix(); |
532 | } | 526 | } |
533 | 527 | ||
534 | led_flags_t rgb_matrix_get_flags(void) { | 528 | led_flags_t rgb_matrix_get_flags(void) { |
@@ -542,7 +536,7 @@ void rgb_matrix_set_flags(led_flags_t flags) { | |||
542 | void rgb_matrix_mode(uint8_t mode) { | 536 | void rgb_matrix_mode(uint8_t mode) { |
543 | rgb_matrix_config.mode = mode; | 537 | rgb_matrix_config.mode = mode; |
544 | rgb_task_state = STARTING; | 538 | rgb_task_state = STARTING; |
545 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 539 | eeconfig_update_rgb_matrix(); |
546 | } | 540 | } |
547 | 541 | ||
548 | void rgb_matrix_mode_noeeprom(uint8_t mode) { | 542 | void rgb_matrix_mode_noeeprom(uint8_t mode) { |
@@ -555,7 +549,7 @@ uint8_t rgb_matrix_get_mode(void) { | |||
555 | 549 | ||
556 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { | 550 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { |
557 | rgb_matrix_sethsv_noeeprom(hue, sat, val); | 551 | rgb_matrix_sethsv_noeeprom(hue, sat, val); |
558 | eeconfig_update_rgb_matrix(rgb_matrix_config.raw); | 552 | eeconfig_update_rgb_matrix(); |
559 | } | 553 | } |
560 | 554 | ||
561 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | 555 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { |