From dc8c7011b15b1c0703fe788b42f18adce90907ee Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 26 Jul 2020 12:49:43 -0500 Subject: [PATCH] If LED strip can't be found, behaviors return err --- app/src/rgb_underglow.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 16a49894..95adcec2 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -203,6 +203,8 @@ static int zmk_rgb_underglow_init(struct device *_arg) int zmk_rgb_underglow_cycle_effect(int direction) { + if (!led_strip) return -ENODEV; + if (state.current_effect == 0 && direction < 0) { state.current_effect = UNDERGLOW_EFFECT_NUMBER - 1; return 0; @@ -221,6 +223,8 @@ int zmk_rgb_underglow_cycle_effect(int direction) int zmk_rgb_underglow_toggle() { + if (!led_strip) return -ENODEV; + state.on = !state.on; if (state.on) { @@ -243,6 +247,8 @@ int zmk_rgb_underglow_toggle() int zmk_rgb_underglow_change_hue(int direction) { + if (!led_strip) return -ENODEV; + if (state.hue == 0 && direction < 0) { state.hue = 350; return 0; @@ -259,6 +265,8 @@ int zmk_rgb_underglow_change_hue(int direction) int zmk_rgb_underglow_change_sat(int direction) { + if (!led_strip) return -ENODEV; + if (state.saturation == 0 && direction < 0) { return 0; } @@ -274,6 +282,8 @@ int zmk_rgb_underglow_change_sat(int direction) int zmk_rgb_underglow_change_brt(int direction) { + if (!led_strip) return -ENODEV; + if (state.brightness == 0 && direction < 0) { return 0; } @@ -289,6 +299,8 @@ int zmk_rgb_underglow_change_brt(int direction) int zmk_rgb_underglow_change_spd(int direction) { + if (!led_strip) return -ENODEV; + if (state.animation_speed == 1 && direction < 0) { return 0; }