Skip to content

Commit

Permalink
feat(underglow): max and min brightness in Kconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Smit committed Feb 17, 2021
1 parent af9d6e9 commit 8e8a20f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
30 changes: 24 additions & 6 deletions app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -210,35 +210,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 1 5
default 0

config ZMK_RGB_UNDERGLOW_ON_START
Expand Down
10 changes: 5 additions & 5 deletions app/src/rgb_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ 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 > BRT_MAX) {
if (color.h > HUE_MAX || color.s > SAT_MAX || color.b > CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX) {
return -ENOTSUP;
}

Expand Down Expand Up @@ -371,10 +371,10 @@ struct zmk_led_hsb zmk_rgb_underglow_calc_brt(int direction) {
struct zmk_led_hsb color = state.color;

int b = color.b + (direction * CONFIG_ZMK_RGB_UNDERGLOW_BRT_STEP);
if (b < 0) {
b = 0;
} else if (b > BRT_MAX) {
b = BRT_MAX;
if (b < CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN) {
b = CONFIG_ZMK_RGB_UNDERGLOW_BRT_MIN;
} else if (b > CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX) {
b = CONFIG_ZMK_RGB_UNDERGLOW_BRT_MAX;
}
color.b = b;

Expand Down

0 comments on commit 8e8a20f

Please sign in to comment.