aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keyboards/ergodox/keymaps/default/visualizer.c76
-rw-r--r--quantum/visualizer/visualizer.c28
-rw-r--r--quantum/visualizer/visualizer.h1
3 files changed, 44 insertions, 61 deletions
diff --git a/keyboards/ergodox/keymaps/default/visualizer.c b/keyboards/ergodox/keymaps/default/visualizer.c
index d99d5f702..305aaae15 100644
--- a/keyboards/ergodox/keymaps/default/visualizer.c
+++ b/keyboards/ergodox/keymaps/default/visualizer.c
@@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "visualizer.h"
#include "system/serial_link.h"
+#include "led.h"
// To generate an image array like this
// Ensure the image is 128 x 32 or smaller
@@ -117,34 +118,11 @@ static keyframe_animation_t startup_animation = {
},
};
-// The LCD animation alternates between the layer name display and a
-// bitmap that displays all active layers
-static keyframe_animation_t lcd_layer_bitmap_animation = {
- .num_frames = 2,
- .loop = true,
- .frame_lengths = {
- gfxMillisecondsToTicks(2000),
- gfxMillisecondsToTicks(2000)
- },
- .frame_functions = {
- keyframe_display_layer_text,
- keyframe_display_layer_bitmap
- },
-};
-
-static keyframe_animation_t lcd_layer_bitmap_leds_animation = {
- .num_frames = 3,
- .loop = true,
- .frame_lengths = {
- gfxMillisecondsToTicks(2000),
- gfxMillisecondsToTicks(2000),
- gfxMillisecondsToTicks(2000)
- },
- .frame_functions = {
- keyframe_display_layer_text,
- keyframe_display_led_states,
- keyframe_display_layer_bitmap,
- },
+static keyframe_animation_t lcd_layer_display = {
+ .num_frames = 1,
+ .loop = false,
+ .frame_lengths = {gfxMillisecondsToTicks(0)},
+ .frame_functions = {keyframe_display_layer_and_led_states}
};
static keyframe_animation_t suspend_animation = {
@@ -200,49 +178,31 @@ void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard
// state->status.default_layer
// state->status.leds (see led.h for available statuses)
+ uint8_t saturation = 60;
+ if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
+ saturation = 255;
+ }
if (state->status.layer & 0x4) {
- state->target_lcd_color = LCD_COLOR(0, 0xB0, 0xFF);
+ state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
state->layer_text = "Media & Mouse";
}
else if (state->status.layer & 0x2) {
- state->target_lcd_color = LCD_COLOR(0x80, 0xB0, 0xFF);
+ state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
state->layer_text = "Symbol";
}
else {
- state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF);
+ state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
state->layer_text = "Default";
}
- if (lcd_state == LCD_STATE_INITIAL || state->status.layer != prev_status->layer) {
+ if (lcd_state == LCD_STATE_INITIAL ||
+ state->status.layer != prev_status->layer ||
+ state->status.default_layer != prev_status->default_layer ||
+ state->status.leds != prev_status->leds) {
start_keyframe_animation(&color_animation);
+ start_keyframe_animation(&lcd_layer_display);
}
- if (state->status.leds) {
- if (lcd_state != LCD_STATE_BITMAP_AND_LEDS ||
- state->status.leds != prev_status->leds ||
- state->status.layer != prev_status->layer ||
- state->status.default_layer != prev_status->default_layer) {
-
- // NOTE: that it doesn't matter if the animation isn't playing, stop will do nothing in that case
- stop_keyframe_animation(&lcd_layer_bitmap_animation);
-
- lcd_state = LCD_STATE_BITMAP_AND_LEDS;
- // For information:
- // The logic in this function makes sure that this doesn't happen, but if you call start on an
- // animation that is already playing it will be restarted.
- start_keyframe_animation(&lcd_layer_bitmap_leds_animation);
- }
- } else {
- if (lcd_state != LCD_STATE_LAYER_BITMAP ||
- state->status.layer != prev_status->layer ||
- state->status.default_layer != prev_status->default_layer) {
-
- stop_keyframe_animation(&lcd_layer_bitmap_leds_animation);
-
- lcd_state = LCD_STATE_LAYER_BITMAP;
- start_keyframe_animation(&lcd_layer_bitmap_animation);
- }
- }
// You can also stop existing animations, and start your custom ones here
// remember that you should normally have only one animation for the LCD
// and one for the background. But you can also combine them if you want.
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index 3b3f51b1f..2533eb709 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -364,9 +364,9 @@ bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_st
return false;
}
-bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
-{
- char output[sizeof("NUM CAPS SCRL COMP KANA")];
+#define LED_STATE_STRING_SIZE sizeof("NUM CAPS SCRL COMP KANA")
+
+static void get_led_state_string(char* output, visualizer_state_t* state) {
uint8_t pos = 0;
if (state->status.leds & (1u << USB_LED_NUM_LOCK)) {
@@ -390,12 +390,34 @@ bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_sta
pos += 5;
}
output[pos] = 0;
+}
+
+bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
+{
+ (void)animation;
+ char output[LED_STATE_STRING_SIZE];
+ get_led_state_string(output, state);
gdispClear(White);
gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black);
gdispFlush();
return false;
}
+bool keyframe_display_layer_and_led_states(keyframe_animation_t* animation, visualizer_state_t* state) {
+ (void)animation;
+ gdispClear(White);
+ uint8_t y = 10;
+ if (state->status.leds) {
+ char output[LED_STATE_STRING_SIZE];
+ get_led_state_string(output, state);
+ gdispDrawString(0, 1, output, state->font_dejavusansbold12, Black);
+ y = 17;
+ }
+ gdispDrawString(0, y, state->layer_text, state->font_dejavusansbold12, Black);
+ gdispFlush();
+ return false;
+}
+
#endif // LCD_ENABLE
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index e8ace5b37..3b05c305e 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -141,6 +141,7 @@ bool keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_s
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_display_layer_and_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);