tidy up, fix underflow again
This commit is contained in:
parent
7193788189
commit
8b5862a227
2 changed files with 9 additions and 8 deletions
|
@ -294,7 +294,7 @@ config ZMK_RGB_UNDERGLOW_BRT_START
|
|||
|
||||
config ZMK_RGB_UNDERGLOW_BRT_MIN
|
||||
int "RGB underglow minimum brightness value in percent"
|
||||
range 0 100
|
||||
range 0 100
|
||||
default 0
|
||||
|
||||
config ZMK_RGB_UNDERGLOW_BRT_MAX
|
||||
|
|
|
@ -58,9 +58,8 @@ static struct led_rgb hsb_to_rgb(struct zmk_led_hsb hsb) {
|
|||
double r, g, b;
|
||||
|
||||
uint8_t i = hsb.h / 60;
|
||||
double v = ((float)hsb.b *
|
||||
(float)(CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX - CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN) /
|
||||
(float)BRT_MAX +
|
||||
double v = ((float)hsb.b / (float)BRT_MAX *
|
||||
(float)(CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX - CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN) +
|
||||
(float)CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN) /
|
||||
(float)BRT_MAX;
|
||||
double s = hsb.s / ((float)SAT_MAX);
|
||||
|
@ -253,7 +252,6 @@ static int zmk_rgb_underglow_init(const struct device *_arg) {
|
|||
k_delayed_work_init(&underglow_save_work, zmk_rgb_underglow_save_state_work);
|
||||
|
||||
settings_load_subtree("rgb/underglow");
|
||||
|
||||
#endif
|
||||
|
||||
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50));
|
||||
|
@ -374,12 +372,15 @@ struct zmk_led_hsb zmk_rgb_underglow_calc_sat(int direction) {
|
|||
|
||||
struct zmk_led_hsb zmk_rgb_underglow_calc_brt(int direction) {
|
||||
struct zmk_led_hsb color = state.color;
|
||||
int b = color.b;
|
||||
b += (direction * CONFIG_ZMK_RGB_UNDERGLOW_BRT_STEP);
|
||||
if (b > BRT_MAX) {
|
||||
|
||||
int b = color.b + (direction * CONFIG_ZMK_RGB_UNDERGLOW_BRT_STEP);
|
||||
if (b < 0) {
|
||||
b = 0;
|
||||
} else if (b > BRT_MAX) {
|
||||
b = BRT_MAX;
|
||||
}
|
||||
color.b = b;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue