diff options
author | Drashna Jaelre <drashna@live.com> | 2020-05-18 06:05:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-18 06:05:35 -0700 |
commit | d0e0202b272a28d6a1e7f0d059396067bb861272 (patch) | |
tree | fb1c7fc315cf53846bda0f55985232e71ee9ce82 /quantum | |
parent | e55d55edc08d5a5ca557e3ff442ca47ccd731067 (diff) | |
download | qmk_firmware-d0e0202b272a28d6a1e7f0d059396067bb861272.tar.gz qmk_firmware-d0e0202b272a28d6a1e7f0d059396067bb861272.zip |
Add query functions for RGB Light and RGB Matrix (#8960)
* Add additional query functions for RGBLIGHT
* Add additional query functions for RGB Matrix
* Change names of enable check functions
* Fix macro for rgb matrix takeover of rgblight functions
* Add documentation for rgb_matrix_get_hsv()
* Add *_get_hsv function to rgblight
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/rgb_matrix.c | 11 | ||||
-rw-r--r-- | quantum/rgb_matrix.h | 13 | ||||
-rw-r--r-- | quantum/rgblight.c | 6 | ||||
-rw-r--r-- | quantum/rgblight.h | 2 |
4 files changed, 32 insertions, 0 deletions
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 3fae9d737..91032b656 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
@@ -440,6 +440,8 @@ void rgb_matrix_set_suspend_state(bool state) { | |||
440 | g_suspend_state = state; | 440 | g_suspend_state = state; |
441 | } | 441 | } |
442 | 442 | ||
443 | bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; } | ||
444 | |||
443 | void rgb_matrix_toggle(void) { | 445 | void rgb_matrix_toggle(void) { |
444 | rgb_matrix_config.enable ^= 1; | 446 | rgb_matrix_config.enable ^= 1; |
445 | rgb_task_state = STARTING; | 447 | rgb_task_state = STARTING; |
@@ -466,6 +468,8 @@ void rgb_matrix_disable_noeeprom(void) { | |||
466 | rgb_matrix_config.enable = 0; | 468 | rgb_matrix_config.enable = 0; |
467 | } | 469 | } |
468 | 470 | ||
471 | uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; } | ||
472 | |||
469 | void rgb_matrix_step(void) { | 473 | void rgb_matrix_step(void) { |
470 | rgb_matrix_config.mode++; | 474 | rgb_matrix_config.mode++; |
471 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1; | 475 | if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1; |
@@ -521,6 +525,8 @@ void rgb_matrix_decrease_speed(void) { | |||
521 | eeconfig_update_rgb_matrix(); | 525 | eeconfig_update_rgb_matrix(); |
522 | } | 526 | } |
523 | 527 | ||
528 | uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; } | ||
529 | |||
524 | led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } | 530 | led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; } |
525 | 531 | ||
526 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } | 532 | void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; } |
@@ -546,3 +552,8 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { | |||
546 | rgb_matrix_config.hsv.v = val; | 552 | rgb_matrix_config.hsv.v = val; |
547 | if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; | 553 | if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS; |
548 | } | 554 | } |
555 | |||
556 | HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; } | ||
557 | uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; } | ||
558 | uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; } | ||
559 | uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; } | ||
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 96494836e..7c37311b4 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
@@ -104,11 +104,13 @@ void rgb_matrix_indicators_user(void); | |||
104 | void rgb_matrix_init(void); | 104 | void rgb_matrix_init(void); |
105 | 105 | ||
106 | void rgb_matrix_set_suspend_state(bool state); | 106 | void rgb_matrix_set_suspend_state(bool state); |
107 | bool rgb_matrix_get_suspend_state(void); | ||
107 | void rgb_matrix_toggle(void); | 108 | void rgb_matrix_toggle(void); |
108 | void rgb_matrix_enable(void); | 109 | void rgb_matrix_enable(void); |
109 | void rgb_matrix_enable_noeeprom(void); | 110 | void rgb_matrix_enable_noeeprom(void); |
110 | void rgb_matrix_disable(void); | 111 | void rgb_matrix_disable(void); |
111 | void rgb_matrix_disable_noeeprom(void); | 112 | void rgb_matrix_disable_noeeprom(void); |
113 | uint8_t rgb_matrix_is_enabled(void); | ||
112 | void rgb_matrix_step(void); | 114 | void rgb_matrix_step(void); |
113 | void rgb_matrix_step_reverse(void); | 115 | void rgb_matrix_step_reverse(void); |
114 | void rgb_matrix_increase_hue(void); | 116 | void rgb_matrix_increase_hue(void); |
@@ -119,6 +121,7 @@ void rgb_matrix_increase_val(void); | |||
119 | void rgb_matrix_decrease_val(void); | 121 | void rgb_matrix_decrease_val(void); |
120 | void rgb_matrix_increase_speed(void); | 122 | void rgb_matrix_increase_speed(void); |
121 | void rgb_matrix_decrease_speed(void); | 123 | void rgb_matrix_decrease_speed(void); |
124 | uint8_t rgb_matrix_get_speed(void); | ||
122 | led_flags_t rgb_matrix_get_flags(void); | 125 | led_flags_t rgb_matrix_get_flags(void); |
123 | void rgb_matrix_set_flags(led_flags_t flags); | 126 | void rgb_matrix_set_flags(led_flags_t flags); |
124 | void rgb_matrix_mode(uint8_t mode); | 127 | void rgb_matrix_mode(uint8_t mode); |
@@ -126,6 +129,10 @@ void rgb_matrix_mode_noeeprom(uint8_t mode); | |||
126 | uint8_t rgb_matrix_get_mode(void); | 129 | uint8_t rgb_matrix_get_mode(void); |
127 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); | 130 | void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val); |
128 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | 131 | void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); |
132 | HSV rgb_matrix_get_hsv(void); | ||
133 | uint8_t rgb_matrix_get_hue(void); | ||
134 | uint8_t rgb_matrix_get_sat(void); | ||
135 | uint8_t rgb_matrix_get_val(void); | ||
129 | 136 | ||
130 | #ifndef RGBLIGHT_ENABLE | 137 | #ifndef RGBLIGHT_ENABLE |
131 | # define rgblight_toggle rgb_matrix_toggle | 138 | # define rgblight_toggle rgb_matrix_toggle |
@@ -133,6 +140,7 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | |||
133 | # define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom | 140 | # define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom |
134 | # define rgblight_disable rgb_matrix_disable | 141 | # define rgblight_disable rgb_matrix_disable |
135 | # define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom | 142 | # define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom |
143 | # define rgblight_is_enabled rgb_matrix_is_enabled | ||
136 | # define rgblight_step rgb_matrix_step | 144 | # define rgblight_step rgb_matrix_step |
137 | # define rgblight_sethsv rgb_matrix_sethsv | 145 | # define rgblight_sethsv rgb_matrix_sethsv |
138 | # define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom | 146 | # define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom |
@@ -145,9 +153,14 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val); | |||
145 | # define rgblight_decrease_val rgb_matrix_decrease_val | 153 | # define rgblight_decrease_val rgb_matrix_decrease_val |
146 | # define rgblight_increase_speed rgb_matrix_increase_speed | 154 | # define rgblight_increase_speed rgb_matrix_increase_speed |
147 | # define rgblight_decrease_speed rgb_matrix_decrease_speed | 155 | # define rgblight_decrease_speed rgb_matrix_decrease_speed |
156 | # define rgblight_get_speed rgb_matrix_get_speed | ||
148 | # define rgblight_mode rgb_matrix_mode | 157 | # define rgblight_mode rgb_matrix_mode |
149 | # define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom | 158 | # define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom |
150 | # define rgblight_get_mode rgb_matrix_get_mode | 159 | # define rgblight_get_mode rgb_matrix_get_mode |
160 | # define rgblight_get_hue rgb_matrix_get_hue | ||
161 | # define rgblight_get_sat rgb_matrix_get_sat | ||
162 | # define rgblight_get_val rgb_matrix_get_val | ||
163 | # define rgblight_get_hsv rgb_matrix_get_hsv | ||
151 | #endif | 164 | #endif |
152 | 165 | ||
153 | typedef struct { | 166 | typedef struct { |
diff --git a/quantum/rgblight.c b/quantum/rgblight.c index 64123774c..b50be200e 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c | |||
@@ -368,6 +368,8 @@ void rgblight_disable_noeeprom(void) { | |||
368 | rgblight_set(); | 368 | rgblight_set(); |
369 | } | 369 | } |
370 | 370 | ||
371 | bool rgblight_is_enabled(void) { return rgblight_config.enable; } | ||
372 | |||
371 | void rgblight_increase_hue_helper(bool write_to_eeprom) { | 373 | void rgblight_increase_hue_helper(bool write_to_eeprom) { |
372 | uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; | 374 | uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; |
373 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); | 375 | rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); |
@@ -522,6 +524,10 @@ uint8_t rgblight_get_sat(void) { return rgblight_config.sat; } | |||
522 | 524 | ||
523 | uint8_t rgblight_get_val(void) { return rgblight_config.val; } | 525 | uint8_t rgblight_get_val(void) { return rgblight_config.val; } |
524 | 526 | ||
527 | HSV rgblight_get_hsv(void) { | ||
528 | return (HSV){ rgblight_config.hue, rgblight_config.sat, rgblight_config.val }; | ||
529 | } | ||
530 | |||
525 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { | 531 | void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { |
526 | if (!rgblight_config.enable) { | 532 | if (!rgblight_config.enable) { |
527 | return; | 533 | return; |
diff --git a/quantum/rgblight.h b/quantum/rgblight.h index 6fc3b6f17..c36b328a3 100644 --- a/quantum/rgblight.h +++ b/quantum/rgblight.h | |||
@@ -350,6 +350,8 @@ uint8_t rgblight_get_mode(void); | |||
350 | uint8_t rgblight_get_hue(void); | 350 | uint8_t rgblight_get_hue(void); |
351 | uint8_t rgblight_get_sat(void); | 351 | uint8_t rgblight_get_sat(void); |
352 | uint8_t rgblight_get_val(void); | 352 | uint8_t rgblight_get_val(void); |
353 | bool rgblight_is_enabled(void); | ||
354 | HSV rgblight_get_hsv(void); | ||
353 | 355 | ||
354 | /* === qmk_firmware (core)internal Functions === */ | 356 | /* === qmk_firmware (core)internal Functions === */ |
355 | void rgblight_init(void); | 357 | void rgblight_init(void); |