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
This commit is contained in:
parent
e55d55edc0
commit
d0e0202b27
6 changed files with 50 additions and 12 deletions
|
@ -437,12 +437,16 @@ Where `28` is an unused index from `eeconfig.h`.
|
||||||
|`rgb_matrix_sethsv_noeeprom(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
|
|`rgb_matrix_sethsv_noeeprom(h, s, v)` |Set LEDs to the given HSV value where `h`/`s`/`v` are between 0 and 255 (not written to EEPROM) |
|
||||||
|
|
||||||
### Query Current Status :id=query-current-status
|
### Query Current Status :id=query-current-status
|
||||||
|Function |Description |
|
|Function |Description |
|
||||||
|-----------------------|-----------------|
|
|---------------------------------|---------------------------|
|
||||||
|`rgb_matrix_get_mode()` |Get current mode |
|
|`rgb_matrix_is_enabled()` |Gets current on/off status |
|
||||||
|`rgb_matrix_get_hue()` |Get current hue |
|
|`rgb_matrix_get_mode()` |Gets current mode |
|
||||||
|`rgb_matrix_get_sat()` |Get current sat |
|
|`rgb_matrix_get_hue()` |Gets current hue |
|
||||||
|`rgb_matrix_get_val()` |Get current val |
|
|`rgb_matrix_get_sat()` |Gets current sat |
|
||||||
|
|`rgb_matrix_get_val()` |Gets current val |
|
||||||
|
|`rgb_matrix_get_hsv()` |Gets hue, sat, and val and returns a [`HSV` structure](https://github.com/qmk/qmk_firmware/blob/7ba6456c0b2e041bb9f97dbed265c5b8b4b12192/quantum/color.h#L56-L61)|
|
||||||
|
|`rgb_matrix_get_speed()` |Gets current speed |
|
||||||
|
|`rgb_matrix_get_suspend_state()` |Gets current suspend state |
|
||||||
|
|
||||||
## Callbacks :id=callbacks
|
## Callbacks :id=callbacks
|
||||||
|
|
||||||
|
|
|
@ -376,12 +376,14 @@ rgblight_sethsv(HSV_GREEN, 2); // led 2
|
||||||
|`rgblight_set_layer_state(i, is_on)` |Enable or disable lighting layer `i` based on value of `bool is_on` |
|
|`rgblight_set_layer_state(i, is_on)` |Enable or disable lighting layer `i` based on value of `bool is_on` |
|
||||||
|
|
||||||
#### query
|
#### query
|
||||||
|Function |Description |
|
|Function |Description |
|
||||||
|-----------------------|-----------------|
|
|-----------------------|---------------------------|
|
||||||
|`rgblight_get_mode()` |Get current mode |
|
|`rgblight_is_enabled()`|Gets current on/off status |
|
||||||
|`rgblight_get_hue()` |Get current hue |
|
|`rgblight_get_mode()` |Gets current mode |
|
||||||
|`rgblight_get_sat()` |Get current sat |
|
|`rgblight_get_hue()` |Gets current hue |
|
||||||
|`rgblight_get_val()` |Get current val |
|
|`rgblight_get_sat()` |Gets current sat |
|
||||||
|
|`rgblight_get_val()` |Gets current val |
|
||||||
|
|`rgblight_get_speed()` |Gets current speed |
|
||||||
|
|
||||||
## Colors
|
## Colors
|
||||||
|
|
||||||
|
|
|
@ -440,6 +440,8 @@ void rgb_matrix_set_suspend_state(bool state) {
|
||||||
g_suspend_state = state;
|
g_suspend_state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rgb_matrix_get_suspend_state(void) { return g_suspend_state; }
|
||||||
|
|
||||||
void rgb_matrix_toggle(void) {
|
void rgb_matrix_toggle(void) {
|
||||||
rgb_matrix_config.enable ^= 1;
|
rgb_matrix_config.enable ^= 1;
|
||||||
rgb_task_state = STARTING;
|
rgb_task_state = STARTING;
|
||||||
|
@ -466,6 +468,8 @@ void rgb_matrix_disable_noeeprom(void) {
|
||||||
rgb_matrix_config.enable = 0;
|
rgb_matrix_config.enable = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t rgb_matrix_is_enabled(void) { return rgb_matrix_config.enable; }
|
||||||
|
|
||||||
void rgb_matrix_step(void) {
|
void rgb_matrix_step(void) {
|
||||||
rgb_matrix_config.mode++;
|
rgb_matrix_config.mode++;
|
||||||
if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1;
|
if (rgb_matrix_config.mode >= RGB_MATRIX_EFFECT_MAX) rgb_matrix_config.mode = 1;
|
||||||
|
@ -521,6 +525,8 @@ void rgb_matrix_decrease_speed(void) {
|
||||||
eeconfig_update_rgb_matrix();
|
eeconfig_update_rgb_matrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t rgb_matrix_get_speed(void) { return rgb_matrix_config.speed; }
|
||||||
|
|
||||||
led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }
|
led_flags_t rgb_matrix_get_flags(void) { return rgb_effect_params.flags; }
|
||||||
|
|
||||||
void rgb_matrix_set_flags(led_flags_t flags) { rgb_effect_params.flags = flags; }
|
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) {
|
||||||
rgb_matrix_config.hsv.v = val;
|
rgb_matrix_config.hsv.v = val;
|
||||||
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS) rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HSV rgb_matrix_get_hsv(void) { return rgb_matrix_config.hsv; }
|
||||||
|
uint8_t rgb_matrix_get_hue(void) { return rgb_matrix_config.hsv.h; }
|
||||||
|
uint8_t rgb_matrix_get_sat(void) { return rgb_matrix_config.hsv.s; }
|
||||||
|
uint8_t rgb_matrix_get_val(void) { return rgb_matrix_config.hsv.v; }
|
||||||
|
|
|
@ -104,11 +104,13 @@ void rgb_matrix_indicators_user(void);
|
||||||
void rgb_matrix_init(void);
|
void rgb_matrix_init(void);
|
||||||
|
|
||||||
void rgb_matrix_set_suspend_state(bool state);
|
void rgb_matrix_set_suspend_state(bool state);
|
||||||
|
bool rgb_matrix_get_suspend_state(void);
|
||||||
void rgb_matrix_toggle(void);
|
void rgb_matrix_toggle(void);
|
||||||
void rgb_matrix_enable(void);
|
void rgb_matrix_enable(void);
|
||||||
void rgb_matrix_enable_noeeprom(void);
|
void rgb_matrix_enable_noeeprom(void);
|
||||||
void rgb_matrix_disable(void);
|
void rgb_matrix_disable(void);
|
||||||
void rgb_matrix_disable_noeeprom(void);
|
void rgb_matrix_disable_noeeprom(void);
|
||||||
|
uint8_t rgb_matrix_is_enabled(void);
|
||||||
void rgb_matrix_step(void);
|
void rgb_matrix_step(void);
|
||||||
void rgb_matrix_step_reverse(void);
|
void rgb_matrix_step_reverse(void);
|
||||||
void rgb_matrix_increase_hue(void);
|
void rgb_matrix_increase_hue(void);
|
||||||
|
@ -119,6 +121,7 @@ void rgb_matrix_increase_val(void);
|
||||||
void rgb_matrix_decrease_val(void);
|
void rgb_matrix_decrease_val(void);
|
||||||
void rgb_matrix_increase_speed(void);
|
void rgb_matrix_increase_speed(void);
|
||||||
void rgb_matrix_decrease_speed(void);
|
void rgb_matrix_decrease_speed(void);
|
||||||
|
uint8_t rgb_matrix_get_speed(void);
|
||||||
led_flags_t rgb_matrix_get_flags(void);
|
led_flags_t rgb_matrix_get_flags(void);
|
||||||
void rgb_matrix_set_flags(led_flags_t flags);
|
void rgb_matrix_set_flags(led_flags_t flags);
|
||||||
void rgb_matrix_mode(uint8_t mode);
|
void rgb_matrix_mode(uint8_t mode);
|
||||||
|
@ -126,6 +129,10 @@ void rgb_matrix_mode_noeeprom(uint8_t mode);
|
||||||
uint8_t rgb_matrix_get_mode(void);
|
uint8_t rgb_matrix_get_mode(void);
|
||||||
void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
|
void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
|
||||||
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
|
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
|
||||||
|
HSV rgb_matrix_get_hsv(void);
|
||||||
|
uint8_t rgb_matrix_get_hue(void);
|
||||||
|
uint8_t rgb_matrix_get_sat(void);
|
||||||
|
uint8_t rgb_matrix_get_val(void);
|
||||||
|
|
||||||
#ifndef RGBLIGHT_ENABLE
|
#ifndef RGBLIGHT_ENABLE
|
||||||
# define rgblight_toggle rgb_matrix_toggle
|
# define rgblight_toggle rgb_matrix_toggle
|
||||||
|
@ -133,6 +140,7 @@ void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
|
||||||
# define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom
|
# define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom
|
||||||
# define rgblight_disable rgb_matrix_disable
|
# define rgblight_disable rgb_matrix_disable
|
||||||
# define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom
|
# define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom
|
||||||
|
# define rgblight_is_enabled rgb_matrix_is_enabled
|
||||||
# define rgblight_step rgb_matrix_step
|
# define rgblight_step rgb_matrix_step
|
||||||
# define rgblight_sethsv rgb_matrix_sethsv
|
# define rgblight_sethsv rgb_matrix_sethsv
|
||||||
# define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom
|
# 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);
|
||||||
# define rgblight_decrease_val rgb_matrix_decrease_val
|
# define rgblight_decrease_val rgb_matrix_decrease_val
|
||||||
# define rgblight_increase_speed rgb_matrix_increase_speed
|
# define rgblight_increase_speed rgb_matrix_increase_speed
|
||||||
# define rgblight_decrease_speed rgb_matrix_decrease_speed
|
# define rgblight_decrease_speed rgb_matrix_decrease_speed
|
||||||
|
# define rgblight_get_speed rgb_matrix_get_speed
|
||||||
# define rgblight_mode rgb_matrix_mode
|
# define rgblight_mode rgb_matrix_mode
|
||||||
# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom
|
# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom
|
||||||
# define rgblight_get_mode rgb_matrix_get_mode
|
# define rgblight_get_mode rgb_matrix_get_mode
|
||||||
|
# define rgblight_get_hue rgb_matrix_get_hue
|
||||||
|
# define rgblight_get_sat rgb_matrix_get_sat
|
||||||
|
# define rgblight_get_val rgb_matrix_get_val
|
||||||
|
# define rgblight_get_hsv rgb_matrix_get_hsv
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -368,6 +368,8 @@ void rgblight_disable_noeeprom(void) {
|
||||||
rgblight_set();
|
rgblight_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rgblight_is_enabled(void) { return rgblight_config.enable; }
|
||||||
|
|
||||||
void rgblight_increase_hue_helper(bool write_to_eeprom) {
|
void rgblight_increase_hue_helper(bool write_to_eeprom) {
|
||||||
uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
|
uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP;
|
||||||
rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom);
|
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; }
|
||||||
|
|
||||||
uint8_t rgblight_get_val(void) { return rgblight_config.val; }
|
uint8_t rgblight_get_val(void) { return rgblight_config.val; }
|
||||||
|
|
||||||
|
HSV rgblight_get_hsv(void) {
|
||||||
|
return (HSV){ rgblight_config.hue, rgblight_config.sat, rgblight_config.val };
|
||||||
|
}
|
||||||
|
|
||||||
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
|
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
|
||||||
if (!rgblight_config.enable) {
|
if (!rgblight_config.enable) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -350,6 +350,8 @@ uint8_t rgblight_get_mode(void);
|
||||||
uint8_t rgblight_get_hue(void);
|
uint8_t rgblight_get_hue(void);
|
||||||
uint8_t rgblight_get_sat(void);
|
uint8_t rgblight_get_sat(void);
|
||||||
uint8_t rgblight_get_val(void);
|
uint8_t rgblight_get_val(void);
|
||||||
|
bool rgblight_is_enabled(void);
|
||||||
|
HSV rgblight_get_hsv(void);
|
||||||
|
|
||||||
/* === qmk_firmware (core)internal Functions === */
|
/* === qmk_firmware (core)internal Functions === */
|
||||||
void rgblight_init(void);
|
void rgblight_init(void);
|
||||||
|
|
Loading…
Reference in a new issue