diff options
Diffstat (limited to 'quantum/visualizer')
21 files changed, 0 insertions, 2107 deletions
diff --git a/quantum/visualizer/LICENSE.md b/quantum/visualizer/LICENSE.md deleted file mode 100644 index 22d4c3f08..000000000 --- a/quantum/visualizer/LICENSE.md +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | The files in this project are licensed under the MIT license | ||
| 2 | It uses the following libraries | ||
| 3 | uGFX - with it's own license, see the license.html file in the uGFX subfolder for more information | ||
| 4 | tmk_core - is indirectly used and not included in the repository. It's licensed under the GPLv2 license | ||
| 5 | Chibios - which is used by tmk_core is licensed under GPLv3. | ||
| 6 | |||
| 7 | Therefore the effective license for any project using the library is GPLv3 | ||
| 8 | |||
| 9 | The MIT License (MIT) | ||
| 10 | |||
| 11 | Copyright (c) 2016 Fred Sundvik | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 14 | of this software and associated documentation files (the "Software"), to deal | ||
| 15 | in the Software without restriction, including without limitation the rights | ||
| 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 17 | copies of the Software, and to permit persons to whom the Software is | ||
| 18 | furnished to do so, subject to the following conditions: | ||
| 19 | |||
| 20 | The above copyright notice and this permission notice shall be included in all | ||
| 21 | copies or substantial portions of the Software. | ||
| 22 | |||
| 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 29 | SOFTWARE. | ||
diff --git a/quantum/visualizer/common_gfxconf.h b/quantum/visualizer/common_gfxconf.h deleted file mode 100644 index e0735b37d..000000000 --- a/quantum/visualizer/common_gfxconf.h +++ /dev/null | |||
| @@ -1,354 +0,0 @@ | |||
| 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 | #pragma once | ||
| 23 | |||
| 24 | /////////////////////////////////////////////////////////////////////////// | ||
| 25 | // GFX - Compatibility options // | ||
| 26 | /////////////////////////////////////////////////////////////////////////// | ||
| 27 | //#define GFX_COMPAT_V2 GFXON | ||
| 28 | //#define GFX_COMPAT_OLDCOLORS GFXON | ||
| 29 | |||
| 30 | /////////////////////////////////////////////////////////////////////////// | ||
| 31 | // GOS - One of these must be defined, preferably in your Makefile // | ||
| 32 | /////////////////////////////////////////////////////////////////////////// | ||
| 33 | //#define GFX_USE_OS_CHIBIOS GFXOFF | ||
| 34 | //#define GFX_USE_OS_FREERTOS GFXOFF | ||
| 35 | // #define GFX_FREERTOS_USE_TRACE GFXOFF | ||
| 36 | //#define GFX_USE_OS_WIN32 GFXOFF | ||
| 37 | //#define GFX_USE_OS_LINUX GFXOFF | ||
| 38 | //#define GFX_USE_OS_OSX GFXOFF | ||
| 39 | //#define GFX_USE_OS_ECOS GFXOFF | ||
| 40 | //#define GFX_USE_OS_RAWRTOS GFXOFF | ||
| 41 | //#define GFX_USE_OS_ARDUINO GFXOFF | ||
| 42 | //#define GFX_USE_OS_KEIL GFXOFF | ||
| 43 | //#define GFX_USE_OS_RTX5 GFXOFF | ||
| 44 | //#define GFX_USE_OS_CMSIS GFXOFF | ||
| 45 | //#define GFX_USE_OS_CMSIS2 GFXOFF | ||
| 46 | //#define GFX_USE_OS_RAW32 GFXOFF | ||
| 47 | //#define GFX_USE_OS_ZEPHYR GFXOFF | ||
| 48 | //#define GFX_USE_OS_NIOS GFXOFF | ||
| 49 | //#define GFX_USE_OS_QT GFXOFF | ||
| 50 | // #define INTERRUPTS_OFF() optional_code | ||
| 51 | // #define INTERRUPTS_ON() optional_code | ||
| 52 | |||
| 53 | // Options that (should where relevant) apply to all operating systems | ||
| 54 | #define GFX_NO_INLINE GFXON | ||
| 55 | // #define GFX_COMPILER GFX_COMPILER_UNKNOWN | ||
| 56 | // #define GFX_SHOW_COMPILER GFXOFF | ||
| 57 | // #define GFX_CPU GFX_CPU_UNKNOWN | ||
| 58 | // #define GFX_CPU_NO_ALIGNMENT_FAULTS GFXOFF | ||
| 59 | // #define GFX_CPU_ENDIAN GFX_CPU_ENDIAN_UNKNOWN | ||
| 60 | // #define GFX_OS_HEAP_SIZE 0 | ||
| 61 | // #define GFX_OS_NO_INIT GFXOFF | ||
| 62 | // #define GFX_OS_INIT_NO_WARNING GFXOFF | ||
| 63 | // #define GFX_OS_PRE_INIT_FUNCTION myHardwareInitRoutine | ||
| 64 | // #define GFX_OS_EXTRA_INIT_FUNCTION myOSInitRoutine | ||
| 65 | // #define GFX_OS_EXTRA_DEINIT_FUNCTION myOSDeInitRoutine | ||
| 66 | // #define GFX_OS_CALL_UGFXMAIN GFXOFF | ||
| 67 | // #define GFX_OS_UGFXMAIN_STACKSIZE 0 | ||
| 68 | // #define GFX_EMULATE_MALLOC GFXOFF | ||
| 69 | // #define GFX_MEM_LT64K GFXOFF | ||
| 70 | |||
| 71 | /////////////////////////////////////////////////////////////////////////// | ||
| 72 | // GDISP // | ||
| 73 | /////////////////////////////////////////////////////////////////////////// | ||
| 74 | #define GFX_USE_GDISP GFXON | ||
| 75 | |||
| 76 | //#define GDISP_NEED_AUTOFLUSH GFXOFF | ||
| 77 | //#define GDISP_NEED_TIMERFLUSH GFXOFF | ||
| 78 | //#define GDISP_NEED_VALIDATION GFXON | ||
| 79 | //#define GDISP_NEED_CLIP GFXON | ||
| 80 | #define GDISP_NEED_CIRCLE GFXON | ||
| 81 | //#define GDISP_NEED_DUALCIRCLE GFXOFF | ||
| 82 | #define GDISP_NEED_ELLIPSE GFXON | ||
| 83 | #define GDISP_NEED_ARC GFXON | ||
| 84 | #define GDISP_NEED_ARCSECTORS GFXON | ||
| 85 | #define GDISP_NEED_CONVEX_POLYGON GFXON | ||
| 86 | //#define GDISP_NEED_SCROLL GFXOFF | ||
| 87 | #define GDISP_NEED_PIXELREAD GFXON | ||
| 88 | #define GDISP_NEED_CONTROL GFXON | ||
| 89 | //#define GDISP_NEED_QUERY GFXOFF | ||
| 90 | //#define GDISP_NEED_MULTITHREAD GFXOFF | ||
| 91 | //#define GDISP_NEED_STREAMING GFXOFF | ||
| 92 | #define GDISP_NEED_TEXT GFXON | ||
| 93 | // #define GDISP_NEED_TEXT_WORDWRAP GFXOFF | ||
| 94 | // #define GDISP_NEED_TEXT_BOXPADLR 1 | ||
| 95 | // #define GDISP_NEED_TEXT_BOXPADTB 1 | ||
| 96 | // #define GDISP_NEED_ANTIALIAS GFXOFF | ||
| 97 | // #define GDISP_NEED_UTF8 GFXOFF | ||
| 98 | #define GDISP_NEED_TEXT_KERNING GFXON | ||
| 99 | // #define GDISP_INCLUDE_FONT_UI1 GFXOFF | ||
| 100 | // #define GDISP_INCLUDE_FONT_UI2 GFXOFF // The smallest preferred font. | ||
| 101 | // #define GDISP_INCLUDE_FONT_LARGENUMBERS GFXOFF | ||
| 102 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS10 GFXOFF | ||
| 103 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS12 GFXOFF | ||
| 104 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS16 GFXOFF | ||
| 105 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20 GFXOFF | ||
| 106 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS24 GFXOFF | ||
| 107 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS32 GFXOFF | ||
| 108 | #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 GFXON | ||
| 109 | // #define GDISP_INCLUDE_FONT_FIXED_10X20 GFXOFF | ||
| 110 | // #define GDISP_INCLUDE_FONT_FIXED_7X14 GFXOFF | ||
| 111 | #define GDISP_INCLUDE_FONT_FIXED_5X8 GFXON | ||
| 112 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA GFXOFF | ||
| 113 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA GFXOFF | ||
| 114 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA GFXOFF | ||
| 115 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA GFXOFF | ||
| 116 | // #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA GFXOFF | ||
| 117 | // #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA GFXOFF | ||
| 118 | // #define GDISP_INCLUDE_USER_FONTS GFXOFF | ||
| 119 | |||
| 120 | //#define GDISP_NEED_IMAGE GFXOFF | ||
| 121 | // #define GDISP_NEED_IMAGE_NATIVE GFXOFF | ||
| 122 | // #define GDISP_NEED_IMAGE_GIF GFXOFF | ||
| 123 | // #define GDISP_IMAGE_GIF_BLIT_BUFFER_SIZE 32 | ||
| 124 | // #define GDISP_NEED_IMAGE_BMP GFXOFF | ||
| 125 | // #define GDISP_NEED_IMAGE_BMP_1 GFXON | ||
| 126 | // #define GDISP_NEED_IMAGE_BMP_4 GFXON | ||
| 127 | // #define GDISP_NEED_IMAGE_BMP_4_RLE GFXON | ||
| 128 | // #define GDISP_NEED_IMAGE_BMP_8 GFXON | ||
| 129 | // #define GDISP_NEED_IMAGE_BMP_8_RLE GFXON | ||
| 130 | // #define GDISP_NEED_IMAGE_BMP_16 GFXON | ||
| 131 | // #define GDISP_NEED_IMAGE_BMP_24 GFXON | ||
| 132 | // #define GDISP_NEED_IMAGE_BMP_32 GFXON | ||
| 133 | // #define GDISP_IMAGE_BMP_BLIT_BUFFER_SIZE 32 | ||
| 134 | // #define GDISP_NEED_IMAGE_JPG GFXOFF | ||
| 135 | // #define GDISP_NEED_IMAGE_PNG GFXOFF | ||
| 136 | // #define GDISP_NEED_IMAGE_PNG_INTERLACED GFXOFF | ||
| 137 | // #define GDISP_NEED_IMAGE_PNG_TRANSPARENCY GFXON | ||
| 138 | // #define GDISP_NEED_IMAGE_PNG_BACKGROUND GFXON | ||
| 139 | // #define GDISP_NEED_IMAGE_PNG_ALPHACLIFF 32 | ||
| 140 | // #define GDISP_NEED_IMAGE_PNG_PALETTE_124 GFXON | ||
| 141 | // #define GDISP_NEED_IMAGE_PNG_PALETTE_8 GFXON | ||
| 142 | // #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_124 GFXON | ||
| 143 | // #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_8 GFXON | ||
| 144 | // #define GDISP_NEED_IMAGE_PNG_GRAYSCALE_16 GFXON | ||
| 145 | // #define GDISP_NEED_IMAGE_PNG_GRAYALPHA_8 GFXON | ||
| 146 | // #define GDISP_NEED_IMAGE_PNG_GRAYALPHA_16 GFXON | ||
| 147 | // #define GDISP_NEED_IMAGE_PNG_RGB_8 GFXON | ||
| 148 | // #define GDISP_NEED_IMAGE_PNG_RGB_16 GFXON | ||
| 149 | // #define GDISP_NEED_IMAGE_PNG_RGBALPHA_8 GFXON | ||
| 150 | // #define GDISP_NEED_IMAGE_PNG_RGBALPHA_16 GFXON | ||
| 151 | // #define GDISP_IMAGE_PNG_BLIT_BUFFER_SIZE 32 | ||
| 152 | // #define GDISP_IMAGE_PNG_FILE_BUFFER_SIZE 8 | ||
| 153 | // #define GDISP_IMAGE_PNG_Z_BUFFER_SIZE 32768 | ||
| 154 | // #define GDISP_NEED_IMAGE_ACCOUNTING GFXOFF | ||
| 155 | |||
| 156 | //#define GDISP_NEED_PIXMAP GFXOFF | ||
| 157 | // #define GDISP_NEED_PIXMAP_IMAGE GFXOFF | ||
| 158 | |||
| 159 | //#define GDISP_DEFAULT_ORIENTATION gOrientationLandscape // If not defined the native hardware orientation is used. | ||
| 160 | //#define GDISP_LINEBUF_SIZE 128 | ||
| 161 | //#define GDISP_STARTUP_COLOR GFX_BLACK | ||
| 162 | #define GDISP_NEED_STARTUP_LOGO GFXOFF | ||
| 163 | |||
| 164 | //#define GDISP_TOTAL_DISPLAYS 1 | ||
| 165 | |||
| 166 | //#define GDISP_DRIVER_LIST GDISPVMT_Win32, GDISPVMT_Win32 | ||
| 167 | #ifdef GDISP_DRIVER_LIST | ||
| 168 | // // For code and speed optimization define as GFXON or GFXOFF if all controllers have the same capability | ||
| 169 | # define GDISP_HARDWARE_STREAM_WRITE GFXOFF | ||
| 170 | # define GDISP_HARDWARE_STREAM_READ GFXOFF | ||
| 171 | # define GDISP_HARDWARE_STREAM_POS GFXOFF | ||
| 172 | # define GDISP_HARDWARE_DRAWPIXEL GFXON | ||
| 173 | # define GDISP_HARDWARE_CLEARS GFXOFF | ||
| 174 | # define GDISP_HARDWARE_FILLS GFXOFF | ||
| 175 | //#define GDISP_HARDWARE_BITFILLS GFXOFF | ||
| 176 | # define GDISP_HARDWARE_SCROLL GFXOFF | ||
| 177 | # define GDISP_HARDWARE_PIXELREAD GFXON | ||
| 178 | # define GDISP_HARDWARE_CONTROL GFXON | ||
| 179 | # define GDISP_HARDWARE_QUERY GFXOFF | ||
| 180 | # define GDISP_HARDWARE_CLIP GFXOFF | ||
| 181 | |||
| 182 | # define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 | ||
| 183 | #endif | ||
| 184 | |||
| 185 | #define GDISP_USE_GFXNET GFXOFF | ||
| 186 | // #define GDISP_GFXNET_PORT 13001 | ||
| 187 | // #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP GFXOFF | ||
| 188 | // #define GDISP_DONT_WAIT_FOR_NET_DISPLAY GFXOFF | ||
| 189 | // #define GDISP_GFXNET_UNSAFE_SOCKETS GFXOFF | ||
| 190 | |||
| 191 | /////////////////////////////////////////////////////////////////////////// | ||
| 192 | // GWIN // | ||
| 193 | /////////////////////////////////////////////////////////////////////////// | ||
| 194 | #define GFX_USE_GWIN GFXOFF | ||
| 195 | |||
| 196 | //#define GWIN_NEED_WINDOWMANAGER GFXOFF | ||
| 197 | // #define GWIN_REDRAW_IMMEDIATE GFXOFF | ||
| 198 | // #define GWIN_REDRAW_SINGLEOP GFXOFF | ||
| 199 | // #define GWIN_NEED_FLASHING GFXOFF | ||
| 200 | // #define GWIN_FLASHING_PERIOD 250 | ||
| 201 | |||
| 202 | //#define GWIN_NEED_CONSOLE GFXOFF | ||
| 203 | // #define GWIN_CONSOLE_USE_HISTORY GFXOFF | ||
| 204 | // #define GWIN_CONSOLE_HISTORY_AVERAGING GFXOFF | ||
| 205 | // #define GWIN_CONSOLE_HISTORY_ATCREATE GFXOFF | ||
| 206 | // #define GWIN_CONSOLE_ESCSEQ GFXOFF | ||
| 207 | // #define GWIN_CONSOLE_USE_BASESTREAM GFXOFF | ||
| 208 | // #define GWIN_CONSOLE_USE_FLOAT GFXOFF | ||
| 209 | //#define GWIN_NEED_GRAPH GFXOFF | ||
| 210 | //#define GWIN_NEED_GL3D GFXOFF | ||
| 211 | |||
| 212 | //#define GWIN_NEED_WIDGET GFXOFF | ||
| 213 | //#define GWIN_FOCUS_HIGHLIGHT_WIDTH 1 | ||
| 214 | // #define GWIN_NEED_LABEL GFXOFF | ||
| 215 | // #define GWIN_LABEL_ATTRIBUTE GFXOFF | ||
| 216 | // #define GWIN_NEED_BUTTON GFXOFF | ||
| 217 | // #define GWIN_BUTTON_LAZY_RELEASE GFXOFF | ||
| 218 | // #define GWIN_NEED_SLIDER GFXOFF | ||
| 219 | // #define GWIN_SLIDER_NOSNAP GFXOFF | ||
| 220 | // #define GWIN_SLIDER_DEAD_BAND 5 | ||
| 221 | // #define GWIN_SLIDER_TOGGLE_INC 20 | ||
| 222 | // #define GWIN_NEED_CHECKBOX GFXOFF | ||
| 223 | // #define GWIN_NEED_IMAGE GFXOFF | ||
| 224 | // #define GWIN_NEED_IMAGE_ANIMATION GFXOFF | ||
| 225 | // #define GWIN_NEED_RADIO GFXOFF | ||
| 226 | // #define GWIN_NEED_LIST GFXOFF | ||
| 227 | // #define GWIN_NEED_LIST_IMAGES GFXOFF | ||
| 228 | // #define GWIN_NEED_PROGRESSBAR GFXOFF | ||
| 229 | // #define GWIN_PROGRESSBAR_AUTO GFXOFF | ||
| 230 | // #define GWIN_NEED_KEYBOARD GFXOFF | ||
| 231 | // #define GWIN_KEYBOARD_DEFAULT_LAYOUT VirtualKeyboard_English1 | ||
| 232 | // #define GWIN_NEED_KEYBOARD_ENGLISH1 GFXON | ||
| 233 | // #define GWIN_NEED_TEXTEDIT GFXOFF | ||
| 234 | // #define GWIN_FLAT_STYLING GFXOFF | ||
| 235 | // #define GWIN_WIDGET_TAGS GFXOFF | ||
| 236 | |||
| 237 | //#define GWIN_NEED_CONTAINERS GFXOFF | ||
| 238 | // #define GWIN_NEED_CONTAINER GFXOFF | ||
| 239 | // #define GWIN_NEED_FRAME GFXOFF | ||
| 240 | // #define GWIN_NEED_TABSET GFXOFF | ||
| 241 | // #define GWIN_TABSET_TABHEIGHT 18 | ||
| 242 | |||
| 243 | /////////////////////////////////////////////////////////////////////////// | ||
| 244 | // GTRANS // | ||
| 245 | /////////////////////////////////////////////////////////////////////////// | ||
| 246 | //#define GFX_USE_GTRANS GFXOFF | ||
| 247 | |||
| 248 | /////////////////////////////////////////////////////////////////////////// | ||
| 249 | // GEVENT // | ||
| 250 | /////////////////////////////////////////////////////////////////////////// | ||
| 251 | #define GFX_USE_GEVENT GFXON | ||
| 252 | |||
| 253 | //#define GEVENT_ASSERT_NO_RESOURCE GFXOFF | ||
| 254 | //#define GEVENT_MAXIMUM_SIZE 32 | ||
| 255 | //#define GEVENT_MAX_SOURCE_LISTENERS 32 | ||
| 256 | |||
| 257 | /////////////////////////////////////////////////////////////////////////// | ||
| 258 | // GTIMER // | ||
| 259 | /////////////////////////////////////////////////////////////////////////// | ||
| 260 | #define GFX_USE_GTIMER GFXOFF | ||
| 261 | |||
| 262 | //#define GTIMER_THREAD_PRIORITY gThreadpriorityHigh | ||
| 263 | //#define GTIMER_THREAD_WORKAREA_SIZE 2048 | ||
| 264 | |||
| 265 | /////////////////////////////////////////////////////////////////////////// | ||
| 266 | // GQUEUE // | ||
| 267 | /////////////////////////////////////////////////////////////////////////// | ||
| 268 | #define GFX_USE_GQUEUE GFXOFF | ||
| 269 | |||
| 270 | //#define GQUEUE_NEED_ASYNC GFXOFF | ||
| 271 | //#define GQUEUE_NEED_GSYNC GFXOFF | ||
| 272 | //#define GQUEUE_NEED_FSYNC GFXOFF | ||
| 273 | //#define GQUEUE_NEED_BUFFERS GFXOFF | ||
| 274 | |||
| 275 | /////////////////////////////////////////////////////////////////////////// | ||
| 276 | // GINPUT // | ||
| 277 | /////////////////////////////////////////////////////////////////////////// | ||
| 278 | #define GFX_USE_GINPUT GFXOFF | ||
| 279 | |||
| 280 | //#define GINPUT_NEED_MOUSE GFXOFF | ||
| 281 | // #define GINPUT_TOUCH_STARTRAW GFXOFF | ||
| 282 | // #define GINPUT_TOUCH_NOTOUCH GFXOFF | ||
| 283 | // #define GINPUT_TOUCH_NOCALIBRATE GFXOFF | ||
| 284 | // #define GINPUT_TOUCH_NOCALIBRATE_GUI GFXOFF | ||
| 285 | // #define GINPUT_MOUSE_POLL_PERIOD 25 | ||
| 286 | // #define GINPUT_MOUSE_CLICK_TIME 300 | ||
| 287 | // #define GINPUT_TOUCH_CXTCLICK_TIME 700 | ||
| 288 | // #define GINPUT_TOUCH_USER_CALIBRATION_LOAD GFXOFF | ||
| 289 | // #define GINPUT_TOUCH_USER_CALIBRATION_SAVE GFXOFF | ||
| 290 | // #define GMOUSE_DRIVER_LIST GMOUSEVMT_Win32, GMOUSEVMT_Win32 | ||
| 291 | // #define GINPUT_TOUCH_CALIBRATION_FONT1 "* Double" | ||
| 292 | // #define GINPUT_TOUCH_CALIBRATION_FONT2 "* Narrow" | ||
| 293 | // #define GINPUT_TOUCH_CALIBRATION_TITLE "Calibration" | ||
| 294 | // #define GINPUT_TOUCH_CALIBRATION_ERROR "Calibration Failed!" | ||
| 295 | //#define GINPUT_NEED_KEYBOARD GFXOFF | ||
| 296 | // #define GINPUT_KEYBOARD_POLL_PERIOD 200 | ||
| 297 | // #define GKEYBOARD_DRIVER_LIST GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32 | ||
| 298 | // #define GKEYBOARD_LAYOUT_OFF GFXOFF | ||
| 299 | // #define GKEYBOARD_LAYOUT_SCANCODE2_US GFXOFF | ||
| 300 | //#define GINPUT_NEED_TOGGLE GFXOFF | ||
| 301 | //#define GINPUT_NEED_DIAL GFXOFF | ||
| 302 | |||
| 303 | /////////////////////////////////////////////////////////////////////////// | ||
| 304 | // GFILE // | ||
| 305 | /////////////////////////////////////////////////////////////////////////// | ||
| 306 | #define GFX_USE_GFILE GFXOFF | ||
| 307 | |||
| 308 | //#define GFILE_NEED_PRINTG GFXOFF | ||
| 309 | //#define GFILE_NEED_SCANG GFXOFF | ||
| 310 | //#define GFILE_NEED_STRINGS GFXOFF | ||
| 311 | //#define GFILE_NEED_FILELISTS GFXOFF | ||
| 312 | //#define GFILE_NEED_STDIO GFXOFF | ||
| 313 | //#define GFILE_NEED_NOAUTOMOUNT GFXOFF | ||
| 314 | //#define GFILE_NEED_NOAUTOSYNC GFXOFF | ||
| 315 | |||
| 316 | //#define GFILE_NEED_MEMFS GFXOFF | ||
| 317 | //#define GFILE_NEED_ROMFS GFXOFF | ||
| 318 | //#define GFILE_NEED_RAMFS GFXOFF | ||
| 319 | //#define GFILE_NEED_FATFS GFXOFF | ||
| 320 | //#define GFILE_NEED_NATIVEFS GFXOFF | ||
| 321 | //#define GFILE_NEED_CHBIOSFS GFXOFF | ||
| 322 | //#define GFILE_NEED_USERFS GFXOFF | ||
| 323 | |||
| 324 | //#define GFILE_ALLOW_FLOATS GFXOFF | ||
| 325 | //#define GFILE_ALLOW_DEVICESPECIFIC GFXOFF | ||
| 326 | //#define GFILE_MAX_GFILES 3 | ||
| 327 | |||
| 328 | /////////////////////////////////////////////////////////////////////////// | ||
| 329 | // GADC // | ||
| 330 | /////////////////////////////////////////////////////////////////////////// | ||
| 331 | #define GFX_USE_GADC GFXOFF | ||
| 332 | // #define GADC_MAX_LOWSPEED_DEVICES 4 | ||
| 333 | |||
| 334 | /////////////////////////////////////////////////////////////////////////// | ||
| 335 | // GAUDIO // | ||
| 336 | /////////////////////////////////////////////////////////////////////////// | ||
| 337 | #define GFX_USE_GAUDIO GFXOFF | ||
| 338 | // #define GAUDIO_NEED_PLAY GFXOFF | ||
| 339 | // #define GAUDIO_NEED_RECORD GFXOFF | ||
| 340 | |||
| 341 | /////////////////////////////////////////////////////////////////////////// | ||
| 342 | // GMISC // | ||
| 343 | /////////////////////////////////////////////////////////////////////////// | ||
| 344 | #define GFX_USE_GMISC GFXON | ||
| 345 | |||
| 346 | //#define GMISC_NEED_ARRAYOPS GFXOFF | ||
| 347 | //#define GMISC_NEED_FASTTRIG GFXOFF | ||
| 348 | //#define GMISC_NEED_FIXEDTRIG GFXOFF | ||
| 349 | //#define GMISC_NEED_INVSQRT GFXOFF | ||
| 350 | // #define GMISC_INVSQRT_MIXED_ENDIAN GFXOFF | ||
| 351 | // #define GMISC_INVSQRT_REAL_SLOW GFXOFF | ||
| 352 | #define GMISC_NEED_MATRIXFLOAT2D GFXON | ||
| 353 | #define GMISC_NEED_MATRIXFIXED2D GFXOFF | ||
| 354 | //#define GMISC_NEED_HITTEST_POLY GFXOFF | ||
diff --git a/quantum/visualizer/default_animations.c b/quantum/visualizer/default_animations.c deleted file mode 100644 index 2f43c67cc..000000000 --- a/quantum/visualizer/default_animations.c +++ /dev/null | |||
| @@ -1,177 +0,0 @@ | |||
| 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 | # if defined(LCD_ENABLE) || defined(LCD_BACKLIGHT_ENABLE) || defined(BACKLIGHT_ENABLE) | ||
| 35 | |||
| 36 | static bool keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 37 | # ifdef LCD_ENABLE | ||
| 38 | lcd_keyframe_enable(animation, state); | ||
| 39 | # endif | ||
| 40 | # ifdef LCD_BACKLIGHT_ENABLE | ||
| 41 | lcd_backlight_keyframe_enable(animation, state); | ||
| 42 | # endif | ||
| 43 | # ifdef BACKLIGHT_ENABLE | ||
| 44 | led_backlight_keyframe_enable(animation, state); | ||
| 45 | # endif | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | |||
| 49 | static bool keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 50 | # ifdef LCD_ENABLE | ||
| 51 | lcd_keyframe_disable(animation, state); | ||
| 52 | # endif | ||
| 53 | # ifdef LCD_BACKLIGHT_ENABLE | ||
| 54 | lcd_backlight_keyframe_disable(animation, state); | ||
| 55 | # endif | ||
| 56 | # ifdef BACKLIGHT_ENABLE | ||
| 57 | led_backlight_keyframe_disable(animation, state); | ||
| 58 | # endif | ||
| 59 | return false; | ||
| 60 | } | ||
| 61 | |||
| 62 | static bool keyframe_fade_in(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 63 | bool ret = false; | ||
| 64 | # ifdef LCD_BACKLIGHT_ENABLE | ||
| 65 | ret |= lcd_backlight_keyframe_animate_color(animation, state); | ||
| 66 | # endif | ||
| 67 | # ifdef BACKLIGHT_ENABLE | ||
| 68 | ret |= led_backlight_keyframe_fade_in_all(animation, state); | ||
| 69 | # endif | ||
| 70 | return ret; | ||
| 71 | } | ||
| 72 | |||
| 73 | static bool keyframe_fade_out(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 74 | bool ret = false; | ||
| 75 | # ifdef LCD_BACKLIGHT_ENABLE | ||
| 76 | ret |= lcd_backlight_keyframe_animate_color(animation, state); | ||
| 77 | # endif | ||
| 78 | # ifdef BACKLIGHT_ENABLE | ||
| 79 | ret |= led_backlight_keyframe_fade_out_all(animation, state); | ||
| 80 | # endif | ||
| 81 | return ret; | ||
| 82 | } | ||
| 83 | |||
| 84 | // Don't worry, if the startup animation is long, you can use the keyboard like normal | ||
| 85 | // during that time | ||
| 86 | keyframe_animation_t default_startup_animation = { | ||
| 87 | # if LCD_ENABLE | ||
| 88 | .num_frames = 3, | ||
| 89 | # else | ||
| 90 | .num_frames = 2, | ||
| 91 | # endif | ||
| 92 | .loop = false, | ||
| 93 | .frame_lengths = {0, | ||
| 94 | # if LCD_ENABLE | ||
| 95 | 0, | ||
| 96 | # endif | ||
| 97 | gfxMillisecondsToTicks(5000)}, | ||
| 98 | .frame_functions = | ||
| 99 | { | ||
| 100 | keyframe_enable, | ||
| 101 | # if LCD_ENABLE | ||
| 102 | lcd_keyframe_draw_logo, | ||
| 103 | # endif | ||
| 104 | keyframe_fade_in, | ||
| 105 | }, | ||
| 106 | }; | ||
| 107 | |||
| 108 | keyframe_animation_t default_suspend_animation = { | ||
| 109 | # if LCD_ENABLE | ||
| 110 | .num_frames = 3, | ||
| 111 | # else | ||
| 112 | .num_frames = 2, | ||
| 113 | # endif | ||
| 114 | .loop = false, | ||
| 115 | .frame_lengths = | ||
| 116 | { | ||
| 117 | # if LCD_ENABLE | ||
| 118 | 0, | ||
| 119 | # endif | ||
| 120 | gfxMillisecondsToTicks(1000), 0}, | ||
| 121 | .frame_functions = | ||
| 122 | { | ||
| 123 | # if LCD_ENABLE | ||
| 124 | lcd_keyframe_display_layer_text, | ||
| 125 | # endif | ||
| 126 | keyframe_fade_out, | ||
| 127 | keyframe_disable, | ||
| 128 | }, | ||
| 129 | }; | ||
| 130 | # endif | ||
| 131 | |||
| 132 | # if defined(BACKLIGHT_ENABLE) | ||
| 133 | # define CROSSFADE_TIME 1000 | ||
| 134 | # define GRADIENT_TIME 3000 | ||
| 135 | |||
| 136 | keyframe_animation_t led_test_animation = { | ||
| 137 | .num_frames = 14, | ||
| 138 | .loop = true, | ||
| 139 | .frame_lengths = | ||
| 140 | { | ||
| 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 | { | ||
| 159 | led_backlight_keyframe_fade_in_all, | ||
| 160 | keyframe_no_operation, | ||
| 161 | led_backlight_keyframe_fade_out_all, | ||
| 162 | led_backlight_keyframe_crossfade, | ||
| 163 | led_backlight_keyframe_left_to_right_gradient, | ||
| 164 | led_backlight_keyframe_crossfade, | ||
| 165 | led_backlight_keyframe_top_to_bottom_gradient, | ||
| 166 | led_backlight_keyframe_mirror_orientation, | ||
| 167 | led_backlight_keyframe_crossfade, | ||
| 168 | led_backlight_keyframe_left_to_right_gradient, | ||
| 169 | led_backlight_keyframe_crossfade, | ||
| 170 | led_backlight_keyframe_top_to_bottom_gradient, | ||
| 171 | led_backlight_keyframe_normal_orientation, | ||
| 172 | led_backlight_keyframe_crossfade, | ||
| 173 | }, | ||
| 174 | }; | ||
| 175 | # endif | ||
| 176 | |||
| 177 | #endif | ||
diff --git a/quantum/visualizer/default_animations.h b/quantum/visualizer/default_animations.h deleted file mode 100644 index 9accd8977..000000000 --- a/quantum/visualizer/default_animations.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | #pragma once | ||
| 18 | |||
| 19 | #include "visualizer.h" | ||
| 20 | |||
| 21 | // You can use these default animations, but of course you can also write your own custom ones instead | ||
| 22 | extern keyframe_animation_t default_startup_animation; | ||
| 23 | extern keyframe_animation_t default_suspend_animation; | ||
| 24 | |||
| 25 | // An animation for testing and demonstrating the led support, should probably not be used for real world | ||
| 26 | // cases | ||
| 27 | extern keyframe_animation_t led_test_animation; | ||
diff --git a/quantum/visualizer/lcd_backlight.c b/quantum/visualizer/lcd_backlight.c deleted file mode 100644 index 23978974e..000000000 --- a/quantum/visualizer/lcd_backlight.c +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "lcd_backlight.h" | ||
| 26 | #include <math.h> | ||
| 27 | |||
| 28 | static uint8_t current_hue = 0; | ||
| 29 | static uint8_t current_saturation = 0; | ||
| 30 | static uint8_t current_intensity = 0; | ||
| 31 | static uint8_t current_brightness = 0; | ||
| 32 | |||
| 33 | void lcd_backlight_init(void) { | ||
| 34 | lcd_backlight_hal_init(); | ||
| 35 | lcd_backlight_color(current_hue, current_saturation, current_intensity); | ||
| 36 | } | ||
| 37 | |||
| 38 | // This code is based on Brian Neltner's blogpost and example code | ||
| 39 | // "Why every LED light should be using HSI colorspace". | ||
| 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) { | ||
| 42 | unsigned int r, g, b; | ||
| 43 | h = fmodf(h, 360.0f); // cycle h around to 0-360 degrees | ||
| 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] | ||
| 46 | i = i > 0.0f ? (i < 1.0f ? i : 1.0f) : 0.0f; | ||
| 47 | |||
| 48 | // Math! Thanks in part to Kyle Miller. | ||
| 49 | if (h < 2.09439f) { | ||
| 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))); | ||
| 52 | b = 65535.0f * i / 3.0f * (1.0f - s); | ||
| 53 | } else if (h < 4.188787) { | ||
| 54 | h = h - 2.09439; | ||
| 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))); | ||
| 57 | r = 65535.0f * i / 3.0f * (1.0f - s); | ||
| 58 | } else { | ||
| 59 | h = h - 4.188787; | ||
| 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))); | ||
| 62 | g = 65535.0f * i / 3.0f * (1.0f - s); | ||
| 63 | } | ||
| 64 | *r_out = r > 65535 ? 65535 : r; | ||
| 65 | *g_out = g > 65535 ? 65535 : g; | ||
| 66 | *b_out = b > 65535 ? 65535 : b; | ||
| 67 | } | ||
| 68 | |||
| 69 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity) { | ||
| 70 | uint16_t r, g, b; | ||
| 71 | float hue_f = 360.0f * (float)hue / 255.0f; | ||
| 72 | float saturation_f = (float)saturation / 255.0f; | ||
| 73 | float intensity_f = (float)intensity / 255.0f; | ||
| 74 | intensity_f *= (float)current_brightness / 255.0f; | ||
| 75 | hsi_to_rgb(hue_f, saturation_f, intensity_f, &r, &g, &b); | ||
| 76 | current_hue = hue; | ||
| 77 | current_saturation = saturation; | ||
| 78 | current_intensity = intensity; | ||
| 79 | lcd_backlight_hal_color(r, g, b); | ||
| 80 | } | ||
| 81 | |||
| 82 | void lcd_backlight_brightness(uint8_t b) { | ||
| 83 | current_brightness = b; | ||
| 84 | lcd_backlight_color(current_hue, current_saturation, current_intensity); | ||
| 85 | } | ||
| 86 | |||
| 87 | uint8_t lcd_get_backlight_brightness(void) { return current_brightness; } | ||
diff --git a/quantum/visualizer/lcd_backlight.h b/quantum/visualizer/lcd_backlight.h deleted file mode 100644 index 4ea5b1463..000000000 --- a/quantum/visualizer/lcd_backlight.h +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #pragma once | ||
| 26 | |||
| 27 | #include <stdint.h> | ||
| 28 | |||
| 29 | // Helper macros for storing hue, staturation and intensity as unsigned integers | ||
| 30 | #define LCD_COLOR(hue, saturation, intensity) (hue << 16 | saturation << 8 | intensity) | ||
| 31 | #define LCD_HUE(color) ((color >> 16) & 0xFF) | ||
| 32 | #define LCD_SAT(color) ((color >> 8) & 0xFF) | ||
| 33 | #define LCD_INT(color) (color & 0xFF) | ||
| 34 | |||
| 35 | static inline uint32_t change_lcd_color_intensity(uint32_t color, uint8_t new_intensity) { return (color & 0xFFFFFF00) | new_intensity; } | ||
| 36 | |||
| 37 | void lcd_backlight_init(void); | ||
| 38 | void lcd_backlight_color(uint8_t hue, uint8_t saturation, uint8_t intensity); | ||
| 39 | void lcd_backlight_brightness(uint8_t b); | ||
| 40 | uint8_t lcd_get_backlight_brightness(void); | ||
| 41 | |||
| 42 | void lcd_backlight_hal_init(void); | ||
| 43 | void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b); | ||
diff --git a/quantum/visualizer/lcd_backlight_keyframes.c b/quantum/visualizer/lcd_backlight_keyframes.c deleted file mode 100644 index c13cce311..000000000 --- a/quantum/visualizer/lcd_backlight_keyframes.c +++ /dev/null | |||
| @@ -1,69 +0,0 @@ | |||
| 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 | #include "lcd_backlight_keyframes.h" | ||
| 18 | |||
| 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]; | ||
| 21 | int current_pos = frame_length - animation->time_left_in_frame; | ||
| 22 | uint8_t t_h = LCD_HUE(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); | ||
| 25 | uint8_t p_h = LCD_HUE(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); | ||
| 28 | |||
| 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; | ||
| 31 | // Chose the shortest way around | ||
| 32 | int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1; | ||
| 33 | int d_s = t_s - p_s; | ||
| 34 | int d_i = t_i - p_i; | ||
| 35 | |||
| 36 | int hue = (d_h * current_pos) / frame_length; | ||
| 37 | int sat = (d_s * current_pos) / frame_length; | ||
| 38 | int intensity = (d_i * current_pos) / frame_length; | ||
| 39 | // dprintf("%X -> %X = %X\n", p_h, t_h, hue); | ||
| 40 | hue += p_h; | ||
| 41 | sat += p_s; | ||
| 42 | intensity += p_i; | ||
| 43 | state->current_lcd_color = LCD_COLOR(hue, sat, intensity); | ||
| 44 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); | ||
| 45 | |||
| 46 | return true; | ||
| 47 | } | ||
| 48 | |||
| 49 | bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 50 | (void)animation; | ||
| 51 | state->prev_lcd_color = state->target_lcd_color; | ||
| 52 | state->current_lcd_color = state->target_lcd_color; | ||
| 53 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); | ||
| 54 | return false; | ||
| 55 | } | ||
| 56 | |||
| 57 | bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 58 | (void)animation; | ||
| 59 | (void)state; | ||
| 60 | lcd_backlight_hal_color(0, 0, 0); | ||
| 61 | return false; | ||
| 62 | } | ||
| 63 | |||
| 64 | bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 65 | (void)animation; | ||
| 66 | (void)state; | ||
| 67 | lcd_backlight_color(LCD_HUE(state->current_lcd_color), LCD_SAT(state->current_lcd_color), LCD_INT(state->current_lcd_color)); | ||
| 68 | return false; | ||
| 69 | } | ||
diff --git a/quantum/visualizer/lcd_backlight_keyframes.h b/quantum/visualizer/lcd_backlight_keyframes.h deleted file mode 100644 index 88768dd4a..000000000 --- a/quantum/visualizer/lcd_backlight_keyframes.h +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 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 | #pragma once | ||
| 18 | |||
| 19 | #include "visualizer.h" | ||
| 20 | |||
| 21 | // Animates the LCD backlight color between the current color and the target color (of the state) | ||
| 22 | bool lcd_backlight_keyframe_animate_color(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 23 | // Sets the backlight color to the target color | ||
| 24 | bool lcd_backlight_keyframe_set_color(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 25 | |||
| 26 | bool lcd_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 27 | bool lcd_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
diff --git a/quantum/visualizer/lcd_keyframes.c b/quantum/visualizer/lcd_keyframes.c deleted file mode 100644 index 1d6f3dca1..000000000 --- a/quantum/visualizer/lcd_keyframes.c +++ /dev/null | |||
| @@ -1,184 +0,0 @@ | |||
| 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 | #include "lcd_keyframes.h" | ||
| 18 | #include <string.h> | ||
| 19 | #include "action_util.h" | ||
| 20 | #include "led.h" | ||
| 21 | #include "resources/resources.h" | ||
| 22 | |||
| 23 | bool lcd_keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 24 | (void)animation; | ||
| 25 | gdispClear(White); | ||
| 26 | gdispDrawString(0, 10, state->layer_text, state->font_dejavusansbold12, Black); | ||
| 27 | return false; | ||
| 28 | } | ||
| 29 | |||
| 30 | static void format_layer_bitmap_string(uint16_t default_layer, uint16_t layer, char* buffer) { | ||
| 31 | for (int i = 0; i < 16; i++) { | ||
| 32 | uint32_t mask = (1u << i); | ||
| 33 | if (default_layer & mask) { | ||
| 34 | if (layer & mask) { | ||
| 35 | *buffer = 'B'; | ||
| 36 | } else { | ||
| 37 | *buffer = 'D'; | ||
| 38 | } | ||
| 39 | } else if (layer & mask) { | ||
| 40 | *buffer = '1'; | ||
| 41 | } else { | ||
| 42 | *buffer = '0'; | ||
| 43 | } | ||
| 44 | ++buffer; | ||
| 45 | |||
| 46 | if (i == 3 || i == 7 || i == 11) { | ||
| 47 | *buffer = ' '; | ||
| 48 | ++buffer; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | *buffer = 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | bool lcd_keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 55 | (void)animation; | ||
| 56 | const char* layer_help = "1=On D=Default B=Both"; | ||
| 57 | char layer_buffer[16 + 4]; // 3 spaces and one null terminator | ||
| 58 | gdispClear(White); | ||
| 59 | gdispDrawString(0, 0, layer_help, state->font_fixed5x8, Black); | ||
| 60 | format_layer_bitmap_string(state->status.default_layer, state->status.layer, layer_buffer); | ||
| 61 | gdispDrawString(0, 10, layer_buffer, state->font_fixed5x8, Black); | ||
| 62 | format_layer_bitmap_string(state->status.default_layer >> 16, state->status.layer >> 16, layer_buffer); | ||
| 63 | gdispDrawString(0, 20, layer_buffer, state->font_fixed5x8, Black); | ||
| 64 | return false; | ||
| 65 | } | ||
| 66 | |||
| 67 | static void format_mods_bitmap_string(uint8_t mods, char* buffer) { | ||
| 68 | *buffer = ' '; | ||
| 69 | ++buffer; | ||
| 70 | |||
| 71 | for (int i = 0; i < 8; i++) { | ||
| 72 | uint32_t mask = (1u << i); | ||
| 73 | if (mods & mask) { | ||
| 74 | *buffer = '1'; | ||
| 75 | } else { | ||
| 76 | *buffer = '0'; | ||
| 77 | } | ||
| 78 | ++buffer; | ||
| 79 | |||
| 80 | if (i == 3) { | ||
| 81 | *buffer = ' '; | ||
| 82 | ++buffer; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | *buffer = 0; | ||
| 86 | } | ||
| 87 | |||
| 88 | bool lcd_keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 89 | (void)animation; | ||
| 90 | |||
| 91 | const char* title = "Modifier states"; | ||
| 92 | const char* mods_header = " CSAG CSAG "; | ||
| 93 | char status_buffer[12]; | ||
| 94 | |||
| 95 | gdispClear(White); | ||
| 96 | gdispDrawString(0, 0, title, state->font_fixed5x8, Black); | ||
| 97 | gdispDrawString(0, 10, mods_header, state->font_fixed5x8, Black); | ||
| 98 | format_mods_bitmap_string(state->status.mods, status_buffer); | ||
| 99 | gdispDrawString(0, 20, status_buffer, state->font_fixed5x8, Black); | ||
| 100 | |||
| 101 | return false; | ||
| 102 | } | ||
| 103 | |||
| 104 | #define LED_STATE_STRING_SIZE sizeof("NUM CAPS SCRL COMP KANA") | ||
| 105 | |||
| 106 | static void get_led_state_string(char* output, visualizer_state_t* state) { | ||
| 107 | uint8_t pos = 0; | ||
| 108 | |||
| 109 | if (state->status.leds & (1u << USB_LED_NUM_LOCK)) { | ||
| 110 | memcpy(output + pos, "NUM ", 4); | ||
| 111 | pos += 4; | ||
| 112 | } | ||
| 113 | if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) { | ||
| 114 | memcpy(output + pos, "CAPS ", 5); | ||
| 115 | pos += 5; | ||
| 116 | } | ||
| 117 | if (state->status.leds & (1u << USB_LED_SCROLL_LOCK)) { | ||
| 118 | memcpy(output + pos, "SCRL ", 5); | ||
| 119 | pos += 5; | ||
| 120 | } | ||
| 121 | if (state->status.leds & (1u << USB_LED_COMPOSE)) { | ||
| 122 | memcpy(output + pos, "COMP ", 5); | ||
| 123 | pos += 5; | ||
| 124 | } | ||
| 125 | if (state->status.leds & (1u << USB_LED_KANA)) { | ||
| 126 | memcpy(output + pos, "KANA", 4); | ||
| 127 | pos += 4; | ||
| 128 | } | ||
| 129 | output[pos] = 0; | ||
| 130 | } | ||
| 131 | |||
| 132 | bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 133 | (void)animation; | ||
| 134 | char output[LED_STATE_STRING_SIZE]; | ||
| 135 | get_led_state_string(output, state); | ||
| 136 | gdispClear(White); | ||
| 137 | gdispDrawString(0, 10, output, state->font_dejavusansbold12, Black); | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | |||
| 141 | bool lcd_keyframe_display_layer_and_led_states(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 142 | (void)animation; | ||
| 143 | gdispClear(White); | ||
| 144 | uint8_t y = 10; | ||
| 145 | if (state->status.leds) { | ||
| 146 | char output[LED_STATE_STRING_SIZE]; | ||
| 147 | get_led_state_string(output, state); | ||
| 148 | gdispDrawString(0, 1, output, state->font_dejavusansbold12, Black); | ||
| 149 | y = 17; | ||
| 150 | } | ||
| 151 | gdispDrawString(0, y, state->layer_text, state->font_dejavusansbold12, Black); | ||
| 152 | return false; | ||
| 153 | } | ||
| 154 | |||
| 155 | bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 156 | (void)state; | ||
| 157 | (void)animation; | ||
| 158 | // Read the uGFX documentation for information how to use the displays | ||
| 159 | // http://wiki.ugfx.org/index.php/Main_Page | ||
| 160 | gdispClear(Black); | ||
| 161 | |||
| 162 | // You can use static variables for things that can't be found in the animation | ||
| 163 | // or state structs, here we use the image | ||
| 164 | |||
| 165 | // gdispGBlitArea is a tricky function to use since it supports blitting part of the image | ||
| 166 | // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions | ||
| 167 | gdispGBlitArea(GDISP, 0, 0, 128, 32, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo); | ||
| 168 | |||
| 169 | return false; | ||
| 170 | } | ||
| 171 | |||
| 172 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 173 | (void)animation; | ||
| 174 | (void)state; | ||
| 175 | gdispSetPowerMode(powerOff); | ||
| 176 | return false; | ||
| 177 | } | ||
| 178 | |||
| 179 | bool lcd_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 180 | (void)animation; | ||
| 181 | (void)state; | ||
| 182 | gdispSetPowerMode(powerOn); | ||
| 183 | return false; | ||
| 184 | } | ||
diff --git a/quantum/visualizer/lcd_keyframes.h b/quantum/visualizer/lcd_keyframes.h deleted file mode 100644 index b7125e832..000000000 --- a/quantum/visualizer/lcd_keyframes.h +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 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 | #pragma once | ||
| 18 | |||
| 19 | #include "visualizer.h" | ||
| 20 | |||
| 21 | // Displays the layer text centered vertically on the screen | ||
| 22 | bool lcd_keyframe_display_layer_text(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 23 | // Displays a bitmap (0/1) of all the currently active layers | ||
| 24 | bool lcd_keyframe_display_layer_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 25 | // Displays a bitmap (0/1) of all the currently active mods | ||
| 26 | bool lcd_keyframe_display_mods_bitmap(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 27 | // Displays the keyboard led states (CAPS (Caps lock), NUM (Num lock), SCRL (Scroll lock), COMP (Compose), KANA) | ||
| 28 | bool lcd_keyframe_display_led_states(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 29 | // Displays both the layer text and the led states | ||
| 30 | bool lcd_keyframe_display_layer_and_led_states(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 31 | // Displays the QMK logo on the LCD screen | ||
| 32 | bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 33 | |||
| 34 | bool lcd_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 35 | bool lcd_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
diff --git a/quantum/visualizer/led_backlight_keyframes.c b/quantum/visualizer/led_backlight_keyframes.c deleted file mode 100644 index 338ada522..000000000 --- a/quantum/visualizer/led_backlight_keyframes.c +++ /dev/null | |||
| @@ -1,143 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | #include "gfx.h" | ||
| 25 | #include <math.h> | ||
| 26 | #include "led_backlight_keyframes.h" | ||
| 27 | |||
| 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]; | ||
| 30 | int current_pos = frame_length - animation->time_left_in_frame; | ||
| 31 | int delta = to - from; | ||
| 32 | int luma = (delta * current_pos) / frame_length; | ||
| 33 | luma += from; | ||
| 34 | return luma; | ||
| 35 | } | ||
| 36 | |||
| 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); | ||
| 39 | color_t color = LUMA2COLOR(luma); | ||
| 40 | gdispGClear(LED_DISPLAY, color); | ||
| 41 | } | ||
| 42 | |||
| 43 | // TODO: Should be customizable per keyboard | ||
| 44 | #define NUM_ROWS LED_HEIGHT | ||
| 45 | #define NUM_COLS LED_WIDTH | ||
| 46 | |||
| 47 | static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS]; | ||
| 48 | static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS]; | ||
| 49 | |||
| 50 | static uint8_t compute_gradient_color(float t, float index, float num) { | ||
| 51 | const float two_pi = M_PI * 2.0f; | ||
| 52 | float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi; | ||
| 53 | float x = t * two_pi + normalized_index; | ||
| 54 | float v = 0.5 * (cosf(x) + 1.0f); | ||
| 55 | return (uint8_t)(255.0f * v); | ||
| 56 | } | ||
| 57 | |||
| 58 | bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 59 | (void)state; | ||
| 60 | keyframe_fade_all_leds_from_to(animation, 0, 255); | ||
| 61 | return true; | ||
| 62 | } | ||
| 63 | |||
| 64 | bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 65 | (void)state; | ||
| 66 | keyframe_fade_all_leds_from_to(animation, 255, 0); | ||
| 67 | return true; | ||
| 68 | } | ||
| 69 | |||
| 70 | bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 71 | (void)state; | ||
| 72 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 73 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 74 | float t = current_pos / frame_length; | ||
| 75 | for (int i = 0; i < NUM_COLS; i++) { | ||
| 76 | uint8_t color = compute_gradient_color(t, i, NUM_COLS); | ||
| 77 | gdispGDrawLine(LED_DISPLAY, i, 0, i, NUM_ROWS - 1, LUMA2COLOR(color)); | ||
| 78 | } | ||
| 79 | return true; | ||
| 80 | } | ||
| 81 | |||
| 82 | bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 83 | (void)state; | ||
| 84 | float frame_length = animation->frame_lengths[animation->current_frame]; | ||
| 85 | float current_pos = frame_length - animation->time_left_in_frame; | ||
| 86 | float t = current_pos / frame_length; | ||
| 87 | for (int i = 0; i < NUM_ROWS; i++) { | ||
| 88 | uint8_t color = compute_gradient_color(t, i, NUM_ROWS); | ||
| 89 | gdispGDrawLine(LED_DISPLAY, 0, i, NUM_COLS - 1, i, LUMA2COLOR(color)); | ||
| 90 | } | ||
| 91 | return true; | ||
| 92 | } | ||
| 93 | |||
| 94 | static void copy_current_led_state(uint8_t* dest) { | ||
| 95 | for (int i = 0; i < NUM_ROWS; i++) { | ||
| 96 | for (int j = 0; j < NUM_COLS; j++) { | ||
| 97 | dest[i * NUM_COLS + j] = gdispGGetPixelColor(LED_DISPLAY, j, i); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | } | ||
| 101 | bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 102 | (void)state; | ||
| 103 | if (animation->first_update_of_frame) { | ||
| 104 | copy_current_led_state(&crossfade_start_frame[0][0]); | ||
| 105 | run_next_keyframe(animation, state); | ||
| 106 | copy_current_led_state(&crossfade_end_frame[0][0]); | ||
| 107 | } | ||
| 108 | for (int i = 0; i < NUM_ROWS; i++) { | ||
| 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])); | ||
| 111 | gdispGDrawPixel(LED_DISPLAY, j, i, color); | ||
| 112 | } | ||
| 113 | } | ||
| 114 | return true; | ||
| 115 | } | ||
| 116 | |||
| 117 | bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 118 | (void)state; | ||
| 119 | (void)animation; | ||
| 120 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_180); | ||
| 121 | return false; | ||
| 122 | } | ||
| 123 | |||
| 124 | bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 125 | (void)state; | ||
| 126 | (void)animation; | ||
| 127 | gdispGSetOrientation(LED_DISPLAY, GDISP_ROTATE_0); | ||
| 128 | return false; | ||
| 129 | } | ||
| 130 | |||
| 131 | bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 132 | (void)state; | ||
| 133 | (void)animation; | ||
| 134 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 135 | return false; | ||
| 136 | } | ||
| 137 | |||
| 138 | bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 139 | (void)state; | ||
| 140 | (void)animation; | ||
| 141 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 142 | return false; | ||
| 143 | } | ||
diff --git a/quantum/visualizer/led_backlight_keyframes.h b/quantum/visualizer/led_backlight_keyframes.h deleted file mode 100644 index 90153be5e..000000000 --- a/quantum/visualizer/led_backlight_keyframes.h +++ /dev/null | |||
| @@ -1,40 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #pragma once | ||
| 26 | |||
| 27 | #include "visualizer.h" | ||
| 28 | |||
| 29 | bool led_backlight_keyframe_fade_in_all(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 30 | bool led_backlight_keyframe_fade_out_all(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 31 | bool led_backlight_keyframe_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 32 | bool led_backlight_keyframe_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 33 | bool led_backlight_keyframe_crossfade(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 34 | bool led_backlight_keyframe_mirror_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 35 | bool led_backlight_keyframe_normal_orientation(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 36 | |||
| 37 | bool led_backlight_keyframe_disable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 38 | bool led_backlight_keyframe_enable(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 39 | |||
| 40 | extern keyframe_animation_t led_test_animation; | ||
diff --git a/quantum/visualizer/readme.md b/quantum/visualizer/readme.md deleted file mode 100644 index 298efb742..000000000 --- a/quantum/visualizer/readme.md +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | # A visualization library for the TMK keyboard firmware | ||
| 2 | |||
| 3 | This library is designed to work together with the [TMK keyboard firmware](https://github.com/tmk/tmk_keyboard). Currently it only works for [Chibios](http://www.chibios.org/) | ||
| 4 | flavors, but it would be possible to add support for other configurations as well. The LCD display functionality is provided by the [uGFX library](https://ugfx.io/). | ||
| 5 | |||
| 6 | ## To use this library as a user | ||
| 7 | You can and should modify the visualizer\_user.c file. Check the comments in the file for more information. | ||
| 8 | |||
| 9 | ## To add this library to custom keyboard projects | ||
| 10 | |||
| 11 | 1. Add tmk_visualizer as a submodule to your project | ||
| 12 | 1. Set VISUALIZER_DIR in the main keyboard project makefile to point to the submodule | ||
| 13 | 1. Define LCD\_ENABLE and/or LCD\_BACKLIGHT\_ENABLE, to enable support | ||
| 14 | 1. Include the visualizer.mk make file | ||
| 15 | 1. Copy the files in the example\_integration folder to your keyboard project | ||
| 16 | 1. All other files than the callback.c file are included automatically, so you will need to add callback.c to your makefile manually. If you already have a similar file in your project, you can just copy the functions instead of the whole file. | ||
| 17 | 1. Edit the files to match your hardware. You might might want to read the Chibios and UGfx documentation, for more information. | ||
| 18 | 1. If you enable LCD support you might also have to write a custom uGFX display driver, check the uGFX documentation for that. You probably also want to enable SPI support in your Chibios configuration. | ||
diff --git a/quantum/visualizer/resources/lcd_logo.c b/quantum/visualizer/resources/lcd_logo.c deleted file mode 100644 index 13bf734cb..000000000 --- a/quantum/visualizer/resources/lcd_logo.c +++ /dev/null | |||
| @@ -1,45 +0,0 @@ | |||
| 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 | #include "resources.h" | ||
| 18 | |||
| 19 | // clang-format off | ||
| 20 | |||
| 21 | // To generate an image array like this | ||
| 22 | // Ensure the image is 128 x 32 or smaller | ||
| 23 | // Convert the bitmap to a C array using a program like http://www.riuson.com/lcd-image-converter/ | ||
| 24 | // Ensure the the conversion process produces a monochrome format array - 1 bit/pixel, left to right, top to bottom | ||
| 25 | // Update array in the source code with the C array produced by the conversion program | ||
| 26 | |||
| 27 | // The image below is generated from lcd_logo.png | ||
| 28 | __attribute__((weak)) const uint8_t resource_lcd_logo[512] = { | ||
| 29 | 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, | ||
| 30 | 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, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 32 | 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 33 | 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 34 | 0x00, 0xFE, 0xEE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xEE, 0xF0, 0x01, 0xC6, 0x0D, 0x8C, 0x1F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 35 | 0x00, 0xFE, 0xEE, 0xFE, 0x03, 0xE7, 0x1D, 0x9C, 0x1F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x37, 0x1D, 0xB8, 0x18, 0x0B, 0x59, 0xC8, 0x09, 0xE5, 0x9E, 0x00, | ||
| 36 | 0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x37, 0xBD, 0xF0, 0x18, 0x6F, 0x7F, 0xEC, 0x9B, 0x37, 0xB3, 0x00, 0x00, 0xFE, 0xEE, 0xFE, 0x06, 0x37, 0xBD, 0xE0, 0x1F, 0x6C, 0x66, 0x6D, 0xD8, 0x36, 0x33, 0x00, | ||
| 37 | 0x00, 0x1E, 0xEE, 0xF0, 0x06, 0x36, 0xED, 0xF0, 0x1F, 0x6C, 0x66, 0x6D, 0x59, 0xF6, 0x3E, 0x00, 0x00, 0x1F, 0x6D, 0xF0, 0x06, 0x36, 0xED, 0xB8, 0x18, 0x6C, 0x66, 0x67, 0x73, 0x36, 0x30, 0x00, | ||
| 38 | 0x00, 0xFF, 0x83, 0xFE, 0x03, 0xE6, 0x4D, 0x9C, 0x18, 0x6C, 0x66, 0x67, 0x73, 0x36, 0x1F, 0x00, 0x00, 0x1F, 0xEF, 0xF0, 0x01, 0xC6, 0x0D, 0x8C, 0x18, 0x6C, 0x66, 0x62, 0x21, 0xD6, 0x0E, 0x00, | ||
| 39 | 0x00, 0xFF, 0xEF, 0xFE, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 40 | 0x00, 0x1F, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 41 | 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x92, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 42 | 0x00, 0x02, 0x92, 0x80, 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, | ||
| 43 | 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, | ||
| 44 | 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 | ||
| 45 | }; | ||
diff --git a/quantum/visualizer/resources/lcd_logo.png b/quantum/visualizer/resources/lcd_logo.png deleted file mode 100644 index 178ef65f1..000000000 --- a/quantum/visualizer/resources/lcd_logo.png +++ /dev/null | |||
| Binary files differ | |||
diff --git a/quantum/visualizer/resources/resources.h b/quantum/visualizer/resources/resources.h deleted file mode 100644 index 5178fbe55..000000000 --- a/quantum/visualizer/resources/resources.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | #pragma once | ||
| 18 | |||
| 19 | #include <stdint.h> | ||
| 20 | |||
| 21 | #ifdef LCD_ENABLE | ||
| 22 | extern const uint8_t resource_lcd_logo[]; | ||
| 23 | #endif | ||
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c deleted file mode 100644 index 709affbb7..000000000 --- a/quantum/visualizer/visualizer.c +++ /dev/null | |||
| @@ -1,483 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include "config.h" | ||
| 26 | #include "visualizer.h" | ||
| 27 | #include <string.h> | ||
| 28 | #ifdef PROTOCOL_CHIBIOS | ||
| 29 | # include <ch.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #include "gfx.h" | ||
| 33 | |||
| 34 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 35 | # include "lcd_backlight.h" | ||
| 36 | #endif | ||
| 37 | |||
| 38 | //#define DEBUG_VISUALIZER | ||
| 39 | |||
| 40 | #ifdef DEBUG_VISUALIZER | ||
| 41 | # include "debug.h" | ||
| 42 | #else | ||
| 43 | # include "nodebug.h" | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #ifdef SERIAL_LINK_ENABLE | ||
| 47 | # include "serial_link/protocol/transport.h" | ||
| 48 | # include "serial_link/system/serial_link.h" | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #include "action_util.h" | ||
| 52 | |||
| 53 | // Define this in config.h | ||
| 54 | #ifndef VISUALIZER_THREAD_PRIORITY | ||
| 55 | // The visualizer needs gfx thread priorities | ||
| 56 | # define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2) | ||
| 57 | #endif | ||
| 58 | |||
| 59 | static visualizer_keyboard_status_t current_status = {.layer = 0xFFFFFFFF, | ||
| 60 | .default_layer = 0xFFFFFFFF, | ||
| 61 | .leds = 0xFFFFFFFF, | ||
| 62 | #ifdef BACKLIGHT_ENABLE | ||
| 63 | .backlight_level = 0, | ||
| 64 | #endif | ||
| 65 | .mods = 0xFF, | ||
| 66 | .suspended = false, | ||
| 67 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 68 | .user_data = {0} | ||
| 69 | #endif | ||
| 70 | }; | ||
| 71 | |||
| 72 | static bool same_status(visualizer_keyboard_status_t* status1, visualizer_keyboard_status_t* status2) { | ||
| 73 | return status1->layer == status2->layer && status1->default_layer == status2->default_layer && status1->mods == status2->mods && status1->leds == status2->leds && status1->suspended == status2->suspended | ||
| 74 | #ifdef BACKLIGHT_ENABLE | ||
| 75 | && status1->backlight_level == status2->backlight_level | ||
| 76 | #endif | ||
| 77 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 78 | && memcmp(status1->user_data, status2->user_data, VISUALIZER_USER_DATA_SIZE) == 0 | ||
| 79 | #endif | ||
| 80 | ; | ||
| 81 | } | ||
| 82 | |||
| 83 | static bool visualizer_enabled = false; | ||
| 84 | |||
| 85 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 86 | static uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; | ||
| 87 | #endif | ||
| 88 | |||
| 89 | #define MAX_SIMULTANEOUS_ANIMATIONS 4 | ||
| 90 | static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {}; | ||
| 91 | |||
| 92 | #ifdef SERIAL_LINK_ENABLE | ||
| 93 | MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t); | ||
| 94 | |||
| 95 | static remote_object_t* remote_objects[] = { | ||
| 96 | REMOTE_OBJECT(current_status), | ||
| 97 | }; | ||
| 98 | |||
| 99 | #endif | ||
| 100 | |||
| 101 | GDisplay* LCD_DISPLAY = 0; | ||
| 102 | GDisplay* LED_DISPLAY = 0; | ||
| 103 | |||
| 104 | #ifdef LCD_DISPLAY_NUMBER | ||
| 105 | __attribute__((weak)) GDisplay* get_lcd_display(void) { return gdispGetDisplay(LCD_DISPLAY_NUMBER); } | ||
| 106 | #endif | ||
| 107 | |||
| 108 | #ifdef LED_DISPLAY_NUMBER | ||
| 109 | __attribute__((weak)) GDisplay* get_led_display(void) { return gdispGetDisplay(LED_DISPLAY_NUMBER); } | ||
| 110 | #endif | ||
| 111 | |||
| 112 | void start_keyframe_animation(keyframe_animation_t* animation) { | ||
| 113 | animation->current_frame = -1; | ||
| 114 | animation->time_left_in_frame = 0; | ||
| 115 | animation->need_update = true; | ||
| 116 | int free_index = -1; | ||
| 117 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { | ||
| 118 | if (animations[i] == animation) { | ||
| 119 | return; | ||
| 120 | } | ||
| 121 | if (free_index == -1 && animations[i] == NULL) { | ||
| 122 | free_index = i; | ||
| 123 | } | ||
| 124 | } | ||
| 125 | if (free_index != -1) { | ||
| 126 | animations[free_index] = animation; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | void stop_keyframe_animation(keyframe_animation_t* animation) { | ||
| 131 | animation->current_frame = animation->num_frames; | ||
| 132 | animation->time_left_in_frame = 0; | ||
| 133 | animation->need_update = true; | ||
| 134 | animation->first_update_of_frame = false; | ||
| 135 | animation->last_update_of_frame = false; | ||
| 136 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { | ||
| 137 | if (animations[i] == animation) { | ||
| 138 | animations[i] = NULL; | ||
| 139 | return; | ||
| 140 | } | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | void stop_all_keyframe_animations(void) { | ||
| 145 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { | ||
| 146 | if (animations[i]) { | ||
| 147 | animations[i]->current_frame = animations[i]->num_frames; | ||
| 148 | animations[i]->time_left_in_frame = 0; | ||
| 149 | animations[i]->need_update = true; | ||
| 150 | animations[i]->first_update_of_frame = false; | ||
| 151 | animations[i]->last_update_of_frame = false; | ||
| 152 | animations[i] = NULL; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | } | ||
| 156 | |||
| 157 | static uint8_t get_num_running_animations(void) { | ||
| 158 | uint8_t count = 0; | ||
| 159 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { | ||
| 160 | count += animations[i] ? 1 : 0; | ||
| 161 | } | ||
| 162 | return count; | ||
| 163 | } | ||
| 164 | |||
| 165 | static bool update_keyframe_animation(keyframe_animation_t* animation, visualizer_state_t* state, systemticks_t delta, systemticks_t* sleep_time) { | ||
| 166 | // TODO: Clean up this messy code | ||
| 167 | dprintf("Animation frame%d, left %d, delta %d\n", animation->current_frame, animation->time_left_in_frame, delta); | ||
| 168 | if (animation->current_frame == animation->num_frames) { | ||
| 169 | animation->need_update = false; | ||
| 170 | return false; | ||
| 171 | } | ||
| 172 | if (animation->current_frame == -1) { | ||
| 173 | animation->current_frame = 0; | ||
| 174 | animation->time_left_in_frame = animation->frame_lengths[0]; | ||
| 175 | animation->need_update = true; | ||
| 176 | animation->first_update_of_frame = true; | ||
| 177 | } else { | ||
| 178 | animation->time_left_in_frame -= delta; | ||
| 179 | while (animation->time_left_in_frame <= 0) { | ||
| 180 | int left = animation->time_left_in_frame; | ||
| 181 | if (animation->need_update) { | ||
| 182 | animation->time_left_in_frame = 0; | ||
| 183 | animation->last_update_of_frame = true; | ||
| 184 | (*animation->frame_functions[animation->current_frame])(animation, state); | ||
| 185 | animation->last_update_of_frame = false; | ||
| 186 | } | ||
| 187 | animation->current_frame++; | ||
| 188 | animation->need_update = true; | ||
| 189 | animation->first_update_of_frame = true; | ||
| 190 | if (animation->current_frame == animation->num_frames) { | ||
| 191 | if (animation->loop) { | ||
| 192 | animation->current_frame = 0; | ||
| 193 | } else { | ||
| 194 | stop_keyframe_animation(animation); | ||
| 195 | return false; | ||
| 196 | } | ||
| 197 | } | ||
| 198 | delta = -left; | ||
| 199 | animation->time_left_in_frame = animation->frame_lengths[animation->current_frame]; | ||
| 200 | animation->time_left_in_frame -= delta; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | if (animation->need_update) { | ||
| 204 | animation->need_update = (*animation->frame_functions[animation->current_frame])(animation, state); | ||
| 205 | animation->first_update_of_frame = false; | ||
| 206 | } | ||
| 207 | |||
| 208 | systemticks_t wanted_sleep = animation->need_update ? gfxMillisecondsToTicks(10) : (unsigned)animation->time_left_in_frame; | ||
| 209 | if (wanted_sleep < *sleep_time) { | ||
| 210 | *sleep_time = wanted_sleep; | ||
| 211 | } | ||
| 212 | |||
| 213 | return true; | ||
| 214 | } | ||
| 215 | |||
| 216 | void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 217 | int next_frame = animation->current_frame + 1; | ||
| 218 | if (next_frame == animation->num_frames) { | ||
| 219 | next_frame = 0; | ||
| 220 | } | ||
| 221 | keyframe_animation_t temp_animation = *animation; | ||
| 222 | temp_animation.current_frame = next_frame; | ||
| 223 | temp_animation.time_left_in_frame = animation->frame_lengths[next_frame]; | ||
| 224 | temp_animation.first_update_of_frame = true; | ||
| 225 | temp_animation.last_update_of_frame = false; | ||
| 226 | temp_animation.need_update = false; | ||
| 227 | visualizer_state_t temp_state = *state; | ||
| 228 | (*temp_animation.frame_functions[next_frame])(&temp_animation, &temp_state); | ||
| 229 | } | ||
| 230 | |||
| 231 | // TODO: Optimize the stack size, this is probably way too big | ||
| 232 | static DECLARE_THREAD_STACK(visualizerThreadStack, 1024); | ||
| 233 | static DECLARE_THREAD_FUNCTION(visualizerThread, arg) { | ||
| 234 | (void)arg; | ||
| 235 | |||
| 236 | GListener event_listener; | ||
| 237 | geventListenerInit(&event_listener); | ||
| 238 | geventAttachSource(&event_listener, (GSourceHandle)¤t_status, 0); | ||
| 239 | |||
| 240 | visualizer_keyboard_status_t initial_status = { | ||
| 241 | .default_layer = 0xFFFFFFFF, | ||
| 242 | .layer = 0xFFFFFFFF, | ||
| 243 | .mods = 0xFF, | ||
| 244 | .leds = 0xFFFFFFFF, | ||
| 245 | .suspended = false, | ||
| 246 | #ifdef BACKLIGHT_ENABLE | ||
| 247 | .backlight_level = 0, | ||
| 248 | #endif | ||
| 249 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 250 | .user_data = {0}, | ||
| 251 | #endif | ||
| 252 | }; | ||
| 253 | |||
| 254 | visualizer_state_t state = {.status = initial_status, | ||
| 255 | .current_lcd_color = 0, | ||
| 256 | #ifdef LCD_ENABLE | ||
| 257 | .font_fixed5x8 = gdispOpenFont("fixed_5x8"), | ||
| 258 | .font_dejavusansbold12 = gdispOpenFont("DejaVuSansBold12") | ||
| 259 | #endif | ||
| 260 | }; | ||
| 261 | initialize_user_visualizer(&state); | ||
| 262 | state.prev_lcd_color = state.current_lcd_color; | ||
| 263 | |||
| 264 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 265 | lcd_backlight_color(LCD_HUE(state.current_lcd_color), LCD_SAT(state.current_lcd_color), LCD_INT(state.current_lcd_color)); | ||
| 266 | #endif | ||
| 267 | |||
| 268 | systemticks_t sleep_time = TIME_INFINITE; | ||
| 269 | systemticks_t current_time = gfxSystemTicks(); | ||
| 270 | bool force_update = true; | ||
| 271 | |||
| 272 | while (true) { | ||
| 273 | systemticks_t new_time = gfxSystemTicks(); | ||
| 274 | systemticks_t delta = new_time - current_time; | ||
| 275 | current_time = new_time; | ||
| 276 | bool enabled = visualizer_enabled; | ||
| 277 | if (force_update || !same_status(&state.status, ¤t_status)) { | ||
| 278 | force_update = false; | ||
| 279 | #if BACKLIGHT_ENABLE | ||
| 280 | if (current_status.backlight_level != state.status.backlight_level) { | ||
| 281 | if (current_status.backlight_level != 0) { | ||
| 282 | gdispGSetPowerMode(LED_DISPLAY, powerOn); | ||
| 283 | uint16_t percent = (uint16_t)current_status.backlight_level * 100 / BACKLIGHT_LEVELS; | ||
| 284 | gdispGSetBacklight(LED_DISPLAY, percent); | ||
| 285 | } else { | ||
| 286 | gdispGSetPowerMode(LED_DISPLAY, powerOff); | ||
| 287 | } | ||
| 288 | state.status.backlight_level = current_status.backlight_level; | ||
| 289 | } | ||
| 290 | #endif | ||
| 291 | if (visualizer_enabled) { | ||
| 292 | if (current_status.suspended) { | ||
| 293 | stop_all_keyframe_animations(); | ||
| 294 | visualizer_enabled = false; | ||
| 295 | state.status = current_status; | ||
| 296 | user_visualizer_suspend(&state); | ||
| 297 | } else { | ||
| 298 | visualizer_keyboard_status_t prev_status = state.status; | ||
| 299 | state.status = current_status; | ||
| 300 | update_user_visualizer_state(&state, &prev_status); | ||
| 301 | } | ||
| 302 | state.prev_lcd_color = state.current_lcd_color; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | if (!enabled && state.status.suspended && current_status.suspended == false) { | ||
| 306 | // Setting the status to the initial status will force an update | ||
| 307 | // when the visualizer is enabled again | ||
| 308 | state.status = initial_status; | ||
| 309 | state.status.suspended = false; | ||
| 310 | stop_all_keyframe_animations(); | ||
| 311 | user_visualizer_resume(&state); | ||
| 312 | state.prev_lcd_color = state.current_lcd_color; | ||
| 313 | } | ||
| 314 | sleep_time = TIME_INFINITE; | ||
| 315 | for (int i = 0; i < MAX_SIMULTANEOUS_ANIMATIONS; i++) { | ||
| 316 | if (animations[i]) { | ||
| 317 | update_keyframe_animation(animations[i], &state, delta, &sleep_time); | ||
| 318 | } | ||
| 319 | } | ||
| 320 | #ifdef BACKLIGHT_ENABLE | ||
| 321 | gdispGFlush(LED_DISPLAY); | ||
| 322 | #endif | ||
| 323 | |||
| 324 | #ifdef LCD_ENABLE | ||
| 325 | gdispGFlush(LCD_DISPLAY); | ||
| 326 | #endif | ||
| 327 | |||
| 328 | #ifdef EMULATOR | ||
| 329 | draw_emulator(); | ||
| 330 | #endif | ||
| 331 | // Enable the visualizer when the startup or the suspend animation has finished | ||
| 332 | if (!visualizer_enabled && state.status.suspended == false && get_num_running_animations() == 0) { | ||
| 333 | visualizer_enabled = true; | ||
| 334 | force_update = true; | ||
| 335 | sleep_time = 0; | ||
| 336 | } | ||
| 337 | |||
| 338 | systemticks_t after_update = gfxSystemTicks(); | ||
| 339 | unsigned update_delta = after_update - current_time; | ||
| 340 | if (sleep_time != TIME_INFINITE) { | ||
| 341 | if (sleep_time > update_delta) { | ||
| 342 | sleep_time -= update_delta; | ||
| 343 | } else { | ||
| 344 | sleep_time = 0; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | dprintf("Update took %d, last delta %d, sleep_time %d\n", update_delta, delta, sleep_time); | ||
| 348 | #ifdef PROTOCOL_CHIBIOS | ||
| 349 | // The gEventWait function really takes milliseconds, even if the documentation says ticks. | ||
| 350 | // Unfortunately there's no generic ugfx conversion from system time to milliseconds, | ||
| 351 | // so let's do it in a platform dependent way. | ||
| 352 | |||
| 353 | // On windows the system ticks is the same as milliseconds anyway | ||
| 354 | if (sleep_time != TIME_INFINITE) { | ||
| 355 | sleep_time = TIME_I2MS(sleep_time); | ||
| 356 | } | ||
| 357 | #endif | ||
| 358 | geventEventWait(&event_listener, sleep_time); | ||
| 359 | } | ||
| 360 | #ifdef LCD_ENABLE | ||
| 361 | gdispCloseFont(state.font_fixed5x8); | ||
| 362 | gdispCloseFont(state.font_dejavusansbold12); | ||
| 363 | #endif | ||
| 364 | |||
| 365 | return 0; | ||
| 366 | } | ||
| 367 | |||
| 368 | void visualizer_init(void) { | ||
| 369 | gfxInit(); | ||
| 370 | |||
| 371 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 372 | lcd_backlight_init(); | ||
| 373 | #endif | ||
| 374 | |||
| 375 | #ifdef SERIAL_LINK_ENABLE | ||
| 376 | add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*)); | ||
| 377 | #endif | ||
| 378 | |||
| 379 | #ifdef LCD_ENABLE | ||
| 380 | LCD_DISPLAY = get_lcd_display(); | ||
| 381 | #endif | ||
| 382 | |||
| 383 | #ifdef BACKLIGHT_ENABLE | ||
| 384 | LED_DISPLAY = get_led_display(); | ||
| 385 | #endif | ||
| 386 | |||
| 387 | // We are using a low priority thread, the idea is to have it run only | ||
| 388 | // when the main thread is sleeping during the matrix scanning | ||
| 389 | gfxThreadCreate(visualizerThreadStack, sizeof(visualizerThreadStack), VISUALIZER_THREAD_PRIORITY, visualizerThread, NULL); | ||
| 390 | } | ||
| 391 | |||
| 392 | void update_status(bool changed) { | ||
| 393 | if (changed) { | ||
| 394 | GSourceListener* listener = geventGetSourceListener((GSourceHandle)¤t_status, NULL); | ||
| 395 | if (listener) { | ||
| 396 | geventSendEvent(listener); | ||
| 397 | } | ||
| 398 | } | ||
| 399 | #ifdef SERIAL_LINK_ENABLE | ||
| 400 | static systime_t last_update = 0; | ||
| 401 | systime_t current_update = chVTGetSystemTimeX(); | ||
| 402 | systime_t delta = current_update - last_update; | ||
| 403 | if (changed || delta > TIME_MS2I(10)) { | ||
| 404 | last_update = current_update; | ||
| 405 | visualizer_keyboard_status_t* r = begin_write_current_status(); | ||
| 406 | *r = current_status; | ||
| 407 | end_write_current_status(); | ||
| 408 | } | ||
| 409 | #endif | ||
| 410 | } | ||
| 411 | |||
| 412 | uint8_t visualizer_get_mods() { | ||
| 413 | uint8_t mods = get_mods(); | ||
| 414 | |||
| 415 | #ifndef NO_ACTION_ONESHOT | ||
| 416 | if (!has_oneshot_mods_timed_out()) { | ||
| 417 | mods |= get_oneshot_mods(); | ||
| 418 | } | ||
| 419 | #endif | ||
| 420 | return mods; | ||
| 421 | } | ||
| 422 | |||
| 423 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 424 | void visualizer_set_user_data(void* u) { memcpy(user_data, u, VISUALIZER_USER_DATA_SIZE); } | ||
| 425 | #endif | ||
| 426 | |||
| 427 | void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds) { | ||
| 428 | // Note that there's a small race condition here, the thread could read | ||
| 429 | // a state where one of these are set but not the other. But this should | ||
| 430 | // not really matter as it will be fixed during the next loop step. | ||
| 431 | // Alternatively a mutex could be used instead of the volatile variables | ||
| 432 | |||
| 433 | bool changed = false; | ||
| 434 | #ifdef SERIAL_LINK_ENABLE | ||
| 435 | if (is_serial_link_connected()) { | ||
| 436 | visualizer_keyboard_status_t* new_status = read_current_status(); | ||
| 437 | if (new_status) { | ||
| 438 | if (!same_status(¤t_status, new_status)) { | ||
| 439 | changed = true; | ||
| 440 | current_status = *new_status; | ||
| 441 | } | ||
| 442 | } | ||
| 443 | } else { | ||
| 444 | #else | ||
| 445 | { | ||
| 446 | #endif | ||
| 447 | visualizer_keyboard_status_t new_status = { | ||
| 448 | .layer = state, | ||
| 449 | .default_layer = default_state, | ||
| 450 | .mods = mods, | ||
| 451 | .leds = leds, | ||
| 452 | #ifdef BACKLIGHT_ENABLE | ||
| 453 | .backlight_level = current_status.backlight_level, | ||
| 454 | #endif | ||
| 455 | .suspended = current_status.suspended, | ||
| 456 | }; | ||
| 457 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 458 | memcpy(new_status.user_data, user_data, VISUALIZER_USER_DATA_SIZE); | ||
| 459 | #endif | ||
| 460 | if (!same_status(¤t_status, &new_status)) { | ||
| 461 | changed = true; | ||
| 462 | current_status = new_status; | ||
| 463 | } | ||
| 464 | } | ||
| 465 | update_status(changed); | ||
| 466 | } | ||
| 467 | |||
| 468 | void visualizer_suspend(void) { | ||
| 469 | current_status.suspended = true; | ||
| 470 | update_status(true); | ||
| 471 | } | ||
| 472 | |||
| 473 | void visualizer_resume(void) { | ||
| 474 | current_status.suspended = false; | ||
| 475 | update_status(true); | ||
| 476 | } | ||
| 477 | |||
| 478 | #ifdef BACKLIGHT_ENABLE | ||
| 479 | void backlight_set(uint8_t level) { | ||
| 480 | current_status.backlight_level = level; | ||
| 481 | update_status(true); | ||
| 482 | } | ||
| 483 | #endif | ||
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h deleted file mode 100644 index 627c80a30..000000000 --- a/quantum/visualizer/visualizer.h +++ /dev/null | |||
| @@ -1,154 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The MIT License (MIT) | ||
| 3 | |||
| 4 | Copyright (c) 2016 Fred Sundvik | ||
| 5 | |||
| 6 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 7 | of this software and associated documentation files (the "Software"), to deal | ||
| 8 | in the Software without restriction, including without limitation the rights | ||
| 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 10 | copies of the Software, and to permit persons to whom the Software is | ||
| 11 | furnished to do so, subject to the following conditions: | ||
| 12 | |||
| 13 | The above copyright notice and this permission notice shall be included in all | ||
| 14 | copies or substantial portions of the Software. | ||
| 15 | |||
| 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 22 | SOFTWARE. | ||
| 23 | */ | ||
| 24 | |||
| 25 | #pragma once | ||
| 26 | |||
| 27 | #include <stdlib.h> | ||
| 28 | #include <stdint.h> | ||
| 29 | #include <stdbool.h> | ||
| 30 | |||
| 31 | #include "config.h" | ||
| 32 | #include "gfx.h" | ||
| 33 | #include "action_layer.h" | ||
| 34 | |||
| 35 | #ifdef LCD_BACKLIGHT_ENABLE | ||
| 36 | # include "lcd_backlight.h" | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #ifdef BACKLIGHT_ENABLE | ||
| 40 | # include "backlight.h" | ||
| 41 | #endif | ||
| 42 | |||
| 43 | // use this function to merge both real_mods and oneshot_mods in a uint16_t | ||
| 44 | uint8_t visualizer_get_mods(void); | ||
| 45 | |||
| 46 | // This need to be called once at the start | ||
| 47 | void visualizer_init(void); | ||
| 48 | // This should be called at every matrix scan | ||
| 49 | void visualizer_update(layer_state_t default_state, layer_state_t state, uint8_t mods, uint32_t leds); | ||
| 50 | |||
| 51 | // This should be called when the keyboard goes to suspend state | ||
| 52 | void visualizer_suspend(void); | ||
| 53 | // This should be called when the keyboard wakes up from suspend state | ||
| 54 | void visualizer_resume(void); | ||
| 55 | |||
| 56 | // These functions are week, so they can be overridden by the keyboard | ||
| 57 | // if needed | ||
| 58 | GDisplay* get_lcd_display(void); | ||
| 59 | GDisplay* get_led_display(void); | ||
| 60 | |||
| 61 | // For emulator builds, this function need to be implemented | ||
| 62 | #ifdef EMULATOR | ||
| 63 | void draw_emulator(void); | ||
| 64 | #endif | ||
| 65 | |||
| 66 | // If you need support for more than 16 keyframes per animation, you can change this | ||
| 67 | #define MAX_VISUALIZER_KEY_FRAMES 16 | ||
| 68 | |||
| 69 | struct keyframe_animation_t; | ||
| 70 | |||
| 71 | typedef struct { | ||
| 72 | layer_state_t layer; | ||
| 73 | layer_state_t default_layer; | ||
| 74 | uint32_t leds; // See led.h for available statuses | ||
| 75 | uint8_t mods; | ||
| 76 | bool suspended; | ||
| 77 | #ifdef BACKLIGHT_ENABLE | ||
| 78 | uint8_t backlight_level; | ||
| 79 | #endif | ||
| 80 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 81 | uint8_t user_data[VISUALIZER_USER_DATA_SIZE]; | ||
| 82 | #endif | ||
| 83 | } visualizer_keyboard_status_t; | ||
| 84 | |||
| 85 | // The state struct is used by the various keyframe functions | ||
| 86 | // It's also used for setting the LCD color and layer text | ||
| 87 | // from the user customized code | ||
| 88 | typedef struct visualizer_state_t { | ||
| 89 | // The user code should primarily be modifying these | ||
| 90 | uint32_t target_lcd_color; | ||
| 91 | const char* layer_text; | ||
| 92 | |||
| 93 | // The user visualizer(and animation functions) can read these | ||
| 94 | visualizer_keyboard_status_t status; | ||
| 95 | |||
| 96 | // These are used by the animation functions | ||
| 97 | uint32_t current_lcd_color; | ||
| 98 | uint32_t prev_lcd_color; | ||
| 99 | #ifdef LCD_ENABLE | ||
| 100 | gFont font_fixed5x8; | ||
| 101 | gFont font_dejavusansbold12; | ||
| 102 | #endif | ||
| 103 | } visualizer_state_t; | ||
| 104 | |||
| 105 | // Any custom keyframe function should have this signature | ||
| 106 | // return true to get continuous updates, otherwise you will only get one | ||
| 107 | // update per frame | ||
| 108 | typedef bool (*frame_func)(struct keyframe_animation_t*, visualizer_state_t*); | ||
| 109 | |||
| 110 | // Represents a keyframe animation, so fields are internal to the system | ||
| 111 | // while others are meant to be initialized by the user code | ||
| 112 | typedef struct keyframe_animation_t { | ||
| 113 | // These should be initialized | ||
| 114 | int num_frames; | ||
| 115 | bool loop; | ||
| 116 | int frame_lengths[MAX_VISUALIZER_KEY_FRAMES]; | ||
| 117 | frame_func frame_functions[MAX_VISUALIZER_KEY_FRAMES]; | ||
| 118 | |||
| 119 | // Used internally by the system, and can also be read by | ||
| 120 | // keyframe update functions | ||
| 121 | int current_frame; | ||
| 122 | int time_left_in_frame; | ||
| 123 | bool first_update_of_frame; | ||
| 124 | bool last_update_of_frame; | ||
| 125 | bool need_update; | ||
| 126 | |||
| 127 | } keyframe_animation_t; | ||
| 128 | |||
| 129 | extern GDisplay* LCD_DISPLAY; | ||
| 130 | extern GDisplay* LED_DISPLAY; | ||
| 131 | |||
| 132 | void start_keyframe_animation(keyframe_animation_t* animation); | ||
| 133 | void stop_keyframe_animation(keyframe_animation_t* animation); | ||
| 134 | // This runs the next keyframe, but does not update the animation state | ||
| 135 | // Useful for crossfades for example | ||
| 136 | void run_next_keyframe(keyframe_animation_t* animation, visualizer_state_t* state); | ||
| 137 | |||
| 138 | // The master can set userdata which will be transferred to the slave | ||
| 139 | #ifdef VISUALIZER_USER_DATA_SIZE | ||
| 140 | void visualizer_set_user_data(void* user_data); | ||
| 141 | #endif | ||
| 142 | |||
| 143 | // These functions have to be implemented by the user | ||
| 144 | // Called regularly each time the state has changed (but not every scan loop) | ||
| 145 | void update_user_visualizer_state(visualizer_state_t* state, visualizer_keyboard_status_t* prev_status); | ||
| 146 | // Called when the computer goes to suspend, will also stop calling update_user_visualizer_state | ||
| 147 | void user_visualizer_suspend(visualizer_state_t* state); | ||
| 148 | // You have to start at least one animation as a response to the following two functions | ||
| 149 | // When the animation has finished the visualizer will resume normal operation and start calling the | ||
| 150 | // update_user_visualizer_state again | ||
| 151 | // Called when the keyboard boots up | ||
| 152 | void initialize_user_visualizer(visualizer_state_t* state); | ||
| 153 | // Called when the computer resumes from a suspend | ||
| 154 | void user_visualizer_resume(visualizer_state_t* state); | ||
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk deleted file mode 100644 index 4c961ac59..000000000 --- a/quantum/visualizer/visualizer.mk +++ /dev/null | |||
| @@ -1,123 +0,0 @@ | |||
| 1 | # The MIT License (MIT) | ||
| 2 | # | ||
| 3 | # Copyright (c) 2016 Fred Sundvik | ||
| 4 | # | ||
| 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 6 | # of this software and associated documentation files (the "Software"), to deal | ||
| 7 | # in the Software without restriction, including without limitation the rights | ||
| 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 9 | # copies of the Software, and to permit persons to whom the Software is | ||
| 10 | # furnished to do so, subject to the following conditions: | ||
| 11 | # | ||
| 12 | # The above copyright notice and this permission notice shall be included in all | ||
| 13 | # copies or substantial portions of the Software. | ||
| 14 | # | ||
| 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 21 | # SOFTWARE. | ||
| 22 | |||
| 23 | define 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 | ||
| 43 | endef | ||
| 44 | |||
| 45 | GDISP_DRIVER_LIST:= | ||
| 46 | |||
| 47 | SRC += $(VISUALIZER_DIR)/visualizer.c \ | ||
| 48 | $(VISUALIZER_DIR)/visualizer_keyframes.c | ||
| 49 | EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR) | ||
| 50 | GFXLIB = $(LIB_PATH)/ugfx | ||
| 51 | VPATH += $(VISUALIZER_PATH) | ||
| 52 | |||
| 53 | OPT_DEFS += -DVISUALIZER_ENABLE | ||
| 54 | |||
| 55 | ifdef LCD_ENABLE | ||
| 56 | OPT_DEFS += -DLCD_ENABLE | ||
| 57 | ULIBS += -lm | ||
| 58 | endif | ||
| 59 | |||
| 60 | ifeq ($(strip $(LCD_ENABLE)), yes) | ||
| 61 | SRC += $(VISUALIZER_DIR)/lcd_keyframes.c | ||
| 62 | ifeq ($(strip $(LCD_BACKLIGHT_ENABLE)), yes) | ||
| 63 | OPT_DEFS += -DLCD_BACKLIGHT_ENABLE | ||
| 64 | SRC += $(VISUALIZER_DIR)/lcd_backlight.c | ||
| 65 | SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c | ||
| 66 | endif | ||
| 67 | # Note, that the linker will strip out any resources that are not actually in use | ||
| 68 | SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c | ||
| 69 | $(eval $(call ADD_DRIVER,LCD)) | ||
| 70 | endif | ||
| 71 | |||
| 72 | ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) | ||
| 73 | SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c | ||
| 74 | $(eval $(call ADD_DRIVER,LED)) | ||
| 75 | endif | ||
| 76 | |||
| 77 | SRC += $(VISUALIZER_DIR)/default_animations.c | ||
| 78 | |||
| 79 | include $(GFXLIB)/gfx.mk | ||
| 80 | # For the common_gfxconf.h | ||
| 81 | GFXINC += quantum/visualizer | ||
| 82 | |||
| 83 | GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC)) | ||
| 84 | GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS))) | ||
| 85 | |||
| 86 | GDISP_LIST_COMMA=, | ||
| 87 | GDISP_LIST_EMPTY= | ||
| 88 | GDISP_LIST_SPACE=$(GDISP_LIST_EMPTY) $(GDISP_LIST_EMPTY) | ||
| 89 | |||
| 90 | GDISP_DRIVER_LIST := $(strip $(GDISP_DRIVER_LIST)) | ||
| 91 | GDISP_DRIVER_LIST := $(subst $(GDISP_LIST_SPACE),$(GDISP_LIST_COMMA),$(GDISP_DRIVER_LIST)) | ||
| 92 | |||
| 93 | GFXDEFS +=-DGDISP_DRIVER_LIST="$(GDISP_DRIVER_LIST)" | ||
| 94 | |||
| 95 | ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","") | ||
| 96 | SRC += $(KEYMAP_PATH)/visualizer.c | ||
| 97 | else | ||
| 98 | VISUALIZER_1 := $(KEYBOARD_PATH_1)/visualizer.c | ||
| 99 | VISUALIZER_2 := $(KEYBOARD_PATH_2)/visualizer.c | ||
| 100 | VISUALIZER_3 := $(KEYBOARD_PATH_3)/visualizer.c | ||
| 101 | VISUALIZER_4 := $(KEYBOARD_PATH_4)/visualizer.c | ||
| 102 | VISUALIZER_5 := $(KEYBOARD_PATH_5)/visualizer.c | ||
| 103 | |||
| 104 | ifneq ("$(wildcard $(VISUALIZER_5))","") | ||
| 105 | SRC += $(VISUALIZER_5) | ||
| 106 | endif | ||
| 107 | ifneq ("$(wildcard $(VISUALIZER_4))","") | ||
| 108 | SRC += $(VISUALIZER_4) | ||
| 109 | endif | ||
| 110 | ifneq ("$(wildcard $(VISUALIZER_3))","") | ||
| 111 | SRC += $(VISUALIZER_3) | ||
| 112 | endif | ||
| 113 | ifneq ("$(wildcard $(VISUALIZER_2))","") | ||
| 114 | SRC += $(VISUALIZER_2) | ||
| 115 | endif | ||
| 116 | ifneq ("$(wildcard $(VISUALIZER_1))","") | ||
| 117 | SRC += $(VISUALIZER_1) | ||
| 118 | endif | ||
| 119 | endif | ||
| 120 | |||
| 121 | ifdef EMULATOR | ||
| 122 | UINCDIR += $(TMK_DIR)/common | ||
| 123 | endif | ||
diff --git a/quantum/visualizer/visualizer_keyframes.c b/quantum/visualizer/visualizer_keyframes.c deleted file mode 100644 index 8f6a7e15a..000000000 --- a/quantum/visualizer/visualizer_keyframes.c +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | #include "visualizer_keyframes.h" | ||
| 18 | |||
| 19 | bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state) { | ||
| 20 | (void)animation; | ||
| 21 | (void)state; | ||
| 22 | return false; | ||
| 23 | } | ||
diff --git a/quantum/visualizer/visualizer_keyframes.h b/quantum/visualizer/visualizer_keyframes.h deleted file mode 100644 index c92ff1611..000000000 --- a/quantum/visualizer/visualizer_keyframes.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 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 | #pragma once | ||
| 18 | |||
| 19 | #include "visualizer.h" | ||
| 20 | |||
| 21 | // Some predefined keyframe functions that can be used by the user code | ||
| 22 | // Does nothing, useful for adding delays | ||
| 23 | bool keyframe_no_operation(keyframe_animation_t* animation, visualizer_state_t* state); | ||
