diff options
author | Fred Sundvik <fsundvik@gmail.com> | 2017-04-01 22:52:58 +0300 |
---|---|---|
committer | Fred Sundvik <fsundvik@gmail.com> | 2017-04-09 18:34:59 +0300 |
commit | 9a4ce28683b667ab67d48d92196bab7e277d4800 (patch) | |
tree | ad518ba049f16a6877775d28aa283d2ff8cc8c34 /quantum/visualizer | |
parent | 951b6f33a0dc479d29831aaa5c73fc526faf0471 (diff) | |
download | qmk_firmware-9a4ce28683b667ab67d48d92196bab7e277d4800.tar.gz qmk_firmware-9a4ce28683b667ab67d48d92196bab7e277d4800.zip |
Display layer bitmap and keyboard led states on the LCD
Diffstat (limited to 'quantum/visualizer')
-rw-r--r-- | quantum/visualizer/visualizer.c | 38 | ||||
-rw-r--r-- | quantum/visualizer/visualizer.h | 4 |
2 files changed, 40 insertions, 2 deletions
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 5826d909e..62ebebcee 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
@@ -56,6 +56,8 @@ SOFTWARE. | |||
56 | // mods status | 56 | // mods status |
57 | #include "action_util.h" | 57 | #include "action_util.h" |
58 | 58 | ||
59 | #include "led.h" | ||
60 | |||
59 | static visualizer_keyboard_status_t current_status = { | 61 | static visualizer_keyboard_status_t current_status = { |
60 | .layer = 0xFFFFFFFF, | 62 | .layer = 0xFFFFFFFF, |
61 | .default_layer = 0xFFFFFFFF, | 63 | .default_layer = 0xFFFFFFFF, |
@@ -350,6 +352,39 @@ bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_st | |||
350 | gdispFlush(); | 352 | gdispFlush(); |
351 | return false; | 353 | return false; |
352 | } | 354 | } |
355 | |||
356 | bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state) | ||
357 | { | ||
358 | char output[sizeof("NUM CAPS SCRL COMP KANA")]; | ||
359 | uint8_t pos = 0; | ||
360 | |||
361 | if (state->status.leds & (1u << USB_LED_NUM_LOCK)) { | ||
362 | memcpy(output + pos, "NUM ", 4); | ||
363 | pos += 4; | ||
364 | } | ||
365 | if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { | ||
366 | memcpy(output + pos, "CAPS ", 5); | ||
367 | pos += 5; | ||
368 | } | ||
369 | if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) { | ||
370 | memcpy(output + pos, "SCRL ", 5); | ||
371 | pos += 5; | ||
372 | } | ||
373 | if (state->status.leds & (1u << USB_LED_COMPOSE)) { | ||
374 | memcpy(output + pos, "COMP ", 5); | ||
375 | pos += 5; | ||
376 | } | ||
377 | if (state->status.leds & (1u << USB_LED_KANA)) { | ||
378 | memcpy(output + pos, "KANA ", 5); | ||
379 | pos += 5; | ||
380 | } | ||
381 | output[pos] = 0; | ||
382 | gdispClear(White); | ||
383 | gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black); | ||
384 | gdispFlush(); | ||
385 | return false; | ||
386 | } | ||
387 | |||
353 | #endif // LCD_ENABLE | 388 | #endif // LCD_ENABLE |
354 | 389 | ||
355 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { | 390 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { |
@@ -433,8 +468,9 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
433 | user_visualizer_suspend(&state); | 468 | user_visualizer_suspend(&state); |
434 | } | 469 | } |
435 | else { | 470 | else { |
471 | visualizer_keyboard_status_t prev_status = state.status; | ||
436 | state.status = current_status; | 472 | state.status = current_status; |
437 | update_user_visualizer_state(&state); | 473 | update_user_visualizer_state(&state, prev_status); |
438 | } | 474 | } |
439 | state.prev_lcd_color = state.current_lcd_color; | 475 | state.prev_lcd_color = state.current_lcd_color; |
440 | } | 476 | } |
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index 315af5022..2c81cb9f7 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h | |||
@@ -136,6 +136,8 @@ bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_sta | |||
136 | bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | 136 | bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); |
137 | // Displays a bitmap (0/1) of all the currently active mods | 137 | // Displays a bitmap (0/1) of all the currently active mods |
138 | bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | 138 | bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); |
139 | // Displays the keyboard led states (CAPS (Caps lock), NUM (Num lock), SCRL (Scroll lock), COMP (Compose), KANA) | ||
140 | bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state); | ||
139 | 141 | ||
140 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); | 142 | bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); |
141 | bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); | 143 | bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state); |
@@ -146,7 +148,7 @@ bool enable_visualization(keyframe_animation_t* animation, visualizer_state_t* s | |||
146 | 148 | ||
147 | // These functions have to be implemented by the user | 149 | // These functions have to be implemented by the user |
148 | void initialize_user_visualizer(visualizer_state_t* state); | 150 | void initialize_user_visualizer(visualizer_state_t* state); |
149 | void update_user_visualizer_state(visualizer_state_t* state); | 151 | void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t prev_status); |
150 | void user_visualizer_suspend(visualizer_state_t* state); | 152 | void user_visualizer_suspend(visualizer_state_t* state); |
151 | void user_visualizer_resume(visualizer_state_t* state); | 153 | void user_visualizer_resume(visualizer_state_t* state); |
152 | 154 | ||