aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
Diffstat (limited to 'quantum')
-rw-r--r--quantum/analog.c69
-rw-r--r--quantum/analog.h52
-rwxr-xr-xquantum/light_ws2812.c342
-rwxr-xr-xquantum/light_ws2812.h91
-rw-r--r--quantum/rgblight.h2
-rw-r--r--quantum/visualizer/common_gfxconf.h325
-rw-r--r--quantum/visualizer/default_animations.c176
-rw-r--r--quantum/visualizer/default_animations.h (renamed from quantum/visualizer/lcd_backlight_keyframes.h)18
-rw-r--r--quantum/visualizer/lcd_backlight_keyframes.c8
-rw-r--r--quantum/visualizer/lcd_keyframes.c4
-rw-r--r--quantum/visualizer/led_backlight_keyframes.c (renamed from quantum/visualizer/led_keyframes.c)24
-rw-r--r--quantum/visualizer/led_backlight_keyframes.h (renamed from quantum/visualizer/led_keyframes.h)22
-rw-r--r--quantum/visualizer/visualizer.c7
-rw-r--r--quantum/visualizer/visualizer.mk42
14 files changed, 587 insertions, 595 deletions
diff --git a/quantum/analog.c b/quantum/analog.c
deleted file mode 100644
index 1ec38df75..000000000
--- a/quantum/analog.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/* Copyright 2015 Jack Humbert
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17// Simple analog to digitial conversion
18
19#include <avr/io.h>
20#include <avr/pgmspace.h>
21#include <stdint.h>
22#include "analog.h"
23
24
25static uint8_t aref = (1<<REFS0); // default to AREF = Vcc
26
27
28void analogReference(uint8_t mode)
29{
30 aref = mode & 0xC0;
31}
32
33
34// Arduino compatible pin input
35int16_t analogRead(uint8_t pin)
36{
37#if defined(__AVR_ATmega32U4__)
38 static const uint8_t PROGMEM pin_to_mux[] = {
39 0x00, 0x01, 0x04, 0x05, 0x06, 0x07,
40 0x25, 0x24, 0x23, 0x22, 0x21, 0x20};
41 if (pin >= 12) return 0;
42 return adc_read(pgm_read_byte(pin_to_mux + pin));
43#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
44 if (pin >= 8) return 0;
45 return adc_read(pin);
46#else
47 return 0;
48#endif
49}
50
51// Mux input
52int16_t adc_read(uint8_t mux)
53{
54#if defined(__AVR_AT90USB162__)
55 return 0;
56#else
57 uint8_t low;
58
59 ADCSRA = (1<<ADEN) | ADC_PRESCALER; // enable ADC
60 ADCSRB = (1<<ADHSM) | (mux & 0x20); // high speed mode
61 ADMUX = aref | (mux & 0x1F); // configure mux input
62 ADCSRA = (1<<ADEN) | ADC_PRESCALER | (1<<ADSC); // start the conversion
63 while (ADCSRA & (1<<ADSC)) ; // wait for result
64 low = ADCL; // must read LSB first
65 return (ADCH << 8) | low; // must read MSB only once!
66#endif
67}
68
69
diff --git a/quantum/analog.h b/quantum/analog.h
deleted file mode 100644
index 8d93de7dc..000000000
--- a/quantum/analog.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/* Copyright 2015 Jack Humbert
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef _analog_h_included__
18#define _analog_h_included__
19
20#include <stdint.h>
21
22void analogReference(uint8_t mode);
23int16_t analogRead(uint8_t pin);
24int16_t adc_read(uint8_t mux);
25
26#define ADC_REF_POWER (1<<REFS0)
27#define ADC_REF_INTERNAL ((1<<REFS1) | (1<<REFS0))
28#define ADC_REF_EXTERNAL (0)
29
30// These prescaler values are for high speed mode, ADHSM = 1
31#if F_CPU == 16000000L
32#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS1))
33#elif F_CPU == 8000000L
34#define ADC_PRESCALER ((1<<ADPS2) | (1<<ADPS0))
35#elif F_CPU == 4000000L
36#define ADC_PRESCALER ((1<<ADPS2))
37#elif F_CPU == 2000000L
38#define ADC_PRESCALER ((1<<ADPS1) | (1<<ADPS0))
39#elif F_CPU == 1000000L
40#define ADC_PRESCALER ((1<<ADPS1))
41#else
42#define ADC_PRESCALER ((1<<ADPS0))
43#endif
44
45// some avr-libc versions do not properly define ADHSM
46#if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
47#if !defined(ADHSM)
48#define ADHSM (7)
49#endif
50#endif
51
52#endif
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c
deleted file mode 100755
index 2506e3d8e..000000000
--- a/quantum/light_ws2812.c
+++ /dev/null
@@ -1,342 +0,0 @@
1/*
2* light weight WS2812 lib V2.0b
3*
4* Controls WS2811/WS2812/WS2812B RGB-LEDs
5* Author: Tim (cpldcpu@gmail.com)
6*
7* Jan 18th, 2014 v2.0b Initial Version
8* Nov 29th, 2015 v2.3 Added SK6812RGBW support
9*
10* This program is free software: you can redistribute it and/or modify
11* it under the terms of the GNU General Public License as published by
12* the Free Software Foundation, either version 2 of the License, or
13* (at your option) any later version.
14*
15* This program is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with this program. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "light_ws2812.h"
25#include <avr/interrupt.h>
26#include <avr/io.h>
27#include <util/delay.h>
28#include "debug.h"
29
30#ifdef RGBW_BB_TWI
31
32// Port for the I2C
33#define I2C_DDR DDRD
34#define I2C_PIN PIND
35#define I2C_PORT PORTD
36
37// Pins to be used in the bit banging
38#define I2C_CLK 0
39#define I2C_DAT 1
40
41#define I2C_DATA_HI()\
42I2C_DDR &= ~ (1 << I2C_DAT);\
43I2C_PORT |= (1 << I2C_DAT);
44#define I2C_DATA_LO()\
45I2C_DDR |= (1 << I2C_DAT);\
46I2C_PORT &= ~ (1 << I2C_DAT);
47
48#define I2C_CLOCK_HI()\
49I2C_DDR &= ~ (1 << I2C_CLK);\
50I2C_PORT |= (1 << I2C_CLK);
51#define I2C_CLOCK_LO()\
52I2C_DDR |= (1 << I2C_CLK);\
53I2C_PORT &= ~ (1 << I2C_CLK);
54
55#define I2C_DELAY 1
56
57void I2C_WriteBit(unsigned char c)
58{
59 if (c > 0)
60 {
61 I2C_DATA_HI();
62 }
63 else
64 {
65 I2C_DATA_LO();
66 }
67
68 I2C_CLOCK_HI();
69 _delay_us(I2C_DELAY);
70
71 I2C_CLOCK_LO();
72 _delay_us(I2C_DELAY);
73
74 if (c > 0)
75 {
76 I2C_DATA_LO();
77 }
78
79 _delay_us(I2C_DELAY);
80}
81
82// Inits bitbanging port, must be called before using the functions below
83//
84void I2C_Init(void)
85{
86 I2C_PORT &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
87
88 I2C_CLOCK_HI();
89 I2C_DATA_HI();
90
91 _delay_us(I2C_DELAY);
92}
93
94// Send a START Condition
95//
96void I2C_Start(void)
97{
98 // set both to high at the same time
99 I2C_DDR &= ~ ((1 << I2C_DAT) | (1 << I2C_CLK));
100 _delay_us(I2C_DELAY);
101
102 I2C_DATA_LO();
103 _delay_us(I2C_DELAY);
104
105 I2C_CLOCK_LO();
106 _delay_us(I2C_DELAY);
107}
108
109// Send a STOP Condition
110//
111void I2C_Stop(void)
112{
113 I2C_CLOCK_HI();
114 _delay_us(I2C_DELAY);
115
116 I2C_DATA_HI();
117 _delay_us(I2C_DELAY);
118}
119
120// write a byte to the I2C slave device
121//
122unsigned char I2C_Write(unsigned char c)
123{
124 for (char i = 0; i < 8; i++)
125 {
126 I2C_WriteBit(c & 128);
127
128 c <<= 1;
129 }
130
131
132 I2C_WriteBit(0);
133 _delay_us(I2C_DELAY);
134 _delay_us(I2C_DELAY);
135
136 // _delay_us(I2C_DELAY);
137 //return I2C_ReadBit();
138 return 0;
139}
140
141
142#endif
143
144// Setleds for standard RGB
145void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds)
146{
147 // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
148 ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF));
149}
150
151void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask)
152{
153 // ws2812_DDRREG |= pinmask; // Enable DDR
154 // new universal format (DDR)
155 _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
156
157 ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask);
158 _delay_us(50);
159}
160
161// Setleds for SK6812RGBW
162void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds)
163{
164
165 #ifdef RGBW_BB_TWI
166 uint8_t sreg_prev, twcr_prev;
167 sreg_prev=SREG;
168 twcr_prev=TWCR;
169 cli();
170 TWCR &= ~(1<<TWEN);
171 I2C_Init();
172 I2C_Start();
173 I2C_Write(0x84);
174 uint16_t datlen = leds<<2;
175 uint8_t curbyte;
176 uint8_t * data = (uint8_t*)ledarray;
177 while (datlen--) {
178 curbyte=*data++;
179 I2C_Write(curbyte);
180 }
181 I2C_Stop();
182 SREG=sreg_prev;
183 TWCR=twcr_prev;
184 #endif
185
186
187 // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
188 // new universal format (DDR)
189 _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
190
191 ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
192
193
194 #ifndef RGBW_BB_TWI
195 _delay_us(80);
196 #endif
197}
198
199void ws2812_sendarray(uint8_t *data,uint16_t datlen)
200{
201 ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF));
202}
203
204/*
205 This routine writes an array of bytes with RGB values to the Dataout pin
206 using the fast 800kHz clockless WS2811/2812 protocol.
207*/
208
209// Timing in ns
210#define w_zeropulse 350
211#define w_onepulse 900
212#define w_totalperiod 1250
213
214// Fixed cycles used by the inner loop
215#define w_fixedlow 2
216#define w_fixedhigh 4
217#define w_fixedtotal 8
218
219// Insert NOPs to match the timing, if possible
220#define w_zerocycles (((F_CPU/1000)*w_zeropulse )/1000000)
221#define w_onecycles (((F_CPU/1000)*w_onepulse +500000)/1000000)
222#define w_totalcycles (((F_CPU/1000)*w_totalperiod +500000)/1000000)
223
224// w1 - nops between rising edge and falling edge - low
225#define w1 (w_zerocycles-w_fixedlow)
226// w2 nops between fe low and fe high
227#define w2 (w_onecycles-w_fixedhigh-w1)
228// w3 nops to complete loop
229#define w3 (w_totalcycles-w_fixedtotal-w1-w2)
230
231#if w1>0
232 #define w1_nops w1
233#else
234 #define w1_nops 0
235#endif
236
237// The only critical timing parameter is the minimum pulse length of the "0"
238// Warn or throw error if this timing can not be met with current F_CPU settings.
239#define w_lowtime ((w1_nops+w_fixedlow)*1000000)/(F_CPU/1000)
240#if w_lowtime>550
241 #error "Light_ws2812: Sorry, the clock speed is too low. Did you set F_CPU correctly?"
242#elif w_lowtime>450
243 #warning "Light_ws2812: The timing is critical and may only work on WS2812B, not on WS2812(S)."
244 #warning "Please consider a higher clockspeed, if possible"
245#endif
246
247#if w2>0
248#define w2_nops w2
249#else
250#define w2_nops 0
251#endif
252
253#if w3>0
254#define w3_nops w3
255#else
256#define w3_nops 0
257#endif
258
259#define w_nop1 "nop \n\t"
260#define w_nop2 "rjmp .+0 \n\t"
261#define w_nop4 w_nop2 w_nop2
262#define w_nop8 w_nop4 w_nop4
263#define w_nop16 w_nop8 w_nop8
264
265void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
266{
267 uint8_t curbyte,ctr,masklo;
268 uint8_t sreg_prev;
269
270 // masklo =~maskhi&ws2812_PORTREG;
271 // maskhi |= ws2812_PORTREG;
272 masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2);
273 maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
274 sreg_prev=SREG;
275 cli();
276
277 while (datlen--) {
278 curbyte=(*data++);
279
280 asm volatile(
281 " ldi %0,8 \n\t"
282 "loop%=: \n\t"
283 " out %2,%3 \n\t" // '1' [01] '0' [01] - re
284#if (w1_nops&1)
285w_nop1
286#endif
287#if (w1_nops&2)
288w_nop2
289#endif
290#if (w1_nops&4)
291w_nop4
292#endif
293#if (w1_nops&8)
294w_nop8
295#endif
296#if (w1_nops&16)
297w_nop16
298#endif
299 " sbrs %1,7 \n\t" // '1' [03] '0' [02]
300 " out %2,%4 \n\t" // '1' [--] '0' [03] - fe-low
301 " lsl %1 \n\t" // '1' [04] '0' [04]
302#if (w2_nops&1)
303 w_nop1
304#endif
305#if (w2_nops&2)
306 w_nop2
307#endif
308#if (w2_nops&4)
309 w_nop4
310#endif
311#if (w2_nops&8)
312 w_nop8
313#endif
314#if (w2_nops&16)
315 w_nop16
316#endif
317 " out %2,%4 \n\t" // '1' [+1] '0' [+1] - fe-high
318#if (w3_nops&1)
319w_nop1
320#endif
321#if (w3_nops&2)
322w_nop2
323#endif
324#if (w3_nops&4)
325w_nop4
326#endif
327#if (w3_nops&8)
328w_nop8
329#endif
330#if (w3_nops&16)
331w_nop16
332#endif
333
334 " dec %0 \n\t" // '1' [+2] '0' [+2]
335 " brne loop%=\n\t" // '1' [+3] '0' [+4]
336 : "=&d" (ctr)
337 : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo)
338 );
339 }
340
341 SREG=sreg_prev;
342}
diff --git a/quantum/light_ws2812.h b/quantum/light_ws2812.h
deleted file mode 100755
index 60924a0fb..000000000
--- a/quantum/light_ws2812.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * light weight WS2812 lib include
3 *
4 * Version 2.3 - Nev 29th 2015
5 * Author: Tim (cpldcpu@gmail.com)
6 *
7 * Please do not change this file! All configuration is handled in "ws2812_config.h"
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef LIGHT_WS2812_H_
24#define LIGHT_WS2812_H_
25
26#include <avr/io.h>
27#include <avr/interrupt.h>
28//#include "ws2812_config.h"
29//#include "i2cmaster.h"
30
31#ifdef RGBW
32 #define LED_TYPE struct cRGBW
33#else
34 #define LED_TYPE struct cRGB
35#endif
36
37
38/*
39 * Structure of the LED array
40 *
41 * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106
42 * cRGBW: RGBW for SK6812RGBW
43 */
44
45struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
46struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;};
47
48
49
50/* User Interface
51 *
52 * Input:
53 * ledarray: An array of GRB data describing the LED colors
54 * number_of_leds: The number of LEDs to write
55 * pinmask (optional): Bitmask describing the output bin. e.g. _BV(PB0)
56 *
57 * The functions will perform the following actions:
58 * - Set the data-out pin as output
59 * - Send out the LED data
60 * - Wait 50�s to reset the LEDs
61 */
62
63void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
64void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
65void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
66
67/*
68 * Old interface / Internal functions
69 *
70 * The functions take a byte-array and send to the data output as WS2812 bitstream.
71 * The length is the number of bytes to send - three per LED.
72 */
73
74void ws2812_sendarray (uint8_t *array,uint16_t length);
75void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
76
77
78/*
79 * Internal defines
80 */
81#ifndef CONCAT
82#define CONCAT(a, b) a ## b
83#endif
84#ifndef CONCAT_EXP
85#define CONCAT_EXP(a, b) CONCAT(a, b)
86#endif
87
88// #define ws2812_PORTREG CONCAT_EXP(PORT,ws2812_port)
89// #define ws2812_DDRREG CONCAT_EXP(DDR,ws2812_port)
90
91#endif /* LIGHT_WS2812_H_ */
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 92130192c..8fea96a9e 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -61,7 +61,7 @@
61#include <stdint.h> 61#include <stdint.h>
62#include <stdbool.h> 62#include <stdbool.h>
63#include "eeconfig.h" 63#include "eeconfig.h"
64#include "light_ws2812.h" 64#include "ws2812.h"
65 65
66extern LED_TYPE led[RGBLED_NUM]; 66extern LED_TYPE led[RGBLED_NUM];
67 67
diff --git a/quantum/visualizer/common_gfxconf.h b/quantum/visualizer/common_gfxconf.h
new file mode 100644
index 000000000..eb705b188
--- /dev/null
+++ b/quantum/visualizer/common_gfxconf.h
@@ -0,0 +1,325 @@
1/**
2 * This file has a different license to the rest of the uGFX system.
3 * You can copy, modify and distribute this file as you see fit.
4 * You do not need to publish your source modifications to this file.
5 * The only thing you are not permitted to do is to relicense it
6 * under a different license.
7 */
8
9/**
10 * Copy this file into your project directory and rename it as gfxconf.h
11 * Edit your copy to turn on the uGFX features you want to use.
12 * The values below are the defaults.
13 *
14 * Only remove the comments from lines where you want to change the
15 * default value. This allows definitions to be included from
16 * driver makefiles when required and provides the best future
17 * compatibility for your project.
18 *
19 * Please use spaces instead of tabs in this file.
20 */
21
22#ifndef COMMON_GFXCONF_H
23#define COMMON_GFXCONF_H
24
25
26///////////////////////////////////////////////////////////////////////////
27// GOS - One of these must be defined, preferably in your Makefile //
28///////////////////////////////////////////////////////////////////////////
29//#define GFX_USE_OS_CHIBIOS TRUE
30//#define GFX_USE_OS_FREERTOS FALSE
31// #define GFX_FREERTOS_USE_TRACE FALSE
32//#define GFX_USE_OS_WIN32 FALSE
33//#define GFX_USE_OS_LINUX FALSE
34//#define GFX_USE_OS_OSX FALSE
35//#define GFX_USE_OS_ECOS FALSE
36//#define GFX_USE_OS_RAWRTOS FALSE
37//#define GFX_USE_OS_ARDUINO FALSE
38//#define GFX_USE_OS_KEIL FALSE
39//#define GFX_USE_OS_CMSIS FALSE
40//#define GFX_USE_OS_RAW32 FALSE
41// #define INTERRUPTS_OFF() optional_code
42// #define INTERRUPTS_ON() optional_code
43// These are not defined by default for some reason
44#define GOS_NEED_X_THREADS FALSE
45#define GOS_NEED_X_HEAP FALSE
46
47// Options that (should where relevant) apply to all operating systems
48 #define GFX_NO_INLINE FALSE
49// #define GFX_COMPILER GFX_COMPILER_UNKNOWN
50// #define GFX_CPU GFX_CPU_UNKNOWN
51// #define GFX_OS_HEAP_SIZE 0
52// #define GFX_OS_NO_INIT FALSE
53// #define GFX_OS_INIT_NO_WARNING FALSE
54// #define GFX_OS_PRE_INIT_FUNCTION myHardwareInitRoutine
55// #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine
56// #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine
57
58
59///////////////////////////////////////////////////////////////////////////
60// GDISP //
61///////////////////////////////////////////////////////////////////////////
62#define GFX_USE_GDISP TRUE
63
64//#define GDISP_NEED_AUTOFLUSH FALSE
65//#define GDISP_NEED_TIMERFLUSH FALSE
66//#define GDISP_NEED_VALIDATION TRUE
67//#define GDISP_NEED_CLIP TRUE
68#define GDISP_NEED_CIRCLE TRUE
69#define GDISP_NEED_ELLIPSE TRUE
70#define GDISP_NEED_ARC TRUE
71#define GDISP_NEED_ARCSECTORS TRUE
72#define GDISP_NEED_CONVEX_POLYGON TRUE
73//#define GDISP_NEED_SCROLL FALSE
74#define GDISP_NEED_PIXELREAD TRUE
75#define GDISP_NEED_CONTROL TRUE
76//#define GDISP_NEED_QUERY FALSE
77//#define GDISP_NEED_MULTITHREAD FALSE
78//#define GDISP_NEED_STREAMING FALSE
79#define GDISP_NEED_TEXT TRUE
80// #define GDISP_NEED_TEXT_WORDWRAP FALSE
81// #define GDISP_NEED_ANTIALIAS FALSE
82// #define GDISP_NEED_UTF8 FALSE
83 #define GDISP_NEED_TEXT_KERNING TRUE
84// #define GDISP_INCLUDE_FONT_UI1 FALSE
85// #define GDISP_INCLUDE_FONT_UI2 FALSE // The smallest preferred font.
86// #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE
87// #define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE
88// #define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE
89// #define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE
90// #define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE
91// #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE
92// #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE
93 #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 TRUE
94// #define GDISP_INCLUDE_FONT_FIXED_10X20 FALSE
95// #define GDISP_INCLUDE_FONT_FIXED_7X14 FALSE
96 #define GDISP_INCLUDE_FONT_FIXED_5X8 TRUE
97// #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE
98// #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE
99// #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA FALSE
100// #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE
101// #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE
102// #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE
103// #define GDISP_INCLUDE_USER_FONTS FALSE
104
105//#define GDISP_NEED_IMAGE FALSE
106// #define GDISP_NEED_IMAGE_NATIVE FALSE
107// #define GDISP_NEED_IMAGE_GIF FALSE
108// #define GDISP_NEED_IMAGE_BMP FALSE
109// #define GDISP_NEED_IMAGE_BMP_1 FALSE
110// #define GDISP_NEED_IMAGE_BMP_4 FALSE
111// #define GDISP_NEED_IMAGE_BMP_4_RLE FALSE
112// #define GDISP_NEED_IMAGE_BMP_8 FALSE
113// #define GDISP_NEED_IMAGE_BMP_8_RLE FALSE
114// #define GDISP_NEED_IMAGE_BMP_16 FALSE
115// #define GDISP_NEED_IMAGE_BMP_24 FALSE
116// #define GDISP_NEED_IMAGE_BMP_32 FALSE
117// #define GDISP_NEED_IMAGE_JPG FALSE
118// #define GDISP_NEED_IMAGE_PNG FALSE
119// #define GDISP_NEED_IMAGE_ACCOUNTING FALSE
120#ifdef EMULATOR
121#define GDISP_NEED_PIXMAP TRUE
122#endif
123// #define GDISP_NEED_PIXMAP_IMAGE FALSE
124
125//#define GDISP_DEFAULT_ORIENTATION GDISP_ROTATE_LANDSCAPE // If not defined the native hardware orientation is used.
126//#define GDISP_LINEBUF_SIZE 128
127//#define GDISP_STARTUP_COLOR Black
128#define GDISP_NEED_STARTUP_LOGO FALSE
129
130//#define GDISP_TOTAL_DISPLAYS 2
131
132 #ifdef GDISP_DRIVER_LIST
133 // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
134 #define GDISP_HARDWARE_STREAM_WRITE FALSE
135 #define GDISP_HARDWARE_STREAM_READ FALSE
136 #define GDISP_HARDWARE_STREAM_POS FALSE
137 #define GDISP_HARDWARE_DRAWPIXEL TRUE
138 #define GDISP_HARDWARE_CLEARS FALSE
139 #define GDISP_HARDWARE_FILLS FALSE
140 //#define GDISP_HARDWARE_BITFILLS FALSE
141 #define GDISP_HARDWARE_SCROLL FALSE
142 #define GDISP_HARDWARE_PIXELREAD TRUE
143 #define GDISP_HARDWARE_CONTROL TRUE
144 #define GDISP_HARDWARE_QUERY FALSE
145 #define GDISP_HARDWARE_CLIP FALSE
146
147 #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
148 #endif
149
150// The custom format is not defined for some reason, so define it as error
151// so we don't get compiler warnings
152#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
153
154#define GDISP_USE_GFXNET FALSE
155// #define GDISP_GFXNET_PORT 13001
156// #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
157// #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
158// #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
159
160
161///////////////////////////////////////////////////////////////////////////
162// GWIN //
163///////////////////////////////////////////////////////////////////////////
164#define GFX_USE_GWIN FALSE
165
166//#define GWIN_NEED_WINDOWMANAGER FALSE
167// #define GWIN_REDRAW_IMMEDIATE FALSE
168// #define GWIN_REDRAW_SINGLEOP FALSE
169// #define GWIN_NEED_FLASHING FALSE
170// #define GWIN_FLASHING_PERIOD 250
171
172//#define GWIN_NEED_CONSOLE FALSE
173// #define GWIN_CONSOLE_USE_HISTORY FALSE
174// #define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
175// #define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
176// #define GWIN_CONSOLE_ESCSEQ FALSE
177// #define GWIN_CONSOLE_USE_BASESTREAM FALSE
178// #define GWIN_CONSOLE_USE_FLOAT FALSE
179//#define GWIN_NEED_GRAPH FALSE
180//#define GWIN_NEED_GL3D FALSE
181
182//#define GWIN_NEED_WIDGET FALSE
183//#define GWIN_FOCUS_HIGHLIGHT_WIDTH 1
184// #define GWIN_NEED_LABEL FALSE
185// #define GWIN_LABEL_ATTRIBUTE FALSE
186// #define GWIN_NEED_BUTTON FALSE
187// #define GWIN_BUTTON_LAZY_RELEASE FALSE
188// #define GWIN_NEED_SLIDER FALSE
189// #define GWIN_SLIDER_NOSNAP FALSE
190// #define GWIN_SLIDER_DEAD_BAND 5
191// #define GWIN_SLIDER_TOGGLE_INC 20
192// #define GWIN_NEED_CHECKBOX FALSE
193// #define GWIN_NEED_IMAGE FALSE
194// #define GWIN_NEED_IMAGE_ANIMATION FALSE
195// #define GWIN_NEED_RADIO FALSE
196// #define GWIN_NEED_LIST FALSE
197// #define GWIN_NEED_LIST_IMAGES FALSE
198// #define GWIN_NEED_PROGRESSBAR FALSE
199// #define GWIN_PROGRESSBAR_AUTO FALSE
200// #define GWIN_NEED_KEYBOARD FALSE
201// #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1
202// #define GWIN_NEED_KEYBOARD_ENGLISH1 TRUE
203// #define GWIN_NEED_TEXTEDIT FALSE
204// #define GWIN_FLAT_STYLING FALSE
205// #define GWIN_WIDGET_TAGS FALSE
206
207//#define GWIN_NEED_CONTAINERS FALSE
208// #define GWIN_NEED_CONTAINER FALSE
209// #define GWIN_NEED_FRAME FALSE
210// #define GWIN_NEED_TABSET FALSE
211// #define GWIN_TABSET_TABHEIGHT 18
212
213
214///////////////////////////////////////////////////////////////////////////
215// GEVENT //
216///////////////////////////////////////////////////////////////////////////
217#define GFX_USE_GEVENT TRUE
218
219//#define GEVENT_ASSERT_NO_RESOURCE FALSE
220//#define GEVENT_MAXIMUM_SIZE 32
221//#define GEVENT_MAX_SOURCE_LISTENERS 32
222
223
224///////////////////////////////////////////////////////////////////////////
225// GTIMER //
226///////////////////////////////////////////////////////////////////////////
227#define GFX_USE_GTIMER FALSE
228
229//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
230//#define GTIMER_THREAD_WORKAREA_SIZE 2048
231
232
233///////////////////////////////////////////////////////////////////////////
234// GQUEUE //
235///////////////////////////////////////////////////////////////////////////
236#define GFX_USE_GQUEUE FALSE
237
238//#define GQUEUE_NEED_ASYNC FALSE
239//#define GQUEUE_NEED_GSYNC FALSE
240//#define GQUEUE_NEED_FSYNC FALSE
241//#define GQUEUE_NEED_BUFFERS FALSE
242
243///////////////////////////////////////////////////////////////////////////
244// GINPUT //
245///////////////////////////////////////////////////////////////////////////
246#define GFX_USE_GINPUT FALSE
247
248//#define GINPUT_NEED_MOUSE FALSE
249// #define GINPUT_TOUCH_STARTRAW FALSE
250// #define GINPUT_TOUCH_NOTOUCH FALSE
251// #define GINPUT_TOUCH_NOCALIBRATE FALSE
252// #define GINPUT_TOUCH_NOCALIBRATE_GUI FALSE
253// #define GINPUT_MOUSE_POLL_PERIOD 25
254// #define GINPUT_MOUSE_CLICK_TIME 300
255// #define GINPUT_TOUCH_CXTCLICK_TIME 700
256// #define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
257// #define GINPUT_TOUCH_USER_CALIBRATION_SAVE FALSE
258// #define GMOUSE_DRIVER_LIST GMOUSEVMT_Win32, GMOUSEVMT_Win32
259//#define GINPUT_NEED_KEYBOARD FALSE
260// #define GINPUT_KEYBOARD_POLL_PERIOD 200
261// #define GKEYBOARD_DRIVER_LIST GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32
262// #define GKEYBOARD_LAYOUT_OFF FALSE
263// #define GKEYBOARD_LAYOUT_SCANCODE2_US FALSE
264//#define GINPUT_NEED_TOGGLE FALSE
265//#define GINPUT_NEED_DIAL FALSE
266
267
268///////////////////////////////////////////////////////////////////////////
269// GFILE //
270///////////////////////////////////////////////////////////////////////////
271#define GFX_USE_GFILE FALSE
272
273//#define GFILE_NEED_PRINTG FALSE
274//#define GFILE_NEED_SCANG FALSE
275//#define GFILE_NEED_STRINGS FALSE
276//#define GFILE_NEED_FILELISTS FALSE
277//#define GFILE_NEED_STDIO FALSE
278//#define GFILE_NEED_NOAUTOMOUNT FALSE
279//#define GFILE_NEED_NOAUTOSYNC FALSE
280
281//#define GFILE_NEED_MEMFS FALSE
282//#define GFILE_NEED_ROMFS FALSE
283//#define GFILE_NEED_RAMFS FALSE
284//#define GFILE_NEED_FATFS FALSE
285//#define GFILE_NEED_NATIVEFS FALSE
286//#define GFILE_NEED_CHBIOSFS FALSE
287
288//#define GFILE_ALLOW_FLOATS FALSE
289//#define GFILE_ALLOW_DEVICESPECIFIC FALSE
290//#define GFILE_MAX_GFILES 3
291
292///////////////////////////////////////////////////////////////////////////
293// GADC //
294///////////////////////////////////////////////////////////////////////////
295#define GFX_USE_GADC FALSE
296
297//#define GADC_MAX_LOWSPEED_DEVICES 4
298
299
300///////////////////////////////////////////////////////////////////////////
301// GAUDIO //
302///////////////////////////////////////////////////////////////////////////
303#define GFX_USE_GAUDIO FALSE
304// There seems to be a bug in the ugfx code, the wrong define is used
305// So define it in order to avoid warnings
306#define GFX_USE_GAUDIN GFX_USE_GAUDIO
307// #define GAUDIO_NEED_PLAY FALSE
308// #define GAUDIO_NEED_RECORD FALSE
309
310
311///////////////////////////////////////////////////////////////////////////
312// GMISC //
313///////////////////////////////////////////////////////////////////////////
314#define GFX_USE_GMISC TRUE
315
316//#define GMISC_NEED_ARRAYOPS FALSE
317//#define GMISC_NEED_FASTTRIG FALSE
318//#define GMISC_NEED_FIXEDTRIG FALSE
319//#define GMISC_NEED_INVSQRT FALSE
320// #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
321// #define GMISC_INVSQRT_REAL_SLOW FALSE
322#define GMISC_NEED_MATRIXFLOAT2D TRUE
323#define GMISC_NEED_MATRIXFIXED2D FALSE
324
325#endif /* COMMON_GFXCONF_H */
diff --git a/quantum/visualizer/default_animations.c b/quantum/visualizer/default_animations.c
new file mode 100644
index 000000000..2d0327372
--- /dev/null
+++ b/quantum/visualizer/default_animations.c
@@ -0,0 +1,176 @@
1/* Copyright 2017 Fred Sundvik
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#if defined(VISUALIZER_ENABLE)
18
19#include "default_animations.h"
20#include "visualizer.h"
21#ifdef LCD_ENABLE
22#include "lcd_keyframes.h"
23#endif
24#ifdef LCD_BACKLIGHT_ENABLE
25#include "lcd_backlight_keyframes.h"
26#endif
27
28#ifdef BACKLIGHT_ENABLE
29#include "led_backlight_keyframes.h"
30#endif
31
32#include "visualizer_keyframes.h"
33
34
35#if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE)
36
37static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
38#ifdef LCD_ENABLE
39 lcd_keyframe_enable(animation, state);
40#endif
41#ifdef LCD_BACKLIGHT_ENABLE
42 lcd_backlight_keyframe_enable(animation, state);
43#endif
44#ifdef BACKLIGHT_ENABLE
45 led_backlight_keyframe_enable(animation, state);
46#endif
47 return false;
48}
49
50static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
51#ifdef LCD_ENABLE
52 lcd_keyframe_disable(animation, state);
53#endif
54#ifdef LCD_BACKLIGHT_ENABLE
55 lcd_backlight_keyframe_disable(animation, state);
56#endif
57#ifdef BACKLIGHT_ENABLE
58 led_backlight_keyframe_disable(animation, state);
59#endif
60 return false;
61}
62
63static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) {
64 bool ret = false;
65#ifdef LCD_BACKLIGHT_ENABLE
66 ret |= lcd_backlight_keyframe_animate_color(animation, state);
67#endif
68#ifdef BACKLIGHT_ENABLE
69 ret |= led_backlight_keyframe_fade_in_all(animation, state);
70#endif
71 return ret;
72}
73
74static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) {
75 bool ret = false;
76#ifdef LCD_BACKLIGHT_ENABLE
77 ret |= lcd_backlight_keyframe_animate_color(animation, state);
78#endif
79#ifdef BACKLIGHT_ENABLE
80 ret |= led_backlight_keyframe_fade_out_all(animation, state);
81#endif
82 return ret;
83}
84
85
86// Don't worry, if the startup animation is long, you can use the keyboard like normal
87// during that time
88keyframe_animation_t default_startup_animation = {
89#if LCD_ENABLE
90 .num_frames = 3,
91#else
92 .num_frames = 2,
93#endif
94 .loop = false,
95 .frame_lengths = {
96 0,
97#if LCD_ENABLE
98 0,
99#endif
100 gfxMillisecondsToTicks(5000)},
101 .frame_functions = {
102 keyframe_enable,
103#if LCD_ENABLE
104 lcd_keyframe_draw_logo,
105#endif
106 keyframe_fade_in,
107 },
108};
109
110keyframe_animation_t default_suspend_animation = {
111#if LCD_ENABLE
112 .num_frames = 3,
113#else
114 .num_frames = 2,
115#endif
116 .loop = false,
117 .frame_lengths = {
118#if LCD_ENABLE
119 0,
120#endif
121 gfxMillisecondsToTicks(1000),
122 0},
123 .frame_functions = {
124#if LCD_ENABLE
125 lcd_keyframe_display_layer_text,
126#endif
127 keyframe_fade_out,
128 keyframe_disable,
129 },
130};
131#endif
132
133#if defined(BACKLIGHT_ENABLE)
134#define CROSSFADE_TIME 1000
135#define GRADIENT_TIME 3000
136
137keyframe_animation_t led_test_animation = {
138 .num_frames = 14,
139 .loop = true,
140 .frame_lengths = {
141 gfxMillisecondsToTicks(1000), // fade in
142 gfxMillisecondsToTicks(1000), // no op (leds on)
143 gfxMillisecondsToTicks(1000), // fade out
144 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
145 gfxMillisecondsToTicks(GRADIENT_TIME), // left to rigt (outside in)
146 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
147 gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
148 0, // mirror leds
149 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
150 gfxMillisecondsToTicks(GRADIENT_TIME), // left_to_right (mirrored, so inside out)
151 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
152 gfxMillisecondsToTicks(GRADIENT_TIME), // top_to_bottom
153 0, // normal leds
154 gfxMillisecondsToTicks(CROSSFADE_TIME), // crossfade
155
156 },
157 .frame_functions = {
158 led_backlight_keyframe_fade_in_all,
159 keyframe_no_operation,
160 led_backlight_keyframe_fade_out_all,
161 led_backlight_keyframe_crossfade,
162 led_backlight_keyframe_left_to_right_gradient,
163 led_backlight_keyframe_crossfade,
164 led_backlight_keyframe_top_to_bottom_gradient,
165 led_backlight_keyframe_mirror_orientation,
166 led_backlight_keyframe_crossfade,
167 led_backlight_keyframe_left_to_right_gradient,
168 led_backlight_keyframe_crossfade,
169 led_backlight_keyframe_top_to_bottom_gradient,
170 led_backlight_keyframe_normal_orientation,
171 led_backlight_keyframe_crossfade,
172 },
173};
174#endif
175
176#endif
diff --git a/quantum/visualizer/lcd_backlight_keyframes.h b/quantum/visualizer/default_animations.h
index e1c125cf9..51320b8b8 100644
--- a/quantum/visualizer/lcd_backlight_keyframes.h
+++ b/quantum/visualizer/default_animations.h
@@ -14,17 +14,17 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16 16
17#ifndef QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ 17#ifndef DEFAULT_ANIMATIONS_H_
18#define QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ 18#define DEFAULT_ANIMATIONS_H_
19 19
20#include "visualizer.h" 20#include "visualizer.h"
21 21
22// Animates the LCD backlight color between the current color and the target color (of the state) 22// You can use these default animations, but of course you can also write your own custom ones instead
23bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state); 23extern keyframe_animation_t default_startup_animation;
24// Sets the backlight color to the target color 24extern keyframe_animation_t default_suspend_animation;
25bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state);
26 25
27bool backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); 26// An animation for testing and demonstrating the led support, should probably not be used for real world
28bool backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); 27// cases
28extern keyframe_animation_t led_test_animation;
29 29
30#endif /* QUANTUM_VISUALIZER_LCD_BACKLIGHT_KEYFRAMES_H_ */ 30#endif /* DEFAULT_ANIMATIONS_H_ */
diff --git a/quantum/visualizer/lcd_backlight_keyframes.c b/quantum/visualizer/lcd_backlight_keyframes.c
index 8436d4e3d..8c402baf6 100644
--- a/quantum/visualizer/lcd_backlight_keyframes.c
+++ b/quantum/visualizer/lcd_backlight_keyframes.c
@@ -16,7 +16,7 @@
16 16
17#include "lcd_backlight_keyframes.h" 17#include "lcd_backlight_keyframes.h"
18 18
19bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state) { 19bool 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);
@@ -49,7 +49,7 @@ bool backlight_keyframe_animate_color(keyframe_animation_t* animation, visualize
49 return true; 49 return true;
50} 50}
51 51
52bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { 52bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) {
53 (void)animation; 53 (void)animation;
54 state->prev_lcd_color = state->target_lcd_color; 54 state->prev_lcd_color = state->target_lcd_color;
55 state->current_lcd_color = state->target_lcd_color; 55 state->current_lcd_color = state->target_lcd_color;
@@ -60,14 +60,14 @@ bool backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_st
60 return false; 60 return false;
61} 61}
62 62
63bool backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { 63bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
64 (void)animation; 64 (void)animation;
65 (void)state; 65 (void)state;
66 lcd_backlight_hal_color(0, 0, 0); 66 lcd_backlight_hal_color(0, 0, 0);
67 return false; 67 return false;
68} 68}
69 69
70bool backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { 70bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
71 (void)animation; 71 (void)animation;
72 (void)state; 72 (void)state;
73 lcd_backlight_color(LCD_HUE(state->current_lcd_color), 73 lcd_backlight_color(LCD_HUE(state->current_lcd_color),
diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c
index 82e4184d2..75eb45700 100644
--- a/quantum/visualizer/lcd_keyframes.c
+++ b/quantum/visualizer/lcd_keyframes.c
@@ -166,8 +166,8 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t*
166 // or state structs, here we use the image 166 // or state structs, here we use the image
167 167
168 //gdispGBlitArea is a tricky function to use since it supports blitting part of the image 168 //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 128 and 32 for both source and target dimensions 169 // 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, 128, 32, 0, 0, 128, (pixel_t*)resource_lcd_logo); 170 gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo);
171 171
172 return false; 172 return false;
173} 173}
diff --git a/quantum/visualizer/led_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c
index 7e6e5d1ab..eb3f5561d 100644
--- a/quantum/visualizer/led_keyframes.c
+++ b/quantum/visualizer/led_backlight_keyframes.c
@@ -23,7 +23,7 @@ SOFTWARE.
23*/ 23*/
24#include "gfx.h" 24#include "gfx.h"
25#include "math.h" 25#include "math.h"
26#include "led_keyframes.h" 26#include "led_backlight_keyframes.h"
27 27
28static uint8_t fade_led_color(keyframe_animation_t* animation, int from, int to) { 28static 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];
@@ -41,8 +41,8 @@ static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint
41} 41}
42 42
43// TODO: Should be customizable per keyboard 43// TODO: Should be customizable per keyboard
44#define NUM_ROWS LED_NUM_ROWS 44#define NUM_ROWS LED_HEIGHT
45#define NUM_COLS LED_NUM_COLS 45#define NUM_COLS LED_WIDTH
46 46
47static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; 47static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
48static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; 48static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
@@ -55,19 +55,19 @@ static uint8_t compute_gradient_color(float t, float index, float num) {
55 return (uint8_t)(255.0f * v); 55 return (uint8_t)(255.0f * v);
56} 56}
57 57
58bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) { 58bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) {
59 (void)state; 59 (void)state;
60 keyframe_fade_all_leds_from_to(animation, 0, 255); 60 keyframe_fade_all_leds_from_to(animation, 0, 255);
61 return true; 61 return true;
62} 62}
63 63
64bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) { 64bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) {
65 (void)state; 65 (void)state;
66 keyframe_fade_all_leds_from_to(animation, 255, 0); 66 keyframe_fade_all_leds_from_to(animation, 255, 0);
67 return true; 67 return true;
68} 68}
69 69
70bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { 70bool 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;
@@ -79,7 +79,7 @@ bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visual
79 return true; 79 return true;
80} 80}
81 81
82bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { 82bool 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;
@@ -98,7 +98,7 @@ static void copy_current_led_state(uint8_t* dest) {
98 } 98 }
99 } 99 }
100} 100}
101bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) { 101bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) {
102 (void)state; 102 (void)state;
103 if (animation->first_update_of_frame) { 103 if (animation->first_update_of_frame) {
104 copy_current_led_state(&crossfade_start_frame[0][0]); 104 copy_current_led_state(&crossfade_start_frame[0][0]);
@@ -114,28 +114,28 @@ bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t*
114 return true; 114 return true;
115} 115}
116 116
117bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { 117bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
118 (void)state; 118 (void)state;
119 (void)animation; 119 (void)animation;
120 gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180); 120 gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180);
121 return false; 121 return false;
122} 122}
123 123
124bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { 124bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) {
125 (void)state; 125 (void)state;
126 (void)animation; 126 (void)animation;
127 gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); 127 gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0);
128 return false; 128 return false;
129} 129}
130 130
131bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { 131bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) {
132 (void)state; 132 (void)state;
133 (void)animation; 133 (void)animation;
134 gdispGSetPowerMode(LED_DISPLAY, powerOff); 134 gdispGSetPowerMode(LED_DISPLAY, powerOff);
135 return false; 135 return false;
136} 136}
137 137
138bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { 138bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) {
139 (void)state; 139 (void)state;
140 (void)animation; 140 (void)animation;
141 gdispGSetPowerMode(LED_DISPLAY, powerOn); 141 gdispGSetPowerMode(LED_DISPLAY, powerOn);
diff --git a/quantum/visualizer/led_keyframes.h b/quantum/visualizer/led_backlight_keyframes.h
index a59a4f37d..487151013 100644
--- a/quantum/visualizer/led_keyframes.h
+++ b/quantum/visualizer/led_backlight_keyframes.h
@@ -22,21 +22,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE. 22SOFTWARE.
23*/ 23*/
24 24
25#ifndef LED_KEYFRAMES_H 25#ifndef LED_BACKLIGHT_KEYFRAMES_H
26#define LED_KEYFRAMES_H 26#define LED_BACKLIGHT_KEYFRAMES_H
27 27
28#include "visualizer.h" 28#include "visualizer.h"
29 29
30bool led_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state); 30bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state);
31bool led_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state); 31bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state);
32bool led_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state); 32bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
33bool led_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state); 33bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
34bool led_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state); 34bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
35bool led_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); 35bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
36bool led_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); 36bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
37 37
38bool led_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); 38bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state);
39bool led_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); 39bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state);
40 40
41extern keyframe_animation_t led_test_animation; 41extern keyframe_animation_t led_test_animation;
42 42
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index cc99d1e3b..5b4d8d603 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -52,7 +52,8 @@ SOFTWARE.
52 52
53// Define this in config.h 53// Define this in config.h
54#ifndef VISUALIZER_THREAD_PRIORITY 54#ifndef VISUALIZER_THREAD_PRIORITY
55#define "Visualizer thread priority not defined" 55// The visualizer needs gfx thread priorities
56#define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
56#endif 57#endif
57 58
58static visualizer_keyboard_status_t current_status = { 59static visualizer_keyboard_status_t current_status = {
@@ -255,6 +256,9 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
255 .mods = 0xFF, 256 .mods = 0xFF,
256 .leds = 0xFFFFFFFF, 257 .leds = 0xFFFFFFFF,
257 .suspended = false, 258 .suspended = false,
259 #ifdef BACKLIGHT_ENABLE
260 .backlight_level = 0,
261 #endif
258 #ifdef VISUALIZER_USER_DATA_SIZE 262 #ifdef VISUALIZER_USER_DATA_SIZE
259 .user_data = {0}, 263 .user_data = {0},
260 #endif 264 #endif
@@ -299,6 +303,7 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
299 else { 303 else {
300 gdispGSetPowerMode(LED_DISPLAY, powerOff); 304 gdispGSetPowerMode(LED_DISPLAY, powerOff);
301 } 305 }
306 state.status.backlight_level = current_status.backlight_level;
302 } 307 }
303 #endif 308 #endif
304 if (visualizer_enabled) { 309 if (visualizer_enabled) {
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk
index 0f7d8636c..102d23b7e 100644
--- a/quantum/visualizer/visualizer.mk
+++ b/quantum/visualizer/visualizer.mk
@@ -20,6 +20,30 @@
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21# SOFTWARE. 21# SOFTWARE.
22 22
23define ADD_DRIVER
24 $(1)_DRIVER:=$(strip $($(1)_DRIVER))
25 $(1)_WIDTH:=$(strip $($(1)_WIDTH))
26 $(1)_HEIGHT:=$(strip $($(1)_HEIGHT))
27 ifeq ($($(1)_DRIVER),)
28 $$(error $(1)_DRIVER is not defined)
29 endif
30 ifeq ($($(1)_WIDTH),)
31 $$(error $(1)_WIDTH is not defined)
32 endif
33 ifeq ($($(1)_HEIGHT),)
34 $$(error $(1)_HEIGHT is not defined)
35 endif
36 OPT_DEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
37 OPT_DEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
38 GFXDEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
39 GFXDEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
40 $(1)_DISPLAY_NUMBER:=$$(words $$(GDISP_DRIVER_LIST))
41 OPT_DEFS+=-D$(1)_DISPLAY_NUMBER=$$($(1)_DISPLAY_NUMBER)
42 include $(TOP_DIR)/drivers/ugfx/gdisp/$($(1)_DRIVER)/driver.mk
43endef
44
45GDISP_DRIVER_LIST:=
46
23SRC += $(VISUALIZER_DIR)/visualizer.c \ 47SRC += $(VISUALIZER_DIR)/visualizer.c \
24 $(VISUALIZER_DIR)/visualizer_keyframes.c 48 $(VISUALIZER_DIR)/visualizer_keyframes.c
25EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR) 49EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
@@ -40,16 +64,32 @@ SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c
40# Note, that the linker will strip out any resources that are not actually in use 64# Note, that the linker will strip out any resources that are not actually in use
41SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c 65SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c
42OPT_DEFS += -DLCD_BACKLIGHT_ENABLE 66OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
67$(eval $(call ADD_DRIVER,LCD))
43endif 68endif
44 69
45ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) 70ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
46SRC += $(VISUALIZER_DIR)/led_keyframes.c 71SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c
72$(eval $(call ADD_DRIVER,LED))
47endif 73endif
48 74
75SRC += $(VISUALIZER_DIR)/default_animations.c
76
49include $(GFXLIB)/gfx.mk 77include $(GFXLIB)/gfx.mk
78# For the common_gfxconf.h
79GFXINC += quantum/visualizer
80
50GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) 81GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
51GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) 82GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
52 83
84GDISP_LIST_COMMA=,
85GDISP_LIST_EMPTY=
86GDISP_LIST_SPACE=$(GDISP_LIST_EMPTY) $(GDISP_LIST_EMPTY)
87
88GDISP_DRIVER_LIST := $(strip $(GDISP_DRIVER_LIST))
89GDISP_DRIVER_LIST := $(subst $(GDISP_LIST_SPACE),$(GDISP_LIST_COMMA),$(GDISP_DRIVER_LIST))
90
91GFXDEFS +=-DGDISP_DRIVER_LIST="$(GDISP_DRIVER_LIST)"
92
53ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","") 93ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
54 SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c 94 SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
55else 95else