diff options
Diffstat (limited to 'quantum/visualizer')
-rw-r--r-- | quantum/visualizer/common_gfxconf.h | 103 | ||||
-rw-r--r-- | quantum/visualizer/default_animations.c | 203 | ||||
-rw-r--r-- | quantum/visualizer/lcd_backlight.c | 50 | ||||
-rw-r--r-- | quantum/visualizer/lcd_backlight.h | 10 | ||||
-rw-r--r-- | quantum/visualizer/lcd_backlight_keyframes.c | 42 | ||||
-rw-r--r-- | quantum/visualizer/lcd_keyframes.c | 42 | ||||
-rw-r--r-- | quantum/visualizer/lcd_keyframes.h | 1 | ||||
-rw-r--r-- | quantum/visualizer/led_backlight_keyframes.c | 40 | ||||
-rw-r--r-- | quantum/visualizer/led_backlight_keyframes.h | 1 | ||||
-rw-r--r-- | quantum/visualizer/resources/lcd_logo.c | 41 | ||||
-rw-r--r-- | quantum/visualizer/resources/resources.h | 1 | ||||
-rw-r--r-- | quantum/visualizer/visualizer.c | 256 | ||||
-rw-r--r-- | quantum/visualizer/visualizer.h | 22 |
13 files changed, 364 insertions, 448 deletions
diff --git a/quantum/visualizer/common_gfxconf.h b/quantum/visualizer/common_gfxconf.h index eb705b188..865e58869 100644 --- a/quantum/visualizer/common_gfxconf.h +++ b/quantum/visualizer/common_gfxconf.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #ifndef COMMON_GFXCONF_H | 22 | #ifndef COMMON_GFXCONF_H |
23 | #define COMMON_GFXCONF_H | 23 | #define COMMON_GFXCONF_H |
24 | 24 | ||
25 | |||
26 | /////////////////////////////////////////////////////////////////////////// | 25 | /////////////////////////////////////////////////////////////////////////// |
27 | // GOS - One of these must be defined, preferably in your Makefile // | 26 | // GOS - One of these must be defined, preferably in your Makefile // |
28 | /////////////////////////////////////////////////////////////////////////// | 27 | /////////////////////////////////////////////////////////////////////////// |
@@ -41,11 +40,11 @@ | |||
41 | // #define INTERRUPTS_OFF() optional_code | 40 | // #define INTERRUPTS_OFF() optional_code |
42 | // #define INTERRUPTS_ON() optional_code | 41 | // #define INTERRUPTS_ON() optional_code |
43 | // These are not defined by default for some reason | 42 | // These are not defined by default for some reason |
44 | #define GOS_NEED_X_THREADS FALSE | 43 | #define GOS_NEED_X_THREADS FALSE |
45 | #define GOS_NEED_X_HEAP FALSE | 44 | #define GOS_NEED_X_HEAP FALSE |
46 | 45 | ||
47 | // Options that (should where relevant) apply to all operating systems | 46 | // Options that (should where relevant) apply to all operating systems |
48 | #define GFX_NO_INLINE FALSE | 47 | #define GFX_NO_INLINE FALSE |
49 | // #define GFX_COMPILER GFX_COMPILER_UNKNOWN | 48 | // #define GFX_COMPILER GFX_COMPILER_UNKNOWN |
50 | // #define GFX_CPU GFX_CPU_UNKNOWN | 49 | // #define GFX_CPU GFX_CPU_UNKNOWN |
51 | // #define GFX_OS_HEAP_SIZE 0 | 50 | // #define GFX_OS_HEAP_SIZE 0 |
@@ -55,32 +54,31 @@ | |||
55 | // #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine | 54 | // #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine |
56 | // #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine | 55 | // #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine |
57 | 56 | ||
58 | |||
59 | /////////////////////////////////////////////////////////////////////////// | 57 | /////////////////////////////////////////////////////////////////////////// |
60 | // GDISP // | 58 | // GDISP // |
61 | /////////////////////////////////////////////////////////////////////////// | 59 | /////////////////////////////////////////////////////////////////////////// |
62 | #define GFX_USE_GDISP TRUE | 60 | #define GFX_USE_GDISP TRUE |
63 | 61 | ||
64 | //#define GDISP_NEED_AUTOFLUSH FALSE | 62 | //#define GDISP_NEED_AUTOFLUSH FALSE |
65 | //#define GDISP_NEED_TIMERFLUSH FALSE | 63 | //#define GDISP_NEED_TIMERFLUSH FALSE |
66 | //#define GDISP_NEED_VALIDATION TRUE | 64 | //#define GDISP_NEED_VALIDATION TRUE |
67 | //#define GDISP_NEED_CLIP TRUE | 65 | //#define GDISP_NEED_CLIP TRUE |
68 | #define GDISP_NEED_CIRCLE TRUE | 66 | #define GDISP_NEED_CIRCLE TRUE |
69 | #define GDISP_NEED_ELLIPSE TRUE | 67 | #define GDISP_NEED_ELLIPSE TRUE |
70 | #define GDISP_NEED_ARC TRUE | 68 | #define GDISP_NEED_ARC TRUE |
71 | #define GDISP_NEED_ARCSECTORS TRUE | 69 | #define GDISP_NEED_ARCSECTORS TRUE |
72 | #define GDISP_NEED_CONVEX_POLYGON TRUE | 70 | #define GDISP_NEED_CONVEX_POLYGON TRUE |
73 | //#define GDISP_NEED_SCROLL FALSE | 71 | //#define GDISP_NEED_SCROLL FALSE |
74 | #define GDISP_NEED_PIXELREAD TRUE | 72 | #define GDISP_NEED_PIXELREAD TRUE |
75 | #define GDISP_NEED_CONTROL TRUE | 73 | #define GDISP_NEED_CONTROL TRUE |
76 | //#define GDISP_NEED_QUERY FALSE | 74 | //#define GDISP_NEED_QUERY FALSE |
77 | //#define GDISP_NEED_MULTITHREAD FALSE | 75 | //#define GDISP_NEED_MULTITHREAD FALSE |
78 | //#define GDISP_NEED_STREAMING FALSE | 76 | //#define GDISP_NEED_STREAMING FALSE |
79 | #define GDISP_NEED_TEXT TRUE | 77 | #define GDISP_NEED_TEXT TRUE |
80 | // #define GDISP_NEED_TEXT_WORDWRAP FALSE | 78 | // #define GDISP_NEED_TEXT_WORDWRAP FALSE |
81 | // #define GDISP_NEED_ANTIALIAS FALSE | 79 | // #define GDISP_NEED_ANTIALIAS FALSE |
82 | // #define GDISP_NEED_UTF8 FALSE | 80 | // #define GDISP_NEED_UTF8 FALSE |
83 | #define GDISP_NEED_TEXT_KERNING TRUE | 81 | #define GDISP_NEED_TEXT_KERNING TRUE |
84 | // #define GDISP_INCLUDE_FONT_UI1 FALSE | 82 | // #define GDISP_INCLUDE_FONT_UI1 FALSE |
85 | // #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font. | 83 | // #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font. |
86 | // #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE | 84 | // #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE |
@@ -90,10 +88,10 @@ | |||
90 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE | 88 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE |
91 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE | 89 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE |
92 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE | 90 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE |
93 | #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE | 91 | #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE |
94 | // #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE | 92 | // #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE |
95 | // #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE | 93 | // #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE |
96 | #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE | 94 | #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE |
97 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE | 95 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE |
98 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE | 96 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE |
99 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE | 97 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE |
@@ -118,50 +116,49 @@ | |||
118 | // #define GDISP_NEED_IMAGE_PNG FALSE | 116 | // #define GDISP_NEED_IMAGE_PNG FALSE |
119 | // #define GDISP_NEED_IMAGE_ACCOUNTING FALSE | 117 | // #define GDISP_NEED_IMAGE_ACCOUNTING FALSE |
120 | #ifdef EMULATOR | 118 | #ifdef EMULATOR |
121 | #define GDISP_NEED_PIXMAP TRUE | 119 | # define GDISP_NEED_PIXMAP TRUE |
122 | #endif | 120 | #endif |
123 | // #define GDISP_NEED_PIXMAP_IMAGE FALSE | 121 | // #define GDISP_NEED_PIXMAP_IMAGE FALSE |
124 | 122 | ||
125 | //#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used. | 123 | //#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used. |
126 | //#define GDISP_LINEBUF_SIZE 128 | 124 | //#define GDISP_LINEBUF_SIZE 128 |
127 | //#define GDISP_STARTUP_COLOR Black | 125 | //#define GDISP_STARTUP_COLOR Black |
128 | #define GDISP_NEED_STARTUP_LOGO FALSE | 126 | #define GDISP_NEED_STARTUP_LOGO FALSE |
129 | 127 | ||
130 | //#define GDISP_TOTAL_DISPLAYS 2 | 128 | //#define GDISP_TOTAL_DISPLAYS 2 |
131 | 129 | ||
132 | #ifdef GDISP_DRIVER_LIST | 130 | #ifdef GDISP_DRIVER_LIST |
133 | // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability | 131 | // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability |
134 | #define GDISP_HARDWARE_STREAM_WRITE FALSE | 132 | # define GDISP_HARDWARE_STREAM_WRITE FALSE |
135 | #define GDISP_HARDWARE_STREAM_READ FALSE | 133 | # define GDISP_HARDWARE_STREAM_READ FALSE |
136 | #define GDISP_HARDWARE_STREAM_POS FALSE | 134 | # define GDISP_HARDWARE_STREAM_POS FALSE |
137 | #define GDISP_HARDWARE_DRAWPIXEL TRUE | 135 | # define GDISP_HARDWARE_DRAWPIXEL TRUE |
138 | #define GDISP_HARDWARE_CLEARS FALSE | 136 | # define GDISP_HARDWARE_CLEARS FALSE |
139 | #define GDISP_HARDWARE_FILLS FALSE | 137 | # define GDISP_HARDWARE_FILLS FALSE |
140 | //#define GDISP_HARDWARE_BITFILLS FALSE | 138 | //#define GDISP_HARDWARE_BITFILLS FALSE |
141 | #define GDISP_HARDWARE_SCROLL FALSE | 139 | # define GDISP_HARDWARE_SCROLL FALSE |
142 | #define GDISP_HARDWARE_PIXELREAD TRUE | 140 | # define GDISP_HARDWARE_PIXELREAD TRUE |
143 | #define GDISP_HARDWARE_CONTROL TRUE | 141 | # define GDISP_HARDWARE_CONTROL TRUE |
144 | #define GDISP_HARDWARE_QUERY FALSE | 142 | # define GDISP_HARDWARE_QUERY FALSE |
145 | #define GDISP_HARDWARE_CLIP FALSE | 143 | # define GDISP_HARDWARE_CLIP FALSE |
146 | 144 | ||
147 | #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 | 145 | # define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 |
148 | #endif | 146 | #endif |
149 | 147 | ||
150 | // The custom format is not defined for some reason, so define it as error | 148 | // The custom format is not defined for some reason, so define it as error |
151 | // so we don't get compiler warnings | 149 | // so we don't get compiler warnings |
152 | #define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR | 150 | #define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR |
153 | 151 | ||
154 | #define GDISP_USE_GFXNET FALSE | 152 | #define GDISP_USE_GFXNET FALSE |
155 | // #define GDISP_GFXNET_PORT 13001 | 153 | // #define GDISP_GFXNET_PORT 13001 |
156 | // #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE | 154 | // #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE |
157 | // #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE | 155 | // #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE |
158 | // #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE | 156 | // #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE |
159 | 157 | ||
160 | |||
161 | /////////////////////////////////////////////////////////////////////////// | 158 | /////////////////////////////////////////////////////////////////////////// |
162 | // GWIN // | 159 | // GWIN // |
163 | /////////////////////////////////////////////////////////////////////////// | 160 | /////////////////////////////////////////////////////////////////////////// |
164 | #define GFX_USE_GWIN FALSE | 161 | #define GFX_USE_GWIN FALSE |
165 | 162 | ||
166 | //#define GWIN_NEED_WINDOWMANAGER FALSE | 163 | //#define GWIN_NEED_WINDOWMANAGER FALSE |
167 | // #define GWIN_REDRAW_IMMEDIATE FALSE | 164 | // #define GWIN_REDRAW_IMMEDIATE FALSE |
@@ -210,30 +207,27 @@ | |||
210 | // #define GWIN_NEED_TABSET FALSE | 207 | // #define GWIN_NEED_TABSET FALSE |
211 | // #define GWIN_TABSET_TABHEIGHT 18 | 208 | // #define GWIN_TABSET_TABHEIGHT 18 |
212 | 209 | ||
213 | |||
214 | /////////////////////////////////////////////////////////////////////////// | 210 | /////////////////////////////////////////////////////////////////////////// |
215 | // GEVENT // | 211 | // GEVENT // |
216 | /////////////////////////////////////////////////////////////////////////// | 212 | /////////////////////////////////////////////////////////////////////////// |
217 | #define GFX_USE_GEVENT TRUE | 213 | #define GFX_USE_GEVENT TRUE |
218 | 214 | ||
219 | //#define GEVENT_ASSERT_NO_RESOURCE FALSE | 215 | //#define GEVENT_ASSERT_NO_RESOURCE FALSE |
220 | //#define GEVENT_MAXIMUM_SIZE 32 | 216 | //#define GEVENT_MAXIMUM_SIZE 32 |
221 | //#define GEVENT_MAX_SOURCE_LISTENERS 32 | 217 | //#define GEVENT_MAX_SOURCE_LISTENERS 32 |
222 | 218 | ||
223 | |||
224 | /////////////////////////////////////////////////////////////////////////// | 219 | /////////////////////////////////////////////////////////////////////////// |
225 | // GTIMER // | 220 | // GTIMER // |
226 | /////////////////////////////////////////////////////////////////////////// | 221 | /////////////////////////////////////////////////////////////////////////// |
227 | #define GFX_USE_GTIMER FALSE | 222 | #define GFX_USE_GTIMER FALSE |
228 | 223 | ||
229 | //#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY | 224 | //#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY |
230 | //#define GTIMER_THREAD_WORKAREA_SIZE 2048 | 225 | //#define GTIMER_THREAD_WORKAREA_SIZE 2048 |
231 | 226 | ||
232 | |||
233 | /////////////////////////////////////////////////////////////////////////// | 227 | /////////////////////////////////////////////////////////////////////////// |
234 | // GQUEUE // | 228 | // GQUEUE // |
235 | /////////////////////////////////////////////////////////////////////////// | 229 | /////////////////////////////////////////////////////////////////////////// |
236 | #define GFX_USE_GQUEUE FALSE | 230 | #define GFX_USE_GQUEUE FALSE |
237 | 231 | ||
238 | //#define GQUEUE_NEED_ASYNC FALSE | 232 | //#define GQUEUE_NEED_ASYNC FALSE |
239 | //#define GQUEUE_NEED_GSYNC FALSE | 233 | //#define GQUEUE_NEED_GSYNC FALSE |
@@ -243,7 +237,7 @@ | |||
243 | /////////////////////////////////////////////////////////////////////////// | 237 | /////////////////////////////////////////////////////////////////////////// |
244 | // GINPUT // | 238 | // GINPUT // |
245 | /////////////////////////////////////////////////////////////////////////// | 239 | /////////////////////////////////////////////////////////////////////////// |
246 | #define GFX_USE_GINPUT FALSE | 240 | #define GFX_USE_GINPUT FALSE |
247 | 241 | ||
248 | //#define GINPUT_NEED_MOUSE FALSE | 242 | //#define GINPUT_NEED_MOUSE FALSE |
249 | // #define GINPUT_TOUCH_STARTRAW FALSE | 243 | // #define GINPUT_TOUCH_STARTRAW FALSE |
@@ -264,11 +258,10 @@ | |||
264 | //#define GINPUT_NEED_TOGGLE FALSE | 258 | //#define GINPUT_NEED_TOGGLE FALSE |
265 | //#define GINPUT_NEED_DIAL FALSE | 259 | //#define GINPUT_NEED_DIAL FALSE |
266 | 260 | ||
267 | |||
268 | /////////////////////////////////////////////////////////////////////////// | 261 | /////////////////////////////////////////////////////////////////////////// |
269 | // GFILE // | 262 | // GFILE // |
270 | /////////////////////////////////////////////////////////////////////////// | 263 | /////////////////////////////////////////////////////////////////////////// |
271 | #define GFX_USE_GFILE FALSE | 264 | #define GFX_USE_GFILE FALSE |
272 | 265 | ||
273 | //#define GFILE_NEED_PRINTG FALSE | 266 | //#define GFILE_NEED_PRINTG FALSE |
274 | //#define GFILE_NEED_SCANG FALSE | 267 | //#define GFILE_NEED_SCANG FALSE |
@@ -292,26 +285,24 @@ | |||
292 | /////////////////////////////////////////////////////////////////////////// | 285 | /////////////////////////////////////////////////////////////////////////// |
293 | // GADC // | 286 | // GADC // |
294 | /////////////////////////////////////////////////////////////////////////// | 287 | /////////////////////////////////////////////////////////////////////////// |
295 | #define GFX_USE_GADC FALSE | 288 | #define GFX_USE_GADC FALSE |
296 | 289 | ||
297 | //#define GADC_MAX_LOWSPEED_DEVICES 4 | 290 | //#define GADC_MAX_LOWSPEED_DEVICES 4 |
298 | 291 | ||
299 | |||
300 | /////////////////////////////////////////////////////////////////////////// | 292 | /////////////////////////////////////////////////////////////////////////// |
301 | // GAUDIO // | 293 | // GAUDIO // |
302 | /////////////////////////////////////////////////////////////////////////// | 294 | /////////////////////////////////////////////////////////////////////////// |
303 | #define GFX_USE_GAUDIO FALSE | 295 | #define GFX_USE_GAUDIO FALSE |
304 | // There seems to be a bug in the ugfx code, the wrong define is used | 296 | // There seems to be a bug in the ugfx code, the wrong define is used |
305 | // So define it in order to avoid warnings | 297 | // So define it in order to avoid warnings |
306 | #define GFX_USE_GAUDIN GFX_USE_GAUDIO | 298 | #define GFX_USE_GAUDIN GFX_USE_GAUDIO |
307 | // #define GAUDIO_NEED_PLAY FALSE | 299 | // #define GAUDIO_NEED_PLAY FALSE |
308 | // #define GAUDIO_NEED_RECORD FALSE | 300 | // #define GAUDIO_NEED_RECORD FALSE |
309 | 301 | ||
310 | |||
311 | /////////////////////////////////////////////////////////////////////////// | 302 | /////////////////////////////////////////////////////////////////////////// |
312 | // GMISC // | 303 | // GMISC // |
313 | /////////////////////////////////////////////////////////////////////////// | 304 | /////////////////////////////////////////////////////////////////////////// |
314 | #define GFX_USE_GMISC TRUE | 305 | #define GFX_USE_GMISC TRUE |
315 | 306 | ||
316 | //#define GMISC_NEED_ARRAYOPS FALSE | 307 | //#define GMISC_NEED_ARRAYOPS FALSE |
317 | //#define GMISC_NEED_FASTTRIG FALSE | 308 | //#define GMISC_NEED_FASTTRIG FALSE |
@@ -319,7 +310,7 @@ | |||
319 | //#define GMISC_NEED_INVSQRT FALSE | 310 | //#define GMISC_NEED_INVSQRT FALSE |
320 | // #define GMISC_INVSQRT_MIXED_ENDIAN FALSE | 311 | // #define GMISC_INVSQRT_MIXED_ENDIAN FALSE |
321 | // #define GMISC_INVSQRT_REAL_SLOW FALSE | 312 | // #define GMISC_INVSQRT_REAL_SLOW FALSE |
322 | #define GMISC_NEED_MATRIXFLOAT2D TRUE | 313 | #define GMISC_NEED_MATRIXFLOAT2D TRUE |
323 | #define GMISC_NEED_MATRIXFIXED2D FALSE | 314 | #define GMISC_NEED_MATRIXFIXED2D FALSE |
324 | 315 | ||
325 | #endif /* COMMON_GFXCONF_H */ | 316 | #endif /* COMMON_GFXCONF_H */ |
diff --git a/quantum/visualizer/default_animations.c b/quantum/visualizer/default_animations.c index 2d0327372..2f43c67cc 100644 --- a/quantum/visualizer/default_animations.c +++ b/quantum/visualizer/default_animations.c | |||
@@ -16,161 +16,162 @@ | |||
16 | 16 | ||
17 | #if defined(VISUALIZER_ENABLE) | 17 | #if defined(VISUALIZER_ENABLE) |
18 | 18 | ||
19 | #include "default_animations.h" | 19 | # include "default_animations.h" |
20 | #include "visualizer.h" | 20 | # include "visualizer.h" |
21 | #ifdef LCD_ENABLE | 21 | # ifdef LCD_ENABLE |
22 | #include "lcd_keyframes.h" | 22 | # include "lcd_keyframes.h" |
23 | #endif | 23 | # endif |
24 | #ifdef LCD_BACKLIGHT_ENABLE | 24 | # ifdef LCD_BACKLIGHT_ENABLE |
25 | #include "lcd_backlight_keyframes.h" | 25 | # include "lcd_backlight_keyframes.h" |
26 | #endif | 26 | # endif |
27 | |||
28 | #ifdef BACKLIGHT_ENABLE | ||
29 | #include "led_backlight_keyframes.h" | ||
30 | #endif | ||
31 | 27 | ||
32 | #include "visualizer_keyframes.h" | 28 | # ifdef BACKLIGHT_ENABLE |
29 | # include "led_backlight_keyframes.h" | ||
30 | # endif | ||
33 | 31 | ||
32 | # include "visualizer_keyframes.h" | ||
34 | 33 | ||
35 | #if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) | 34 | # if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) |
36 | 35 | ||
37 | static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | 36 | static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { |
38 | #ifdef LCD_ENABLE | 37 | # ifdef LCD_ENABLE |
39 | lcd_keyframe_enable(animation, state); | 38 | lcd_keyframe_enable(animation, state); |
40 | #endif | 39 | # endif |
41 | #ifdef LCD_BACKLIGHT_ENABLE | 40 | # ifdef LCD_BACKLIGHT_ENABLE |
42 | lcd_backlight_keyframe_enable(animation, state); | 41 | lcd_backlight_keyframe_enable(animation, state); |
43 | #endif | 42 | # endif |
44 | #ifdef BACKLIGHT_ENABLE | 43 | # ifdef BACKLIGHT_ENABLE |
45 | led_backlight_keyframe_enable(animation, state); | 44 | led_backlight_keyframe_enable(animation, state); |
46 | #endif | 45 | # endif |
47 | return false; | 46 | return false; |
48 | } | 47 | } |
49 | 48 | ||
50 | static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | 49 | static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { |
51 | #ifdef LCD_ENABLE | 50 | # ifdef LCD_ENABLE |
52 | lcd_keyframe_disable(animation, state); | 51 | lcd_keyframe_disable(animation, state); |
53 | #endif | 52 | # endif |
54 | #ifdef LCD_BACKLIGHT_ENABLE | 53 | # ifdef LCD_BACKLIGHT_ENABLE |
55 | lcd_backlight_keyframe_disable(animation, state); | 54 | lcd_backlight_keyframe_disable(animation, state); |
56 | #endif | 55 | # endif |
57 | #ifdef BACKLIGHT_ENABLE | 56 | # ifdef BACKLIGHT_ENABLE |
58 | led_backlight_keyframe_disable(animation, state); | 57 | led_backlight_keyframe_disable(animation, state); |
59 | #endif | 58 | # endif |
60 | return false; | 59 | return false; |
61 | } | 60 | } |
62 | 61 | ||
63 | static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { | 62 | static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { |
64 | bool ret = false; | 63 | bool ret = false; |
65 | #ifdef LCD_BACKLIGHT_ENABLE | 64 | # ifdef LCD_BACKLIGHT_ENABLE |
66 | ret |= lcd_backlight_keyframe_animate_color(animation, state); | 65 | ret |= lcd_backlight_keyframe_animate_color(animation, state); |
67 | #endif | 66 | # endif |
68 | #ifdef BACKLIGHT_ENABLE | 67 | # ifdef BACKLIGHT_ENABLE |
69 | ret |= led_backlight_keyframe_fade_in_all(animation, state); | 68 | ret |= led_backlight_keyframe_fade_in_all(animation, state); |
70 | #endif | 69 | # endif |
71 | return ret; | 70 | return ret; |
72 | } | 71 | } |
73 | 72 | ||
74 | static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { | 73 | static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { |
75 | bool ret = false; | 74 | bool ret = false; |
76 | #ifdef LCD_BACKLIGHT_ENABLE | 75 | # ifdef LCD_BACKLIGHT_ENABLE |
77 | ret |= lcd_backlight_keyframe_animate_color(animation, state); | 76 | ret |= lcd_backlight_keyframe_animate_color(animation, state); |
78 | #endif | 77 | # endif |
79 | #ifdef BACKLIGHT_ENABLE | 78 | # ifdef BACKLIGHT_ENABLE |
80 | ret |= led_backlight_keyframe_fade_out_all(animation, state); | 79 | ret |= led_backlight_keyframe_fade_out_all(animation, state); |
81 | #endif | 80 | # endif |
82 | return ret; | 81 | return ret; |
83 | } | 82 | } |
84 | 83 | ||
85 | |||
86 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | 84 | // Don't worry, if the startup animation is long, you can use the keyboard like normal |
87 | // during that time | 85 | // during that time |
88 | keyframe_animation_t default_startup_animation = { | 86 | keyframe_animation_t default_startup_animation = { |
89 | #if LCD_ENABLE | 87 | # if LCD_ENABLE |
90 | .num_frames = 3, | 88 | .num_frames = 3, |
91 | #else | 89 | # else |
92 | .num_frames = 2, | 90 | .num_frames = 2, |
93 | #endif | 91 | # endif |
94 | .loop = false, | 92 | .loop = false, |
95 | .frame_lengths = { | 93 | .frame_lengths = {0, |
96 | 0, | 94 | # if LCD_ENABLE |
97 | #if LCD_ENABLE | 95 | 0, |
98 | 0, | 96 | # endif |
99 | #endif | 97 | gfxMillisecondsToTicks(5000)}, |
100 | gfxMillisecondsToTicks(5000)}, | 98 | .frame_functions = |
101 | .frame_functions = { | 99 | { |
102 | keyframe_enable, | 100 | keyframe_enable, |
103 | #if LCD_ENABLE | 101 | # if LCD_ENABLE |
104 | lcd_keyframe_draw_logo, | 102 | lcd_keyframe_draw_logo, |
105 | #endif | 103 | # endif |
106 | keyframe_fade_in, | 104 | keyframe_fade_in, |
107 | }, | 105 | }, |
108 | }; | 106 | }; |
109 | 107 | ||
110 | keyframe_animation_t default_suspend_animation = { | 108 | keyframe_animation_t default_suspend_animation = { |
111 | #if LCD_ENABLE | 109 | # if LCD_ENABLE |
112 | .num_frames = 3, | 110 | .num_frames = 3, |
113 | #else | 111 | # else |
114 | .num_frames = 2, | 112 | .num_frames = 2, |
115 | #endif | 113 | # endif |
116 | .loop = false, | 114 | .loop = false, |
117 | .frame_lengths = { | 115 | .frame_lengths = |
118 | #if LCD_ENABLE | 116 | { |
119 | 0, | 117 | # if LCD_ENABLE |
120 | #endif | 118 | 0, |
121 | gfxMillisecondsToTicks(1000), | 119 | # endif |
122 | 0}, | 120 | gfxMillisecondsToTicks(1000), 0}, |
123 | .frame_functions = { | 121 | .frame_functions = |
124 | #if LCD_ENABLE | 122 | { |
123 | # if LCD_ENABLE | ||
125 | lcd_keyframe_display_layer_text, | 124 | lcd_keyframe_display_layer_text, |
126 | #endif | 125 | # endif |
127 | keyframe_fade_out, | 126 | keyframe_fade_out, |
128 | keyframe_disable, | 127 | keyframe_disable, |
129 | }, | 128 | }, |
130 | }; | 129 | }; |
131 | #endif | 130 | # endif |
132 | 131 | ||
133 | #if defined(BACKLIGHT_ENABLE) | 132 | # if defined(BACKLIGHT_ENABLE) |
134 | #define CROSSFADE_TIME 1000 | 133 | # define CROSSFADE_TIME 1000 |
135 | #define GRADIENT_TIME 3000 | 134 | # define GRADIENT_TIME 3000 |
136 | 135 | ||
137 | keyframe_animation_t led_test_animation = { | 136 | keyframe_animation_t led_test_animation = { |
138 | .num_frames = 14, | 137 | .num_frames = 14, |
139 | .loop = true, | 138 | .loop = true, |
140 | .frame_lengths = { | 139 | .frame_lengths = |
141 | gfxMillisecondsToTicks(1000), // fade in | 140 | { |
142 | gfxMillisecondsToTicks(1000), // no op (leds on) | 141 | gfxMillisecondsToTicks(1000), // fade in |
143 | gfxMillisecondsToTicks(1000), // fade out | 142 | gfxMillisecondsToTicks(1000), // no op (leds on) |
144 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | 143 | gfxMillisecondsToTicks(1000), // fade out |
145 | gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) | 144 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade |
146 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | 145 | gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in) |
147 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | 146 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade |
148 | 0, // mirror leds | 147 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom |
149 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | 148 | 0, // mirror leds |
150 | gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) | 149 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade |
151 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | 150 | gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out) |
152 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom | 151 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade |
153 | 0, // normal leds | 152 | gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom |
154 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | 153 | 0, // normal leds |
155 | 154 | gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade | |
156 | }, | 155 | |
157 | .frame_functions = { | 156 | }, |
158 | led_backlight_keyframe_fade_in_all, | 157 | .frame_functions = |
159 | keyframe_no_operation, | 158 | { |
160 | led_backlight_keyframe_fade_out_all, | 159 | led_backlight_keyframe_fade_in_all, |
161 | led_backlight_keyframe_crossfade, | 160 | keyframe_no_operation, |
162 | led_backlight_keyframe_left_to_right_gradient, | 161 | led_backlight_keyframe_fade_out_all, |
163 | led_backlight_keyframe_crossfade, | 162 | led_backlight_keyframe_crossfade, |
164 | led_backlight_keyframe_top_to_bottom_gradient, | 163 | led_backlight_keyframe_left_to_right_gradient, |
165 | led_backlight_keyframe_mirror_orientation, | 164 | led_backlight_keyframe_crossfade, |
166 | led_backlight_keyframe_crossfade, | 165 | led_backlight_keyframe_top_to_bottom_gradient, |
167 | led_backlight_keyframe_left_to_right_gradient, | 166 | led_backlight_keyframe_mirror_orientation, |
168 | led_backlight_keyframe_crossfade, | 167 | led_backlight_keyframe_crossfade, |
169 | led_backlight_keyframe_top_to_bottom_gradient, | 168 | led_backlight_keyframe_left_to_right_gradient, |
170 | led_backlight_keyframe_normal_orientation, | 169 | led_backlight_keyframe_crossfade, |
171 | led_backlight_keyframe_crossfade, | 170 | led_backlight_keyframe_top_to_bottom_gradient, |
172 | }, | 171 | led_backlight_keyframe_normal_orientation, |
172 | led_backlight_keyframe_crossfade, | ||
173 | }, | ||
173 | }; | 174 | }; |
174 | #endif | 175 | # endif |
175 | 176 | ||
176 | #endif | 177 | #endif |
diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c index 6cd996f75..23978974e 100644 --- a/quantum/visualizer/lcd_backlight.c +++ b/quantum/visualizer/lcd_backlight.c | |||
@@ -25,9 +25,9 @@ SOFTWARE. | |||
25 | #include "lcd_backlight.h" | 25 | #include "lcd_backlight.h" |
26 | #include <math.h> | 26 | #include <math.h> |
27 | 27 | ||
28 | static uint8_t current_hue = 0; | 28 | static uint8_t current_hue = 0; |
29 | static uint8_t current_saturation = 0; | 29 | static uint8_t current_saturation = 0; |
30 | static uint8_t current_intensity = 0; | 30 | static uint8_t current_intensity = 0; |
31 | static uint8_t current_brightness = 0; | 31 | static uint8_t current_brightness = 0; |
32 | 32 | ||
33 | void lcd_backlight_init(void) { | 33 | void lcd_backlight_init(void) { |
@@ -40,26 +40,26 @@ void lcd_backlight_init(void) { | |||
40 | // http://blog.saikoled.com/post/43693602826/why-every-led-light-should-be-using-hsi | 40 | // http://blog.saikoled.com/post/43693602826/why-every-led-light-should-be-using-hsi |
41 | static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_out, uint16_t* b_out) { | 41 | static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_out, uint16_t* b_out) { |
42 | unsigned int r, g, b; | 42 | unsigned int r, g, b; |
43 | h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees | 43 | h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees |
44 | h = 3.14159f * h / 180.0f; // Convert to radians. | 44 | h = 3.14159f * h / 180.0f; // Convert to radians. |
45 | s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1] | 45 | s = s > 0.0f ? (s < 1.0f ? s : 1.0f) : 0.0f; // clamp s and i to interval [0,1] |
46 | i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f; | 46 | i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f; |
47 | 47 | ||
48 | // Math! Thanks in part to Kyle Miller. | 48 | // Math! Thanks in part to Kyle Miller. |
49 | if(h < 2.09439f) { | 49 | if (h < 2.09439f) { |
50 | r = 65535.0f * i/3.0f *(1.0f + s * cos(h) / cosf(1.047196667f - h)); | 50 | r = 65535.0f * i / 3.0f * (1.0f + s * cos(h) / cosf(1.047196667f - h)); |
51 | g = 65535.0f * i/3.0f *(1.0f + s *(1.0f - cosf(h) / cos(1.047196667f - h))); | 51 | g = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cos(1.047196667f - h))); |
52 | b = 65535.0f * i/3.0f *(1.0f - s); | 52 | b = 65535.0f * i / 3.0f * (1.0f - s); |
53 | } else if(h < 4.188787) { | 53 | } else if (h < 4.188787) { |
54 | h = h - 2.09439; | 54 | h = h - 2.09439; |
55 | g = 65535.0f * i/3.0f *(1.0f + s * cosf(h) / cosf(1.047196667f - h)); | 55 | g = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); |
56 | b = 65535.0f * i/3.0f *(1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); | 56 | b = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); |
57 | r = 65535.0f * i/3.0f *(1.0f - s); | 57 | r = 65535.0f * i / 3.0f * (1.0f - s); |
58 | } else { | 58 | } else { |
59 | h = h - 4.188787; | 59 | h = h - 4.188787; |
60 | b = 65535.0f*i/3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); | 60 | b = 65535.0f * i / 3.0f * (1.0f + s * cosf(h) / cosf(1.047196667f - h)); |
61 | r = 65535.0f*i/3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); | 61 | r = 65535.0f * i / 3.0f * (1.0f + s * (1.0f - cosf(h) / cosf(1.047196667f - h))); |
62 | g = 65535.0f*i/3.0f * (1.0f - s); | 62 | g = 65535.0f * i / 3.0f * (1.0f - s); |
63 | } | 63 | } |
64 | *r_out = r > 65535 ? 65535 : r; | 64 | *r_out = r > 65535 ? 65535 : r; |
65 | *g_out = g > 65535 ? 65535 : g; | 65 | *g_out = g > 65535 ? 65535 : g; |
@@ -68,15 +68,15 @@ static void hsi_to_rgb(float h, float s, float i, uint16_t* r_out, uint16_t* g_o | |||
68 | 68 | ||
69 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) { | 69 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) { |
70 | uint16_t r, g, b; | 70 | uint16_t r, g, b; |
71 | float hue_f = 360.0f * (float)hue / 255.0f; | 71 | float hue_f = 360.0f * (float)hue / 255.0f; |
72 | float saturation_f = (float)saturation / 255.0f; | 72 | float saturation_f = (float)saturation / 255.0f; |
73 | float intensity_f = (float)intensity / 255.0f; | 73 | float intensity_f = (float)intensity / 255.0f; |
74 | intensity_f *= (float)current_brightness / 255.0f; | 74 | intensity_f *= (float)current_brightness / 255.0f; |
75 | hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b); | 75 | hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b); |
76 | current_hue = hue; | 76 | current_hue = hue; |
77 | current_saturation = saturation; | 77 | current_saturation = saturation; |
78 | current_intensity = intensity; | 78 | current_intensity = intensity; |
79 | lcd_backlight_hal_color(r, g, b); | 79 | lcd_backlight_hal_color(r, g, b); |
80 | } | 80 | } |
81 | 81 | ||
82 | void lcd_backlight_brightness(uint8_t b) { | 82 | void lcd_backlight_brightness(uint8_t b) { |
@@ -84,6 +84,4 @@ void lcd_backlight_brightness(uint8_t b) { | |||
84 | lcd_backlight_color(current_hue, current_saturation, current_intensity); | 84 | lcd_backlight_color(current_hue, current_saturation, current_intensity); |
85 | } | 85 | } |
86 | 86 | ||
87 | uint8_t lcd_get_backlight_brightness(void) { | 87 | uint8_t lcd_get_backlight_brightness(void) { return current_brightness; } |
88 | return current_brightness; | ||
89 | } | ||
diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h index 95d7a07b4..7b0b6a9fd 100644 --- a/quantum/visualizer/lcd_backlight.h +++ b/quantum/visualizer/lcd_backlight.h | |||
@@ -32,13 +32,11 @@ SOFTWARE. | |||
32 | #define LCD_SAT(color) ((color >> 8) & 0xFF) | 32 | #define LCD_SAT(color) ((color >> 8) & 0xFF) |
33 | #define LCD_INT(color) (color & 0xFF) | 33 | #define LCD_INT(color) (color & 0xFF) |
34 | 34 | ||
35 | static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { | 35 | static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { return (color & 0xFFFFFF00) | new_intensity; } |
36 | return (color & 0xFFFFFF00) | new_intensity; | ||
37 | } | ||
38 | 36 | ||
39 | void lcd_backlight_init(void); | 37 | void lcd_backlight_init(void); |
40 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity); | 38 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity); |
41 | void lcd_backlight_brightness(uint8_t b); | 39 | void lcd_backlight_brightness(uint8_t b); |
42 | uint8_t lcd_get_backlight_brightness(void); | 40 | uint8_t lcd_get_backlight_brightness(void); |
43 | 41 | ||
44 | void lcd_backlight_hal_init(void); | 42 | void lcd_backlight_hal_init(void); |
diff --git a/quantum/visualizer/lcd_backlight_keyframes.c b/quantum/visualizer/lcd_backlight_keyframes.c index 8c402baf6..c13cce311 100644 --- a/quantum/visualizer/lcd_backlight_keyframes.c +++ b/quantum/visualizer/lcd_backlight_keyframes.c | |||
@@ -17,46 +17,40 @@ | |||
17 | #include "lcd_backlight_keyframes.h" | 17 | #include "lcd_backlight_keyframes.h" |
18 | 18 | ||
19 | bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) { | 19 | bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) { |
20 | int frame_length = animation->frame_lengths[animation->current_frame]; | 20 | int frame_length = animation->frame_lengths[animation->current_frame]; |
21 | int current_pos = frame_length - animation->time_left_in_frame; | 21 | int current_pos = frame_length - animation->time_left_in_frame; |
22 | uint8_t t_h = LCD_HUE(state->target_lcd_color); | 22 | uint8_t t_h = LCD_HUE(state->target_lcd_color); |
23 | uint8_t t_s = LCD_SAT(state->target_lcd_color); | 23 | uint8_t t_s = LCD_SAT(state->target_lcd_color); |
24 | uint8_t t_i = LCD_INT(state->target_lcd_color); | 24 | uint8_t t_i = LCD_INT(state->target_lcd_color); |
25 | uint8_t p_h = LCD_HUE(state->prev_lcd_color); | 25 | uint8_t p_h = LCD_HUE(state->prev_lcd_color); |
26 | uint8_t p_s = LCD_SAT(state->prev_lcd_color); | 26 | uint8_t p_s = LCD_SAT(state->prev_lcd_color); |
27 | uint8_t p_i = LCD_INT(state->prev_lcd_color); | 27 | uint8_t p_i = LCD_INT(state->prev_lcd_color); |
28 | 28 | ||
29 | uint8_t d_h1 = t_h - p_h; //Modulo arithmetic since we want to wrap around | 29 | uint8_t d_h1 = t_h - p_h; // Modulo arithmetic since we want to wrap around |
30 | int d_h2 = t_h - p_h; | 30 | int d_h2 = t_h - p_h; |
31 | // Chose the shortest way around | 31 | // Chose the shortest way around |
32 | int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1; | 32 | int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1; |
33 | int d_s = t_s - p_s; | 33 | int d_s = t_s - p_s; |
34 | int d_i = t_i - p_i; | 34 | int d_i = t_i - p_i; |
35 | 35 | ||
36 | int hue = (d_h * current_pos) / frame_length; | 36 | int hue = (d_h * current_pos) / frame_length; |
37 | int sat = (d_s * current_pos) / frame_length; | 37 | int sat = (d_s * current_pos) / frame_length; |
38 | int intensity = (d_i * current_pos) / frame_length; | 38 | int intensity = (d_i * current_pos) / frame_length; |
39 | //dprintf("%X -> %X = %X\n", p_h, t_h, hue); | 39 | // dprintf("%X -> %X = %X\n", p_h, t_h, hue); |
40 | hue += p_h; | 40 | hue += p_h; |
41 | sat += p_s; | 41 | sat += p_s; |
42 | intensity += p_i; | 42 | intensity += p_i; |
43 | state->current_lcd_color = LCD_COLOR(hue, sat, intensity); | 43 | state->current_lcd_color = LCD_COLOR(hue, sat, intensity); |
44 | lcd_backlight_color( | 44 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); |
45 | LCD_HUE(state->current_lcd_color), | ||
46 | LCD_SAT(state->current_lcd_color), | ||
47 | LCD_INT(state->current_lcd_color)); | ||
48 | 45 | ||
49 | return true; | 46 | return true; |
50 | } | 47 | } |
51 | 48 | ||
52 | bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { | 49 | bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { |
53 | (void)animation; | 50 | (void)animation; |
54 | state->prev_lcd_color = state->target_lcd_color; | 51 | state->prev_lcd_color = state->target_lcd_color; |
55 | state->current_lcd_color = state->target_lcd_color; | 52 | state->current_lcd_color = state->target_lcd_color; |
56 | lcd_backlight_color( | 53 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); |
57 | LCD_HUE(state->current_lcd_color), | ||
58 | LCD_SAT(state->current_lcd_color), | ||
59 | LCD_INT(state->current_lcd_color)); | ||
60 | return false; | 54 | return false; |
61 | } | 55 | } |
62 | 56 | ||
@@ -70,8 +64,6 @@ bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_ | |||
70 | bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | 64 | bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { |
71 | (void)animation; | 65 | (void)animation; |
72 | (void)state; | 66 | (void)state; |
73 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), | 67 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); |
74 | LCD_SAT(state->current_lcd_color), | ||
75 | LCD_INT(state->current_lcd_color)); | ||
76 | return false; | 68 | return false; |
77 | } | 69 | } |
diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c index 75eb45700..c7d9841df 100644 --- a/quantum/visualizer/lcd_keyframes.c +++ b/quantum/visualizer/lcd_keyframes.c | |||
@@ -28,8 +28,7 @@ bool lcd_keyframe_display_layer_text(keyframe_animation_t* animation, visualizer | |||
28 | } | 28 | } |
29 | 29 | ||
30 | static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) { | 30 | static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) { |
31 | for (int i=0; i<16;i++) | 31 | for (int i = 0; i < 16; i++) { |
32 | { | ||
33 | uint32_t mask = (1u << i); | 32 | uint32_t mask = (1u << i); |
34 | if (default_layer & mask) { | 33 | if (default_layer & mask) { |
35 | if (layer & mask) { | 34 | if (layer & mask) { |
@@ -44,7 +43,7 @@ static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, c | |||
44 | } | 43 | } |
45 | ++buffer; | 44 | ++buffer; |
46 | 45 | ||
47 | if (i==3 || i==7 || i==11) { | 46 | if (i == 3 || i == 7 || i == 11) { |
48 | *buffer = ' '; | 47 | *buffer = ' '; |
49 | ++buffer; | 48 | ++buffer; |
50 | } | 49 | } |
@@ -55,7 +54,7 @@ static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, c | |||
55 | bool lcd_keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { | 54 | bool lcd_keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { |
56 | (void)animation; | 55 | (void)animation; |
57 | const char* layer_help = "1=On D=Default B=Both"; | 56 | const char* layer_help = "1=On D=Default B=Both"; |
58 | char layer_buffer[16 + 4]; // 3 spaces and one null terminator | 57 | char layer_buffer[16 + 4]; // 3 spaces and one null terminator |
59 | gdispClear(White); | 58 | gdispClear(White); |
60 | gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black); | 59 | gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black); |
61 | format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer); | 60 | format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer); |
@@ -69,8 +68,7 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) { | |||
69 | *buffer = ' '; | 68 | *buffer = ' '; |
70 | ++buffer; | 69 | ++buffer; |
71 | 70 | ||
72 | for (int i = 0; i<8; i++) | 71 | for (int i = 0; i < 8; i++) { |
73 | { | ||
74 | uint32_t mask = (1u << i); | 72 | uint32_t mask = (1u << i); |
75 | if (mods & mask) { | 73 | if (mods & mask) { |
76 | *buffer = '1'; | 74 | *buffer = '1'; |
@@ -79,7 +77,7 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) { | |||
79 | } | 77 | } |
80 | ++buffer; | 78 | ++buffer; |
81 | 79 | ||
82 | if (i==3) { | 80 | if (i == 3) { |
83 | *buffer = ' '; | 81 | *buffer = ' '; |
84 | ++buffer; | 82 | ++buffer; |
85 | } | 83 | } |
@@ -90,9 +88,9 @@ static void format_mods_bitmap_string(uint8_t mods, char* buffer) { | |||
90 | bool lcd_keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { | 88 | bool lcd_keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { |
91 | (void)animation; | 89 | (void)animation; |
92 | 90 | ||
93 | const char* title = "Modifier states"; | 91 | const char* title = "Modifier states"; |
94 | const char* mods_header = " CSAG CSAG "; | 92 | const char* mods_header = " CSAG CSAG "; |
95 | char status_buffer[12]; | 93 | char status_buffer[12]; |
96 | 94 | ||
97 | gdispClear(White); | 95 | gdispClear(White); |
98 | gdispDrawString(0, 0, title, state->font_fixed5x8, Black); | 96 | gdispDrawString(0, 0, title, state->font_fixed5x8, Black); |
@@ -109,30 +107,29 @@ static void get_led_state_string(char* output, visualizer_state_t* state) { | |||
109 | uint8_t pos = 0; | 107 | uint8_t pos = 0; |
110 | 108 | ||
111 | if (state->status.leds & (1u << USB_LED_NUM_LOCK)) { | 109 | if (state->status.leds & (1u << USB_LED_NUM_LOCK)) { |
112 | memcpy(output + pos, "NUM ", 4); | 110 | memcpy(output + pos, "NUM ", 4); |
113 | pos += 4; | 111 | pos += 4; |
114 | } | 112 | } |
115 | if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { | 113 | if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { |
116 | memcpy(output + pos, "CAPS ", 5); | 114 | memcpy(output + pos, "CAPS ", 5); |
117 | pos += 5; | 115 | pos += 5; |
118 | } | 116 | } |
119 | if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) { | 117 | if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) { |
120 | memcpy(output + pos, "SCRL ", 5); | 118 | memcpy(output + pos, "SCRL ", 5); |
121 | pos += 5; | 119 | pos += 5; |
122 | } | 120 | } |
123 | if (state->status.leds & (1u << USB_LED_COMPOSE)) { | 121 | if (state->status.leds & (1u << USB_LED_COMPOSE)) { |
124 | memcpy(output + pos, "COMP ", 5); | 122 | memcpy(output + pos, "COMP ", 5); |
125 | pos += 5; | 123 | pos += 5; |
126 | } | 124 | } |
127 | if (state->status.leds & (1u << USB_LED_KANA)) { | 125 | if (state->status.leds & (1u << USB_LED_KANA)) { |
128 | memcpy(output + pos, "KANA", 4); | 126 | memcpy(output + pos, "KANA", 4); |
129 | pos += 4; | 127 | pos += 4; |
130 | } | 128 | } |
131 | output[pos] = 0; | 129 | output[pos] = 0; |
132 | } | 130 | } |
133 | 131 | ||
134 | bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state) | 132 | bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state) { |
135 | { | ||
136 | (void)animation; | 133 | (void)animation; |
137 | char output[LED_STATE_STRING_SIZE]; | 134 | char output[LED_STATE_STRING_SIZE]; |
138 | get_led_state_string(output, state); | 135 | get_led_state_string(output, state); |
@@ -165,14 +162,13 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* | |||
165 | // You can use static variables for things that can't be found in the animation | 162 | // You can use static variables for things that can't be found in the animation |
166 | // or state structs, here we use the image | 163 | // or state structs, here we use the image |
167 | 164 | ||
168 | //gdispGBlitArea is a tricky function to use since it supports blitting part of the image | 165 | // gdispGBlitArea is a tricky function to use since it supports blitting part of the image |
169 | // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions | 166 | // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions |
170 | gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); | 167 | gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); |
171 | 168 | ||
172 | return false; | 169 | return false; |
173 | } | 170 | } |
174 | 171 | ||
175 | |||
176 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | 172 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { |
177 | (void)animation; | 173 | (void)animation; |
178 | (void)state; | 174 | (void)state; |
diff --git a/quantum/visualizer/lcd_keyframes.h b/quantum/visualizer/lcd_keyframes.h index 2e912b4c7..6346c8643 100644 --- a/quantum/visualizer/lcd_keyframes.h +++ b/quantum/visualizer/lcd_keyframes.h | |||
@@ -35,5 +35,4 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* | |||
35 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | 35 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); |
36 | bool lcd_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | 36 | bool lcd_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); |
37 | 37 | ||
38 | |||
39 | #endif /* QUANTUM_VISUALIZER_LCD_KEYFRAMES_H_ */ | 38 | #endif /* QUANTUM_VISUALIZER_LCD_KEYFRAMES_H_ */ |
diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c index eb3f5561d..d81117d2b 100644 --- a/quantum/visualizer/led_backlight_keyframes.c +++ b/quantum/visualizer/led_backlight_keyframes.c | |||
@@ -27,15 +27,15 @@ SOFTWARE. | |||
27 | 27 | ||
28 | static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { | 28 | static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { |
29 | int frame_length = animation->frame_lengths[animation->current_frame]; | 29 | int frame_length = animation->frame_lengths[animation->current_frame]; |
30 | int current_pos = frame_length - animation->time_left_in_frame; | 30 | int current_pos = frame_length - animation->time_left_in_frame; |
31 | int delta = to - from; | 31 | int delta = to - from; |
32 | int luma = (delta * current_pos) / frame_length; | 32 | int luma = (delta * current_pos) / frame_length; |
33 | luma += from; | 33 | luma += from; |
34 | return luma; | 34 | return luma; |
35 | } | 35 | } |
36 | 36 | ||
37 | static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) { | 37 | static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint8_t from, uint8_t to) { |
38 | uint8_t luma = fade_led_color(animation, from, to); | 38 | uint8_t luma = fade_led_color(animation, from, to); |
39 | color_t color = LUMA2COLOR(luma); | 39 | color_t color = LUMA2COLOR(luma); |
40 | gdispGClear(LED_DISPLAY, color); | 40 | gdispGClear(LED_DISPLAY, color); |
41 | } | 41 | } |
@@ -48,10 +48,10 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; | |||
48 | static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; | 48 | static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; |
49 | 49 | ||
50 | static uint8_t compute_gradient_color(float t, float index, float num) { | 50 | static uint8_t compute_gradient_color(float t, float index, float num) { |
51 | const float two_pi = M_PI * 2.0f; | 51 | const float two_pi = M_PI * 2.0f; |
52 | float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; | 52 | float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; |
53 | float x = t * two_pi + normalized_index; | 53 | float x = t * two_pi + normalized_index; |
54 | float v = 0.5 * (cosf(x) + 1.0f); | 54 | float v = 0.5 * (cosf(x) + 1.0f); |
55 | return (uint8_t)(255.0f * v); | 55 | return (uint8_t)(255.0f * v); |
56 | } | 56 | } |
57 | 57 | ||
@@ -70,9 +70,9 @@ bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visual | |||
70 | bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | 70 | bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { |
71 | (void)state; | 71 | (void)state; |
72 | float frame_length = animation->frame_lengths[animation->current_frame]; | 72 | float frame_length = animation->frame_lengths[animation->current_frame]; |
73 | float current_pos = frame_length - animation->time_left_in_frame; | 73 | float current_pos = frame_length - animation->time_left_in_frame; |
74 | float t = current_pos / frame_length; | 74 | float t = current_pos / frame_length; |
75 | for (int i=0; i< NUM_COLS; i++) { | 75 | for (int i = 0; i < NUM_COLS; i++) { |
76 | uint8_t color = compute_gradient_color(t, i, NUM_COLS); | 76 | uint8_t color = compute_gradient_color(t, i, NUM_COLS); |
77 | gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); | 77 | gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); |
78 | } | 78 | } |
@@ -82,9 +82,9 @@ bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animati | |||
82 | bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | 82 | bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { |
83 | (void)state; | 83 | (void)state; |
84 | float frame_length = animation->frame_lengths[animation->current_frame]; | 84 | float frame_length = animation->frame_lengths[animation->current_frame]; |
85 | float current_pos = frame_length - animation->time_left_in_frame; | 85 | float current_pos = frame_length - animation->time_left_in_frame; |
86 | float t = current_pos / frame_length; | 86 | float t = current_pos / frame_length; |
87 | for (int i=0; i< NUM_ROWS; i++) { | 87 | for (int i = 0; i < NUM_ROWS; i++) { |
88 | uint8_t color = compute_gradient_color(t, i, NUM_ROWS); | 88 | uint8_t color = compute_gradient_color(t, i, NUM_ROWS); |
89 | gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); | 89 | gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); |
90 | } | 90 | } |
@@ -92,9 +92,9 @@ bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animati | |||
92 | } | 92 | } |
93 | 93 | ||
94 | static void copy_current_led_state(uint8_t* dest) { | 94 | static void copy_current_led_state(uint8_t* dest) { |
95 | for (int i=0;i<NUM_ROWS;i++) { | 95 | for (int i = 0; i < NUM_ROWS; i++) { |
96 | for (int j=0;j<NUM_COLS;j++) { | 96 | for (int j = 0; j < NUM_COLS; j++) { |
97 | dest[i*NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i); | 97 | dest[i * NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | } | 100 | } |
@@ -105,9 +105,9 @@ bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualize | |||
105 | run_next_keyframe(animation, state); | 105 | run_next_keyframe(animation, state); |
106 | copy_current_led_state(&crossfade_end_frame[0][0]); | 106 | copy_current_led_state(&crossfade_end_frame[0][0]); |
107 | } | 107 | } |
108 | for (int i=0;i<NUM_ROWS;i++) { | 108 | for (int i = 0; i < NUM_ROWS; i++) { |
109 | for (int j=0;j<NUM_COLS;j++) { | 109 | for (int j = 0; j < NUM_COLS; j++) { |
110 | color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j])); | 110 | color_t color = LUMA2COLOR(fade_led_color(animation, crossfade_start_frame[i][j], crossfade_end_frame[i][j])); |
111 | gdispGDrawPixel(LED_DISPLAY, j, i, color); | 111 | gdispGDrawPixel(LED_DISPLAY, j, i, color); |
112 | } | 112 | } |
113 | } | 113 | } |
diff --git a/quantum/visualizer/led_backlight_keyframes.h b/quantum/visualizer/led_backlight_keyframes.h index 487151013..648f92b91 100644 --- a/quantum/visualizer/led_backlight_keyframes.h +++ b/quantum/visualizer/led_backlight_keyframes.h | |||
@@ -40,5 +40,4 @@ bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_s | |||
40 | 40 | ||
41 | extern keyframe_animation_t led_test_animation; | 41 | extern keyframe_animation_t led_test_animation; |
42 | 42 | ||
43 | |||
44 | #endif /* LED_KEYFRAMES_H */ | 43 | #endif /* LED_KEYFRAMES_H */ |
diff --git a/quantum/visualizer/resources/lcd_logo.c b/quantum/visualizer/resources/lcd_logo.c index 314776c0b..165e6d1f5 100644 --- a/quantum/visualizer/resources/lcd_logo.c +++ b/quantum/visualizer/resources/lcd_logo.c | |||
@@ -16,7 +16,6 @@ | |||
16 | 16 | ||
17 | #include "resources.h" | 17 | #include "resources.h" |
18 | 18 | ||
19 | |||
20 | // To generate an image array like this | 19 | // To generate an image array like this |
21 | // Ensure the image is 128 x 32 or smaller | 20 | // Ensure the image is 128 x 32 or smaller |
22 | // Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/ | 21 | // Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/ |
@@ -24,39 +23,7 @@ | |||
24 | // Update array in the source code with the C array produced by the conversion program | 23 | // Update array in the source code with the C array produced by the conversion program |
25 | 24 | ||
26 | // The image below is generated from lcd_logo.png | 25 | // The image below is generated from lcd_logo.png |
27 | __attribute__((weak)) | 26 | __attribute__((weak)) const uint8_t resource_lcd_logo[512] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
28 | const uint8_t resource_lcd_logo[512] = { | 27 | 0x00, 0x38, 0x38, 0x38, 0x06, 0x29, 0x41, 0x24, 0x52, 0x24, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x42, 0xaa, 0xaa, 0xaa, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x82, 0x28, 0xaa, 0xae, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x43, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x0a, 0x55, 0x42, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 0x38, 0x05, 0x45, 0x42, 0x28, 0x89, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
29 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 28 | 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x80, 0x04, 0x45, 0x14, 0xa4, 0x92, 0x83, 0x52, 0x22, 0x22, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0xba, 0x84, 0x55, 0x55, 0x57, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0xb2, 0x55, 0x55, 0x42, 0x65, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x56, 0x65, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x54, 0x45, 0x42, 0x45, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x04, 0x48, 0xa2, 0x4a, 0x89, 0x06, 0x24, 0x42, 0x41, 0x36, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
30 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 29 | 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
32 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
33 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
35 | 0x00, 0xf8, 0xfe, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
36 | 0x00, 0x38, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
37 | 0x00, 0x38, 0x38, 0x38, 0x06, 0x29, 0x41, 0x24, 0x52, 0x24, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
38 | 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x42, 0xaa, 0xaa, 0xaa, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
39 | 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x82, 0x28, 0xaa, 0xae, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
40 | 0x00, 0x38, 0x38, 0x38, 0x09, 0x55, 0x43, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
41 | 0x00, 0x38, 0x38, 0x38, 0x0a, 0x55, 0x42, 0x28, 0xaa, 0xaa, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
42 | 0x00, 0x38, 0x38, 0x38, 0x05, 0x45, 0x42, 0x28, 0x89, 0x4a, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
43 | 0x00, 0x18, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
44 | 0x00, 0x1c, 0x38, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
45 | 0x00, 0x0e, 0x38, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
46 | 0x00, 0x03, 0xff, 0x80, 0x04, 0x45, 0x14, 0xa4, 0x92, 0x83, 0x52, 0x22, 0x22, 0x36, 0x00, 0x00, | ||
47 | 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0xba, 0x84, 0x55, 0x55, 0x57, 0x45, 0x00, 0x00, | ||
48 | 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0xb2, 0x55, 0x55, 0x42, 0x65, 0x00, 0x00, | ||
49 | 0x00, 0x00, 0x38, 0x00, 0x08, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x56, 0x65, 0x42, 0x45, 0x00, 0x00, | ||
50 | 0x00, 0x00, 0x38, 0x00, 0x0a, 0xaa, 0xaa, 0xaa, 0x92, 0x81, 0x54, 0x45, 0x42, 0x45, 0x00, 0x00, | ||
51 | 0x00, 0x00, 0x38, 0x00, 0x04, 0x48, 0xa2, 0x4a, 0x89, 0x06, 0x24, 0x42, 0x41, 0x36, 0x00, 0x00, | ||
52 | 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
53 | 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
55 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
57 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
61 | }; | ||
62 | |||
diff --git a/quantum/visualizer/resources/resources.h b/quantum/visualizer/resources/resources.h index 1ea27a536..74fd8d2f6 100644 --- a/quantum/visualizer/resources/resources.h +++ b/quantum/visualizer/resources/resources.h | |||
@@ -23,5 +23,4 @@ | |||
23 | extern const uint8_t resource_lcd_logo[]; | 23 | extern const uint8_t resource_lcd_logo[]; |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | |||
27 | #endif /* QUANTUM_VISUALIZER_RESOURCES_RESOURCES_H_ */ | 26 | #endif /* QUANTUM_VISUALIZER_RESOURCES_RESOURCES_H_ */ |
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c index 516cf2a84..3f182e74d 100644 --- a/quantum/visualizer/visualizer.c +++ b/quantum/visualizer/visualizer.c | |||
@@ -26,26 +26,26 @@ SOFTWARE. | |||
26 | #include "visualizer.h" | 26 | #include "visualizer.h" |
27 | #include <string.h> | 27 | #include <string.h> |
28 | #ifdef PROTOCOL_CHIBIOS | 28 | #ifdef PROTOCOL_CHIBIOS |
29 | #include "ch.h" | 29 | # include "ch.h" |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include "gfx.h" | 32 | #include "gfx.h" |
33 | 33 | ||
34 | #ifdef LCD_BACKLIGHT_ENABLE | 34 | #ifdef LCD_BACKLIGHT_ENABLE |
35 | #include "lcd_backlight.h" | 35 | # include "lcd_backlight.h" |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | //#define DEBUG_VISUALIZER | 38 | //#define DEBUG_VISUALIZER |
39 | 39 | ||
40 | #ifdef DEBUG_VISUALIZER | 40 | #ifdef DEBUG_VISUALIZER |
41 | #include "debug.h" | 41 | # include "debug.h" |
42 | #else | 42 | #else |
43 | #include "nodebug.h" | 43 | # include "nodebug.h" |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #ifdef SERIAL_LINK_ENABLE | 46 | #ifdef SERIAL_LINK_ENABLE |
47 | #include "serial_link/protocol/transport.h" | 47 | # include "serial_link/protocol/transport.h" |
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" | 51 | #include "action_util.h" |
@@ -53,36 +53,31 @@ SOFTWARE. | |||
53 | // Define this in config.h | 53 | // Define this in config.h |
54 | #ifndef VISUALIZER_THREAD_PRIORITY | 54 | #ifndef VISUALIZER_THREAD_PRIORITY |
55 | // The visualizer needs gfx thread priorities | 55 | // The visualizer needs gfx thread priorities |
56 | #define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2) | 56 | # define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2) |
57 | #endif | 57 | #endif |
58 | 58 | ||
59 | static visualizer_keyboard_status_t current_status = { | 59 | static visualizer_keyboard_status_t current_status = {.layer = 0xFFFFFFFF, |
60 | .layer = 0xFFFFFFFF, | 60 | .default_layer = 0xFFFFFFFF, |
61 | .default_layer = 0xFFFFFFFF, | 61 | .leds = 0xFFFFFFFF, |
62 | .leds = 0xFFFFFFFF, | ||
63 | #ifdef BACKLIGHT_ENABLE | 62 | #ifdef BACKLIGHT_ENABLE |
64 | .backlight_level = 0, | 63 | .backlight_level = 0, |
65 | #endif | 64 | #endif |
66 | .mods = 0xFF, | 65 | .mods = 0xFF, |
67 | .suspended = false, | 66 | .suspended = false, |
68 | #ifdef VISUALIZER_USER_DATA_SIZE | 67 | #ifdef VISUALIZER_USER_DATA_SIZE |
69 | .user_data = {0} | 68 | .user_data = {0} |
70 | #endif | 69 | #endif |
71 | }; | 70 | }; |
72 | 71 | ||
73 | static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) { | 72 | static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) { |
74 | return status1->layer == status2->layer && | 73 | return status1->layer == status2->layer && status1->default_layer == status2->default_layer && status1->mods == status2->mods && status1->leds == status2->leds && status1->suspended == status2->suspended |
75 | status1->default_layer == status2->default_layer && | ||
76 | status1->mods == status2->mods && | ||
77 | status1->leds == status2->leds && | ||
78 | status1->suspended == status2->suspended | ||
79 | #ifdef BACKLIGHT_ENABLE | 74 | #ifdef BACKLIGHT_ENABLE |
80 | && status1->backlight_level == status2->backlight_level | 75 | && status1->backlight_level == status2->backlight_level |
81 | #endif | 76 | #endif |
82 | #ifdef VISUALIZER_USER_DATA_SIZE | 77 | #ifdef VISUALIZER_USER_DATA_SIZE |
83 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 | 78 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 |
84 | #endif | 79 | #endif |
85 | ; | 80 | ; |
86 | } | 81 | } |
87 | 82 | ||
88 | static bool visualizer_enabled = false; | 83 | static bool visualizer_enabled = false; |
@@ -107,44 +102,38 @@ GDisplay* LCD_DISPLAY = 0; | |||
107 | GDisplay* LED_DISPLAY = 0; | 102 | GDisplay* LED_DISPLAY = 0; |
108 | 103 | ||
109 | #ifdef LCD_DISPLAY_NUMBER | 104 | #ifdef LCD_DISPLAY_NUMBER |
110 | __attribute__((weak)) | 105 | __attribute__((weak)) GDisplay* get_lcd_display(void) { return gdispGetDisplay(LCD_DISPLAY_NUMBER); } |
111 | GDisplay* get_lcd_display(void) { | ||
112 | return gdispGetDisplay(LCD_DISPLAY_NUMBER); | ||
113 | } | ||
114 | #endif | 106 | #endif |
115 | 107 | ||
116 | #ifdef LED_DISPLAY_NUMBER | 108 | #ifdef LED_DISPLAY_NUMBER |
117 | __attribute__((weak)) | 109 | __attribute__((weak)) GDisplay* get_led_display(void) { return gdispGetDisplay(LED_DISPLAY_NUMBER); } |
118 | GDisplay* get_led_display(void) { | ||
119 | return gdispGetDisplay(LED_DISPLAY_NUMBER); | ||
120 | } | ||
121 | #endif | 110 | #endif |
122 | 111 | ||
123 | void start_keyframe_animation(keyframe_animation_t* animation) { | 112 | void start_keyframe_animation(keyframe_animation_t* animation) { |
124 | animation->current_frame = -1; | 113 | animation->current_frame = -1; |
125 | animation->time_left_in_frame = 0; | 114 | animation->time_left_in_frame = 0; |
126 | animation->need_update = true; | 115 | animation->need_update = true; |
127 | int free_index = -1; | 116 | int free_index = -1; |
128 | for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) { | 117 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { |
129 | if (animations[i] == animation) { | 118 | if (animations[i] == animation) { |
130 | return; | 119 | return; |
131 | } | 120 | } |
132 | if (free_index == -1 && animations[i] == NULL) { | 121 | if (free_index == -1 && animations[i] == NULL) { |
133 | free_index=i; | 122 | free_index = i; |
134 | } | 123 | } |
135 | } | 124 | } |
136 | if (free_index!=-1) { | 125 | if (free_index != -1) { |
137 | animations[free_index] = animation; | 126 | animations[free_index] = animation; |
138 | } | 127 | } |
139 | } | 128 | } |
140 | 129 | ||
141 | void stop_keyframe_animation(keyframe_animation_t* animation) { | 130 | void stop_keyframe_animation(keyframe_animation_t* animation) { |
142 | animation->current_frame = animation->num_frames; | 131 | animation->current_frame = animation->num_frames; |
143 | animation->time_left_in_frame = 0; | 132 | animation->time_left_in_frame = 0; |
144 | animation->need_update = true; | 133 | animation->need_update = true; |
145 | animation->first_update_of_frame = false; | 134 | animation->first_update_of_frame = false; |
146 | animation->last_update_of_frame = false; | 135 | animation->last_update_of_frame = false; |
147 | for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) { | 136 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { |
148 | if (animations[i] == animation) { | 137 | if (animations[i] == animation) { |
149 | animations[i] = NULL; | 138 | animations[i] = NULL; |
150 | return; | 139 | return; |
@@ -153,21 +142,21 @@ void stop_keyframe_animation(keyframe_animation_t* animation) { | |||
153 | } | 142 | } |
154 | 143 | ||
155 | void stop_all_keyframe_animations(void) { | 144 | void stop_all_keyframe_animations(void) { |
156 | for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) { | 145 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { |
157 | if (animations[i]) { | 146 | if (animations[i]) { |
158 | animations[i]->current_frame = animations[i]->num_frames; | 147 | animations[i]->current_frame = animations[i]->num_frames; |
159 | animations[i]->time_left_in_frame = 0; | 148 | animations[i]->time_left_in_frame = 0; |
160 | animations[i]->need_update = true; | 149 | animations[i]->need_update = true; |
161 | animations[i]->first_update_of_frame = false; | 150 | animations[i]->first_update_of_frame = false; |
162 | animations[i]->last_update_of_frame = false; | 151 | animations[i]->last_update_of_frame = false; |
163 | animations[i] = NULL; | 152 | animations[i] = NULL; |
164 | } | 153 | } |
165 | } | 154 | } |
166 | } | 155 | } |
167 | 156 | ||
168 | static uint8_t get_num_running_animations(void) { | 157 | static uint8_t get_num_running_animations(void) { |
169 | uint8_t count = 0; | 158 | uint8_t count = 0; |
170 | for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) { | 159 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { |
171 | count += animations[i] ? 1 : 0; | 160 | count += animations[i] ? 1 : 0; |
172 | } | 161 | } |
173 | return count; | 162 | return count; |
@@ -175,46 +164,44 @@ static uint8_t get_num_running_animations(void) { | |||
175 | 164 | ||
176 | static bool update_keyframe_animation(keyframe_animation_t* animation, visualizer_state_t* state, systemticks_t delta, systemticks_t* sleep_time) { | 165 | static bool update_keyframe_animation(keyframe_animation_t* animation, visualizer_state_t* state, systemticks_t delta, systemticks_t* sleep_time) { |
177 | // TODO: Clean up this messy code | 166 | // TODO: Clean up this messy code |
178 | dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame, | 167 | dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame, animation->time_left_in_frame, delta); |
179 | animation->time_left_in_frame, delta); | ||
180 | if (animation->current_frame == animation->num_frames) { | 168 | if (animation->current_frame == animation->num_frames) { |
181 | animation->need_update = false; | 169 | animation->need_update = false; |
182 | return false; | 170 | return false; |
183 | } | 171 | } |
184 | if (animation->current_frame == -1) { | 172 | if (animation->current_frame == -1) { |
185 | animation->current_frame = 0; | 173 | animation->current_frame = 0; |
186 | animation->time_left_in_frame = animation->frame_lengths[0]; | 174 | animation->time_left_in_frame = animation->frame_lengths[0]; |
187 | animation->need_update = true; | 175 | animation->need_update = true; |
188 | animation->first_update_of_frame = true; | 176 | animation->first_update_of_frame = true; |
189 | } else { | 177 | } else { |
190 | animation->time_left_in_frame -= delta; | 178 | animation->time_left_in_frame -= delta; |
191 | while (animation->time_left_in_frame <= 0) { | 179 | while (animation->time_left_in_frame <= 0) { |
192 | int left = animation->time_left_in_frame; | 180 | int left = animation->time_left_in_frame; |
193 | if (animation->need_update) { | 181 | if (animation->need_update) { |
194 | animation->time_left_in_frame = 0; | 182 | animation->time_left_in_frame = 0; |
195 | animation->last_update_of_frame = true; | 183 | animation->last_update_of_frame = true; |
196 | (*animation->frame_functions[animation->current_frame])(animation, state); | 184 | (*animation->frame_functions[animation->current_frame])(animation, state); |
197 | animation->last_update_of_frame = false; | 185 | animation->last_update_of_frame = false; |
198 | } | 186 | } |
199 | animation->current_frame++; | 187 | animation->current_frame++; |
200 | animation->need_update = true; | 188 | animation->need_update = true; |
201 | animation->first_update_of_frame = true; | 189 | animation->first_update_of_frame = true; |
202 | if (animation->current_frame == animation->num_frames) { | 190 | if (animation->current_frame == animation->num_frames) { |
203 | if (animation->loop) { | 191 | if (animation->loop) { |
204 | animation->current_frame = 0; | 192 | animation->current_frame = 0; |
205 | } | 193 | } else { |
206 | else { | ||
207 | stop_keyframe_animation(animation); | 194 | stop_keyframe_animation(animation); |
208 | return false; | 195 | return false; |
209 | } | 196 | } |
210 | } | 197 | } |
211 | delta = -left; | 198 | delta = -left; |
212 | animation->time_left_in_frame = animation->frame_lengths[animation->current_frame]; | 199 | animation->time_left_in_frame = animation->frame_lengths[animation->current_frame]; |
213 | animation->time_left_in_frame -= delta; | 200 | animation->time_left_in_frame -= delta; |
214 | } | 201 | } |
215 | } | 202 | } |
216 | if (animation->need_update) { | 203 | if (animation->need_update) { |
217 | animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state); | 204 | animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state); |
218 | animation->first_update_of_frame = false; | 205 | animation->first_update_of_frame = false; |
219 | } | 206 | } |
220 | 207 | ||
@@ -231,13 +218,13 @@ void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* stat | |||
231 | if (next_frame == animation->num_frames) { | 218 | if (next_frame == animation->num_frames) { |
232 | next_frame = 0; | 219 | next_frame = 0; |
233 | } | 220 | } |
234 | keyframe_animation_t temp_animation = *animation; | 221 | keyframe_animation_t temp_animation = *animation; |
235 | temp_animation.current_frame = next_frame; | 222 | temp_animation.current_frame = next_frame; |
236 | temp_animation.time_left_in_frame = animation->frame_lengths[next_frame]; | 223 | temp_animation.time_left_in_frame = animation->frame_lengths[next_frame]; |
237 | temp_animation.first_update_of_frame = true; | 224 | temp_animation.first_update_of_frame = true; |
238 | temp_animation.last_update_of_frame = false; | 225 | temp_animation.last_update_of_frame = false; |
239 | temp_animation.need_update = false; | 226 | temp_animation.need_update = false; |
240 | visualizer_state_t temp_state = *state; | 227 | visualizer_state_t temp_state = *state; |
241 | (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state); | 228 | (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state); |
242 | } | 229 | } |
243 | 230 | ||
@@ -252,70 +239,64 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
252 | 239 | ||
253 | visualizer_keyboard_status_t initial_status = { | 240 | visualizer_keyboard_status_t initial_status = { |
254 | .default_layer = 0xFFFFFFFF, | 241 | .default_layer = 0xFFFFFFFF, |
255 | .layer = 0xFFFFFFFF, | 242 | .layer = 0xFFFFFFFF, |
256 | .mods = 0xFF, | 243 | .mods = 0xFF, |
257 | .leds = 0xFFFFFFFF, | 244 | .leds = 0xFFFFFFFF, |
258 | .suspended = false, | 245 | .suspended = false, |
259 | #ifdef BACKLIGHT_ENABLE | 246 | #ifdef BACKLIGHT_ENABLE |
260 | .backlight_level = 0, | 247 | .backlight_level = 0, |
261 | #endif | 248 | #endif |
262 | #ifdef VISUALIZER_USER_DATA_SIZE | 249 | #ifdef VISUALIZER_USER_DATA_SIZE |
263 | .user_data = {0}, | 250 | .user_data = {0}, |
264 | #endif | 251 | #endif |
265 | }; | 252 | }; |
266 | 253 | ||
267 | visualizer_state_t state = { | 254 | visualizer_state_t state = {.status = initial_status, |
268 | .status = initial_status, | 255 | .current_lcd_color = 0, |
269 | .current_lcd_color = 0, | ||
270 | #ifdef LCD_ENABLE | 256 | #ifdef LCD_ENABLE |
271 | .font_fixed5x8 = gdispOpenFont("fixed_5x8"), | 257 | .font_fixed5x8 = gdispOpenFont("fixed_5x8"), |
272 | .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12") | 258 | .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12") |
273 | #endif | 259 | #endif |
274 | }; | 260 | }; |
275 | initialize_user_visualizer(&state); | 261 | initialize_user_visualizer(&state); |
276 | state.prev_lcd_color = state.current_lcd_color; | 262 | state.prev_lcd_color = state.current_lcd_color; |
277 | 263 | ||
278 | #ifdef LCD_BACKLIGHT_ENABLE | 264 | #ifdef LCD_BACKLIGHT_ENABLE |
279 | lcd_backlight_color( | 265 | lcd_backlight_color(LCD_HUE(state.current_lcd_color), LCD_SAT(state.current_lcd_color), LCD_INT(state.current_lcd_color)); |
280 | LCD_HUE(state.current_lcd_color), | ||
281 | LCD_SAT(state.current_lcd_color), | ||
282 | LCD_INT(state.current_lcd_color)); | ||
283 | #endif | 266 | #endif |
284 | 267 | ||
285 | systemticks_t sleep_time = TIME_INFINITE; | 268 | systemticks_t sleep_time = TIME_INFINITE; |
286 | systemticks_t current_time = gfxSystemTicks(); | 269 | systemticks_t current_time = gfxSystemTicks(); |
287 | bool force_update = true; | 270 | bool force_update = true; |
288 | 271 | ||
289 | while(true) { | 272 | while (true) { |
290 | systemticks_t new_time = gfxSystemTicks(); | 273 | systemticks_t new_time = gfxSystemTicks(); |
291 | systemticks_t delta = new_time - current_time; | 274 | systemticks_t delta = new_time - current_time; |
292 | current_time = new_time; | 275 | current_time = new_time; |
293 | bool enabled = visualizer_enabled; | 276 | bool enabled = visualizer_enabled; |
294 | if (force_update || !same_status(&state.status, ¤t_status)) { | 277 | if (force_update || !same_status(&state.status, ¤t_status)) { |
295 | force_update = false; | 278 | force_update = false; |
296 | #if BACKLIGHT_ENABLE | 279 | #if BACKLIGHT_ENABLE |
297 | if(current_status.backlight_level != state.status.backlight_level) { | 280 | if (current_status.backlight_level != state.status.backlight_level) { |
298 | if (current_status.backlight_level != 0) { | 281 | if (current_status.backlight_level != 0) { |
299 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | 282 | gdispGSetPowerMode(LED_DISPLAY, powerOn); |
300 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; | 283 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; |
301 | gdispGSetBacklight(LED_DISPLAY, percent); | 284 | gdispGSetBacklight(LED_DISPLAY, percent); |
302 | } | 285 | } else { |
303 | else { | ||
304 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | 286 | gdispGSetPowerMode(LED_DISPLAY, powerOff); |
305 | } | 287 | } |
306 | state.status.backlight_level = current_status.backlight_level; | 288 | state.status.backlight_level = current_status.backlight_level; |
307 | } | 289 | } |
308 | #endif | 290 | #endif |
309 | if (visualizer_enabled) { | 291 | if (visualizer_enabled) { |
310 | if (current_status.suspended) { | 292 | if (current_status.suspended) { |
311 | stop_all_keyframe_animations(); | 293 | stop_all_keyframe_animations(); |
312 | visualizer_enabled = false; | 294 | visualizer_enabled = false; |
313 | state.status = current_status; | 295 | state.status = current_status; |
314 | user_visualizer_suspend(&state); | 296 | user_visualizer_suspend(&state); |
315 | } | 297 | } else { |
316 | else { | ||
317 | visualizer_keyboard_status_t prev_status = state.status; | 298 | visualizer_keyboard_status_t prev_status = state.status; |
318 | state.status = current_status; | 299 | state.status = current_status; |
319 | update_user_visualizer_state(&state, &prev_status); | 300 | update_user_visualizer_state(&state, &prev_status); |
320 | } | 301 | } |
321 | state.prev_lcd_color = state.current_lcd_color; | 302 | state.prev_lcd_color = state.current_lcd_color; |
@@ -324,14 +305,14 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
324 | if (!enabled && state.status.suspended && current_status.suspended == false) { | 305 | if (!enabled && state.status.suspended && current_status.suspended == false) { |
325 | // Setting the status to the initial status will force an update | 306 | // Setting the status to the initial status will force an update |
326 | // when the visualizer is enabled again | 307 | // when the visualizer is enabled again |
327 | state.status = initial_status; | 308 | state.status = initial_status; |
328 | state.status.suspended = false; | 309 | state.status.suspended = false; |
329 | stop_all_keyframe_animations(); | 310 | stop_all_keyframe_animations(); |
330 | user_visualizer_resume(&state); | 311 | user_visualizer_resume(&state); |
331 | state.prev_lcd_color = state.current_lcd_color; | 312 | state.prev_lcd_color = state.current_lcd_color; |
332 | } | 313 | } |
333 | sleep_time = TIME_INFINITE; | 314 | sleep_time = TIME_INFINITE; |
334 | for (int i=0;i<MAX_SIMULTANEOUS_ANIMATIONS;i++) { | 315 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { |
335 | if (animations[i]) { | 316 | if (animations[i]) { |
336 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); | 317 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); |
337 | } | 318 | } |
@@ -350,17 +331,16 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
350 | // Enable the visualizer when the startup or the suspend animation has finished | 331 | // Enable the visualizer when the startup or the suspend animation has finished |
351 | if (!visualizer_enabled && state.status.suspended == false && get_num_running_animations() == 0) { | 332 | if (!visualizer_enabled && state.status.suspended == false && get_num_running_animations() == 0) { |
352 | visualizer_enabled = true; | 333 | visualizer_enabled = true; |
353 | force_update = true; | 334 | force_update = true; |
354 | sleep_time = 0; | 335 | sleep_time = 0; |
355 | } | 336 | } |
356 | 337 | ||
357 | systemticks_t after_update = gfxSystemTicks(); | 338 | systemticks_t after_update = gfxSystemTicks(); |
358 | unsigned update_delta = after_update - current_time; | 339 | unsigned update_delta = after_update - current_time; |
359 | if (sleep_time != TIME_INFINITE) { | 340 | if (sleep_time != TIME_INFINITE) { |
360 | if (sleep_time > update_delta) { | 341 | if (sleep_time > update_delta) { |
361 | sleep_time -= update_delta; | 342 | sleep_time -= update_delta; |
362 | } | 343 | } else { |
363 | else { | ||
364 | sleep_time = 0; | 344 | sleep_time = 0; |
365 | } | 345 | } |
366 | } | 346 | } |
@@ -388,26 +368,25 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | |||
388 | void visualizer_init(void) { | 368 | void visualizer_init(void) { |
389 | gfxInit(); | 369 | gfxInit(); |
390 | 370 | ||
391 | #ifdef LCD_BACKLIGHT_ENABLE | 371 | #ifdef LCD_BACKLIGHT_ENABLE |
392 | lcd_backlight_init(); | 372 | lcd_backlight_init(); |
393 | #endif | 373 | #endif |
394 | 374 | ||
395 | #ifdef SERIAL_LINK_ENABLE | 375 | #ifdef SERIAL_LINK_ENABLE |
396 | add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) ); | 376 | add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*)); |
397 | #endif | 377 | #endif |
398 | 378 | ||
399 | #ifdef LCD_ENABLE | 379 | #ifdef LCD_ENABLE |
400 | LCD_DISPLAY = get_lcd_display(); | 380 | LCD_DISPLAY = get_lcd_display(); |
401 | #endif | 381 | #endif |
402 | 382 | ||
403 | #ifdef BACKLIGHT_ENABLE | 383 | #ifdef BACKLIGHT_ENABLE |
404 | LED_DISPLAY = get_led_display(); | 384 | LED_DISPLAY = get_led_display(); |
405 | #endif | 385 | #endif |
406 | 386 | ||
407 | // We are using a low priority thread, the idea is to have it run only | 387 | // We are using a low priority thread, the idea is to have it run only |
408 | // when the main thread is sleeping during the matrix scanning | 388 | // when the main thread is sleeping during the matrix scanning |
409 | gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), | 389 | gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL); |
410 | VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL); | ||
411 | } | 390 | } |
412 | 391 | ||
413 | void update_status(bool changed) { | 392 | void update_status(bool changed) { |
@@ -418,33 +397,31 @@ void update_status(bool changed) { | |||
418 | } | 397 | } |
419 | } | 398 | } |
420 | #ifdef SERIAL_LINK_ENABLE | 399 | #ifdef SERIAL_LINK_ENABLE |
421 | static systime_t last_update = 0; | 400 | static systime_t last_update = 0; |
422 | systime_t current_update = chVTGetSystemTimeX(); | 401 | systime_t current_update = chVTGetSystemTimeX(); |
423 | systime_t delta = current_update - last_update; | 402 | systime_t delta = current_update - last_update; |
424 | if (changed || delta > MS2ST(10)) { | 403 | if (changed || delta > MS2ST(10)) { |
425 | last_update = current_update; | 404 | last_update = current_update; |
426 | visualizer_keyboard_status_t* r = begin_write_current_status(); | 405 | visualizer_keyboard_status_t* r = begin_write_current_status(); |
427 | *r = current_status; | 406 | *r = current_status; |
428 | end_write_current_status(); | 407 | end_write_current_status(); |
429 | } | 408 | } |
430 | #endif | 409 | #endif |
431 | } | 410 | } |
432 | 411 | ||
433 | uint8_t visualizer_get_mods() { | 412 | uint8_t visualizer_get_mods() { |
434 | uint8_t mods = get_mods(); | 413 | uint8_t mods = get_mods(); |
435 | 414 | ||
436 | #ifndef NO_ACTION_ONESHOT | 415 | #ifndef NO_ACTION_ONESHOT |
437 | if (!has_oneshot_mods_timed_out()) { | 416 | if (!has_oneshot_mods_timed_out()) { |
438 | mods |= get_oneshot_mods(); | 417 | mods |= get_oneshot_mods(); |
439 | } | 418 | } |
440 | #endif | 419 | #endif |
441 | return mods; | 420 | return mods; |
442 | } | 421 | } |
443 | 422 | ||
444 | #ifdef VISUALIZER_USER_DATA_SIZE | 423 | #ifdef VISUALIZER_USER_DATA_SIZE |
445 | void visualizer_set_user_data(void* u) { | 424 | void visualizer_set_user_data(void* u) { memcpy(user_data, u, VISUALIZER_USER_DATA_SIZE); } |
446 | memcpy(user_data, u, VISUALIZER_USER_DATA_SIZE); | ||
447 | } | ||
448 | #endif | 425 | #endif |
449 | 426 | ||
450 | void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds) { | 427 | void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds) { |
@@ -455,34 +432,33 @@ void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t | |||
455 | 432 | ||
456 | bool changed = false; | 433 | bool changed = false; |
457 | #ifdef SERIAL_LINK_ENABLE | 434 | #ifdef SERIAL_LINK_ENABLE |
458 | if (is_serial_link_connected ()) { | 435 | if (is_serial_link_connected()) { |
459 | visualizer_keyboard_status_t* new_status = read_current_status(); | 436 | visualizer_keyboard_status_t* new_status = read_current_status(); |
460 | if (new_status) { | 437 | if (new_status) { |
461 | if (!same_status(¤t_status, new_status)) { | 438 | if (!same_status(¤t_status, new_status)) { |
462 | changed = true; | 439 | changed = true; |
463 | current_status = *new_status; | 440 | current_status = *new_status; |
464 | } | 441 | } |
465 | } | 442 | } |
466 | } | 443 | } else { |
467 | else { | ||
468 | #else | 444 | #else |
469 | { | 445 | { |
470 | #endif | 446 | #endif |
471 | visualizer_keyboard_status_t new_status = { | 447 | visualizer_keyboard_status_t new_status = { |
472 | .layer = state, | 448 | .layer = state, |
473 | .default_layer = default_state, | 449 | .default_layer = default_state, |
474 | .mods = mods, | 450 | .mods = mods, |
475 | .leds = leds, | 451 | .leds = leds, |
476 | #ifdef BACKLIGHT_ENABLE | 452 | #ifdef BACKLIGHT_ENABLE |
477 | .backlight_level = current_status.backlight_level, | 453 | .backlight_level = current_status.backlight_level, |
478 | #endif | 454 | #endif |
479 | .suspended = current_status.suspended, | 455 | .suspended = current_status.suspended, |
480 | }; | 456 | }; |
481 | #ifdef VISUALIZER_USER_DATA_SIZE | 457 | #ifdef VISUALIZER_USER_DATA_SIZE |
482 | memcpy(new_status.user_data, user_data, VISUALIZER_USER_DATA_SIZE); | 458 | memcpy(new_status.user_data, user_data, VISUALIZER_USER_DATA_SIZE); |
483 | #endif | 459 | #endif |
484 | if (!same_status(¤t_status, &new_status)) { | 460 | if (!same_status(¤t_status, &new_status)) { |
485 | changed = true; | 461 | changed = true; |
486 | current_status = new_status; | 462 | current_status = new_status; |
487 | } | 463 | } |
488 | } | 464 | } |
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h index 56ea1fd98..7ca6837ce 100644 --- a/quantum/visualizer/visualizer.h +++ b/quantum/visualizer/visualizer.h | |||
@@ -33,11 +33,11 @@ SOFTWARE. | |||
33 | #include "action_layer.h" | 33 | #include "action_layer.h" |
34 | 34 | ||
35 | #ifdef LCD_BACKLIGHT_ENABLE | 35 | #ifdef LCD_BACKLIGHT_ENABLE |
36 | #include "lcd_backlight.h" | 36 | # include "lcd_backlight.h" |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #ifdef BACKLIGHT_ENABLE | 39 | #ifdef BACKLIGHT_ENABLE |
40 | #include "backlight.h" | 40 | # include "backlight.h" |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | // use this function to merge both real_mods and oneshot_mods in a uint16_t | 43 | // use this function to merge both real_mods and oneshot_mods in a uint16_t |
@@ -71,9 +71,9 @@ struct keyframe_animation_t; | |||
71 | typedef struct { | 71 | typedef struct { |
72 | layer_state_t layer; | 72 | layer_state_t layer; |
73 | layer_state_t default_layer; | 73 | layer_state_t default_layer; |
74 | uint32_t leds; // See led.h for available statuses | 74 | uint32_t leds; // See led.h for available statuses |
75 | uint8_t mods; | 75 | uint8_t mods; |
76 | bool suspended; | 76 | bool suspended; |
77 | #ifdef BACKLIGHT_ENABLE | 77 | #ifdef BACKLIGHT_ENABLE |
78 | uint8_t backlight_level; | 78 | uint8_t backlight_level; |
79 | #endif | 79 | #endif |
@@ -87,7 +87,7 @@ typedef struct { | |||
87 | // from the user customized code | 87 | // from the user customized code |
88 | typedef struct visualizer_state_t { | 88 | typedef struct visualizer_state_t { |
89 | // The user code should primarily be modifying these | 89 | // The user code should primarily be modifying these |
90 | uint32_t target_lcd_color; | 90 | uint32_t target_lcd_color; |
91 | const char* layer_text; | 91 | const char* layer_text; |
92 | 92 | ||
93 | // The user visualizer(and animation functions) can read these | 93 | // The user visualizer(and animation functions) can read these |
@@ -111,15 +111,15 @@ typedef bool (*frame_func)(struct keyframe_animation_t*, visualizer_state_t*); | |||
111 | // while others are meant to be initialized by the user code | 111 | // while others are meant to be initialized by the user code |
112 | typedef struct keyframe_animation_t { | 112 | typedef struct keyframe_animation_t { |
113 | // These should be initialized | 113 | // These should be initialized |
114 | int num_frames; | 114 | int num_frames; |
115 | bool loop; | 115 | bool loop; |
116 | int frame_lengths[MAX_VISUALIZER_KEY_FRAMES]; | 116 | int frame_lengths[MAX_VISUALIZER_KEY_FRAMES]; |
117 | frame_func frame_functions[MAX_VISUALIZER_KEY_FRAMES]; | 117 | frame_func frame_functions[MAX_VISUALIZER_KEY_FRAMES]; |
118 | 118 | ||
119 | // Used internally by the system, and can also be read by | 119 | // Used internally by the system, and can also be read by |
120 | // keyframe update functions | 120 | // keyframe update functions |
121 | int current_frame; | 121 | int current_frame; |
122 | int time_left_in_frame; | 122 | int time_left_in_frame; |
123 | bool first_update_of_frame; | 123 | bool first_update_of_frame; |
124 | bool last_update_of_frame; | 124 | bool last_update_of_frame; |
125 | bool need_update; | 125 | bool need_update; |