aboutsummaryrefslogtreecommitdiff
path: root/keyboards/ergodox/keymaps/default/visualizer.c
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-04-04 22:29:40 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-04-09 18:34:59 +0300
commit05bc4880ddc9e904cfa1773caff1ae81977d2a76 (patch)
tree1dd6d75c3725a0002fa352746c543e8d4d77fd25 /keyboards/ergodox/keymaps/default/visualizer.c
parentfa6da78ff3c96a71ed65684e276352700843d539 (diff)
downloadqmk_firmware-05bc4880ddc9e904cfa1773caff1ae81977d2a76.tar.gz
qmk_firmware-05bc4880ddc9e904cfa1773caff1ae81977d2a76.zip
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
Diffstat (limited to 'keyboards/ergodox/keymaps/default/visualizer.c')
-rw-r--r--keyboards/ergodox/keymaps/default/visualizer.c76
1 files changed, 18 insertions, 58 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/>.
28 28
29#include "visualizer.h" 29#include "visualizer.h"
30#include "system/serial_link.h" 30#include "system/serial_link.h"
31#include "led.h"
31 32
32// To generate an image array like this 33// To generate an image array like this
33// Ensure the image is 128 x 32 or smaller 34// Ensure the image is 128 x 32 or smaller
@@ -117,34 +118,11 @@ static keyframe_animation_t startup_animation = {
117 }, 118 },
118}; 119};
119 120
120// The LCD animation alternates between the layer name display and a 121static keyframe_animation_t lcd_layer_display = {
121// bitmap that displays all active layers 122 .num_frames = 1,
122static keyframe_animation_t lcd_layer_bitmap_animation = { 123 .loop = false,
123 .num_frames = 2, 124 .frame_lengths = {gfxMillisecondsToTicks(0)},
124 .loop = true, 125 .frame_functions = {keyframe_display_layer_and_led_states}
125 .frame_lengths = {
126 gfxMillisecondsToTicks(2000),
127 gfxMillisecondsToTicks(2000)
128 },
129 .frame_functions = {
130 keyframe_display_layer_text,
131 keyframe_display_layer_bitmap
132 },
133};
134
135static keyframe_animation_t lcd_layer_bitmap_leds_animation = {
136 .num_frames = 3,
137 .loop = true,
138 .frame_lengths = {
139 gfxMillisecondsToTicks(2000),
140 gfxMillisecondsToTicks(2000),
141 gfxMillisecondsToTicks(2000)
142 },
143 .frame_functions = {
144 keyframe_display_layer_text,
145 keyframe_display_led_states,
146 keyframe_display_layer_bitmap,
147 },
148}; 126};
149 127
150static keyframe_animation_t suspend_animation = { 128static keyframe_animation_t suspend_animation = {
@@ -200,49 +178,31 @@ void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard
200 // state->status.default_layer 178 // state->status.default_layer
201 // state->status.leds (see led.h for available statuses) 179 // state->status.leds (see led.h for available statuses)
202 180
181 uint8_t saturation = 60;
182 if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
183 saturation = 255;
184 }
203 if (state->status.layer & 0x4) { 185 if (state->status.layer & 0x4) {
204 state->target_lcd_color = LCD_COLOR(0, 0xB0, 0xFF); 186 state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
205 state->layer_text = "Media & Mouse"; 187 state->layer_text = "Media & Mouse";
206 } 188 }
207 else if (state->status.layer & 0x2) { 189 else if (state->status.layer & 0x2) {
208 state->target_lcd_color = LCD_COLOR(0x80, 0xB0, 0xFF); 190 state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
209 state->layer_text = "Symbol"; 191 state->layer_text = "Symbol";
210 } 192 }
211 else { 193 else {
212 state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF); 194 state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
213 state->layer_text = "Default"; 195 state->layer_text = "Default";
214 } 196 }
215 197
216 if (lcd_state == LCD_STATE_INITIAL || state->status.layer != prev_status->layer) { 198 if (lcd_state == LCD_STATE_INITIAL ||
199 state->status.layer != prev_status->layer ||
200 state->status.default_layer != prev_status->default_layer ||
201 state->status.leds != prev_status->leds) {
217 start_keyframe_animation(&color_animation); 202 start_keyframe_animation(&color_animation);
203 start_keyframe_animation(&lcd_layer_display);
218 } 204 }
219 205
220 if (state->status.leds) {
221 if (lcd_state != LCD_STATE_BITMAP_AND_LEDS ||
222 state->status.leds != prev_status->leds ||
223 state->status.layer != prev_status->layer ||
224 state->status.default_layer != prev_status->default_layer) {
225
226 // NOTE: that it doesn't matter if the animation isn't playing, stop will do nothing in that case
227 stop_keyframe_animation(&lcd_layer_bitmap_animation);
228
229 lcd_state = LCD_STATE_BITMAP_AND_LEDS;
230 // For information:
231 // The logic in this function makes sure that this doesn't happen, but if you call start on an
232 // animation that is already playing it will be restarted.
233 start_keyframe_animation(&lcd_layer_bitmap_leds_animation);
234 }
235 } else {
236 if (lcd_state != LCD_STATE_LAYER_BITMAP ||
237 state->status.layer != prev_status->layer ||
238 state->status.default_layer != prev_status->default_layer) {
239
240 stop_keyframe_animation(&lcd_layer_bitmap_leds_animation);
241
242 lcd_state = LCD_STATE_LAYER_BITMAP;
243 start_keyframe_animation(&lcd_layer_bitmap_animation);
244 }
245 }
246 // You can also stop existing animations, and start your custom ones here 206 // You can also stop existing animations, and start your custom ones here
247 // remember that you should normally have only one animation for the LCD 207 // remember that you should normally have only one animation for the LCD
248 // and one for the background. But you can also combine them if you want. 208 // and one for the background. But you can also combine them if you want.