aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/visualizer
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-04-01 22:52:58 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-04-09 18:34:59 +0300
commit9a4ce28683b667ab67d48d92196bab7e277d4800 (patch)
treead518ba049f16a6877775d28aa283d2ff8cc8c34 /quantum/visualizer
parent951b6f33a0dc479d29831aaa5c73fc526faf0471 (diff)
downloadfirmware-9a4ce28683b667ab67d48d92196bab7e277d4800.tar.gz
firmware-9a4ce28683b667ab67d48d92196bab7e277d4800.tar.bz2
firmware-9a4ce28683b667ab67d48d92196bab7e277d4800.zip
Display layer bitmap and keyboard led states on the LCD
Diffstat (limited to 'quantum/visualizer')
-rw-r--r--quantum/visualizer/visualizer.c38
-rw-r--r--quantum/visualizer/visualizer.h4
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.
// mods status
#include "action_util.h"
+#include "led.h"
+
static visualizer_keyboard_status_t current_status = {
.layer = 0xFFFFFFFF,
.default_layer = 0xFFFFFFFF,
@@ -350,6 +352,39 @@ bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_st
gdispFlush();
return false;
}
+
+bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
+{
+ char output[sizeof("NUM CAPS SCRL COMP KANA")];
+ uint8_t pos = 0;
+
+ if (state->status.leds & (1u << USB_LED_NUM_LOCK)) {
+ memcpy(output + pos, "NUM ", 4);
+ pos += 4;
+ }
+ if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
+ memcpy(output + pos, "CAPS ", 5);
+ pos += 5;
+ }
+ if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) {
+ memcpy(output + pos, "SCRL ", 5);
+ pos += 5;
+ }
+ if (state->status.leds & (1u << USB_LED_COMPOSE)) {
+ memcpy(output + pos, "COMP ", 5);
+ pos += 5;
+ }
+ if (state->status.leds & (1u << USB_LED_KANA)) {
+ memcpy(output + pos, "KANA ", 5);
+ pos += 5;
+ }
+ output[pos] = 0;
+ gdispClear(White);
+ gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black);
+ gdispFlush();
+ return false;
+}
+
#endif // LCD_ENABLE
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
@@ -433,8 +468,9 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
user_visualizer_suspend(&state);
}
else {
+ visualizer_keyboard_status_t prev_status = state.status;
state.status = current_status;
- update_user_visualizer_state(&state);
+ update_user_visualizer_state(&state, prev_status);
}
state.prev_lcd_color = state.current_lcd_color;
}
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
bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
// Displays a bitmap (0/1) of all the currently active mods
bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state);
+// Displays the keyboard led states (CAPS (Caps lock), NUM (Num lock), SCRL (Scroll lock), COMP (Compose), KANA)
+bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
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
// These functions have to be implemented by the user
void initialize_user_visualizer(visualizer_state_t* state);
-void update_user_visualizer_state(visualizer_state_t* state);
+void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t prev_status);
void user_visualizer_suspend(visualizer_state_t* state);
void user_visualizer_resume(visualizer_state_t* state);