]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/visualizer/visualizer.c
Chimera Ortho Readme (#1943)
[qmk_firmware.git] / quantum / visualizer / visualizer.c
index a4b3ea7e491805434ac1218e35c8c82f73d6ce68..5b4d8d603ec6b332eb76d7bce176a5d9201d3701 100644 (file)
@@ -52,7 +52,8 @@ SOFTWARE.
 
 // Define this in config.h
 #ifndef VISUALIZER_THREAD_PRIORITY
-#define "Visualizer thread priority not defined"
+// The visualizer needs gfx thread priorities
+#define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
 #endif
 
 static visualizer_keyboard_status_t current_status = {
@@ -105,15 +106,19 @@ static remote_object_t* remote_objects[] = {
 GDisplay* LCD_DISPLAY = 0;
 GDisplay* LED_DISPLAY = 0;
 
+#ifdef LCD_DISPLAY_NUMBER
 __attribute__((weak))
 GDisplay* get_lcd_display(void) {
-    return gdispGetDisplay(0);
+    return gdispGetDisplay(LCD_DISPLAY_NUMBER);
 }
+#endif
 
+#ifdef LED_DISPLAY_NUMBER
 __attribute__((weak))
 GDisplay* get_led_display(void) {
-    return gdispGetDisplay(1);
+    return gdispGetDisplay(LED_DISPLAY_NUMBER);
 }
+#endif
 
 void start_keyframe_animation(keyframe_animation_t* animation) {
     animation->current_frame = -1;
@@ -251,9 +256,12 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
         .mods = 0xFF,
         .leds = 0xFFFFFFFF,
         .suspended = false,
-#ifdef VISUALIZER_USER_DATA_SIZE
+    #ifdef BACKLIGHT_ENABLE
+        .backlight_level = 0,
+    #endif
+    #ifdef VISUALIZER_USER_DATA_SIZE
         .user_data = {0},
-#endif
+    #endif
     };
 
     visualizer_state_t state = {
@@ -295,6 +303,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
                 else {
                     gdispGSetPowerMode(LED_DISPLAY, powerOff);
                 }
+                state.status.backlight_level = current_status.backlight_level;
             }
     #endif
             if (visualizer_enabled) {
@@ -379,25 +388,26 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
 void visualizer_init(void) {
     gfxInit();
 
-#ifdef LCD_BACKLIGHT_ENABLE
+  #ifdef LCD_BACKLIGHT_ENABLE
     lcd_backlight_init();
-#endif
+  #endif
 
-#ifdef SERIAL_LINK_ENABLE
+  #ifdef SERIAL_LINK_ENABLE
     add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
-#endif
+  #endif
 
-#ifdef LCD_ENABLE
+  #ifdef LCD_ENABLE
     LCD_DISPLAY = get_lcd_display();
-#endif
-#ifdef BACKLIGHT_ENABLE
+  #endif
+
+  #ifdef BACKLIGHT_ENABLE
     LED_DISPLAY = get_led_display();
-#endif
+  #endif
 
     // We are using a low priority thread, the idea is to have it run only
     // when the main thread is sleeping during the matrix scanning
-    gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack),
-                              VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL);
+  gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack),
+                  VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL);
 }
 
 void update_status(bool changed) {