diff options
Diffstat (limited to 'quantum/visualizer/visualizer.c')
| -rw-r--r-- | quantum/visualizer/visualizer.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 6f134097f..486ff25b3 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
| @@ -58,8 +58,11 @@ SOFTWARE. | |||
| 58 | static visualizer_keyboard_status_t current_status = { | 58 | static visualizer_keyboard_status_t current_status = { |
| 59 | .layer = 0xFFFFFFFF, | 59 | .layer = 0xFFFFFFFF, |
| 60 | .default_layer = 0xFFFFFFFF, | 60 | .default_layer = 0xFFFFFFFF, |
| 61 | .mods = 0xFF, | ||
| 62 | .leds = 0xFFFFFFFF, | 61 | .leds = 0xFFFFFFFF, |
| 62 | #ifdef BACKLIGHT_ENABLE | ||
| 63 | .backlight_level = 0, | ||
| 64 | #endif | ||
| 65 | .mods = 0xFF, | ||
| 63 | .suspended = false, | 66 | .suspended = false, |
| 64 | #ifdef VISUALIZER_USER_DATA_SIZE | 67 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 65 | .user_data = {0} | 68 | .user_data = {0} |
| @@ -72,6 +75,9 @@ static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboa | |||
| 72 | status1->mods == status2->mods && | 75 | status1->mods == status2->mods && |
| 73 | status1->leds == status2->leds && | 76 | status1->leds == status2->leds && |
| 74 | status1->suspended == status2->suspended | 77 | status1->suspended == status2->suspended |
| 78 | #ifdef BACKLIGHT_ENABLE | ||
| 79 | && status1->backlight_level == status2->backlight_level | ||
| 80 | #endif | ||
| 75 | #ifdef VISUALIZER_USER_DATA_SIZE | 81 | #ifdef VISUALIZER_USER_DATA_SIZE |
| 76 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 | 82 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 |
| 77 | #endif | 83 | #endif |
| @@ -279,6 +285,18 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 279 | bool enabled = visualizer_enabled; | 285 | bool enabled = visualizer_enabled; |
| 280 | if (force_update || !same_status(&state.status, ¤t_status)) { | 286 | if (force_update || !same_status(&state.status, ¤t_status)) { |
| 281 | force_update = false; | 287 | force_update = false; |
| 288 | #if BACKLIGHT_ENABLE | ||
| 289 | if(current_status.backlight_level != state.status.backlight_level) { | ||
| 290 | if (current_status.backlight_level != 0) { | ||
| 291 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 292 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; | ||
| 293 | gdispGSetBacklight(LED_DISPLAY, percent); | ||
| 294 | } | ||
| 295 | else { | ||
| 296 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | #endif | ||
| 282 | if (visualizer_enabled) { | 300 | if (visualizer_enabled) { |
| 283 | if (current_status.suspended) { | 301 | if (current_status.suspended) { |
| 284 | stop_all_keyframe_animations(); | 302 | stop_all_keyframe_animations(); |
| @@ -309,7 +327,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
| 309 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); | 327 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); |
| 310 | } | 328 | } |
| 311 | } | 329 | } |
| 312 | #ifdef LED_ENABLE | 330 | #ifdef BACKLIGHT_ENABLE |
| 313 | gdispGFlush(LED_DISPLAY); | 331 | gdispGFlush(LED_DISPLAY); |
| 314 | #endif | 332 | #endif |
| 315 | 333 | ||
| @@ -372,7 +390,7 @@ void visualizer_init(void) { | |||
| 372 | #ifdef LCD_ENABLE | 390 | #ifdef LCD_ENABLE |
| 373 | LCD_DISPLAY = get_lcd_display(); | 391 | LCD_DISPLAY = get_lcd_display(); |
| 374 | #endif | 392 | #endif |
| 375 | #ifdef LED_ENABLE | 393 | #ifdef BACKLIGHT_ENABLE |
| 376 | LED_DISPLAY = get_led_display(); | 394 | LED_DISPLAY = get_led_display(); |
| 377 | #endif | 395 | #endif |
| 378 | 396 | ||
| @@ -445,6 +463,9 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint8_t mods, uin | |||
| 445 | .default_layer = default_state, | 463 | .default_layer = default_state, |
| 446 | .mods = mods, | 464 | .mods = mods, |
| 447 | .leds = leds, | 465 | .leds = leds, |
| 466 | #ifdef BACKLIGHT_ENABLE | ||
| 467 | .backlight_level = current_status.backlight_level, | ||
| 468 | #endif | ||
| 448 | .suspended = current_status.suspended, | 469 | .suspended = current_status.suspended, |
| 449 | }; | 470 | }; |
| 450 | #ifdef VISUALIZER_USER_DATA_SIZE | 471 | #ifdef VISUALIZER_USER_DATA_SIZE |
| @@ -467,3 +488,10 @@ void visualizer_resume(void) { | |||
| 467 | current_status.suspended = false; | 488 | current_status.suspended = false; |
| 468 | update_status(true); | 489 | update_status(true); |
| 469 | } | 490 | } |
| 491 | |||
| 492 | #ifdef BACKLIGHT_ENABLE | ||
| 493 | void backlight_set(uint8_t level) { | ||
| 494 | current_status.backlight_level = level; | ||
| 495 | update_status(true); | ||
| 496 | } | ||
| 497 | #endif | ||
