1
0
Fork 0

Add multithreadedness for lighting options

This commit is contained in:
Drashna Jael're 2024-12-04 18:45:26 -08:00
parent 2df0263010
commit 82aed74e67
Signed by: drashna
GPG key ID: DBA1FD3A860D1B11
2 changed files with 65 additions and 14 deletions

View file

@ -963,6 +963,10 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes)
endif
endif
ifeq ($(strip $(MULTITHREADED_LIGHTING_ENABLE)), yes)
OPT_DEFS += -DMULTITHREADED_LIGHTING_ENABLE
endif
VALID_WS2812_DRIVER_TYPES := bitbang custom i2c pwm spi vendor
WS2812_DRIVER ?= bitbang

View file

@ -403,6 +403,45 @@ void quantum_init(void) {
layer_state_set_kb((layer_state_t)layer_state);
}
#ifdef MULTITHREADED_LIGHTING_ENABLE
static THD_WORKING_AREA(waLightingThread, 1024);
static THD_FUNCTION(LightingThread, arg) {
(void)arg;
chRegSetThreadName("lighting");
# ifdef LED_MATRIX_ENABLE
led_matrix_init();
# endif
# ifdef RGB_MATRIX_ENABLE
rgb_matrix_init();
# endif
# ifdef RGBLIGHT_ENABLE
rgblight_init();
# endif
# ifdef BACKLIGHT_ENABLE
backlight_init();
# endif
while (true) {
# if defined(RGBLIGHT_ENABLE)
rgblight_task();
# endif
# ifdef LED_MATRIX_ENABLE
led_matrix_task();
# endif
# ifdef RGB_MATRIX_ENABLE
rgb_matrix_task();
# endif
# if defined(BACKLIGHT_ENABLE)
# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
backlight_task();
# endif
# endif
chThdSleepMicroseconds(500);
}
}
#endif // MULTITHREADED_EFFECTS_ENABLE
/** \brief keyboard_init
*
* FIXME: needs doc
@ -428,11 +467,15 @@ void keyboard_init(void) {
#ifdef AUDIO_ENABLE
audio_init();
#endif
#ifdef LED_MATRIX_ENABLE
#ifdef MULTITHREADED_LIGHTING_ENABLE
chThdCreateStatic(waLightingThread, sizeof(waLightingThread), HIGHPRIO, LightingThread, NULL);
#else
# ifdef LED_MATRIX_ENABLE
led_matrix_init();
#endif
#ifdef RGB_MATRIX_ENABLE
# endif
# ifdef RGB_MATRIX_ENABLE
rgb_matrix_init();
# endif
#endif
#if defined(UNICODE_COMMON_ENABLE)
unicode_input_mode_init();
@ -449,11 +492,13 @@ void keyboard_init(void) {
#ifdef PS2_MOUSE_ENABLE
ps2_mouse_init();
#endif
#ifdef BACKLIGHT_ENABLE
#ifndef MULTITHREADED_LIGHTING_ENABLE
# ifdef BACKLIGHT_ENABLE
backlight_init();
#endif
#ifdef RGBLIGHT_ENABLE
# endif
# ifdef RGBLIGHT_ENABLE
rgblight_init();
# endif
#endif
#ifdef STENO_ENABLE_ALL
steno_init();
@ -682,21 +727,23 @@ void keyboard_task(void) {
split_watchdog_task();
#endif
#if defined(RGBLIGHT_ENABLE)
#ifndef MULTITHREADED_LIGHTING_ENABLE
# if defined(RGBLIGHT_ENABLE)
rgblight_task();
#endif
# endif
#ifdef LED_MATRIX_ENABLE
# ifdef LED_MATRIX_ENABLE
led_matrix_task();
#endif
#ifdef RGB_MATRIX_ENABLE
# endif
# ifdef RGB_MATRIX_ENABLE
rgb_matrix_task();
#endif
# endif
#if defined(BACKLIGHT_ENABLE)
# if defined(BACKLIGHT_ENABLE)
# if defined(BACKLIGHT_PIN) || defined(BACKLIGHT_PINS)
backlight_task();
# endif
# endif
#endif
#ifdef ENCODER_ENABLE