summaryrefslogtreecommitdiff
path: root/app/src/rgb_underglow.c
diff options
context:
space:
mode:
authorPeter Johanson <peter@peterjohanson.com>2021-11-09 05:04:54 +0000
committerPete Johanson <peter@peterjohanson.com>2022-01-31 23:03:34 -0500
commitd486304f7987e6cfd5ab9a77f3e077087759a258 (patch)
tree8cf2f97596750d5ec48182068dd7d5a0a07ac9c0 /app/src/rgb_underglow.c
parent0febaa142a2baca1be293aca339bdc6920500c01 (diff)
fix(underglow): Handle cycling effects on splits.
* Convert relative effect cycling to absolute effect selection.
Diffstat (limited to 'app/src/rgb_underglow.c')
-rw-r--r--app/src/rgb_underglow.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c
index 40d99c7..427552f 100644
--- a/app/src/rgb_underglow.c
+++ b/app/src/rgb_underglow.c
@@ -332,18 +332,28 @@ int zmk_rgb_underglow_off() {
return zmk_rgb_underglow_save_state();
}
-int zmk_rgb_underglow_cycle_effect(int direction) {
+int zmk_rgb_underglow_calc_effect(int direction) {
+ return (state.current_effect + UNDERGLOW_EFFECT_NUMBER + direction) % UNDERGLOW_EFFECT_NUMBER;
+}
+
+int zmk_rgb_underglow_select_effect(int effect) {
if (!led_strip)
return -ENODEV;
- state.current_effect += UNDERGLOW_EFFECT_NUMBER + direction;
- state.current_effect %= UNDERGLOW_EFFECT_NUMBER;
+ if (effect < 0 || effect >= UNDERGLOW_EFFECT_NUMBER) {
+ return -EINVAL;
+ }
+ state.current_effect = effect;
state.animation_step = 0;
return zmk_rgb_underglow_save_state();
}
+int zmk_rgb_underglow_cycle_effect(int direction) {
+ return zmk_rgb_underglow_select_effect(zmk_rgb_underglow_calc_effect(direction));
+}
+
int zmk_rgb_underglow_toggle() {
return state.on ? zmk_rgb_underglow_off() : zmk_rgb_underglow_on();
}