summaryrefslogtreecommitdiff
path: root/app/include
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2021-02-02 14:50:02 -0500
committerPete Johanson <peter@peterjohanson.com>2021-02-09 01:27:50 -0500
commit2af794eed3fe03b3c3ab904bb02b3953d234adc0 (patch)
treec55adef1b046a31ee1e2ff9907eaef1768132c6c /app/include
parente6f168d6dfe0a27407a7229a549f2dbab37b0f2d (diff)
feat(underglow): Convert HSB changes to absolute.
* Public type for HSB led color. * New API for calculating "next" HSB based on current state. * Update behavior to convert the increment/decrement commands to absolute command as well.
Diffstat (limited to 'app/include')
-rw-r--r--app/include/dt-bindings/zmk/rgb.h3
-rw-r--r--app/include/zmk/rgb_underglow.h11
2 files changed, 12 insertions, 2 deletions
diff --git a/app/include/dt-bindings/zmk/rgb.h b/app/include/dt-bindings/zmk/rgb.h
index 403cba9..95aa502 100644
--- a/app/include/dt-bindings/zmk/rgb.h
+++ b/app/include/dt-bindings/zmk/rgb.h
@@ -32,5 +32,6 @@
#define RGB_SPD RGB_SPD_CMD 0
#define RGB_EFF RGB_EFF_CMD 0
#define RGB_EFR RGB_EFR_CMD 0
-#define RGB_COLOR_HSB(h, s, v) RGB_COLOR_HSB_CMD(((h) << 16) + ((s) << 8) + (v))
+#define RGB_COLOR_HSB_VAL(h, s, v) (((h) << 16) + ((s) << 8) + (v))
+#define RGB_COLOR_HSB(h, s, v) RGB_COLOR_HSB_CMD##(RGB_COLOR_HSB_VAL(h, s, v))
#define RGB_COLOR_HSV RGB_COLOR_HSB \ No newline at end of file
diff --git a/app/include/zmk/rgb_underglow.h b/app/include/zmk/rgb_underglow.h
index 7c2ff13..4d452a6 100644
--- a/app/include/zmk/rgb_underglow.h
+++ b/app/include/zmk/rgb_underglow.h
@@ -6,13 +6,22 @@
#pragma once
+struct zmk_led_hsb {
+ uint16_t h;
+ uint8_t s;
+ uint8_t b;
+};
+
int zmk_rgb_underglow_toggle();
int zmk_rgb_underglow_get_state(bool *state);
int zmk_rgb_underglow_on();
int zmk_rgb_underglow_off();
int zmk_rgb_underglow_cycle_effect(int direction);
+struct zmk_led_hsb zmk_rgb_underglow_calc_hue(int direction);
+struct zmk_led_hsb zmk_rgb_underglow_calc_sat(int direction);
+struct zmk_led_hsb zmk_rgb_underglow_calc_brt(int direction);
int zmk_rgb_underglow_change_hue(int direction);
int zmk_rgb_underglow_change_sat(int direction);
int zmk_rgb_underglow_change_brt(int direction);
int zmk_rgb_underglow_change_spd(int direction);
-int zmk_rgb_underglow_set_hsb(uint16_t hue, uint8_t saturation, uint8_t brightness); \ No newline at end of file
+int zmk_rgb_underglow_set_hsb(struct zmk_led_hsb color); \ No newline at end of file