From 9099224c3390e7c4477bf5fd829d116270dd3032 Mon Sep 17 00:00:00 2001 From: XiNGRZ Date: Tue, 17 Oct 2023 18:26:53 +0800 Subject: [PATCH] indicator: Update indicator in low priority workqueue --- config/app/indicator.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config/app/indicator.c b/config/app/indicator.c index 38563a44..86cbbe5b 100644 --- a/config/app/indicator.c +++ b/config/app/indicator.c @@ -12,6 +12,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include +#include #include #include @@ -57,7 +58,9 @@ static inline void apply_brightness(struct led_rgb *c_out, const struct led_rgb static void indicator_update(struct k_work *work) { if (!settings.enable) { + unsigned int key = irq_lock(); led_strip_remap_clear(led_strip, STRIP_INDICATOR_LABEL); + irq_unlock(key); return; } @@ -72,14 +75,16 @@ static void indicator_update(struct k_work *work) LOG_DBG("Update indicator, color: %02X%02X%02X, brightness: %d -> %02X%02X%02X", current.r, current.g, current.b, bri, color.r, color.g, color.b); + unsigned int key = irq_lock(); led_strip_remap_set(led_strip, STRIP_INDICATOR_LABEL, &color); + irq_unlock(key); } K_WORK_DEFINE(indicator_update_work, indicator_update); static inline void post_indicator_update(void) { - k_work_submit_to_queue(&k_sys_work_q, &indicator_update_work); + k_work_submit_to_queue(zmk_workqueue_lowprio_work_q(), &indicator_update_work); } uint32_t indicator_set_bits(uint32_t bits) @@ -167,7 +172,9 @@ static void indicator_preview_brightness(uint8_t brightness) LOG_DBG("Preview indicator, color: %02X%02X%02X, brightness: %d -> %02X%02X%02X", current.r, current.g, current.b, brightness, color.r, color.g, color.b); + unsigned int key = irq_lock(); led_strip_remap_set(led_strip, "STATUS", &color); + irq_unlock(key); k_work_reschedule(&indicator_clear_preview_work, K_MSEC(2000)); } @@ -235,7 +242,7 @@ static int indicator_init(const struct device *dev) #endif k_mutex_init(&lock); - k_work_submit_to_queue(&k_sys_work_q, &indicator_update_work); + k_work_submit_to_queue(zmk_workqueue_lowprio_work_q(), &indicator_update_work); return 0; }