Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -263,35 +263,53 @@ config ZMK_RGB_UNDERGLOW_EXT_POWER
default y

config ZMK_RGB_UNDERGLOW_HUE_STEP
int "RGB underglow hue step in degrees of 360"
int "RGB underglow hue step in degrees"
range 0 359
default 10

config ZMK_RGB_UNDERGLOW_SAT_STEP
int "RGB underglow sturation step in percent"
int "RGB underglow saturation step in percent"
range 0 100
default 10

config ZMK_RGB_UNDERGLOW_BRT_STEP
int "RGB underglow brightness step in percent"
range 0 100
default 10

config ZMK_RGB_UNDERGLOW_HUE_START
int "RGB underglow start hue value from 0-359"
int "RGB underglow start hue value in degrees"
range 0 359
default 0

config ZMK_RGB_UNDERGLOW_SAT_START
int "RGB underglow start saturations value from 0-100"
int "RGB underglow start saturations value in percent"
range 0 100
default 100

config ZMK_RGB_UNDERGLOW_BRT_START
int "RGB underglow start brightness value from 0-100"
int "RGB underglow start brightness value in percent"
range ZMK_RGB_UNDERGLOW_BRT_MIN ZMK_RGB_UNDERGLOW_BRT_MAX
default ZMK_RGB_UNDERGLOW_BRT_MAX

config ZMK_RGB_UNDERGLOW_BRT_MIN
int "RGB underglow minimum brightness value in percent"
range 0 100
default 0

config ZMK_RGB_UNDERGLOW_BRT_MAX
int "RGB underglow maximum brightness value in percent"
range ZMK_RGB_UNDERGLOW_BRT_MIN 100
default 100

config ZMK_RGB_UNDERGLOW_SPD_START
int "RGB underglow start animation speed value from 1-5"
int "RGB underglow start animation speed value"
range 1 5
default 3

config ZMK_RGB_UNDERGLOW_EFF_START
int "RGB underglow start effect int value related to the effect enum list"
range 0 3
default 0

config ZMK_RGB_UNDERGLOW_ON_START
Expand Down
5 changes: 4 additions & 1 deletion app/src/rgb_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ static struct led_rgb hsb_to_rgb(struct zmk_led_hsb hsb) {
double r, g, b;

uint8_t i = hsb.h / 60;
double v = hsb.b / ((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;
Comment on lines +61 to +64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how simple this solution is, but it feels like this min/max conversion of brightness should probably be preprocessed before being sent to the hsb_to_rgb function, as now this function does more than hsb_to_rgb functionality.

double s = hsb.s / ((float)SAT_MAX);
double f = hsb.h / ((float)HUE_MAX) * 6 - i;
double p = v * (1 - s);
Expand Down