aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2016-07-07 00:20:20 +0300
committerFred Sundvik <fsundvik@gmail.com>2016-07-07 00:20:20 +0300
commit70797bb8f21c72cba15b314b2d0a6684bfedc369 (patch)
tree988c9464320f49d71037df05ecee443ba4282125
parent10f3a1b6215af2a1c74b0245e46f5b6352ee18a4 (diff)
downloadqmk_firmware-70797bb8f21c72cba15b314b2d0a6684bfedc369.tar.gz
qmk_firmware-70797bb8f21c72cba15b314b2d0a6684bfedc369.zip
Makefile changes and files to compile Visualizer
-rw-r--r--Makefile15
-rw-r--r--keyboards/infinity_ergodox/Makefile3
-rw-r--r--keyboards/infinity_ergodox/gfxconf.h331
-rw-r--r--keyboards/infinity_ergodox/lcd_backlight_hal.c84
-rw-r--r--keyboards/infinity_ergodox/visualizer_user.c168
-rw-r--r--quantum/visualizer/visualizer.c2
-rw-r--r--quantum/visualizer/visualizer.h2
-rw-r--r--quantum/visualizer/visualizer.mk22
8 files changed, 604 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 7c00ce2cc..a7a10bf32 100644
--- a/Makefile
+++ b/Makefile
@@ -218,14 +218,6 @@ ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
218 VAPTH += $(SERIAL_PATH) 218 VAPTH += $(SERIAL_PATH)
219endif 219endif
220 220
221ifeq ($(MASTER),right)
222 OPT_DEFS += -DMASTER_IS_ON_RIGHT
223else
224 ifneq ($(MASTER),left)
225$(error MASTER does not have a valid value(left/right))
226 endif
227endif
228
229# Optimize size but this may cause error "relocation truncated to fit" 221# Optimize size but this may cause error "relocation truncated to fit"
230#EXTRALDFLAGS = -Wl,--relax 222#EXTRALDFLAGS = -Wl,--relax
231 223
@@ -257,10 +249,17 @@ ifeq ($(PLATFORM),AVR)
257else ifeq ($(PLATFORM),CHIBIOS) 249else ifeq ($(PLATFORM),CHIBIOS)
258 include $(TMK_PATH)/protocol/chibios.mk 250 include $(TMK_PATH)/protocol/chibios.mk
259 include $(TMK_PATH)/chibios.mk 251 include $(TMK_PATH)/chibios.mk
252 OPT_OS = chibios
260else 253else
261 $(error Unknown platform) 254 $(error Unknown platform)
262endif 255endif
263 256
257ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
258 VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
259 VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
260 include $(VISUALIZER_PATH)/visualizer.mk
261endif
262
264include $(TMK_PATH)/rules.mk 263include $(TMK_PATH)/rules.mk
265 264
266GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S") 265GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
diff --git a/keyboards/infinity_ergodox/Makefile b/keyboards/infinity_ergodox/Makefile
index efa32e037..8be2f51b1 100644
--- a/keyboards/infinity_ergodox/Makefile
+++ b/keyboards/infinity_ergodox/Makefile
@@ -67,6 +67,9 @@ SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
67NKRO_ENABLE ?= yes # USB Nkey Rollover 67NKRO_ENABLE ?= yes # USB Nkey Rollover
68CUSTOM_MATRIX ?= yes # Custom matrix file 68CUSTOM_MATRIX ?= yes # Custom matrix file
69SERIAL_LINK_ENABLE = yes 69SERIAL_LINK_ENABLE = yes
70VISUALIZER_ENABLE ?= yes
71LCD_ENABLE ?= yes
72LCD_BACKLIGHT_ENABLE ?= yes
70 73
71ifndef QUANTUM_DIR 74ifndef QUANTUM_DIR
72 include ../../Makefile 75 include ../../Makefile
diff --git a/keyboards/infinity_ergodox/gfxconf.h b/keyboards/infinity_ergodox/gfxconf.h
new file mode 100644
index 000000000..8caa577b7
--- /dev/null
+++ b/keyboards/infinity_ergodox/gfxconf.h
@@ -0,0 +1,331 @@
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 _GFXCONF_H
23#define _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#ifndef EMULATOR
133#define GDISP_DRIVER_LIST GDISPVMT_ST7565_ERGODOX, GDISPVMT_IS31FL3731C_ERGODOX
134#else
135#define GDISP_DRIVER_LIST GDISPVMT_EMULATOR_LCD_ERGODOX, GDISPVMT_EMULATOR_LED_ERGODOX
136#endif
137
138 #ifdef GDISP_DRIVER_LIST
139 // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
140 #define GDISP_HARDWARE_STREAM_WRITE FALSE
141 #define GDISP_HARDWARE_STREAM_READ FALSE
142 #define GDISP_HARDWARE_STREAM_POS FALSE
143 #define GDISP_HARDWARE_DRAWPIXEL TRUE
144 #define GDISP_HARDWARE_CLEARS FALSE
145 #define GDISP_HARDWARE_FILLS FALSE
146 #define GDISP_HARDWARE_BITFILLS FALSE
147 #define GDISP_HARDWARE_SCROLL FALSE
148 #define GDISP_HARDWARE_PIXELREAD TRUE
149 #define GDISP_HARDWARE_CONTROL TRUE
150 #define GDISP_HARDWARE_QUERY FALSE
151 #define GDISP_HARDWARE_CLIP FALSE
152
153 #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
154 #endif
155
156// The custom format is not defined for some reason, so define it as error
157// so we don't get compiler warnings
158#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
159
160#define GDISP_USE_GFXNET FALSE
161// #define GDISP_GFXNET_PORT 13001
162// #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP FALSE
163// #define GDISP_DONT_WAIT_FOR_NET_DISPLAY FALSE
164// #define GDISP_GFXNET_UNSAFE_SOCKETS FALSE
165
166
167///////////////////////////////////////////////////////////////////////////
168// GWIN //
169///////////////////////////////////////////////////////////////////////////
170#define GFX_USE_GWIN FALSE
171
172//#define GWIN_NEED_WINDOWMANAGER FALSE
173// #define GWIN_REDRAW_IMMEDIATE FALSE
174// #define GWIN_REDRAW_SINGLEOP FALSE
175// #define GWIN_NEED_FLASHING FALSE
176// #define GWIN_FLASHING_PERIOD 250
177
178//#define GWIN_NEED_CONSOLE FALSE
179// #define GWIN_CONSOLE_USE_HISTORY FALSE
180// #define GWIN_CONSOLE_HISTORY_AVERAGING FALSE
181// #define GWIN_CONSOLE_HISTORY_ATCREATE FALSE
182// #define GWIN_CONSOLE_ESCSEQ FALSE
183// #define GWIN_CONSOLE_USE_BASESTREAM FALSE
184// #define GWIN_CONSOLE_USE_FLOAT FALSE
185//#define GWIN_NEED_GRAPH FALSE
186//#define GWIN_NEED_GL3D FALSE
187
188//#define GWIN_NEED_WIDGET FALSE
189//#define GWIN_FOCUS_HIGHLIGHT_WIDTH 1
190// #define GWIN_NEED_LABEL FALSE
191// #define GWIN_LABEL_ATTRIBUTE FALSE
192// #define GWIN_NEED_BUTTON FALSE
193// #define GWIN_BUTTON_LAZY_RELEASE FALSE
194// #define GWIN_NEED_SLIDER FALSE
195// #define GWIN_SLIDER_NOSNAP FALSE
196// #define GWIN_SLIDER_DEAD_BAND 5
197// #define GWIN_SLIDER_TOGGLE_INC 20
198// #define GWIN_NEED_CHECKBOX FALSE
199// #define GWIN_NEED_IMAGE FALSE
200// #define GWIN_NEED_IMAGE_ANIMATION FALSE
201// #define GWIN_NEED_RADIO FALSE
202// #define GWIN_NEED_LIST FALSE
203// #define GWIN_NEED_LIST_IMAGES FALSE
204// #define GWIN_NEED_PROGRESSBAR FALSE
205// #define GWIN_PROGRESSBAR_AUTO FALSE
206// #define GWIN_NEED_KEYBOARD FALSE
207// #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1
208// #define GWIN_NEED_KEYBOARD_ENGLISH1 TRUE
209// #define GWIN_NEED_TEXTEDIT FALSE
210// #define GWIN_FLAT_STYLING FALSE
211// #define GWIN_WIDGET_TAGS FALSE
212
213//#define GWIN_NEED_CONTAINERS FALSE
214// #define GWIN_NEED_CONTAINER FALSE
215// #define GWIN_NEED_FRAME FALSE
216// #define GWIN_NEED_TABSET FALSE
217// #define GWIN_TABSET_TABHEIGHT 18
218
219
220///////////////////////////////////////////////////////////////////////////
221// GEVENT //
222///////////////////////////////////////////////////////////////////////////
223#define GFX_USE_GEVENT TRUE
224
225//#define GEVENT_ASSERT_NO_RESOURCE FALSE
226//#define GEVENT_MAXIMUM_SIZE 32
227//#define GEVENT_MAX_SOURCE_LISTENERS 32
228
229
230///////////////////////////////////////////////////////////////////////////
231// GTIMER //
232///////////////////////////////////////////////////////////////////////////
233#define GFX_USE_GTIMER FALSE
234
235//#define GTIMER_THREAD_PRIORITY HIGH_PRIORITY
236//#define GTIMER_THREAD_WORKAREA_SIZE 2048
237
238
239///////////////////////////////////////////////////////////////////////////
240// GQUEUE //
241///////////////////////////////////////////////////////////////////////////
242#define GFX_USE_GQUEUE FALSE
243
244//#define GQUEUE_NEED_ASYNC FALSE
245//#define GQUEUE_NEED_GSYNC FALSE
246//#define GQUEUE_NEED_FSYNC FALSE
247//#define GQUEUE_NEED_BUFFERS FALSE
248
249///////////////////////////////////////////////////////////////////////////
250// GINPUT //
251///////////////////////////////////////////////////////////////////////////
252#define GFX_USE_GINPUT FALSE
253
254//#define GINPUT_NEED_MOUSE FALSE
255// #define GINPUT_TOUCH_STARTRAW FALSE
256// #define GINPUT_TOUCH_NOTOUCH FALSE
257// #define GINPUT_TOUCH_NOCALIBRATE FALSE
258// #define GINPUT_TOUCH_NOCALIBRATE_GUI FALSE
259// #define GINPUT_MOUSE_POLL_PERIOD 25
260// #define GINPUT_MOUSE_CLICK_TIME 300
261// #define GINPUT_TOUCH_CXTCLICK_TIME 700
262// #define GINPUT_TOUCH_USER_CALIBRATION_LOAD FALSE
263// #define GINPUT_TOUCH_USER_CALIBRATION_SAVE FALSE
264// #define GMOUSE_DRIVER_LIST GMOUSEVMT_Win32, GMOUSEVMT_Win32
265//#define GINPUT_NEED_KEYBOARD FALSE
266// #define GINPUT_KEYBOARD_POLL_PERIOD 200
267// #define GKEYBOARD_DRIVER_LIST GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32
268// #define GKEYBOARD_LAYOUT_OFF FALSE
269// #define GKEYBOARD_LAYOUT_SCANCODE2_US FALSE
270//#define GINPUT_NEED_TOGGLE FALSE
271//#define GINPUT_NEED_DIAL FALSE
272
273
274///////////////////////////////////////////////////////////////////////////
275// GFILE //
276///////////////////////////////////////////////////////////////////////////
277#define GFX_USE_GFILE FALSE
278
279//#define GFILE_NEED_PRINTG FALSE
280//#define GFILE_NEED_SCANG FALSE
281//#define GFILE_NEED_STRINGS FALSE
282//#define GFILE_NEED_FILELISTS FALSE
283//#define GFILE_NEED_STDIO FALSE
284//#define GFILE_NEED_NOAUTOMOUNT FALSE
285//#define GFILE_NEED_NOAUTOSYNC FALSE
286
287//#define GFILE_NEED_MEMFS FALSE
288//#define GFILE_NEED_ROMFS FALSE
289//#define GFILE_NEED_RAMFS FALSE
290//#define GFILE_NEED_FATFS FALSE
291//#define GFILE_NEED_NATIVEFS FALSE
292//#define GFILE_NEED_CHBIOSFS FALSE
293
294//#define GFILE_ALLOW_FLOATS FALSE
295//#define GFILE_ALLOW_DEVICESPECIFIC FALSE
296//#define GFILE_MAX_GFILES 3
297
298///////////////////////////////////////////////////////////////////////////
299// GADC //
300///////////////////////////////////////////////////////////////////////////
301#define GFX_USE_GADC FALSE
302
303//#define GADC_MAX_LOWSPEED_DEVICES 4
304
305
306///////////////////////////////////////////////////////////////////////////
307// GAUDIO //
308///////////////////////////////////////////////////////////////////////////
309#define GFX_USE_GAUDIO FALSE
310// There seems to be a bug in the ugfx code, the wrong define is used
311// So define it in order to avoid warnings
312#define GFX_USE_GAUDIN GFX_USE_GAUDIO
313// #define GAUDIO_NEED_PLAY FALSE
314// #define GAUDIO_NEED_RECORD FALSE
315
316
317///////////////////////////////////////////////////////////////////////////
318// GMISC //
319///////////////////////////////////////////////////////////////////////////
320#define GFX_USE_GMISC TRUE
321
322//#define GMISC_NEED_ARRAYOPS FALSE
323//#define GMISC_NEED_FASTTRIG FALSE
324//#define GMISC_NEED_FIXEDTRIG FALSE
325//#define GMISC_NEED_INVSQRT FALSE
326// #define GMISC_INVSQRT_MIXED_ENDIAN FALSE
327// #define GMISC_INVSQRT_REAL_SLOW FALSE
328#define GMISC_NEED_MATRIXFLOAT2D TRUE
329#define GMISC_NEED_MATRIXFIXED2D FALSE
330
331#endif /* _GFXCONF_H */
diff --git a/keyboards/infinity_ergodox/lcd_backlight_hal.c b/keyboards/infinity_ergodox/lcd_backlight_hal.c
new file mode 100644
index 000000000..05fc810b4
--- /dev/null
+++ b/keyboards/infinity_ergodox/lcd_backlight_hal.c
@@ -0,0 +1,84 @@
1/*
2Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
3Jun Wako <wakojun@gmail.com>
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "lcd_backlight.h"
19#include "hal.h"
20
21#define RED_PIN 1
22#define GREEN_PIN 2
23#define BLUE_PIN 3
24#define CHANNEL_RED FTM0->CHANNEL[0]
25#define CHANNEL_GREEN FTM0->CHANNEL[1]
26#define CHANNEL_BLUE FTM0->CHANNEL[2]
27
28#define RGB_PORT PORTC
29#define RGB_PORT_GPIO GPIOC
30
31// Base FTM clock selection (72 MHz system clock)
32// @ 0xFFFF period, 72 MHz / (0xFFFF * 2) = Actual period
33// Higher pre-scalar will use the most power (also look the best)
34// Pre-scalar calculations
35// 0 - 72 MHz -> 549 Hz
36// 1 - 36 MHz -> 275 Hz
37// 2 - 18 MHz -> 137 Hz
38// 3 - 9 MHz -> 69 Hz (Slightly visible flicker)
39// 4 - 4 500 kHz -> 34 Hz (Visible flickering)
40// 5 - 2 250 kHz -> 17 Hz
41// 6 - 1 125 kHz -> 9 Hz
42// 7 - 562 500 Hz -> 4 Hz
43// Using a higher pre-scalar without flicker is possible but FTM0_MOD will need to be reduced
44// Which will reduce the brightness range
45#define PRESCALAR_DEFINE 0
46
47void lcd_backlight_hal_init(void) {
48 // Setup Backlight
49 SIM->SCGC6 |= SIM_SCGC6_FTM0;
50 FTM0->CNT = 0; // Reset counter
51
52 // PWM Period
53 // 16-bit maximum
54 FTM0->MOD = 0xFFFF;
55
56 // Set FTM to PWM output - Edge Aligned, Low-true pulses
57#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
58 CHANNEL_RED.CnSC = CNSC_MODE;
59 CHANNEL_GREEN.CnSC = CNSC_MODE;
60 CHANNEL_BLUE.CnSC = CNSC_MODE;
61
62 // System clock, /w prescalar setting
63 FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
64
65 CHANNEL_RED.CnV = 0;
66 CHANNEL_GREEN.CnV = 0;
67 CHANNEL_BLUE.CnV = 0;
68
69 RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
70 RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
71 RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
72
73#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
74 RGB_PORT->PCR[RED_PIN] = RGB_MODE;
75 RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
76 RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
77}
78
79void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
80 CHANNEL_RED.CnV = r;
81 CHANNEL_GREEN.CnV = g;
82 CHANNEL_BLUE.CnV = b;
83}
84
diff --git a/keyboards/infinity_ergodox/visualizer_user.c b/keyboards/infinity_ergodox/visualizer_user.c
new file mode 100644
index 000000000..c0d335ce6
--- /dev/null
+++ b/keyboards/infinity_ergodox/visualizer_user.c
@@ -0,0 +1,168 @@
1/*
2Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18// Currently we are assuming that both the backlight and LCD are enabled
19// But it's entirely possible to write a custom visualizer that use only
20// one of them
21#ifndef LCD_BACKLIGHT_ENABLE
22#error This visualizer needs that LCD backlight is enabled
23#endif
24
25#ifndef LCD_ENABLE
26#error This visualizer needs that LCD is enabled
27#endif
28
29#include "visualizer.h"
30#include "led_test.h"
31
32static const char* welcome_text[] = {"TMK", "Infinity Ergodox"};
33
34// Just an example how to write custom keyframe functions, we could have moved
35// all this into the init function
36bool display_welcome(keyframe_animation_t* animation, visualizer_state_t* state) {
37 (void)animation;
38 // Read the uGFX documentation for information how to use the displays
39 // http://wiki.ugfx.org/index.php/Main_Page
40 gdispClear(White);
41 // You can use static variables for things that can't be found in the animation
42 // or state structs
43 gdispDrawString(0, 3, welcome_text[0], state->font_dejavusansbold12, Black);
44 gdispDrawString(0, 15, welcome_text[1], state->font_dejavusansbold12, Black);
45 // Always remember to flush the display
46 gdispFlush();
47 // you could set the backlight color as well, but we won't do it here, since
48 // it's part of the following animation
49 // lcd_backlight_color(hue, saturation, intensity);
50 // We don't need constant updates, just drawing the screen once is enough
51 return false;
52}
53
54// Feel free to modify the animations below, or even add new ones if needed
55
56// Don't worry, if the startup animation is long, you can use the keyboard like normal
57// during that time
58static keyframe_animation_t startup_animation = {
59 .num_frames = 4,
60 .loop = false,
61 .frame_lengths = {0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
62 .frame_functions = {
63 display_welcome,
64 keyframe_animate_backlight_color,
65 keyframe_no_operation,
66 enable_visualization
67 },
68};
69
70// The color animation animates the LCD color when you change layers
71static keyframe_animation_t color_animation = {
72 .num_frames = 2,
73 .loop = false,
74 // Note that there's a 200 ms no-operation frame,
75 // this prevents the color from changing when activating the layer
76 // momentarily
77 .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)},
78 .frame_functions = {keyframe_no_operation, keyframe_animate_backlight_color},
79};
80
81// The LCD animation alternates between the layer name display and a
82// bitmap that displays all active layers
83static keyframe_animation_t lcd_animation = {
84 .num_frames = 2,
85 .loop = true,
86 .frame_lengths = {gfxMillisecondsToTicks(2000), gfxMillisecondsToTicks(2000)},
87 .frame_functions = {keyframe_display_layer_text, keyframe_display_layer_bitmap},
88};
89
90static keyframe_animation_t suspend_animation = {
91 .num_frames = 3,
92 .loop = false,
93 .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0},
94 .frame_functions = {
95 keyframe_display_layer_text,
96 keyframe_animate_backlight_color,
97 keyframe_disable_lcd_and_backlight,
98 },
99};
100
101static keyframe_animation_t resume_animation = {
102 .num_frames = 5,
103 .loop = false,
104 .frame_lengths = {0, 0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
105 .frame_functions = {
106 keyframe_enable_lcd_and_backlight,
107 display_welcome,
108 keyframe_animate_backlight_color,
109 keyframe_no_operation,
110 enable_visualization,
111 },
112};
113
114void initialize_user_visualizer(visualizer_state_t* state) {
115 // The brightness will be dynamically adjustable in the future
116 // But for now, change it here.
117 lcd_backlight_brightness(0x50);
118 state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0xFF);
119 state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
120 start_keyframe_animation(&startup_animation);
121 start_keyframe_animation(&led_test_animation);
122}
123
124void update_user_visualizer_state(visualizer_state_t* state) {
125 // Add more tests, change the colors and layer texts here
126 // Usually you want to check the high bits (higher layers first)
127 // because that's the order layers are processed for keypresses
128 // You can for check for example:
129 // state->status.layer
130 // state->status.default_layer
131 // state->status.leds (see led.h for available statuses)
132 if (state->status.layer & 0x8) {
133 state->target_lcd_color = LCD_COLOR(0xC0, 0xB0, 0xFF);
134 state->layer_text = "Numpad";
135 }
136 else if (state->status.layer & 0x4) {
137 state->target_lcd_color = LCD_COLOR(0, 0xB0, 0xFF);
138 state->layer_text = "KBD functions";
139 }
140 else if (state->status.layer & 0x2) {
141 state->target_lcd_color = LCD_COLOR(0x80, 0xB0, 0xFF);
142 state->layer_text = "Function keys";
143 }
144 else {
145 state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF);
146 state->layer_text = "Default";
147 }
148 // You can also stop existing animations, and start your custom ones here
149 // remember that you should normally have only one animation for the LCD
150 // and one for the background. But you can also combine them if you want.
151 start_keyframe_animation(&lcd_animation);
152 start_keyframe_animation(&color_animation);
153}
154
155void user_visualizer_suspend(visualizer_state_t* state) {
156 state->layer_text = "Suspending...";
157 uint8_t hue = LCD_HUE(state->current_lcd_color);
158 uint8_t sat = LCD_SAT(state->current_lcd_color);
159 state->target_lcd_color = LCD_COLOR(hue, sat, 0);
160 start_keyframe_animation(&suspend_animation);
161}
162
163void user_visualizer_resume(visualizer_state_t* state) {
164 state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0x00);
165 state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
166 start_keyframe_animation(&resume_animation);
167 start_keyframe_animation(&led_test_animation);
168}
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index c24073405..abca22d85 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -29,9 +29,7 @@ SOFTWARE.
29#include "ch.h" 29#include "ch.h"
30#endif 30#endif
31 31
32#ifdef LCD_ENABLE
33#include "gfx.h" 32#include "gfx.h"
34#endif
35 33
36#ifdef LCD_BACKLIGHT_ENABLE 34#ifdef LCD_BACKLIGHT_ENABLE
37#include "lcd_backlight.h" 35#include "lcd_backlight.h"
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index 45cfa9aa9..53e250725 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -28,9 +28,7 @@ SOFTWARE.
28#include <stdint.h> 28#include <stdint.h>
29#include <stdbool.h> 29#include <stdbool.h>
30 30
31#ifdef LCD_ENABLE
32#include "gfx.h" 31#include "gfx.h"
33#endif
34 32
35#ifdef LCD_BACKLIGHT_ENABLE 33#ifdef LCD_BACKLIGHT_ENABLE
36#include "lcd_backlight.h" 34#include "lcd_backlight.h"
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk
index 56525ffd9..b5dfad8e1 100644
--- a/quantum/visualizer/visualizer.mk
+++ b/quantum/visualizer/visualizer.mk
@@ -20,14 +20,14 @@
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
23GFXLIB = $(VISUALIZER_DIR)/ugfx
24SRC += $(VISUALIZER_DIR)/visualizer.c 23SRC += $(VISUALIZER_DIR)/visualizer.c
25UINCDIR += $(GFXINC) $(VISUALIZER_DIR) 24EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
25GFXLIB = $(LIB_PATH)/ugfx
26VPATH += $(VISUALIZER_PATH)
26 27
27ifdef LCD_ENABLE 28ifdef LCD_ENABLE
28UDEFS += -DLCD_ENABLE 29OPT_DEFS += -DLCD_ENABLE
29ULIBS += -lm 30ULIBS += -lm
30USE_UGFX = yes
31endif 31endif
32 32
33ifdef LCD_BACKLIGHT_ENABLE 33ifdef LCD_BACKLIGHT_ENABLE
@@ -35,21 +35,21 @@ SRC += $(VISUALIZER_DIR)/lcd_backlight.c
35ifndef EMULATOR 35ifndef EMULATOR
36SRC += lcd_backlight_hal.c 36SRC += lcd_backlight_hal.c
37endif 37endif
38UDEFS += -DLCD_BACKLIGHT_ENABLE 38OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
39endif 39endif
40 40
41ifdef LED_ENABLE 41ifdef LED_ENABLE
42SRC += $(VISUALIZER_DIR)/led_test.c 42SRC += $(VISUALIZER_DIR)/led_test.c
43UDEFS += -DLED_ENABLE 43UDEFS += -DLED_ENABLE
44USE_UGFX = yes
45endif 44endif
46 45
47ifdef USE_UGFX
48include $(GFXLIB)/gfx.mk 46include $(GFXLIB)/gfx.mk
49SRC += $(GFXSRC) 47#SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c)
50UDEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) 48#SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
51ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS))) 49#SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
52endif 50#SRC += $(GFXSRC)
51OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
52#ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS)))
53 53
54ifndef VISUALIZER_USER 54ifndef VISUALIZER_USER
55VISUALIZER_USER = visualizer_user.c 55VISUALIZER_USER = visualizer_user.c