aboutsummaryrefslogtreecommitdiff
path: root/quantum/visualizer/visualizer.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/visualizer/visualizer.c')
-rw-r--r--quantum/visualizer/visualizer.c150
1 files changed, 2 insertions, 148 deletions
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index 2533eb709..514d7c44e 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -48,16 +48,13 @@ SOFTWARE.
48#include "serial_link/system/serial_link.h" 48#include "serial_link/system/serial_link.h"
49#endif 49#endif
50 50
51#include "action_util.h"
52
51// Define this in config.h 53// Define this in config.h
52#ifndef VISUALIZER_THREAD_PRIORITY 54#ifndef VISUALIZER_THREAD_PRIORITY
53#define "Visualizer thread priority not defined" 55#define "Visualizer thread priority not defined"
54#endif 56#endif
55 57
56// mods status
57#include "action_util.h"
58
59#include "led.h"
60
61static visualizer_keyboard_status_t current_status = { 58static visualizer_keyboard_status_t current_status = {
62 .layer = 0xFFFFFFFF, 59 .layer = 0xFFFFFFFF,
63 .default_layer = 0xFFFFFFFF, 60 .default_layer = 0xFFFFFFFF,
@@ -277,149 +274,6 @@ bool keyframe_set_backlight_color(keyframe_animation_t* animation, visualizer_st
277} 274}
278#endif // LCD_BACKLIGHT_ENABLE 275#endif // LCD_BACKLIGHT_ENABLE
279 276
280#ifdef LCD_ENABLE
281bool keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state) {
282 (void)animation;
283 gdispClear(White);
284 gdispDrawString(0, 10, state->layer_text, state->font_dejavusansbold12, Black);
285 gdispFlush();
286 return false;
287}
288
289static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) {
290 for (int i=0; i<16;i++)
291 {
292 uint32_t mask = (1u << i);
293 if (default_layer & mask) {
294 if (layer & mask) {
295 *buffer = 'B';
296 } else {
297 *buffer = 'D';
298 }
299 } else if (layer & mask) {
300 *buffer = '1';
301 } else {
302 *buffer = '0';
303 }
304 ++buffer;
305
306 if (i==3 || i==7 || i==11) {
307 *buffer = ' ';
308 ++buffer;
309 }
310 }
311 *buffer = 0;
312}
313
314bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
315 (void)animation;
316 const char* layer_help = "1=On D=Default B=Both";
317 char layer_buffer[16 + 4]; // 3 spaces and one null terminator
318 gdispClear(White);
319 gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black);
320 format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer);
321 gdispDrawString(0, 10, layer_buffer, state->font_fixed5x8, Black);
322 format_layer_bitmap_string(state->status.default_layer >> 16, state->status.layer >> 16, layer_buffer);
323 gdispDrawString(0, 20, layer_buffer, state->font_fixed5x8, Black);
324 gdispFlush();
325 return false;
326}
327
328static void format_mods_bitmap_string(uint8_t mods, char* buffer) {
329 *buffer = ' ';
330 ++buffer;
331
332 for (int i = 0; i<8; i++)
333 {
334 uint32_t mask = (1u << i);
335 if (mods & mask) {
336 *buffer = '1';
337 } else {
338 *buffer = '0';
339 }
340 ++buffer;
341
342 if (i==3) {
343 *buffer = ' ';
344 ++buffer;
345 }
346 }
347 *buffer = 0;
348}
349
350bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) {
351 (void)animation;
352
353 const char* title = "Modifier states";
354 const char* mods_header = " CSAG CSAG ";
355 char status_buffer[12];
356
357 gdispClear(White);
358 gdispDrawString(0, 0, title, state->font_fixed5x8, Black);
359 gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black);
360 format_mods_bitmap_string(state->status.mods, status_buffer);
361 gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black);
362
363 gdispFlush();
364 return false;
365}
366
367#define LED_STATE_STRING_SIZE sizeof("NUM CAPS SCRL COMP KANA")
368
369static void get_led_state_string(char* output, visualizer_state_t* state) {
370 uint8_t pos = 0;
371
372 if (state->status.leds & (1u << USB_LED_NUM_LOCK)) {
373 memcpy(output + pos, "NUM ", 4);
374 pos += 4;
375 }
376 if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
377 memcpy(output + pos, "CAPS ", 5);
378 pos += 5;
379 }
380 if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) {
381 memcpy(output + pos, "SCRL ", 5);
382 pos += 5;
383 }
384 if (state->status.leds & (1u << USB_LED_COMPOSE)) {
385 memcpy(output + pos, "COMP ", 5);
386 pos += 5;
387 }
388 if (state->status.leds & (1u << USB_LED_KANA)) {
389 memcpy(output + pos, "KANA ", 5);
390 pos += 5;
391 }
392 output[pos] = 0;
393}
394
395bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
396{
397 (void)animation;
398 char output[LED_STATE_STRING_SIZE];
399 get_led_state_string(output, state);
400 gdispClear(White);
401 gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black);
402 gdispFlush();
403 return false;
404}
405
406bool keyframe_display_layer_and_led_states(keyframe_animation_t* animation, visualizer_state_t* state) {
407 (void)animation;
408 gdispClear(White);
409 uint8_t y = 10;
410 if (state->status.leds) {
411 char output[LED_STATE_STRING_SIZE];
412 get_led_state_string(output, state);
413 gdispDrawString(0, 1, output, state->font_dejavusansbold12, Black);
414 y = 17;
415 }
416 gdispDrawString(0, y, state->layer_text, state->font_dejavusansbold12, Black);
417 gdispFlush();
418 return false;
419}
420
421#endif // LCD_ENABLE
422
423bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) { 277bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
424 (void)animation; 278 (void)animation;
425 (void)state; 279 (void)state;