mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-12-27 11:38:58 +06:00
Tweaks to the Ergodox default visualizer
No animation, display led statuses and layer name on the same screen Don't display layer bitmap Fully saturated colors for caps, less saturated ones normally
This commit is contained in:
parent
fa6da78ff3
commit
05bc4880dd
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include "visualizer.h"
|
#include "visualizer.h"
|
||||||
#include "system/serial_link.h"
|
#include "system/serial_link.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
// To generate an image array like this
|
// To generate an image array like this
|
||||||
// Ensure the image is 128 x 32 or smaller
|
// 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
|
static keyframe_animation_t lcd_layer_display = {
|
||||||
// bitmap that displays all active layers
|
.num_frames = 1,
|
||||||
static keyframe_animation_t lcd_layer_bitmap_animation = {
|
.loop = false,
|
||||||
.num_frames = 2,
|
.frame_lengths = {gfxMillisecondsToTicks(0)},
|
||||||
.loop = true,
|
.frame_functions = {keyframe_display_layer_and_led_states}
|
||||||
.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 suspend_animation = {
|
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.default_layer
|
||||||
// state->status.leds (see led.h for available statuses)
|
// 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) {
|
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";
|
state->layer_text = "Media & Mouse";
|
||||||
}
|
}
|
||||||
else if (state->status.layer & 0x2) {
|
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";
|
state->layer_text = "Symbol";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF);
|
state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
|
||||||
state->layer_text = "Default";
|
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(&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
|
// You can also stop existing animations, and start your custom ones here
|
||||||
// remember that you should normally have only one animation for the LCD
|
// 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.
|
// and one for the background. But you can also combine them if you want.
|
||||||
|
@ -364,9 +364,9 @@ bool keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_st
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state)
|
#define LED_STATE_STRING_SIZE sizeof("NUM CAPS SCRL COMP KANA")
|
||||||
{
|
|
||||||
char output[sizeof("NUM CAPS SCRL COMP KANA")];
|
static void get_led_state_string(char* output, visualizer_state_t* state) {
|
||||||
uint8_t pos = 0;
|
uint8_t pos = 0;
|
||||||
|
|
||||||
if (state->status.leds & (1u << USB_LED_NUM_LOCK)) {
|
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;
|
pos += 5;
|
||||||
}
|
}
|
||||||
output[pos] = 0;
|
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);
|
gdispClear(White);
|
||||||
gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black);
|
gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black);
|
||||||
gdispFlush();
|
gdispFlush();
|
||||||
return false;
|
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
|
#endif // LCD_ENABLE
|
||||||
|
|
||||||
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
|
bool keyframe_disable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state) {
|
||||||
|
@ -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);
|
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)
|
// 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_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_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);
|
bool keyframe_enable_lcd_and_backlight(keyframe_animation_t* animation, visualizer_state_t* state);
|
||||||
|
Loading…
Reference in New Issue
Block a user