Skip to content

Commit

Permalink
set brighness in zmk_underglow_set_hsb as percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Smit committed Jun 26, 2021
1 parent 7491ed0 commit 1024634
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/rgb_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,14 @@ int zmk_rgb_underglow_toggle() {
}

int zmk_rgb_underglow_set_hsb(struct zmk_led_hsb color) {
if (color.h > HUE_MAX || color.s > SAT_MAX || color.b < CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN ||
color.b > CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX) {
if (color.h > HUE_MAX || color.s > SAT_MAX || color.b > BRT_MAX) {
return -ENOTSUP;
}

color.b =
(uint8_t)((float)(CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX - CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN) *
(float)color.b / 100.0F) +
CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN;
state.color = color;

return 0;
Expand Down

0 comments on commit 1024634

Please sign in to comment.