|
|
|
@ -15,7 +15,6 @@
@@ -15,7 +15,6 @@
|
|
|
|
|
#include <logging/log.h> |
|
|
|
|
|
|
|
|
|
#include <drivers/led_strip.h> |
|
|
|
|
#include <device.h> |
|
|
|
|
|
|
|
|
|
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); |
|
|
|
|
|
|
|
|
@ -106,6 +105,16 @@ static struct led_rgb hsb_to_rgb(struct led_hsb hsb)
@@ -106,6 +105,16 @@ static struct led_rgb hsb_to_rgb(struct led_hsb hsb)
|
|
|
|
|
return rgb; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void zmk_rgb_underglow_off() |
|
|
|
|
{ |
|
|
|
|
for (int i=0; i<STRIP_NUM_PIXELS; i++) |
|
|
|
|
{ |
|
|
|
|
pixels[i] = (struct led_rgb){ r: 0, g: 0, b: 0}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
led_strip_update_rgb(led_strip, pixels, STRIP_NUM_PIXELS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void zmk_rgb_underglow_effect_solid() |
|
|
|
|
{ |
|
|
|
|
for (int i=0; i<STRIP_NUM_PIXELS; i++) |
|
|
|
@ -199,6 +208,15 @@ K_WORK_DEFINE(underglow_work, zmk_rgb_underglow_tick);
@@ -199,6 +208,15 @@ K_WORK_DEFINE(underglow_work, zmk_rgb_underglow_tick);
|
|
|
|
|
|
|
|
|
|
static void zmk_rgb_underglow_tick_handler(struct k_timer *timer) |
|
|
|
|
{ |
|
|
|
|
if (!state.on) |
|
|
|
|
{ |
|
|
|
|
zmk_rgb_underglow_off(); |
|
|
|
|
|
|
|
|
|
k_timer_stop(timer); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
k_work_submit(&underglow_work); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -221,20 +239,12 @@ static int zmk_rgb_underglow_init(struct device *_arg)
@@ -221,20 +239,12 @@ static int zmk_rgb_underglow_init(struct device *_arg)
|
|
|
|
|
animation_speed: CONFIG_ZMK_RGB_UNDERGLOW_SPD_START, |
|
|
|
|
current_effect: CONFIG_ZMK_RGB_UNDERGLOW_EFF_START, |
|
|
|
|
animation_step: 0, |
|
|
|
|
#ifdef CONFIG_ZMK_RGB_UNDERGLOW_ON_START |
|
|
|
|
on: true |
|
|
|
|
#else |
|
|
|
|
on: false |
|
|
|
|
#endif |
|
|
|
|
on: IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_ON_START) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
settings_subsys_init(); |
|
|
|
|
settings_register(&rgb_conf); |
|
|
|
|
settings_load(); |
|
|
|
|
|
|
|
|
|
if (state.on) { |
|
|
|
|
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); |
|
|
|
|
} |
|
|
|
|
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -274,13 +284,7 @@ int zmk_rgb_underglow_toggle()
@@ -274,13 +284,7 @@ int zmk_rgb_underglow_toggle()
|
|
|
|
|
state.animation_step = 0; |
|
|
|
|
k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
for (int i=0; i<STRIP_NUM_PIXELS; i++) |
|
|
|
|
{ |
|
|
|
|
pixels[i] = (struct led_rgb){ r: 0, g: 0, b: 0}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
led_strip_update_rgb(led_strip, pixels, STRIP_NUM_PIXELS); |
|
|
|
|
zmk_rgb_underglow_off(); |
|
|
|
|
|
|
|
|
|
k_timer_stop(&underglow_tick); |
|
|
|
|
} |
|
|
|
|