├── .github └── workflows │ └── arduino_lint.yml ├── .gitignore ├── LICENSE ├── README_CN.md ├── docs └── no-docs.md ├── examples ├── display │ ├── display_touch │ │ └── display_touch.ino │ ├── hello_world │ │ └── hello_world.ino │ ├── jpeg_show │ │ └── jpeg_show.ino │ └── user_font │ │ └── user_font.ino ├── lvgl │ ├── lvgl_demo │ │ ├── lv_conf.h │ │ └── lvgl_demo.ino │ └── squareline_studio │ │ ├── README.md │ │ ├── README_CN.md │ │ ├── example_ui │ │ ├── example_ui.ino │ │ ├── library.properties │ │ ├── src │ │ │ ├── CMakeLists.txt │ │ │ ├── components │ │ │ │ └── ui_comp_hook.c │ │ │ ├── filelist.txt │ │ │ ├── readme.txt │ │ │ ├── screens │ │ │ │ └── ui_Screen1.c │ │ │ ├── ui.c │ │ │ ├── ui.h │ │ │ ├── ui_events.h │ │ │ ├── ui_helpers.c │ │ │ └── ui_helpers.h │ │ └── ui.h │ │ └── libraries │ │ └── lv_conf.h └── peripherals │ ├── aw9523 │ ├── README.md │ ├── README_CN.md │ └── aw9523.ino │ ├── rs485 │ └── rs485.ino │ └── sdcard │ └── sdcard.ino ├── library.properties ├── readme.md └── src ├── PanelLan.h └── board ├── bc02 ├── bc02.cpp ├── bc02_pin.h └── bc02_rgb_spi_init.hpp ├── boards.cpp ├── boards.h ├── kc01 ├── kc01.cpp ├── kc01_pin.h └── kc01_rgb_spi_init.hpp ├── sc01 ├── sc01.cpp └── sc01_pin.h ├── sc01_plus ├── sc01_plus.cpp └── sc01_plus_pin.h ├── sc02 ├── sc02.cpp └── sc02_pin.h ├── sc05 ├── sc05.cpp └── sc05_pin.h ├── sc05_plus ├── sc05_plus.cpp └── sc05_plus_pin.h └── sc07 ├── Panel_NV3041A.hpp ├── Touch_CST3240.cpp ├── Touch_CST3240.hpp ├── sc07.cpp └── sc07_pin.h /.github/workflows/arduino_lint.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Lint Action 2 | 3 | on: 4 | workflow_dispatch: 5 | pull_request: 6 | types: [opened, reopened, synchronize] 7 | push: 8 | 9 | jobs: 10 | lint: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v3 14 | - uses: arduino/arduino-lint-action@v1 15 | with: 16 | library-manager: update -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .clang-format 2 | 3 | .vscode 4 | 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 PanelLan 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. -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # 描述 2 | 3 | 本仓库提供对启明智显所销售的开发板的屏幕和触摸功能的支持,使开发过程更加迅速和高效。 4 | 5 | # 如何使用 6 | 7 | 支持的开发板已经配置好, 可直接点亮使用 8 | 9 | ```c++ 10 | #include "PanelLan.h" 11 | 12 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 13 | PanelLan tft(BOARD_SC01_PLUS); 14 | 15 | void setup(void) 16 | { 17 | tft.begin(); 18 | 19 | tft.setTextDatum(textdatum_t::middle_center); 20 | tft.setFont(&fonts::FreeSerifBold18pt7b); 21 | tft.drawString("HELLO WORLD",tft.width() / 2, tft.height() / 2); 22 | } 23 | ``` 24 | 25 | 仓库屏幕及触摸驱动部分依赖于[LovyanGFX](https://github.com/lovyan03/LovyanGFX), 示例可以参照[这里](https://github.com/lovyan03/LovyanGFX/tree/master/examples). 26 | 27 | # 支持的开发板 28 | 29 | |||||| 30 | |---|---|---|---|---| 31 | |名称|型号|LCD接口|触摸|其它外设| 32 | | SC01 | - | spi/ST7796 | FT5x06 | - | 33 | | SC01-PLUS | ZX3D50CE08S | 8080-8bit / ST7796 | FT5x06 | sdcard, spk, rs485 | 34 | | SC02 | ZX4D30NE01S-UR | RGB | - | rs485 | 35 | | SC05 | ZX7D00CE01S | RGB | GT911 | - | 36 | | SC05_PLUS | ZX2D80CECOF | 8080-8bit / ST7789 | GT911 | rs485 | 37 | | SC07 | ZX4D30CE08S-4827 | 8080 | CST3240 | rs485, can, buzzer| 38 | | KC01 | ZX2D10GE01S | RGB | - | ab-encoder, motor | 39 | | BC02 | ZX3D95CE01S-TR | RGB | FT5x06 | sht20 | 40 | 41 | 42 | # Board 选择配置 43 | 44 | ||||| 45 | |---|---|---|---| 46 | |名称|型号|FLSAH|PSRAM| 47 | | SC01 | ESP32 Dev Module | 4MB QIO 80MHz | QSPI PSRAM | 48 | | SC01-PLUS | ESP32S3 Dev Module | 8MB QIO 80MHz | QSPI PSRAM | 49 | | SC02 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 50 | | SC05 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 51 | | SC05_PLUS | ESP32S3 Dev Module | 16MB QIO 80MHz | QSPI PSRAM | 52 | | SC07 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 53 | | KC01 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 54 | | BC02 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 55 | 56 | 57 | # 依赖库 58 | 59 | |名称|版本|介绍| 60 | |---|---|---| 61 | | [LovyanGFX](https://github.com/lovyan03/LovyanGFX) | >= v1.1.9|SPI LCD graphics library for ESP32 / ESP8266 / SAMD51| 62 | | [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v2.0.9|Arduino core for the ESP32, ESP32-S3, etc| 63 | 64 | 65 | # 其他 66 | 如果遇到RGB屏幕撕裂的情况,参考下面连接: 67 | https://github.com/esp-arduino-libs/arduino-esp32-sdk 68 | 69 | 70 | # 感谢 71 | 72 | - 感谢 [lovyan03](https://github.com/lovyan03) 开源了优秀好用且易于扩展的的驱动仓库 [LovyanGFX](https://github.com/lovyan03/LovyanGFX) 73 | 74 | -------------------------------------------------------------------------------- /docs/no-docs.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smartpanle/PanelLan_esp32_arduino/58cce8eabd530501aa3450387e80f9cab1f91b63/docs/no-docs.md -------------------------------------------------------------------------------- /examples/display/display_touch/display_touch.ino: -------------------------------------------------------------------------------- 1 | #include "PanelLan.h" 2 | 3 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 4 | PanelLan tft(BOARD_SC01_PLUS); 5 | 6 | void setup(void) { 7 | Serial.begin(115200); 8 | 9 | tft.init(); 10 | tft.initDMA(); 11 | tft.fillScreen(TFT_GREEN); 12 | tft.drawString("touch test", 10, 10); 13 | 14 | Serial.printf("Fill screen finish\r\n"); 15 | } 16 | 17 | void loop() { 18 | int16_t x = 0; 19 | int16_t y = 0; 20 | 21 | if (tft.getTouch(&x, &y) > 0) { 22 | tft.drawPixel(x, y, TFT_RED); 23 | } 24 | 25 | delay(20); 26 | } 27 | -------------------------------------------------------------------------------- /examples/display/hello_world/hello_world.ino: -------------------------------------------------------------------------------- 1 | #include "PanelLan.h" 2 | 3 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 4 | PanelLan tft(BOARD_SC01_PLUS); 5 | 6 | void setup(void) { 7 | tft.begin(); 8 | 9 | tft.setTextDatum(textdatum_t::middle_center); 10 | tft.setFont(&fonts::FreeSerifBold18pt7b); 11 | tft.drawString("HELLO WORLD", tft.width() / 2, tft.height() / 2); 12 | } 13 | 14 | void loop() { 15 | delay(20); 16 | } 17 | -------------------------------------------------------------------------------- /examples/display/user_font/user_font.ino: -------------------------------------------------------------------------------- 1 | #include "PanelLan.h" 2 | 3 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 4 | PanelLan tft(BOARD_SC01_PLUS); 5 | 6 | void setup(void) { 7 | Serial.begin(115200); 8 | 9 | tft.begin(); 10 | tft.fillScreen(TFT_WHITE); 11 | tft.drawString("Font test", 10, 10); 12 | 13 | // text color 14 | tft.setTextColor(0x000000U); 15 | 16 | // change font 17 | tft.setFont(&fonts::Font2); 18 | tft.setCursor(10, 30); 19 | tft.println("Font2:\n Hello World"); 20 | 21 | tft.setFont(&fonts::Font4); 22 | tft.setCursor(10, 60); 23 | tft.println("Font4:\n Hello World"); 24 | 25 | tft.setFont(&fonts::FreeSerif12pt7b); 26 | tft.setCursor(10, 120); 27 | tft.println("FreeSerif24pt7b:\n Hello World"); 28 | 29 | tft.setFont(&fonts::FreeSerifBold12pt7b); 30 | tft.setCursor(10, 180); 31 | tft.println("FreeSerifBold24pt7b:\n Hello World"); 32 | } 33 | 34 | void loop() { 35 | delay(1000); 36 | } 37 | -------------------------------------------------------------------------------- /examples/lvgl/lvgl_demo/lv_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_conf.h 3 | * Configuration file for v8.3.0-dev 4 | */ 5 | 6 | /* 7 | * Copy this file as `lv_conf.h` 8 | * 1. simply next to the `lvgl` folder 9 | * 2. or any other places and 10 | * - define `LV_CONF_INCLUDE_SIMPLE` 11 | * - add the path as include path 12 | */ 13 | 14 | /* clang-format off */ 15 | #if 1 /*Set it to "1" to enable content*/ 16 | 17 | #ifndef LV_CONF_H 18 | #define LV_CONF_H 19 | 20 | #include 21 | 22 | /*==================== 23 | COLOR SETTINGS 24 | *====================*/ 25 | 26 | /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ 27 | #define LV_COLOR_DEPTH 16 28 | 29 | /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ 30 | #define LV_COLOR_16_SWAP 1 31 | 32 | /*Enable more complex drawing routines to manage screens transparency. 33 | *Can be used if the UI is above another layer, e.g. an OSD menu or video player. 34 | *Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/ 35 | #define LV_COLOR_SCREEN_TRANSP 0 36 | 37 | /* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. 38 | * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ 39 | #define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128) 40 | 41 | /*Images pixels with this color will not be drawn if they are chroma keyed)*/ 42 | #define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ 43 | 44 | /*========================= 45 | MEMORY SETTINGS 46 | *=========================*/ 47 | 48 | /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ 49 | #define LV_MEM_CUSTOM 0 50 | #if LV_MEM_CUSTOM == 0 51 | /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ 52 | #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ 53 | 54 | /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ 55 | #define LV_MEM_ADR 0 /*0: unused*/ 56 | /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ 57 | #if LV_MEM_ADR == 0 58 | //#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/ 59 | //#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/ 60 | #endif 61 | 62 | #else /*LV_MEM_CUSTOM*/ 63 | #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ 64 | #define LV_MEM_CUSTOM_ALLOC malloc 65 | #define LV_MEM_CUSTOM_FREE free 66 | #define LV_MEM_CUSTOM_REALLOC realloc 67 | #endif /*LV_MEM_CUSTOM*/ 68 | 69 | /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. 70 | *You will see an error log message if there wasn't enough buffers. */ 71 | #define LV_MEM_BUF_MAX_NUM 16 72 | 73 | /*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ 74 | #define LV_MEMCPY_MEMSET_STD 0 75 | 76 | /*==================== 77 | HAL SETTINGS 78 | *====================*/ 79 | 80 | /*Default display refresh period. LVG will redraw changed areas with this period time*/ 81 | #define LV_DISP_DEF_REFR_PERIOD 16 /*[ms]*/ 82 | 83 | /*Input device read period in milliseconds*/ 84 | #define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ 85 | 86 | /*Use a custom tick source that tells the elapsed time in milliseconds. 87 | *It removes the need to manually update the tick with `lv_tick_inc()`)*/ 88 | #define LV_TICK_CUSTOM 1 89 | #if LV_TICK_CUSTOM 90 | #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ 91 | #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ 92 | #endif /*LV_TICK_CUSTOM*/ 93 | 94 | /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. 95 | *(Not so important, you can adjust it to modify default sizes and spaces)*/ 96 | #define LV_DPI_DEF 130 /*[px/inch]*/ 97 | 98 | /*======================= 99 | * FEATURE CONFIGURATION 100 | *=======================*/ 101 | 102 | /*------------- 103 | * Drawing 104 | *-----------*/ 105 | 106 | /*Enable complex draw engine. 107 | *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ 108 | #define LV_DRAW_COMPLEX 1 109 | #if LV_DRAW_COMPLEX != 0 110 | 111 | /*Allow buffering some shadow calculation. 112 | *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` 113 | *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ 114 | #define LV_SHADOW_CACHE_SIZE 0 115 | 116 | /* Set number of maximally cached circle data. 117 | * The circumference of 1/4 circle are saved for anti-aliasing 118 | * radius * 4 bytes are used per circle (the most often used radiuses are saved) 119 | * 0: to disable caching */ 120 | #define LV_CIRCLE_CACHE_SIZE 4 121 | #endif /*LV_DRAW_COMPLEX*/ 122 | 123 | /*Default image cache size. Image caching keeps the images opened. 124 | *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) 125 | *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. 126 | *However the opened images might consume additional RAM. 127 | *0: to disable caching*/ 128 | #define LV_IMG_CACHE_DEF_SIZE 0 129 | 130 | /*Number of stops allowed per gradient. Increase this to allow more stops. 131 | *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ 132 | #define LV_GRADIENT_MAX_STOPS 2 133 | 134 | /*Default gradient buffer size. 135 | *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. 136 | *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. 137 | *If the cache is too small the map will be allocated only while it's required for the drawing. 138 | *0 mean no caching.*/ 139 | #define LV_GRAD_CACHE_DEF_SIZE 0 140 | 141 | /*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) 142 | *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface 143 | *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ 144 | #define LV_DITHER_GRADIENT 0 145 | #if LV_DITHER_GRADIENT 146 | /*Add support for error diffusion dithering. 147 | *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. 148 | *The increase in memory consumption is (24 bits * object's width)*/ 149 | #define LV_DITHER_ERROR_DIFFUSION 0 150 | #endif 151 | 152 | /*Maximum buffer size to allocate for rotation. 153 | *Only used if software rotation is enabled in the display driver.*/ 154 | #define LV_DISP_ROT_MAX_BUF (10*1024) 155 | 156 | /*------------- 157 | * GPU 158 | *-----------*/ 159 | 160 | /*Use Arm's 2D acceleration library Arm-2D */ 161 | #define LV_USE_GPU_ARM2D 0 162 | 163 | /*Use STM32's DMA2D (aka Chrom Art) GPU*/ 164 | #define LV_USE_GPU_STM32_DMA2D 0 165 | #if LV_USE_GPU_STM32_DMA2D 166 | /*Must be defined to include path of CMSIS header of target processor 167 | e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ 168 | #define LV_GPU_DMA2D_CMSIS_INCLUDE 169 | #endif 170 | 171 | /*Use NXP's PXP GPU iMX RTxxx platforms*/ 172 | #define LV_USE_GPU_NXP_PXP 0 173 | #if LV_USE_GPU_NXP_PXP 174 | /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) 175 | * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS 176 | * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. 177 | *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() 178 | */ 179 | #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 180 | #endif 181 | 182 | /*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ 183 | #define LV_USE_GPU_NXP_VG_LITE 0 184 | 185 | /*Use SDL renderer API*/ 186 | #define LV_USE_GPU_SDL 0 187 | #if LV_USE_GPU_SDL 188 | #define LV_GPU_SDL_INCLUDE_PATH 189 | /*Texture cache size, 8MB by default*/ 190 | #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) 191 | /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ 192 | #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) 193 | #endif 194 | 195 | /*------------- 196 | * Logging 197 | *-----------*/ 198 | 199 | /*Enable the log module*/ 200 | #define LV_USE_LOG 0 201 | #if LV_USE_LOG 202 | 203 | /*How important log should be added: 204 | *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information 205 | *LV_LOG_LEVEL_INFO Log important events 206 | *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem 207 | *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail 208 | *LV_LOG_LEVEL_USER Only logs added by the user 209 | *LV_LOG_LEVEL_NONE Do not log anything*/ 210 | #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN 211 | 212 | /*1: Print the log with 'printf'; 213 | *0: User need to register a callback with `lv_log_register_print_cb()`*/ 214 | #define LV_LOG_PRINTF 0 215 | 216 | /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ 217 | #define LV_LOG_TRACE_MEM 1 218 | #define LV_LOG_TRACE_TIMER 1 219 | #define LV_LOG_TRACE_INDEV 1 220 | #define LV_LOG_TRACE_DISP_REFR 1 221 | #define LV_LOG_TRACE_EVENT 1 222 | #define LV_LOG_TRACE_OBJ_CREATE 1 223 | #define LV_LOG_TRACE_LAYOUT 1 224 | #define LV_LOG_TRACE_ANIM 1 225 | 226 | #endif /*LV_USE_LOG*/ 227 | 228 | /*------------- 229 | * Asserts 230 | *-----------*/ 231 | 232 | /*Enable asserts if an operation is failed or an invalid data is found. 233 | *If LV_USE_LOG is enabled an error message will be printed on failure*/ 234 | #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ 235 | #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ 236 | #define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ 237 | #define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ 238 | #define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ 239 | 240 | /*Add a custom handler when assert happens e.g. to restart the MCU*/ 241 | #define LV_ASSERT_HANDLER_INCLUDE 242 | #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ 243 | 244 | /*------------- 245 | * Others 246 | *-----------*/ 247 | 248 | /*1: Show CPU usage and FPS count*/ 249 | #define LV_USE_PERF_MONITOR 0 250 | #if LV_USE_PERF_MONITOR 251 | #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT 252 | #endif 253 | 254 | /*1: Show the used memory and the memory fragmentation 255 | * Requires LV_MEM_CUSTOM = 0*/ 256 | #define LV_USE_MEM_MONITOR 0 257 | #if LV_USE_MEM_MONITOR 258 | #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT 259 | #endif 260 | 261 | /*1: Draw random colored rectangles over the redrawn areas*/ 262 | #define LV_USE_REFR_DEBUG 0 263 | 264 | /*Change the built in (v)snprintf functions*/ 265 | #define LV_SPRINTF_CUSTOM 0 266 | #if LV_SPRINTF_CUSTOM 267 | #define LV_SPRINTF_INCLUDE 268 | #define lv_snprintf snprintf 269 | #define lv_vsnprintf vsnprintf 270 | #else /*LV_SPRINTF_CUSTOM*/ 271 | #define LV_SPRINTF_USE_FLOAT 0 272 | #endif /*LV_SPRINTF_CUSTOM*/ 273 | 274 | #define LV_USE_USER_DATA 1 275 | 276 | /*Garbage Collector settings 277 | *Used if lvgl is bound to higher level language and the memory is managed by that language*/ 278 | #define LV_ENABLE_GC 0 279 | #if LV_ENABLE_GC != 0 280 | #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ 281 | #endif /*LV_ENABLE_GC*/ 282 | 283 | /*===================== 284 | * COMPILER SETTINGS 285 | *====================*/ 286 | 287 | /*For big endian systems set to 1*/ 288 | #define LV_BIG_ENDIAN_SYSTEM 0 289 | 290 | /*Define a custom attribute to `lv_tick_inc` function*/ 291 | #define LV_ATTRIBUTE_TICK_INC 292 | 293 | /*Define a custom attribute to `lv_timer_handler` function*/ 294 | #define LV_ATTRIBUTE_TIMER_HANDLER 295 | 296 | /*Define a custom attribute to `lv_disp_flush_ready` function*/ 297 | #define LV_ATTRIBUTE_FLUSH_READY 298 | 299 | /*Required alignment size for buffers*/ 300 | #define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 301 | 302 | /*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). 303 | * E.g. __attribute__((aligned(4)))*/ 304 | #define LV_ATTRIBUTE_MEM_ALIGN 305 | 306 | /*Attribute to mark large constant arrays for example font's bitmaps*/ 307 | #define LV_ATTRIBUTE_LARGE_CONST 308 | 309 | /*Compiler prefix for a big array declaration in RAM*/ 310 | #define LV_ATTRIBUTE_LARGE_RAM_ARRAY 311 | 312 | /*Place performance critical functions into a faster memory (e.g RAM)*/ 313 | #define LV_ATTRIBUTE_FAST_MEM 314 | 315 | /*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ 316 | #define LV_ATTRIBUTE_DMA 317 | 318 | /*Export integer constant to binding. This macro is used with constants in the form of LV_ that 319 | *should also appear on LVGL binding API such as Micropython.*/ 320 | #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ 321 | 322 | /*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ 323 | #define LV_USE_LARGE_COORD 0 324 | 325 | /*================== 326 | * FONT USAGE 327 | *===================*/ 328 | 329 | /*Montserrat fonts with ASCII range and some symbols using bpp = 4 330 | *https://fonts.google.com/specimen/Montserrat*/ 331 | #define LV_FONT_MONTSERRAT_8 0 332 | #define LV_FONT_MONTSERRAT_10 0 333 | #define LV_FONT_MONTSERRAT_12 1 334 | #define LV_FONT_MONTSERRAT_14 1 335 | #define LV_FONT_MONTSERRAT_16 1 336 | #define LV_FONT_MONTSERRAT_18 0 337 | #define LV_FONT_MONTSERRAT_20 0 338 | #define LV_FONT_MONTSERRAT_22 0 339 | #define LV_FONT_MONTSERRAT_24 0 340 | #define LV_FONT_MONTSERRAT_26 0 341 | #define LV_FONT_MONTSERRAT_28 0 342 | #define LV_FONT_MONTSERRAT_30 0 343 | #define LV_FONT_MONTSERRAT_32 0 344 | #define LV_FONT_MONTSERRAT_34 0 345 | #define LV_FONT_MONTSERRAT_36 0 346 | #define LV_FONT_MONTSERRAT_38 0 347 | #define LV_FONT_MONTSERRAT_40 0 348 | #define LV_FONT_MONTSERRAT_42 0 349 | #define LV_FONT_MONTSERRAT_44 0 350 | #define LV_FONT_MONTSERRAT_46 0 351 | #define LV_FONT_MONTSERRAT_48 0 352 | 353 | /*Demonstrate special features*/ 354 | #define LV_FONT_MONTSERRAT_12_SUBPX 0 355 | #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ 356 | #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ 357 | #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ 358 | 359 | /*Pixel perfect monospace fonts*/ 360 | #define LV_FONT_UNSCII_8 0 361 | #define LV_FONT_UNSCII_16 0 362 | 363 | /*Optionally declare custom fonts here. 364 | *You can use these fonts as default font too and they will be available globally. 365 | *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ 366 | #define LV_FONT_CUSTOM_DECLARE 367 | 368 | /*Always set a default font*/ 369 | #define LV_FONT_DEFAULT &lv_font_montserrat_14 370 | 371 | /*Enable handling large font and/or fonts with a lot of characters. 372 | *The limit depends on the font size, font face and bpp. 373 | *Compiler error will be triggered if a font needs it.*/ 374 | #define LV_FONT_FMT_TXT_LARGE 0 375 | 376 | /*Enables/disables support for compressed fonts.*/ 377 | #define LV_USE_FONT_COMPRESSED 0 378 | 379 | /*Enable subpixel rendering*/ 380 | #define LV_USE_FONT_SUBPX 0 381 | #if LV_USE_FONT_SUBPX 382 | /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ 383 | #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ 384 | #endif 385 | 386 | /*================= 387 | * TEXT SETTINGS 388 | *=================*/ 389 | 390 | /** 391 | * Select a character encoding for strings. 392 | * Your IDE or editor should have the same character encoding 393 | * - LV_TXT_ENC_UTF8 394 | * - LV_TXT_ENC_ASCII 395 | */ 396 | #define LV_TXT_ENC LV_TXT_ENC_UTF8 397 | 398 | /*Can break (wrap) texts on these chars*/ 399 | #define LV_TXT_BREAK_CHARS " ,.;:-_" 400 | 401 | /*If a word is at least this long, will break wherever "prettiest" 402 | *To disable, set to a value <= 0*/ 403 | #define LV_TXT_LINE_BREAK_LONG_LEN 0 404 | 405 | /*Minimum number of characters in a long word to put on a line before a break. 406 | *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ 407 | #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 408 | 409 | /*Minimum number of characters in a long word to put on a line after a break. 410 | *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ 411 | #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 412 | 413 | /*The control character to use for signalling text recoloring.*/ 414 | #define LV_TXT_COLOR_CMD "#" 415 | 416 | /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. 417 | *The direction will be processed according to the Unicode Bidirectional Algorithm: 418 | *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ 419 | #define LV_USE_BIDI 0 420 | #if LV_USE_BIDI 421 | /*Set the default direction. Supported values: 422 | *`LV_BASE_DIR_LTR` Left-to-Right 423 | *`LV_BASE_DIR_RTL` Right-to-Left 424 | *`LV_BASE_DIR_AUTO` detect texts base direction*/ 425 | #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO 426 | #endif 427 | 428 | /*Enable Arabic/Persian processing 429 | *In these languages characters should be replaced with an other form based on their position in the text*/ 430 | #define LV_USE_ARABIC_PERSIAN_CHARS 0 431 | 432 | /*================== 433 | * WIDGET USAGE 434 | *================*/ 435 | 436 | /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ 437 | 438 | #define LV_USE_ARC 1 439 | 440 | #define LV_USE_ANIMIMG 1 441 | 442 | #define LV_USE_BAR 1 443 | 444 | #define LV_USE_BTN 1 445 | 446 | #define LV_USE_BTNMATRIX 1 447 | 448 | #define LV_USE_CANVAS 1 449 | 450 | #define LV_USE_CHECKBOX 1 451 | 452 | #define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ 453 | 454 | #define LV_USE_IMG 1 /*Requires: lv_label*/ 455 | 456 | #define LV_USE_LABEL 1 457 | #if LV_USE_LABEL 458 | #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ 459 | #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ 460 | #endif 461 | 462 | #define LV_USE_LINE 1 463 | 464 | #define LV_USE_ROLLER 1 /*Requires: lv_label*/ 465 | #if LV_USE_ROLLER 466 | #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ 467 | #endif 468 | 469 | #define LV_USE_SLIDER 1 /*Requires: lv_bar*/ 470 | 471 | #define LV_USE_SWITCH 1 472 | 473 | #define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ 474 | #if LV_USE_TEXTAREA != 0 475 | #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ 476 | #endif 477 | 478 | #define LV_USE_TABLE 1 479 | 480 | /*================== 481 | * EXTRA COMPONENTS 482 | *==================*/ 483 | 484 | /*----------- 485 | * Widgets 486 | *----------*/ 487 | #define LV_USE_CALENDAR 1 488 | #if LV_USE_CALENDAR 489 | #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 490 | #if LV_CALENDAR_WEEK_STARTS_MONDAY 491 | #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} 492 | #else 493 | #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} 494 | #endif 495 | 496 | #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} 497 | #define LV_USE_CALENDAR_HEADER_ARROW 1 498 | #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 499 | #endif /*LV_USE_CALENDAR*/ 500 | 501 | #define LV_USE_CHART 1 502 | 503 | #define LV_USE_COLORWHEEL 1 504 | 505 | #define LV_USE_IMGBTN 1 506 | 507 | #define LV_USE_KEYBOARD 1 508 | 509 | #define LV_USE_LED 1 510 | 511 | #define LV_USE_LIST 1 512 | 513 | #define LV_USE_MENU 1 514 | 515 | #define LV_USE_METER 1 516 | 517 | #define LV_USE_MSGBOX 1 518 | 519 | #define LV_USE_SPINBOX 1 520 | 521 | #define LV_USE_SPINNER 1 522 | 523 | #define LV_USE_TABVIEW 1 524 | 525 | #define LV_USE_TILEVIEW 1 526 | 527 | #define LV_USE_WIN 1 528 | 529 | #define LV_USE_SPAN 1 530 | #if LV_USE_SPAN 531 | /*A line text can contain maximum num of span descriptor */ 532 | #define LV_SPAN_SNIPPET_STACK_SIZE 64 533 | #endif 534 | 535 | /*----------- 536 | * Themes 537 | *----------*/ 538 | 539 | /*A simple, impressive and very complete theme*/ 540 | #define LV_USE_THEME_DEFAULT 1 541 | #if LV_USE_THEME_DEFAULT 542 | 543 | /*0: Light mode; 1: Dark mode*/ 544 | #define LV_THEME_DEFAULT_DARK 0 545 | 546 | /*1: Enable grow on press*/ 547 | #define LV_THEME_DEFAULT_GROW 1 548 | 549 | /*Default transition time in [ms]*/ 550 | #define LV_THEME_DEFAULT_TRANSITION_TIME 80 551 | #endif /*LV_USE_THEME_DEFAULT*/ 552 | 553 | /*A very simple theme that is a good starting point for a custom theme*/ 554 | #define LV_USE_THEME_BASIC 1 555 | 556 | /*A theme designed for monochrome displays*/ 557 | #define LV_USE_THEME_MONO 1 558 | 559 | /*----------- 560 | * Layouts 561 | *----------*/ 562 | 563 | /*A layout similar to Flexbox in CSS.*/ 564 | #define LV_USE_FLEX 1 565 | 566 | /*A layout similar to Grid in CSS.*/ 567 | #define LV_USE_GRID 1 568 | 569 | /*--------------------- 570 | * 3rd party libraries 571 | *--------------------*/ 572 | 573 | /*File system interfaces for common APIs */ 574 | 575 | /*API for fopen, fread, etc*/ 576 | #define LV_USE_FS_STDIO 0 577 | #if LV_USE_FS_STDIO 578 | #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 579 | #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 580 | #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 581 | #endif 582 | 583 | /*API for open, read, etc*/ 584 | #define LV_USE_FS_POSIX 0 585 | #if LV_USE_FS_POSIX 586 | #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 587 | #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 588 | #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 589 | #endif 590 | 591 | /*API for CreateFile, ReadFile, etc*/ 592 | #define LV_USE_FS_WIN32 0 593 | #if LV_USE_FS_WIN32 594 | #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 595 | #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 596 | #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 597 | #endif 598 | 599 | /*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ 600 | #define LV_USE_FS_FATFS 0 601 | #if LV_USE_FS_FATFS 602 | #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 603 | #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 604 | #endif 605 | 606 | /*PNG decoder library*/ 607 | #define LV_USE_PNG 0 608 | 609 | /*BMP decoder library*/ 610 | #define LV_USE_BMP 0 611 | 612 | /* JPG + split JPG decoder library. 613 | * Split JPG is a custom format optimized for embedded systems. */ 614 | #define LV_USE_SJPG 0 615 | 616 | /*GIF decoder library*/ 617 | #define LV_USE_GIF 0 618 | 619 | /*QR code library*/ 620 | #define LV_USE_QRCODE 0 621 | 622 | /*FreeType library*/ 623 | #define LV_USE_FREETYPE 0 624 | #if LV_USE_FREETYPE 625 | /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ 626 | #define LV_FREETYPE_CACHE_SIZE (16 * 1024) 627 | #if LV_FREETYPE_CACHE_SIZE >= 0 628 | /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ 629 | /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ 630 | /* if font size >= 256, must be configured as image cache */ 631 | #define LV_FREETYPE_SBIT_CACHE 0 632 | /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ 633 | /* (0:use system defaults) */ 634 | #define LV_FREETYPE_CACHE_FT_FACES 0 635 | #define LV_FREETYPE_CACHE_FT_SIZES 0 636 | #endif 637 | #endif 638 | 639 | /*Rlottie library*/ 640 | #define LV_USE_RLOTTIE 0 641 | 642 | /*FFmpeg library for image decoding and playing videos 643 | *Supports all major image formats so do not enable other image decoder with it*/ 644 | #define LV_USE_FFMPEG 0 645 | #if LV_USE_FFMPEG 646 | /*Dump input information to stderr*/ 647 | #define LV_FFMPEG_AV_DUMP_FORMAT 0 648 | #endif 649 | 650 | /*----------- 651 | * Others 652 | *----------*/ 653 | 654 | /*1: Enable API to take snapshot for object*/ 655 | #define LV_USE_SNAPSHOT 0 656 | 657 | /*1: Enable Monkey test*/ 658 | #define LV_USE_MONKEY 0 659 | 660 | /*1: Enable grid navigation*/ 661 | #define LV_USE_GRIDNAV 0 662 | 663 | /*1: Enable lv_obj fragment*/ 664 | #define LV_USE_FRAGMENT 0 665 | 666 | /*================== 667 | * EXAMPLES 668 | *==================*/ 669 | 670 | /*Enable the examples to be built with the library*/ 671 | #define LV_BUILD_EXAMPLES 1 672 | 673 | /*--END OF LV_CONF_H--*/ 674 | 675 | #endif /*LV_CONF_H*/ 676 | 677 | #endif /*End of "Content enable"*/ 678 | -------------------------------------------------------------------------------- /examples/lvgl/lvgl_demo/lvgl_demo.ino: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include "PanelLan.h" 5 | 6 | // BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02, BOARD_SC07 7 | PanelLan tft(BOARD_SC01_PLUS); 8 | 9 | /*Change to your screen resolution*/ 10 | static const uint16_t screenWidth = 320; 11 | static const uint16_t screenHeight = 480; 12 | 13 | static lv_disp_draw_buf_t draw_buf; 14 | static lv_color_t buf[2][ screenWidth * 10 ]; 15 | 16 | /* Display flushing */ 17 | void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ) 18 | { 19 | if (tft.getStartCount() == 0) 20 | { // Processing if not yet started 21 | tft.startWrite(); 22 | } 23 | tft.pushImageDMA( area->x1 24 | , area->y1 25 | , area->x2 - area->x1 + 1 26 | , area->y2 - area->y1 + 1 27 | , ( lgfx::swap565_t* )&color_p->full); 28 | lv_disp_flush_ready( disp ); 29 | } 30 | 31 | /*Read the touchpad*/ 32 | void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data ) 33 | { 34 | uint16_t touchX, touchY; 35 | 36 | data->state = LV_INDEV_STATE_REL; 37 | 38 | if( tft.getTouch( &touchX, &touchY ) ) 39 | { 40 | data->state = LV_INDEV_STATE_PR; 41 | 42 | /*Set the coordinates*/ 43 | data->point.x = touchX; 44 | data->point.y = touchY; 45 | } 46 | } 47 | 48 | void lvgl_ui() 49 | { 50 | lv_obj_t* page_main = lv_obj_create(NULL); 51 | 52 | lv_obj_t* slider = lv_slider_create(page_main); 53 | lv_obj_set_size(slider, 150, 10); 54 | lv_obj_set_align( slider, LV_ALIGN_CENTER ); 55 | 56 | lv_obj_t* label = lv_label_create(page_main); 57 | lv_label_set_text(label, "Hello LVGL"); 58 | 59 | // lv_obj_t* ui_Spinner1 = lv_spinner_create(page_main, 500, 90); 60 | // lv_obj_set_width(ui_Spinner1, 80); 61 | // lv_obj_set_height(ui_Spinner1, 80); 62 | // lv_obj_set_align(ui_Spinner1, LV_ALIGN_CENTER); 63 | // lv_obj_clear_flag(ui_Spinner1, LV_OBJ_FLAG_CLICKABLE); /// Flags 64 | 65 | lv_scr_load(page_main); 66 | } 67 | 68 | void setup() 69 | { 70 | tft.begin(); 71 | 72 | lv_init(); 73 | lv_disp_draw_buf_init( &draw_buf, buf[0], buf[1], screenWidth * 10 ); 74 | 75 | /*Initialize the display*/ 76 | static lv_disp_drv_t disp_drv; 77 | lv_disp_drv_init( &disp_drv ); 78 | /*Change the following line to your display resolution*/ 79 | disp_drv.hor_res = screenWidth; 80 | disp_drv.ver_res = screenHeight; 81 | disp_drv.flush_cb = my_disp_flush; 82 | disp_drv.draw_buf = &draw_buf; 83 | lv_disp_drv_register( &disp_drv ); 84 | 85 | /*Initialize the input device driver*/ 86 | static lv_indev_drv_t indev_drv; 87 | lv_indev_drv_init( &indev_drv ); 88 | indev_drv.type = LV_INDEV_TYPE_POINTER; 89 | indev_drv.read_cb = my_touchpad_read; 90 | lv_indev_drv_register( &indev_drv ); 91 | 92 | lvgl_ui(); 93 | } 94 | 95 | void loop() 96 | { 97 | lv_timer_handler(); /* let the GUI do its work */ 98 | delay(20); 99 | } -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/README.md: -------------------------------------------------------------------------------- 1 | # Arduino project for SquareLine Studio with SmartPlane 2 | 3 | ## Get started 4 | 5 | 1. Install the LVGL library corresponding to SquareLine Studio in Arduino 6 | 2. Place the UI project file generated by SquareLine Studio in the same directory as the `src` file, and copy the `libraries/lv_conf.h` of the generated UI file to the Arduino library directory. 7 | 3. Open the `.ino` file in Arduino 8 | 4. Board of your choice 9 | 5. Build the project 10 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/README_CN.md: -------------------------------------------------------------------------------- 1 | # 在PanelLan中使用SquareLine Studio开发Arduino项目 2 | 3 | ## 开始 4 | 5 | 1. 在Arduino仓库中安装SquareLine Studio对应的LVGL库. 6 | 2. 将SquareLine Studio生成的UI项目文件放置`src`文件夹当中,将生成的UI文件的`libraries/lv_conf.h`复制到Arduino库目录中。 7 | 3. 在Arduino中打开`.ino`文件 8 | 4. 选择对应的板子 9 | 5. 编译项目 10 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/example_ui.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PanelLan.h" 3 | #include "ui.h" 4 | 5 | // BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02, BOARD_SC07 6 | PanelLan tft(BOARD_SC01_PLUS); 7 | 8 | /*Change to your screen resolution*/ 9 | static const uint16_t screenWidth = 320; 10 | static const uint16_t screenHeight = 480; 11 | 12 | static lv_disp_draw_buf_t draw_buf; 13 | static lv_color_t buf[2][ screenWidth * 10 ]; 14 | 15 | /* Display flushing */ 16 | void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p ) 17 | { 18 | if (tft.getStartCount() == 0) 19 | { // Processing if not yet started 20 | tft.startWrite(); 21 | } 22 | tft.pushImageDMA( area->x1 23 | , area->y1 24 | , area->x2 - area->x1 + 1 25 | , area->y2 - area->y1 + 1 26 | , ( lgfx::swap565_t* )&color_p->full); 27 | lv_disp_flush_ready( disp ); 28 | } 29 | 30 | /*Read the touchpad*/ 31 | void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data ) 32 | { 33 | uint16_t touchX, touchY; 34 | 35 | data->state = LV_INDEV_STATE_REL; 36 | 37 | if( tft.getTouch( &touchX, &touchY ) ) 38 | { 39 | data->state = LV_INDEV_STATE_PR; 40 | 41 | /*Set the coordinates*/ 42 | data->point.x = touchX; 43 | data->point.y = touchY; 44 | } 45 | } 46 | 47 | void setup() 48 | { 49 | tft.begin(); 50 | 51 | lv_init(); 52 | lv_disp_draw_buf_init( &draw_buf, buf[0], buf[1], screenWidth * 10 ); 53 | 54 | /*Initialize the display*/ 55 | static lv_disp_drv_t disp_drv; 56 | lv_disp_drv_init( &disp_drv ); 57 | /*Change the following line to your display resolution*/ 58 | disp_drv.hor_res = screenWidth; 59 | disp_drv.ver_res = screenHeight; 60 | disp_drv.flush_cb = my_disp_flush; 61 | disp_drv.draw_buf = &draw_buf; 62 | lv_disp_drv_register( &disp_drv ); 63 | 64 | /*Initialize the input device driver*/ 65 | static lv_indev_drv_t indev_drv; 66 | lv_indev_drv_init( &indev_drv ); 67 | indev_drv.type = LV_INDEV_TYPE_POINTER; 68 | indev_drv.read_cb = my_touchpad_read; 69 | lv_indev_drv_register( &indev_drv ); 70 | 71 | ui_init(); 72 | } 73 | 74 | void loop() 75 | { 76 | lv_timer_handler(); /* let the GUI do its work */ 77 | delay(1); 78 | } -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/library.properties: -------------------------------------------------------------------------------- 1 | name=ui 2 | version=1.0 3 | author=SquareLine_Studio 4 | category=Display 5 | url=https://squareline.io 6 | architectures=* 7 | includes=ui.h 8 | sentence=SquareLine_Studio 9 | paragraph=Squareline Studio creates smart, user-friendly LVGL UI solutions. 10 | name=ui 11 | maintainer=Squareline Studio 12 | maintainer_email=contact@squareline.io 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(SOURCES screens/ui_Screen1.c 2 | ui.c 3 | components/ui_comp_hook.c 4 | ui_helpers.c) 5 | 6 | add_library(ui ${SOURCES}) 7 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/components/ui_comp_hook.c: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/filelist.txt: -------------------------------------------------------------------------------- 1 | screens/ui_Screen1.c 2 | ui.c 3 | components/ui_comp_hook.c 4 | ui_helpers.c 5 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/readme.txt: -------------------------------------------------------------------------------- 1 | The UI files will be exported here 2 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/screens/ui_Screen1.c: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #include "../ui.h" 7 | 8 | void ui_Screen1_screen_init(void) 9 | { 10 | ui_Screen1 = lv_obj_create(NULL); 11 | lv_obj_clear_flag( ui_Screen1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags 12 | 13 | ui_Slider1 = lv_slider_create(ui_Screen1); 14 | lv_obj_set_width( ui_Slider1, 150); 15 | lv_obj_set_height( ui_Slider1, 10); 16 | lv_obj_set_align( ui_Slider1, LV_ALIGN_CENTER ); 17 | 18 | 19 | ui_Label1 = lv_label_create(ui_Screen1); 20 | lv_obj_set_width( ui_Label1, LV_SIZE_CONTENT); /// 1 21 | lv_obj_set_height( ui_Label1, LV_SIZE_CONTENT); /// 1 22 | lv_obj_set_x( ui_Label1, 0 ); 23 | lv_obj_set_y( ui_Label1, -30 ); 24 | lv_obj_set_align( ui_Label1, LV_ALIGN_CENTER ); 25 | lv_label_set_text(ui_Label1,"Load Form SquareLine"); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/ui.c: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #include "ui.h" 7 | #include "ui_helpers.h" 8 | 9 | ///////////////////// VARIABLES //////////////////// 10 | 11 | 12 | // SCREEN: ui_Screen1 13 | void ui_Screen1_screen_init(void); 14 | lv_obj_t *ui_Screen1; 15 | lv_obj_t *ui_Slider1; 16 | lv_obj_t *ui_Label1; 17 | lv_obj_t *ui____initial_actions0; 18 | 19 | ///////////////////// TEST LVGL SETTINGS //////////////////// 20 | #if LV_COLOR_DEPTH != 16 21 | #error "LV_COLOR_DEPTH should be 16bit to match SquareLine Studio's settings" 22 | #endif 23 | #if LV_COLOR_16_SWAP !=1 24 | #error "LV_COLOR_16_SWAP should be 1 to match SquareLine Studio's settings" 25 | #endif 26 | 27 | ///////////////////// ANIMATIONS //////////////////// 28 | 29 | ///////////////////// FUNCTIONS //////////////////// 30 | 31 | ///////////////////// SCREENS //////////////////// 32 | 33 | void ui_init( void ) 34 | { 35 | lv_disp_t *dispp = lv_disp_get_default(); 36 | lv_theme_t *theme = lv_theme_default_init(dispp, lv_palette_main(LV_PALETTE_BLUE), lv_palette_main(LV_PALETTE_RED), false, LV_FONT_DEFAULT); 37 | lv_disp_set_theme(dispp, theme); 38 | ui_Screen1_screen_init(); 39 | ui____initial_actions0 = lv_obj_create(NULL); 40 | lv_disp_load_scr( ui_Screen1); 41 | } 42 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/ui.h: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #ifndef _SQUARELINE_PROJECT_UI_H 7 | #define _SQUARELINE_PROJECT_UI_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #if defined __has_include 14 | #if __has_include("lvgl.h") 15 | #include "lvgl.h" 16 | #elif __has_include("lvgl/lvgl.h") 17 | #include "lvgl/lvgl.h" 18 | #else 19 | #include "lvgl.h" 20 | #endif 21 | #else 22 | #include "lvgl.h" 23 | #endif 24 | 25 | #include "ui_helpers.h" 26 | #include "ui_events.h" 27 | // SCREEN: ui_Screen1 28 | void ui_Screen1_screen_init(void); 29 | extern lv_obj_t *ui_Screen1; 30 | extern lv_obj_t *ui_Slider1; 31 | extern lv_obj_t *ui_Label1; 32 | extern lv_obj_t *ui____initial_actions0; 33 | 34 | 35 | 36 | 37 | void ui_init(void); 38 | 39 | #ifdef __cplusplus 40 | } /*extern "C"*/ 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/ui_events.h: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #ifndef _UI_EVENTS_H 7 | #define _UI_EVENTS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | } /*extern "C"*/ 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/ui_helpers.c: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #include "ui_helpers.h" 7 | 8 | void _ui_bar_set_property( lv_obj_t *target, int id, int val) 9 | { 10 | if (id == _UI_BAR_PROPERTY_VALUE_WITH_ANIM) lv_bar_set_value(target, val, LV_ANIM_ON); 11 | if (id == _UI_BAR_PROPERTY_VALUE) lv_bar_set_value(target, val, LV_ANIM_OFF); 12 | } 13 | 14 | void _ui_basic_set_property( lv_obj_t *target, int id, int val) 15 | { 16 | if (id == _UI_BASIC_PROPERTY_POSITION_X) lv_obj_set_x(target, val); 17 | if (id == _UI_BASIC_PROPERTY_POSITION_Y) lv_obj_set_y(target, val); 18 | if (id == _UI_BASIC_PROPERTY_WIDTH) lv_obj_set_width(target, val); 19 | if (id == _UI_BASIC_PROPERTY_HEIGHT) lv_obj_set_height(target, val); 20 | } 21 | 22 | void _ui_dropdown_set_property( lv_obj_t *target, int id, int val) 23 | { 24 | if (id == _UI_DROPDOWN_PROPERTY_SELECTED) lv_dropdown_set_selected(target, val); 25 | } 26 | 27 | void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val) 28 | { 29 | if (id == _UI_IMAGE_PROPERTY_IMAGE) lv_img_set_src(target, val); 30 | } 31 | 32 | void _ui_label_set_property( lv_obj_t *target, int id, const char *val) 33 | { 34 | if (id == _UI_LABEL_PROPERTY_TEXT) lv_label_set_text(target, val); 35 | } 36 | 37 | void _ui_roller_set_property( lv_obj_t *target, int id, int val) 38 | { 39 | if (id == _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM) lv_roller_set_selected(target, val, LV_ANIM_ON); 40 | if (id == _UI_ROLLER_PROPERTY_SELECTED) lv_roller_set_selected(target, val, LV_ANIM_OFF); 41 | } 42 | 43 | void _ui_slider_set_property( lv_obj_t *target, int id, int val) 44 | { 45 | if (id == _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM) lv_slider_set_value(target, val, LV_ANIM_ON); 46 | if (id == _UI_SLIDER_PROPERTY_VALUE) lv_slider_set_value(target, val, LV_ANIM_OFF); 47 | } 48 | 49 | void _ui_screen_change( lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)) 50 | { 51 | if(*target == NULL) 52 | target_init(); 53 | lv_scr_load_anim(*target, fademode, spd, delay, false); 54 | } 55 | 56 | void _ui_screen_delete( lv_obj_t ** target ) 57 | { 58 | if(*target == NULL) 59 | { 60 | lv_obj_del(*target); 61 | target = NULL; 62 | } 63 | } 64 | 65 | void _ui_arc_increment( lv_obj_t *target, int val) 66 | { 67 | int old = lv_arc_get_value(target); 68 | lv_arc_set_value(target, old+val); 69 | lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); 70 | } 71 | 72 | void _ui_bar_increment( lv_obj_t *target, int val, int anm) 73 | { 74 | int old = lv_bar_get_value(target); 75 | lv_bar_set_value(target, old+val, anm); 76 | } 77 | 78 | void _ui_slider_increment( lv_obj_t *target, int val, int anm) 79 | { 80 | int old = lv_slider_get_value(target); 81 | lv_slider_set_value(target, old+val, anm); 82 | lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); 83 | } 84 | 85 | void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea) 86 | { 87 | lv_keyboard_set_textarea(keyboard, textarea); 88 | } 89 | 90 | void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value) 91 | { 92 | if (value==_UI_MODIFY_FLAG_TOGGLE) 93 | { 94 | if ( lv_obj_has_flag(target,flag) ) lv_obj_clear_flag(target,flag); 95 | else lv_obj_add_flag(target,flag); 96 | } 97 | else if (value==_UI_MODIFY_FLAG_ADD) lv_obj_add_flag(target,flag); 98 | else lv_obj_clear_flag(target,flag); 99 | } 100 | void _ui_state_modify( lv_obj_t *target, int32_t state, int value) 101 | { 102 | if (value==_UI_MODIFY_STATE_TOGGLE) 103 | { 104 | if ( lv_obj_has_state(target,state) ) lv_obj_clear_state(target,state); 105 | else lv_obj_add_state(target,state); 106 | } 107 | else if (value==_UI_MODIFY_STATE_ADD) lv_obj_add_state(target,state); 108 | else lv_obj_clear_state(target,state); 109 | } 110 | 111 | void scr_unloaded_delete_cb(lv_event_t * e) 112 | { 113 | lv_obj_t ** var = lv_event_get_user_data(e); 114 | lv_obj_del(*var); 115 | (*var) = NULL; 116 | } 117 | 118 | void _ui_opacity_set( lv_obj_t *target, int val) 119 | { 120 | lv_obj_set_style_opa(target, val, 0); 121 | } 122 | 123 | void _ui_anim_callback_free_user_data(lv_anim_t *a) 124 | { 125 | lv_mem_free(a->user_data); 126 | a->user_data=NULL; 127 | } 128 | 129 | void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v) 130 | { 131 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 132 | lv_obj_set_x(usr->target, v); 133 | } 134 | 135 | void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v) 136 | { 137 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 138 | lv_obj_set_y(usr->target, v); 139 | } 140 | 141 | void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v) 142 | { 143 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 144 | lv_obj_set_width(usr->target, v); 145 | } 146 | 147 | void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v) 148 | { 149 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 150 | lv_obj_set_height(usr->target, v); 151 | } 152 | 153 | void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v) 154 | { 155 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 156 | lv_obj_set_style_opa(usr->target, v, 0); 157 | } 158 | 159 | void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v) 160 | { 161 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 162 | lv_img_set_zoom(usr->target, v); 163 | } 164 | 165 | void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v) 166 | { 167 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 168 | lv_img_set_angle(usr->target, v); 169 | } 170 | 171 | void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v) 172 | { 173 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 174 | usr->val = v; 175 | if ( v<0 ) v=0; 176 | if ( v>=usr->imgset_size ) v=usr->imgset_size-1; 177 | lv_img_set_src(usr->target, usr->imgset[v]); 178 | } 179 | 180 | int32_t _ui_anim_callback_get_x(lv_anim_t* a) 181 | { 182 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 183 | return lv_obj_get_x_aligned(usr->target); 184 | } 185 | 186 | int32_t _ui_anim_callback_get_y(lv_anim_t* a) 187 | { 188 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 189 | return lv_obj_get_y_aligned(usr->target); 190 | } 191 | 192 | int32_t _ui_anim_callback_get_width(lv_anim_t* a) 193 | { 194 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 195 | return lv_obj_get_width(usr->target); 196 | } 197 | 198 | int32_t _ui_anim_callback_get_height(lv_anim_t* a) 199 | { 200 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 201 | return lv_obj_get_height(usr->target); 202 | } 203 | 204 | int32_t _ui_anim_callback_get_opacity(lv_anim_t* a) 205 | { 206 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 207 | return lv_obj_get_style_opa(usr->target, 0); 208 | } 209 | 210 | int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a) 211 | { 212 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 213 | return lv_img_get_zoom(usr->target); 214 | } 215 | 216 | int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a) 217 | { 218 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 219 | return lv_img_get_angle(usr->target); 220 | } 221 | 222 | int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a) 223 | { 224 | ui_anim_user_data_t *usr = (ui_anim_user_data_t *)a->user_data; 225 | return usr->val; 226 | } 227 | 228 | void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix) 229 | { 230 | char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; 231 | lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_arc_get_value(src), postfix); 232 | lv_label_set_text(trg, buf); 233 | } 234 | 235 | void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix) 236 | { 237 | char buf[_UI_TEMPORARY_STRING_BUFFER_SIZE]; 238 | lv_snprintf(buf, sizeof(buf), "%s%d%s", prefix, (int)lv_slider_get_value(src), postfix); 239 | lv_label_set_text(trg, buf); 240 | } 241 | void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_on, const char *txt_off) 242 | { 243 | if (lv_obj_has_state(src,LV_STATE_CHECKED)) lv_label_set_text(trg,txt_on); 244 | else lv_label_set_text(trg,txt_off); 245 | } 246 | 247 | void _ui_spinbox_step(lv_obj_t * target, int val) 248 | { 249 | if(val > 0) lv_spinbox_increment(target); 250 | else lv_spinbox_decrement(target); 251 | 252 | lv_event_send(target,LV_EVENT_VALUE_CHANGED, 0); 253 | } 254 | 255 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/src/ui_helpers.h: -------------------------------------------------------------------------------- 1 | // This file was generated by SquareLine Studio 2 | // SquareLine Studio version: SquareLine Studio 1.3.3 3 | // LVGL version: 8.3.6 4 | // Project name: SquareLine_Project 5 | 6 | #ifndef _SQUARELINE_PROJECT_UI_HELPERS_H 7 | #define _SQUARELINE_PROJECT_UI_HELPERS_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | #include "ui.h" 14 | 15 | #define _UI_TEMPORARY_STRING_BUFFER_SIZE 32 16 | #define _UI_BAR_PROPERTY_VALUE 0 17 | #define _UI_BAR_PROPERTY_VALUE_WITH_ANIM 1 18 | void _ui_bar_set_property( lv_obj_t *target, int id, int val); 19 | 20 | #define _UI_BASIC_PROPERTY_POSITION_X 0 21 | #define _UI_BASIC_PROPERTY_POSITION_Y 1 22 | #define _UI_BASIC_PROPERTY_WIDTH 2 23 | #define _UI_BASIC_PROPERTY_HEIGHT 3 24 | void _ui_basic_set_property( lv_obj_t *target, int id, int val); 25 | 26 | #define _UI_DROPDOWN_PROPERTY_SELECTED 0 27 | void _ui_dropdown_set_property( lv_obj_t *target, int id, int val); 28 | 29 | #define _UI_IMAGE_PROPERTY_IMAGE 0 30 | void _ui_image_set_property( lv_obj_t *target, int id, uint8_t *val); 31 | 32 | #define _UI_LABEL_PROPERTY_TEXT 0 33 | void _ui_label_set_property( lv_obj_t *target, int id, const char *val); 34 | 35 | #define _UI_ROLLER_PROPERTY_SELECTED 0 36 | #define _UI_ROLLER_PROPERTY_SELECTED_WITH_ANIM 1 37 | void _ui_roller_set_property( lv_obj_t *target, int id, int val); 38 | 39 | #define _UI_SLIDER_PROPERTY_VALUE 0 40 | #define _UI_SLIDER_PROPERTY_VALUE_WITH_ANIM 1 41 | void _ui_slider_set_property( lv_obj_t *target, int id, int val); 42 | 43 | void _ui_screen_change( lv_obj_t ** target, lv_scr_load_anim_t fademode, int spd, int delay, void (*target_init)(void)); 44 | 45 | void _ui_screen_delete( lv_obj_t ** target ); 46 | 47 | void _ui_arc_increment( lv_obj_t *target, int val); 48 | 49 | void _ui_bar_increment( lv_obj_t *target, int val, int anm); 50 | 51 | void _ui_slider_increment( lv_obj_t *target, int val, int anm); 52 | 53 | void _ui_keyboard_set_target( lv_obj_t *keyboard, lv_obj_t *textarea); 54 | 55 | #define _UI_MODIFY_FLAG_ADD 0 56 | #define _UI_MODIFY_FLAG_REMOVE 1 57 | #define _UI_MODIFY_FLAG_TOGGLE 2 58 | void _ui_flag_modify( lv_obj_t *target, int32_t flag, int value); 59 | 60 | #define _UI_MODIFY_STATE_ADD 0 61 | #define _UI_MODIFY_STATE_REMOVE 1 62 | #define _UI_MODIFY_STATE_TOGGLE 2 63 | void _ui_state_modify( lv_obj_t *target, int32_t state, int value); 64 | 65 | void scr_unloaded_delete_cb(lv_event_t * e); 66 | 67 | void _ui_opacity_set( lv_obj_t *target, int val); 68 | 69 | /** Describes an animation*/ 70 | typedef struct _ui_anim_user_data_t { 71 | lv_obj_t *target; 72 | lv_img_dsc_t **imgset; 73 | int32_t imgset_size; 74 | int32_t val; 75 | } ui_anim_user_data_t; 76 | void _ui_anim_callback_free_user_data(lv_anim_t *a); 77 | 78 | void _ui_anim_callback_set_x(lv_anim_t* a, int32_t v); 79 | 80 | void _ui_anim_callback_set_y(lv_anim_t* a, int32_t v); 81 | 82 | void _ui_anim_callback_set_width(lv_anim_t* a, int32_t v); 83 | 84 | void _ui_anim_callback_set_height(lv_anim_t* a, int32_t v); 85 | 86 | void _ui_anim_callback_set_opacity(lv_anim_t* a, int32_t v); 87 | 88 | void _ui_anim_callback_set_image_zoom(lv_anim_t* a, int32_t v); 89 | 90 | void _ui_anim_callback_set_image_angle(lv_anim_t* a, int32_t v); 91 | 92 | void _ui_anim_callback_set_image_frame(lv_anim_t* a, int32_t v); 93 | 94 | int32_t _ui_anim_callback_get_x(lv_anim_t* a); 95 | 96 | int32_t _ui_anim_callback_get_y(lv_anim_t* a); 97 | 98 | int32_t _ui_anim_callback_get_width(lv_anim_t* a); 99 | 100 | int32_t _ui_anim_callback_get_height(lv_anim_t* a); 101 | 102 | int32_t _ui_anim_callback_get_opacity(lv_anim_t* a); 103 | 104 | int32_t _ui_anim_callback_get_image_zoom(lv_anim_t* a); 105 | 106 | int32_t _ui_anim_callback_get_image_angle(lv_anim_t* a); 107 | 108 | int32_t _ui_anim_callback_get_image_frame(lv_anim_t* a); 109 | 110 | void _ui_arc_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix); 111 | 112 | void _ui_slider_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *prefix, const char *postfix); 113 | 114 | void _ui_checked_set_text_value( lv_obj_t *trg, lv_obj_t *src, const char *txt_on, const char *txt_off); 115 | 116 | void _ui_spinbox_step(lv_obj_t * target, int val) ; 117 | 118 | #ifdef __cplusplus 119 | } /*extern "C"*/ 120 | #endif 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/example_ui/ui.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ui.h 3 | * 4 | */ 5 | 6 | #ifndef UI_OUTER_H 7 | #define UI_OUTER_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "src/ui.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | #ifdef __cplusplus 35 | } /*extern "C"*/ 36 | #endif 37 | 38 | #endif /*UI_OUTER_H*/ 39 | 40 | -------------------------------------------------------------------------------- /examples/lvgl/squareline_studio/libraries/lv_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_conf.h 3 | * Configuration file for v8.2.0 and v8.3.2 4 | */ 5 | 6 | /* 7 | * Copy this file as `lv_conf.h` 8 | * 1. simply next to the `lvgl` folder 9 | * 2. or any other places and 10 | * - define `LV_CONF_INCLUDE_SIMPLE` 11 | * - add the path as include path 12 | */ 13 | 14 | /* clang-format off */ 15 | #if 1 /*Set it to "1" to enable content*/ 16 | 17 | #ifndef LV_CONF_H 18 | #define LV_CONF_H 19 | 20 | #include 21 | 22 | /*Helper*/ 23 | #define __LVGL_V8_3 (8 == 8 && 3 == 3) 24 | 25 | /*==================== 26 | COLOR SETTINGS 27 | *====================*/ 28 | 29 | /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ 30 | #define LV_COLOR_DEPTH 16 31 | 32 | /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ 33 | #define LV_COLOR_16_SWAP 1 34 | 35 | /*Enable features to draw on transparent background. 36 | *It's required if opa, and transform_* style properties are used. 37 | *Can be also used if the UI is above another layer, e.g. an OSD menu or video player.*/ 38 | #define LV_COLOR_SCREEN_TRANSP (__LVGL_V8_3 ? 1 : 0) 39 | 40 | /* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently. 41 | * 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */ 42 | #define LV_COLOR_MIX_ROUND_OFS 0 43 | 44 | /*Images pixels with this color will not be drawn if they are chroma keyed)*/ 45 | #define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/ 46 | 47 | /*========================= 48 | MEMORY SETTINGS 49 | *=========================*/ 50 | 51 | /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/ 52 | #define LV_MEM_CUSTOM 0 53 | #if LV_MEM_CUSTOM == 0 54 | /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/ 55 | #define LV_MEM_SIZE (48U * 1024U) /*[bytes]*/ 56 | 57 | /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/ 58 | #define LV_MEM_ADR 0 /*0: unused*/ 59 | /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/ 60 | #if LV_MEM_ADR == 0 61 | #undef LV_MEM_POOL_INCLUDE 62 | #undef LV_MEM_POOL_ALLOC 63 | #endif 64 | 65 | #else /*LV_MEM_CUSTOM*/ 66 | #define LV_MEM_CUSTOM_INCLUDE /*Header for the dynamic memory function*/ 67 | #define LV_MEM_CUSTOM_ALLOC malloc 68 | #define LV_MEM_CUSTOM_FREE free 69 | #define LV_MEM_CUSTOM_REALLOC realloc 70 | #endif /*LV_MEM_CUSTOM*/ 71 | 72 | /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms. 73 | *You will see an error log message if there wasn't enough buffers. */ 74 | #define LV_MEM_BUF_MAX_NUM 16 75 | 76 | /*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/ 77 | #define LV_MEMCPY_MEMSET_STD 0 78 | 79 | /*==================== 80 | HAL SETTINGS 81 | *====================*/ 82 | 83 | /*Default display refresh period. LVG will redraw changed areas with this period time*/ 84 | #define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/ 85 | 86 | /*Input device read period in milliseconds*/ 87 | #define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/ 88 | 89 | /*Use a custom tick source that tells the elapsed time in milliseconds. 90 | *It removes the need to manually update the tick with `lv_tick_inc()`)*/ 91 | #define LV_TICK_CUSTOM 1 92 | #if LV_TICK_CUSTOM 93 | #define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/ 94 | #define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/ 95 | #endif /*LV_TICK_CUSTOM*/ 96 | 97 | /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings. 98 | *(Not so important, you can adjust it to modify default sizes and spaces)*/ 99 | #define LV_DPI_DEF 130 /*[px/inch]*/ 100 | 101 | /*======================= 102 | * FEATURE CONFIGURATION 103 | *=======================*/ 104 | 105 | /*------------- 106 | * Drawing 107 | *-----------*/ 108 | 109 | /*Enable complex draw engine. 110 | *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/ 111 | #define LV_DRAW_COMPLEX 1 112 | #if LV_DRAW_COMPLEX != 0 113 | 114 | /*Allow buffering some shadow calculation. 115 | *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius` 116 | *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/ 117 | #define LV_SHADOW_CACHE_SIZE 0 118 | 119 | /* Set number of maximally cached circle data. 120 | * The circumference of 1/4 circle are saved for anti-aliasing 121 | * radius * 4 bytes are used per circle (the most often used radiuses are saved) 122 | * 0: to disable caching */ 123 | #define LV_CIRCLE_CACHE_SIZE 4 124 | #endif /*LV_DRAW_COMPLEX*/ 125 | 126 | /** 127 | * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer 128 | * and blend it as an image with the given opacity. 129 | * Note that `bg_opa`, `text_opa` etc don't require buffering into layer) 130 | * The widget can be buffered in smaller chunks to avoid using large buffers. 131 | * 132 | * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it 133 | * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated. 134 | * 135 | * Both buffer sizes are in bytes. 136 | * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers 137 | * and can't be drawn in chunks. So these settings affects only widgets with opacity. 138 | */ 139 | #define LV_LAYER_SIMPLE_BUF_SIZE (24 * 1024) 140 | #define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (3 * 1024) 141 | 142 | /*Default image cache size. Image caching keeps the images opened. 143 | *If only the built-in image formats are used there is no real advantage of caching. (I.e. if no new image decoder is added) 144 | *With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images. 145 | *However the opened images might consume additional RAM. 146 | *0: to disable caching*/ 147 | #define LV_IMG_CACHE_DEF_SIZE 0 148 | 149 | /*Number of stops allowed per gradient. Increase this to allow more stops. 150 | *This adds (sizeof(lv_color_t) + 1) bytes per additional stop*/ 151 | #define LV_GRADIENT_MAX_STOPS 2 152 | 153 | /*Default gradient buffer size. 154 | *When LVGL calculates the gradient "maps" it can save them into a cache to avoid calculating them again. 155 | *LV_GRAD_CACHE_DEF_SIZE sets the size of this cache in bytes. 156 | *If the cache is too small the map will be allocated only while it's required for the drawing. 157 | *0 mean no caching.*/ 158 | #define LV_GRAD_CACHE_DEF_SIZE 0 159 | 160 | /*Allow dithering the gradients (to achieve visual smooth color gradients on limited color depth display) 161 | *LV_DITHER_GRADIENT implies allocating one or two more lines of the object's rendering surface 162 | *The increase in memory consumption is (32 bits * object width) plus 24 bits * object width if using error diffusion */ 163 | #define LV_DITHER_GRADIENT 0 164 | #if LV_DITHER_GRADIENT 165 | /*Add support for error diffusion dithering. 166 | *Error diffusion dithering gets a much better visual result, but implies more CPU consumption and memory when drawing. 167 | *The increase in memory consumption is (24 bits * object's width)*/ 168 | #define LV_DITHER_ERROR_DIFFUSION 0 169 | #endif 170 | 171 | /*Maximum buffer size to allocate for rotation. 172 | *Only used if software rotation is enabled in the display driver.*/ 173 | #define LV_DISP_ROT_MAX_BUF (10*1024) 174 | 175 | /*------------- 176 | * GPU 177 | *-----------*/ 178 | 179 | /*Use Arm's 2D acceleration library Arm-2D */ 180 | #define LV_USE_GPU_ARM2D 0 181 | 182 | /*Use STM32's DMA2D (aka Chrom Art) GPU*/ 183 | #define LV_USE_GPU_STM32_DMA2D 0 184 | #if LV_USE_GPU_STM32_DMA2D 185 | /*Must be defined to include path of CMSIS header of target processor 186 | e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ 187 | #define LV_GPU_DMA2D_CMSIS_INCLUDE 188 | #endif 189 | 190 | /*Use SWM341's DMA2D GPU*/ 191 | #define LV_USE_GPU_SWM341_DMA2D 0 192 | #if LV_USE_GPU_SWM341_DMA2D 193 | #define LV_GPU_SWM341_DMA2D_INCLUDE "SWM341.h" 194 | #endif 195 | 196 | /*Use NXP's PXP GPU iMX RTxxx platforms*/ 197 | #define LV_USE_GPU_NXP_PXP 0 198 | #if LV_USE_GPU_NXP_PXP 199 | /*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c) 200 | * and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS 201 | * has to be defined in order to use FreeRTOS OSA, otherwise bare-metal implementation is selected. 202 | *0: lv_gpu_nxp_pxp_init() has to be called manually before lv_init() 203 | */ 204 | #define LV_USE_GPU_NXP_PXP_AUTO_INIT 0 205 | #endif 206 | 207 | /*Use NXP's VG-Lite GPU iMX RTxxx platforms*/ 208 | #define LV_USE_GPU_NXP_VG_LITE 0 209 | 210 | /*Use SDL renderer API*/ 211 | #define LV_USE_GPU_SDL 0 212 | #if LV_USE_GPU_SDL 213 | #define LV_GPU_SDL_INCLUDE_PATH 214 | /*Texture cache size, 8MB by default*/ 215 | #define LV_GPU_SDL_LRU_SIZE (1024 * 1024 * 8) 216 | /*Custom blend mode for mask drawing, disable if you need to link with older SDL2 lib*/ 217 | #define LV_GPU_SDL_CUSTOM_BLEND_MODE (SDL_VERSION_ATLEAST(2, 0, 6)) 218 | #endif 219 | 220 | /*------------- 221 | * Logging 222 | *-----------*/ 223 | 224 | /*Enable the log module*/ 225 | #define LV_USE_LOG 0 226 | #if LV_USE_LOG 227 | 228 | /*How important log should be added: 229 | *LV_LOG_LEVEL_TRACE A lot of logs to give detailed information 230 | *LV_LOG_LEVEL_INFO Log important events 231 | *LV_LOG_LEVEL_WARN Log if something unwanted happened but didn't cause a problem 232 | *LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail 233 | *LV_LOG_LEVEL_USER Only logs added by the user 234 | *LV_LOG_LEVEL_NONE Do not log anything*/ 235 | #define LV_LOG_LEVEL LV_LOG_LEVEL_WARN 236 | 237 | /*1: Print the log with 'printf'; 238 | *0: User need to register a callback with `lv_log_register_print_cb()`*/ 239 | #define LV_LOG_PRINTF 0 240 | 241 | /*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/ 242 | #define LV_LOG_TRACE_MEM 1 243 | #define LV_LOG_TRACE_TIMER 1 244 | #define LV_LOG_TRACE_INDEV 1 245 | #define LV_LOG_TRACE_DISP_REFR 1 246 | #define LV_LOG_TRACE_EVENT 1 247 | #define LV_LOG_TRACE_OBJ_CREATE 1 248 | #define LV_LOG_TRACE_LAYOUT 1 249 | #define LV_LOG_TRACE_ANIM 1 250 | 251 | #endif /*LV_USE_LOG*/ 252 | 253 | /*------------- 254 | * Asserts 255 | *-----------*/ 256 | 257 | /*Enable asserts if an operation is failed or an invalid data is found. 258 | *If LV_USE_LOG is enabled an error message will be printed on failure*/ 259 | #define LV_USE_ASSERT_NULL 1 /*Check if the parameter is NULL. (Very fast, recommended)*/ 260 | #define LV_USE_ASSERT_MALLOC 1 /*Checks is the memory is successfully allocated or no. (Very fast, recommended)*/ 261 | #define LV_USE_ASSERT_STYLE 0 /*Check if the styles are properly initialized. (Very fast, recommended)*/ 262 | #define LV_USE_ASSERT_MEM_INTEGRITY 0 /*Check the integrity of `lv_mem` after critical operations. (Slow)*/ 263 | #define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/ 264 | 265 | /*Add a custom handler when assert happens e.g. to restart the MCU*/ 266 | #define LV_ASSERT_HANDLER_INCLUDE 267 | #define LV_ASSERT_HANDLER while(1); /*Halt by default*/ 268 | 269 | /*------------- 270 | * Others 271 | *-----------*/ 272 | 273 | /*1: Show CPU usage and FPS count*/ 274 | #define LV_USE_PERF_MONITOR 0 275 | #if LV_USE_PERF_MONITOR 276 | #define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT 277 | #endif 278 | 279 | /*1: Show the used memory and the memory fragmentation 280 | * Requires LV_MEM_CUSTOM = 0*/ 281 | #define LV_USE_MEM_MONITOR 0 282 | #if LV_USE_MEM_MONITOR 283 | #define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT 284 | #endif 285 | 286 | /*1: Draw random colored rectangles over the redrawn areas*/ 287 | #define LV_USE_REFR_DEBUG 0 288 | 289 | /*Change the built in (v)snprintf functions*/ 290 | #define LV_SPRINTF_CUSTOM 0 291 | #if LV_SPRINTF_CUSTOM 292 | #define LV_SPRINTF_INCLUDE 293 | #define lv_snprintf snprintf 294 | #define lv_vsnprintf vsnprintf 295 | #else /*LV_SPRINTF_CUSTOM*/ 296 | #define LV_SPRINTF_USE_FLOAT 0 297 | #endif /*LV_SPRINTF_CUSTOM*/ 298 | 299 | #define LV_USE_USER_DATA 1 300 | 301 | /*Garbage Collector settings 302 | *Used if lvgl is bound to higher level language and the memory is managed by that language*/ 303 | #define LV_ENABLE_GC 0 304 | #if LV_ENABLE_GC != 0 305 | #define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/ 306 | #endif /*LV_ENABLE_GC*/ 307 | 308 | /*===================== 309 | * COMPILER SETTINGS 310 | *====================*/ 311 | 312 | /*For big endian systems set to 1*/ 313 | #define LV_BIG_ENDIAN_SYSTEM 0 314 | 315 | /*Define a custom attribute to `lv_tick_inc` function*/ 316 | #define LV_ATTRIBUTE_TICK_INC 317 | 318 | /*Define a custom attribute to `lv_timer_handler` function*/ 319 | #define LV_ATTRIBUTE_TIMER_HANDLER 320 | 321 | /*Define a custom attribute to `lv_disp_flush_ready` function*/ 322 | #define LV_ATTRIBUTE_FLUSH_READY 323 | 324 | /*Required alignment size for buffers*/ 325 | #define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1 326 | 327 | /*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default). 328 | * E.g. __attribute__((aligned(4)))*/ 329 | #define LV_ATTRIBUTE_MEM_ALIGN 330 | 331 | /*Attribute to mark large constant arrays for example font's bitmaps*/ 332 | #define LV_ATTRIBUTE_LARGE_CONST 333 | 334 | /*Compiler prefix for a big array declaration in RAM*/ 335 | #define LV_ATTRIBUTE_LARGE_RAM_ARRAY 336 | 337 | /*Place performance critical functions into a faster memory (e.g RAM)*/ 338 | #define LV_ATTRIBUTE_FAST_MEM 339 | 340 | /*Prefix variables that are used in GPU accelerated operations, often these need to be placed in RAM sections that are DMA accessible*/ 341 | #define LV_ATTRIBUTE_DMA 342 | 343 | /*Export integer constant to binding. This macro is used with constants in the form of LV_ that 344 | *should also appear on LVGL binding API such as Micropython.*/ 345 | #define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/ 346 | 347 | /*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/ 348 | #define LV_USE_LARGE_COORD 0 349 | 350 | /*================== 351 | * FONT USAGE 352 | *===================*/ 353 | 354 | /*Montserrat fonts with ASCII range and some symbols using bpp = 4 355 | *https://fonts.google.com/specimen/Montserrat*/ 356 | #define LV_FONT_MONTSERRAT_8 0 357 | #define LV_FONT_MONTSERRAT_10 0 358 | #define LV_FONT_MONTSERRAT_12 0 359 | #define LV_FONT_MONTSERRAT_14 1 360 | #define LV_FONT_MONTSERRAT_16 0 361 | #define LV_FONT_MONTSERRAT_18 0 362 | #define LV_FONT_MONTSERRAT_20 0 363 | #define LV_FONT_MONTSERRAT_22 0 364 | #define LV_FONT_MONTSERRAT_24 0 365 | #define LV_FONT_MONTSERRAT_26 0 366 | #define LV_FONT_MONTSERRAT_28 0 367 | #define LV_FONT_MONTSERRAT_30 0 368 | #define LV_FONT_MONTSERRAT_32 0 369 | #define LV_FONT_MONTSERRAT_34 0 370 | #define LV_FONT_MONTSERRAT_36 0 371 | #define LV_FONT_MONTSERRAT_38 0 372 | #define LV_FONT_MONTSERRAT_40 0 373 | #define LV_FONT_MONTSERRAT_42 0 374 | #define LV_FONT_MONTSERRAT_44 0 375 | #define LV_FONT_MONTSERRAT_46 0 376 | #define LV_FONT_MONTSERRAT_48 0 377 | 378 | /*Demonstrate special features*/ 379 | #define LV_FONT_MONTSERRAT_12_SUBPX 0 380 | #define LV_FONT_MONTSERRAT_28_COMPRESSED 0 /*bpp = 3*/ 381 | #define LV_FONT_DEJAVU_16_PERSIAN_HEBREW 0 /*Hebrew, Arabic, Persian letters and all their forms*/ 382 | #define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/ 383 | 384 | /*Pixel perfect monospace fonts*/ 385 | #define LV_FONT_UNSCII_8 0 386 | #define LV_FONT_UNSCII_16 0 387 | 388 | /*Optionally declare custom fonts here. 389 | *You can use these fonts as default font too and they will be available globally. 390 | *E.g. #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) LV_FONT_DECLARE(my_font_2)*/ 391 | #define LV_FONT_CUSTOM_DECLARE 392 | 393 | /*Always set a default font*/ 394 | #define LV_FONT_DEFAULT &lv_font_montserrat_14 395 | 396 | /*Enable handling large font and/or fonts with a lot of characters. 397 | *The limit depends on the font size, font face and bpp. 398 | *Compiler error will be triggered if a font needs it.*/ 399 | #define LV_FONT_FMT_TXT_LARGE 0 400 | 401 | /*Enables/disables support for compressed fonts.*/ 402 | #define LV_USE_FONT_COMPRESSED 0 403 | 404 | /*Enable subpixel rendering*/ 405 | #define LV_USE_FONT_SUBPX 0 406 | #if LV_USE_FONT_SUBPX 407 | /*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/ 408 | #define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/ 409 | #endif 410 | 411 | /*Enable drawing placeholders when glyph dsc is not found*/ 412 | #define LV_USE_FONT_PLACEHOLDER 1 413 | 414 | /*================= 415 | * TEXT SETTINGS 416 | *=================*/ 417 | 418 | /** 419 | * Select a character encoding for strings. 420 | * Your IDE or editor should have the same character encoding 421 | * - LV_TXT_ENC_UTF8 422 | * - LV_TXT_ENC_ASCII 423 | */ 424 | #define LV_TXT_ENC LV_TXT_ENC_UTF8 425 | 426 | /*Can break (wrap) texts on these chars*/ 427 | #define LV_TXT_BREAK_CHARS " ,.;:-_" 428 | 429 | /*If a word is at least this long, will break wherever "prettiest" 430 | *To disable, set to a value <= 0*/ 431 | #define LV_TXT_LINE_BREAK_LONG_LEN 0 432 | 433 | /*Minimum number of characters in a long word to put on a line before a break. 434 | *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ 435 | #define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3 436 | 437 | /*Minimum number of characters in a long word to put on a line after a break. 438 | *Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/ 439 | #define LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN 3 440 | 441 | /*The control character to use for signalling text recoloring.*/ 442 | #define LV_TXT_COLOR_CMD "#" 443 | 444 | /*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts. 445 | *The direction will be processed according to the Unicode Bidirectional Algorithm: 446 | *https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/ 447 | #define LV_USE_BIDI 0 448 | #if LV_USE_BIDI 449 | /*Set the default direction. Supported values: 450 | *`LV_BASE_DIR_LTR` Left-to-Right 451 | *`LV_BASE_DIR_RTL` Right-to-Left 452 | *`LV_BASE_DIR_AUTO` detect texts base direction*/ 453 | #define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO 454 | #endif 455 | 456 | /*Enable Arabic/Persian processing 457 | *In these languages characters should be replaced with an other form based on their position in the text*/ 458 | #define LV_USE_ARABIC_PERSIAN_CHARS 0 459 | 460 | /*================== 461 | * WIDGET USAGE 462 | *================*/ 463 | 464 | /*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/ 465 | 466 | #define LV_USE_ARC 1 467 | 468 | #define LV_USE_BAR 1 469 | 470 | #define LV_USE_BTN 1 471 | 472 | #define LV_USE_BTNMATRIX 1 473 | 474 | #define LV_USE_CANVAS 1 475 | 476 | #define LV_USE_CHECKBOX 1 477 | 478 | #define LV_USE_DROPDOWN 1 /*Requires: lv_label*/ 479 | 480 | #define LV_USE_IMG 1 /*Requires: lv_label*/ 481 | 482 | #define LV_USE_LABEL 1 483 | #if LV_USE_LABEL 484 | #define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/ 485 | #define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/ 486 | #endif 487 | 488 | #define LV_USE_LINE 1 489 | 490 | #define LV_USE_ROLLER 1 /*Requires: lv_label*/ 491 | #if LV_USE_ROLLER 492 | #define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/ 493 | #endif 494 | 495 | #define LV_USE_SLIDER 1 /*Requires: lv_bar*/ 496 | 497 | #define LV_USE_SWITCH 1 498 | 499 | #define LV_USE_TEXTAREA 1 /*Requires: lv_label*/ 500 | #if LV_USE_TEXTAREA != 0 501 | #define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/ 502 | #endif 503 | 504 | #define LV_USE_TABLE 1 505 | 506 | /*================== 507 | * EXTRA COMPONENTS 508 | *==================*/ 509 | 510 | /*----------- 511 | * Widgets 512 | *----------*/ 513 | #define LV_USE_ANIMIMG 1 514 | 515 | #define LV_USE_CALENDAR 1 516 | #if LV_USE_CALENDAR 517 | #define LV_CALENDAR_WEEK_STARTS_MONDAY 0 518 | #if LV_CALENDAR_WEEK_STARTS_MONDAY 519 | #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"} 520 | #else 521 | #define LV_CALENDAR_DEFAULT_DAY_NAMES {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"} 522 | #endif 523 | 524 | #define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} 525 | #define LV_USE_CALENDAR_HEADER_ARROW 1 526 | #define LV_USE_CALENDAR_HEADER_DROPDOWN 1 527 | #endif /*LV_USE_CALENDAR*/ 528 | 529 | #define LV_USE_CHART 1 530 | 531 | #define LV_USE_COLORWHEEL 1 532 | 533 | #define LV_USE_IMGBTN 1 534 | 535 | #define LV_USE_KEYBOARD 1 536 | 537 | #define LV_USE_LED 1 538 | 539 | #define LV_USE_LIST 1 540 | 541 | #define LV_USE_MENU 1 542 | 543 | #define LV_USE_METER 1 544 | 545 | #define LV_USE_MSGBOX 1 546 | 547 | #define LV_USE_SPAN 1 548 | #if LV_USE_SPAN 549 | /*A line text can contain maximum num of span descriptor */ 550 | #define LV_SPAN_SNIPPET_STACK_SIZE 64 551 | #endif 552 | 553 | #define LV_USE_SPINBOX 1 554 | 555 | #define LV_USE_SPINNER 1 556 | 557 | #define LV_USE_TABVIEW 1 558 | 559 | #define LV_USE_TILEVIEW 1 560 | 561 | #define LV_USE_WIN 1 562 | 563 | /*----------- 564 | * Themes 565 | *----------*/ 566 | 567 | /*A simple, impressive and very complete theme*/ 568 | #define LV_USE_THEME_DEFAULT 1 569 | #if LV_USE_THEME_DEFAULT 570 | 571 | /*0: Light mode; 1: Dark mode*/ 572 | #define LV_THEME_DEFAULT_DARK 0 573 | 574 | /*1: Enable grow on press*/ 575 | #define LV_THEME_DEFAULT_GROW 1 576 | 577 | /*Default transition time in [ms]*/ 578 | #define LV_THEME_DEFAULT_TRANSITION_TIME 80 579 | #endif /*LV_USE_THEME_DEFAULT*/ 580 | 581 | /*A very simple theme that is a good starting point for a custom theme*/ 582 | #define LV_USE_THEME_BASIC 1 583 | 584 | /*A theme designed for monochrome displays*/ 585 | #define LV_USE_THEME_MONO 1 586 | 587 | /*----------- 588 | * Layouts 589 | *----------*/ 590 | 591 | /*A layout similar to Flexbox in CSS.*/ 592 | #define LV_USE_FLEX 1 593 | 594 | /*A layout similar to Grid in CSS.*/ 595 | #define LV_USE_GRID 1 596 | 597 | /*--------------------- 598 | * 3rd party libraries 599 | *--------------------*/ 600 | 601 | /*File system interfaces for common APIs */ 602 | 603 | /*API for fopen, fread, etc*/ 604 | #define LV_USE_FS_STDIO 0 605 | #if LV_USE_FS_STDIO 606 | #define LV_FS_STDIO_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 607 | #define LV_FS_STDIO_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 608 | #define LV_FS_STDIO_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 609 | #endif 610 | 611 | /*API for open, read, etc*/ 612 | #define LV_USE_FS_POSIX 0 613 | #if LV_USE_FS_POSIX 614 | #define LV_FS_POSIX_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 615 | #define LV_FS_POSIX_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 616 | #define LV_FS_POSIX_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 617 | #endif 618 | 619 | /*API for CreateFile, ReadFile, etc*/ 620 | #define LV_USE_FS_WIN32 0 621 | #if LV_USE_FS_WIN32 622 | #define LV_FS_WIN32_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 623 | #define LV_FS_WIN32_PATH "" /*Set the working directory. File/directory paths will be appended to it.*/ 624 | #define LV_FS_WIN32_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 625 | #endif 626 | 627 | /*API for FATFS (needs to be added separately). Uses f_open, f_read, etc*/ 628 | #define LV_USE_FS_FATFS 0 629 | #if LV_USE_FS_FATFS 630 | #define LV_FS_FATFS_LETTER '\0' /*Set an upper cased letter on which the drive will accessible (e.g. 'A')*/ 631 | #define LV_FS_FATFS_CACHE_SIZE 0 /*>0 to cache this number of bytes in lv_fs_read()*/ 632 | #endif 633 | 634 | /*PNG decoder library*/ 635 | #define LV_USE_PNG 0 636 | 637 | /*BMP decoder library*/ 638 | #define LV_USE_BMP 0 639 | 640 | /* JPG + split JPG decoder library. 641 | * Split JPG is a custom format optimized for embedded systems. */ 642 | #define LV_USE_SJPG 0 643 | 644 | /*GIF decoder library*/ 645 | #define LV_USE_GIF 0 646 | 647 | /*QR code library*/ 648 | #define LV_USE_QRCODE 0 649 | 650 | /*FreeType library*/ 651 | #define LV_USE_FREETYPE 0 652 | #if LV_USE_FREETYPE 653 | /*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/ 654 | #define LV_FREETYPE_CACHE_SIZE (16 * 1024) 655 | #if LV_FREETYPE_CACHE_SIZE >= 0 656 | /* 1: bitmap cache use the sbit cache, 0:bitmap cache use the image cache. */ 657 | /* sbit cache:it is much more memory efficient for small bitmaps(font size < 256) */ 658 | /* if font size >= 256, must be configured as image cache */ 659 | #define LV_FREETYPE_SBIT_CACHE 0 660 | /* Maximum number of opened FT_Face/FT_Size objects managed by this cache instance. */ 661 | /* (0:use system defaults) */ 662 | #define LV_FREETYPE_CACHE_FT_FACES 0 663 | #define LV_FREETYPE_CACHE_FT_SIZES 0 664 | #endif 665 | #endif 666 | 667 | /*Rlottie library*/ 668 | #define LV_USE_RLOTTIE 0 669 | 670 | /*FFmpeg library for image decoding and playing videos 671 | *Supports all major image formats so do not enable other image decoder with it*/ 672 | #define LV_USE_FFMPEG 0 673 | #if LV_USE_FFMPEG 674 | /*Dump input information to stderr*/ 675 | #define LV_FFMPEG_DUMP_FORMAT 0 676 | #endif 677 | 678 | /*----------- 679 | * Others 680 | *----------*/ 681 | 682 | /*1: Enable API to take snapshot for object*/ 683 | #define LV_USE_SNAPSHOT 0 684 | 685 | /*1: Enable Monkey test*/ 686 | #define LV_USE_MONKEY 0 687 | 688 | /*1: Enable grid navigation*/ 689 | #define LV_USE_GRIDNAV 0 690 | 691 | /*1: Enable lv_obj fragment*/ 692 | #define LV_USE_FRAGMENT 0 693 | 694 | /*1: Support using images as font in label or span widgets */ 695 | #define LV_USE_IMGFONT 0 696 | 697 | /*1: Enable a published subscriber based messaging system */ 698 | #define LV_USE_MSG 0 699 | 700 | /*1: Enable Pinyin input method*/ 701 | /*Requires: lv_keyboard*/ 702 | #define LV_USE_IME_PINYIN 0 703 | #if LV_USE_IME_PINYIN 704 | /*1: Use default thesaurus*/ 705 | /*If you do not use the default thesaurus, be sure to use `lv_ime_pinyin` after setting the thesauruss*/ 706 | #define LV_IME_PINYIN_USE_DEFAULT_DICT 1 707 | /*Set the maximum number of candidate panels that can be displayed*/ 708 | /*This needs to be adjusted according to the size of the screen*/ 709 | #define LV_IME_PINYIN_CAND_TEXT_NUM 6 710 | 711 | /*Use 9 key input(k9)*/ 712 | #define LV_IME_PINYIN_USE_K9_MODE 1 713 | #if LV_IME_PINYIN_USE_K9_MODE == 1 714 | #define LV_IME_PINYIN_K9_CAND_TEXT_NUM 3 715 | #endif // LV_IME_PINYIN_USE_K9_MODE 716 | #endif 717 | 718 | /*================== 719 | * EXAMPLES 720 | *==================*/ 721 | 722 | /*Enable the examples to be built with the library*/ 723 | #define LV_BUILD_EXAMPLES 1 724 | 725 | /*=================== 726 | * DEMO USAGE 727 | ====================*/ 728 | 729 | /*Show some widget. It might be required to increase `LV_MEM_SIZE` */ 730 | #define LV_USE_DEMO_WIDGETS 0 731 | #if LV_USE_DEMO_WIDGETS 732 | #define LV_DEMO_WIDGETS_SLIDESHOW 0 733 | #endif 734 | 735 | /*Demonstrate the usage of encoder and keyboard*/ 736 | #define LV_USE_DEMO_KEYPAD_AND_ENCODER 0 737 | 738 | /*Benchmark your system*/ 739 | #define LV_USE_DEMO_BENCHMARK 0 740 | #if LV_USE_DEMO_BENCHMARK 741 | /*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/ 742 | #define LV_DEMO_BENCHMARK_RGB565A8 0 743 | #endif 744 | 745 | /*Stress test for LVGL*/ 746 | #define LV_USE_DEMO_STRESS 0 747 | 748 | /*Music player demo*/ 749 | #define LV_USE_DEMO_MUSIC 0 750 | #if LV_USE_DEMO_MUSIC 751 | #define LV_DEMO_MUSIC_SQUARE 0 752 | #define LV_DEMO_MUSIC_LANDSCAPE 0 753 | #define LV_DEMO_MUSIC_ROUND 0 754 | #define LV_DEMO_MUSIC_LARGE 0 755 | #define LV_DEMO_MUSIC_AUTO_PLAY 0 756 | #endif 757 | 758 | /*--END OF LV_CONF_H--*/ 759 | 760 | #endif /*LV_CONF_H*/ 761 | 762 | #endif /*End of "Content enable"*/ 763 | 764 | -------------------------------------------------------------------------------- /examples/peripherals/aw9523/README.md: -------------------------------------------------------------------------------- 1 | # AW9523 Extended IO Usage 2 | 3 | ## Environment 4 | Installation: `Adafruit_AW9523` and its required `Adafruit_BusIO`. 5 | 6 | ## Example: BOARD_SC05 Initialization 7 | 1. I2C Configuration: The screen touch and AW9523 share the same I2C bus. The touch is configured to use `I2C_NUM_1` with a frequency of 400000. 8 | - `cfg.i2c_port = I2C_NUM_1;` 9 | - `cfg.freq = 400000;` 10 | 11 | 2. I2C Initialization 12 | ```cpp 13 | Wire1.begin(I2C_SDA_PIN, I2C_SCL_PIN); 14 | Wire1.setClock(400000); 15 | aw.begin(AW9523_I2C_ADDR, &Wire1); 16 | ``` 17 | 18 | ## Issue: Touch Failure 19 | 20 | - **BOARD_SC05**: The AW9523's P10 pin is connected to the screen reset pin, and the P11 pin is connected to the touch reset pin. 21 | - During the `begin` function, the initialization affects the touch reset pin: 22 | ```cpp 23 | bool Adafruit_AW9523::begin(uint8_t addr, TwoWire *wire) { 24 | ... 25 | configureDirection(0x0); // all inputs! 26 | ... 27 | } 28 | ``` 29 | 30 | ## Solution 31 | ```cpp 32 | aw.pinMode(LCD_RST_Pin, OUTPUT); 33 | aw.pinMode(TP_RST_Pin, OUTPUT); 34 | aw.digitalWrite(LCD_RST_Pin, HIGH); 35 | aw.digitalWrite(TP_RST_Pin, HIGH); 36 | ``` -------------------------------------------------------------------------------- /examples/peripherals/aw9523/README_CN.md: -------------------------------------------------------------------------------- 1 | # aw9523 扩展IO使用 2 | 3 | ## 环境 4 | 安装:Adafruit_AW9523以及它所需要的Adafruit_BusIO 5 | 6 | ## 例子:BOARD_SC05初始化 7 | 1. I2C配置:屏幕触摸与aw9523使用I2C相同,触摸配置处使用`I2C_NUM_1`,频率为400000 8 | - `cfg.i2c_port = I2C_NUM_1;` 9 | - `cfg.freq = 400000;` 10 | 11 | 2. 初始化I2C 12 | - `Wire1.begin(I2C_SDA_PIN, I2C_SCL_PIN);` 13 | - `Wire1.setClock(400000);` 14 | - `aw.begin(AW9523_I2C_ADDR, &Wire1)` 15 | 16 | ## 问题:触摸失灵 17 | 18 | - **BOARD_SC05**:aw9523_P10脚连接屏幕复位脚,aw9523_P11脚连接触摸复位脚 19 | - `begin`函数初始化过程中会影响触摸复位脚: 20 | ```cpp 21 | bool Adafruit_AW9523::begin(uint8_t addr, TwoWire *wire) { 22 | ... 23 | configureDirection(0x0); // all inputs! 24 | ... 25 | } 26 | ``` 27 | 28 | ### 问题解决 29 | ```cpp 30 | aw.pinMode(LCD_RST_Pin, OUTPUT); 31 | aw.pinMode(TP_RST_Pin, OUTPUT); 32 | aw.digitalWrite(LCD_RST_Pin, HIGH); 33 | aw.digitalWrite(TP_RST_Pin, HIGH); 34 | ``` 35 | 36 | 37 | -------------------------------------------------------------------------------- /examples/peripherals/aw9523/aw9523.ino: -------------------------------------------------------------------------------- 1 | #include "PanelLan.h" 2 | #include 3 | 4 | // BOARD_SC05 5 | PanelLan tft(BOARD_SC05); 6 | 7 | #define AW9523_I2C_ADDR 0x5B 8 | #define I2C_SDA_PIN 48 9 | #define I2C_SCL_PIN 47 10 | 11 | Adafruit_AW9523 aw; 12 | uint8_t LedPin = 0; 13 | uint8_t LCD_RST_Pin = 8; // aw9523 P10 connected to LCD_RST 14 | uint8_t TP_RST_Pin = 9; // aw9523 P11 connected to TP_RST 15 | 16 | void aw9523_test() { 17 | Serial.begin(115200); 18 | while (!Serial) 19 | delay(1); 20 | 21 | Serial.println("Adafruit AW9523 GPIO Expander test!"); 22 | 23 | Wire1.begin(I2C_SDA_PIN, I2C_SCL_PIN); 24 | Wire1.setClock(400000); 25 | 26 | // Initialize the AW9523 GPIO expander 27 | if (!aw.begin(AW9523_I2C_ADDR, &Wire1)) 28 | { 29 | Serial.println("AW9523 not found? Check wiring!"); 30 | while (1) 31 | delay(10); 32 | } 33 | Serial.println("AW9523 found!"); 34 | 35 | aw.pinMode(LCD_RST_Pin, OUTPUT); 36 | aw.pinMode(TP_RST_Pin, OUTPUT); 37 | aw.digitalWrite(LCD_RST_Pin, HIGH); 38 | aw.digitalWrite(TP_RST_Pin, HIGH); 39 | 40 | aw.pinMode(LedPin, OUTPUT); 41 | 42 | } 43 | 44 | void setup(void) { 45 | aw9523_test(); 46 | } 47 | 48 | void loop() { 49 | aw.digitalWrite(LedPin, HIGH); 50 | delay(100); 51 | aw.digitalWrite(LedPin, LOW); 52 | delay(100); 53 | } 54 | -------------------------------------------------------------------------------- /examples/peripherals/rs485/rs485.ino: -------------------------------------------------------------------------------- 1 | #include "PanelLan.h" 2 | #include "driver/uart.h" 3 | 4 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 5 | PanelLan tft(BOARD_SC01_PLUS); 6 | 7 | #define BUF_SIZE (127) 8 | 9 | void setup(void) { 10 | Serial.begin(115200); 11 | 12 | tft.begin(); 13 | tft.fillScreen(TFT_BLUE); 14 | tft.setTextColor(0xffffffU); 15 | tft.setTextWrap(true, true); 16 | 17 | if ((tft.pins.rs485.rxd == -1) || (tft.pins.rs485.txd == -1) || (tft.pins.rs485.rts == -1)) { 18 | tft.println("The current board does not support rs485"); 19 | Serial.printf("The current board does not support rs485\n"); 20 | return; 21 | } 22 | 23 | // Set rs485 24 | Serial2.begin(115200); 25 | 26 | // Set UART pins as per KConfig settings 27 | Serial2.setPins(tft.pins.rs485.rxd, tft.pins.rs485.txd, -1, tft.pins.rs485.rts); 28 | 29 | // Set RS485 half duplex mode 30 | Serial2.setMode(UART_MODE_RS485_HALF_DUPLEX); 31 | 32 | // Sets the maximum number of milliseconds to wait 33 | Serial2.setTimeout(3); 34 | 35 | Serial.printf("Start RS485 UART TEST.\r\n"); 36 | tft.println("Start RS485 UART TEST...\r\n"); 37 | Serial2.write("Start RS485 UART TEST.\r\n"); 38 | } 39 | 40 | void loop(void) { 41 | // Allocate buffers for UART 42 | uint8_t* data = (uint8_t*)malloc(BUF_SIZE); 43 | 44 | while (1) { 45 | // Read data from UART 46 | int len = Serial2.read(data, BUF_SIZE); 47 | 48 | // Write data back to UART 49 | if (len > 0) { 50 | Serial2.write("\r\n"); 51 | tft.printf("\r\n"); 52 | char prefix[] = "RS485 Received: ["; 53 | Serial2.write(prefix, (sizeof(prefix) - 1)); 54 | tft.printf(prefix); 55 | Serial.printf("["); 56 | for (int i = 0; i < len; i++) { 57 | Serial.printf("0x%x", (uint8_t)data[i]); 58 | Serial2.write((const char*)&data[i], 1); 59 | tft.printf("0x%x", (uint8_t)data[i]); 60 | // Add a Newline character if you get a return charater from paste (Paste tests multibyte receipt/buffer) 61 | if (data[i] == '\r') { 62 | Serial2.write("\n", 1); 63 | } 64 | } 65 | Serial.printf("] \n"); 66 | Serial2.write("]\r\n", 3); 67 | tft.printf("] \n"); 68 | } else { 69 | // Echo a "." to show we are alive while we wait for input 70 | Serial2.write("."); 71 | //tft.printf("."); 72 | delay(10); 73 | } 74 | } 75 | delay(1000); 76 | } -------------------------------------------------------------------------------- /examples/peripherals/sdcard/sdcard.ino: -------------------------------------------------------------------------------- 1 | 2 | #include "FS.h" 3 | #include "SD_MMC.h" 4 | #include "SD.h" 5 | #include "PanelLan.h" 6 | 7 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 8 | PanelLan tft(BOARD_SC01_PLUS); 9 | 10 | void listDir(fs::FS& fs, const char* dirname, uint8_t levels) { 11 | Serial.printf("Listing directory: %s\n", dirname); 12 | 13 | File root = fs.open(dirname); 14 | if (!root) { 15 | Serial.println("Failed to open directory"); 16 | tft.println("Failed to open directory"); 17 | return; 18 | } 19 | if (!root.isDirectory()) { 20 | Serial.println("Not a directory"); 21 | tft.println("Not a directory"); 22 | return; 23 | } 24 | 25 | File file = root.openNextFile(); 26 | while (file) { 27 | if (file.isDirectory()) { 28 | Serial.print(" DIR : "); 29 | Serial.println(file.name()); 30 | if (levels) { 31 | listDir(fs, file.path(), levels - 1); 32 | } 33 | } else { 34 | Serial.print(" FILE: "); 35 | Serial.print(file.name()); 36 | Serial.print(" SIZE: "); 37 | Serial.println(file.size()); 38 | } 39 | file = root.openNextFile(); 40 | } 41 | } 42 | 43 | void createDir(fs::FS& fs, const char* path) { 44 | Serial.printf("Creating Dir: %s\n", path); 45 | if (fs.mkdir(path)) { 46 | Serial.println("Dir created"); 47 | tft.println("Dir created"); 48 | } else { 49 | Serial.println("mkdir failed"); 50 | tft.println("mkdir failed"); 51 | } 52 | } 53 | 54 | void removeDir(fs::FS& fs, const char* path) { 55 | Serial.printf("Removing Dir: %s\n", path); 56 | if (fs.rmdir(path)) { 57 | Serial.println("Dir removed"); 58 | tft.println("Dir removed"); 59 | } else { 60 | Serial.println("rmdir failed"); 61 | tft.println("rmdir failed"); 62 | } 63 | } 64 | 65 | void readFile(fs::FS& fs, const char* path) { 66 | Serial.printf("Reading file: %s\n", path); 67 | 68 | File file = fs.open(path); 69 | if (!file) { 70 | Serial.println("Failed to open file for reading"); 71 | tft.println("Failed to open file for readin"); 72 | return; 73 | } 74 | 75 | Serial.print("Read from file: "); 76 | tft.print("Read from file:"); 77 | while (file.available()) { 78 | Serial.write(file.read()); 79 | tft.print(file.read()); 80 | } 81 | } 82 | 83 | void writeFile(fs::FS& fs, const char* path, const char* message) { 84 | Serial.printf("Writing file: %s\n", path); 85 | 86 | File file = fs.open(path, FILE_WRITE); 87 | if (!file) { 88 | Serial.println("Failed to open file for writing"); 89 | tft.println("Failed to open file for writing"); 90 | return; 91 | } 92 | if (file.print(message)) { 93 | Serial.println("File written"); 94 | tft.println("File written"); 95 | } else { 96 | Serial.println("Write failed"); 97 | tft.println("Write failed"); 98 | } 99 | } 100 | 101 | void appendFile(fs::FS& fs, const char* path, const char* message) { 102 | Serial.printf("Appending to file: %s\n", path); 103 | 104 | File file = fs.open(path, FILE_APPEND); 105 | if (!file) { 106 | Serial.println("Failed to open file for appending"); 107 | tft.println("Failed to open file for appending"); 108 | return; 109 | } 110 | if (file.print(message)) { 111 | Serial.println("Message appended"); 112 | tft.println("Message appended"); 113 | } else { 114 | Serial.println("Append failed"); 115 | tft.println("Append failed"); 116 | } 117 | } 118 | 119 | void renameFile(fs::FS& fs, const char* path1, const char* path2) { 120 | Serial.printf("Renaming file %s to %s\n", path1, path2); 121 | if (fs.rename(path1, path2)) { 122 | Serial.println("File renamed"); 123 | tft.println("File renamed"); 124 | } else { 125 | Serial.println("Rename failed"); 126 | tft.println("Rename failed"); 127 | } 128 | } 129 | 130 | void deleteFile(fs::FS& fs, const char* path) { 131 | Serial.printf("Deleting file: %s\n", path); 132 | if (fs.remove(path)) { 133 | Serial.println("File deleted"); 134 | tft.println("File deleted"); 135 | } else { 136 | Serial.println("Delete failed"); 137 | tft.println("Delete failed"); 138 | } 139 | } 140 | 141 | void testFileIO(fs::FS& fs, const char* path) { 142 | File file = fs.open(path); 143 | static uint8_t buf[512]; 144 | size_t len = 0; 145 | uint32_t start = millis(); 146 | uint32_t end = start; 147 | if (file) { 148 | len = file.size(); 149 | size_t flen = len; 150 | start = millis(); 151 | while (len) { 152 | size_t toRead = len; 153 | if (toRead > 512) { 154 | toRead = 512; 155 | } 156 | file.read(buf, toRead); 157 | len -= toRead; 158 | } 159 | end = millis() - start; 160 | Serial.printf("%u bytes read for %u ms\n", flen, end); 161 | file.close(); 162 | } else { 163 | Serial.println("Failed to open file for reading"); 164 | } 165 | 166 | file = fs.open(path, FILE_WRITE); 167 | if (!file) { 168 | Serial.println("Failed to open file for writing"); 169 | return; 170 | } 171 | 172 | size_t i; 173 | start = millis(); 174 | for (i = 0; i < 2048; i++) { file.write(buf, 512); } 175 | end = millis() - start; 176 | Serial.printf("%u bytes written for %u ms\n", 2048 * 512, end); 177 | file.close(); 178 | } 179 | 180 | void setup() { 181 | Serial.begin(115200); 182 | tft.begin(); 183 | 184 | if ((tft.pins.sd.clk == -1) || (tft.pins.sd.cmd == -1) || (tft.pins.sd.d0 == -1) || (tft.pins.sd.d3 == -1)) { 185 | Serial.println("The current board does not support SD"); 186 | tft.println("The current board does not support SD"); 187 | return; 188 | } 189 | 190 | SPI.begin(tft.pins.sd.clk, tft.pins.sd.d0, tft.pins.sd.cmd, tft.pins.sd.d3); 191 | if (!SD.begin(tft.pins.sd.d3, SPI)) { 192 | Serial.println("Card Mount Failed"); 193 | tft.println("Card Mount Failed"); 194 | return; 195 | } 196 | uint8_t cardType = SD.cardType(); 197 | if (cardType == CARD_NONE) { 198 | Serial.println("No SD card attached"); 199 | tft.println("No SD card attached"); 200 | return; 201 | } 202 | 203 | uint64_t cardSize = SD.cardSize() / (1024 * 1024); 204 | Serial.printf("SD Card Size: %lluMB\n", cardSize); 205 | tft.printf("SD Card Size: %lluMB\n", cardSize); 206 | 207 | listDir(SD, "/", 0); 208 | createDir(SD, "/mydir"); 209 | listDir(SD, "/", 0); 210 | removeDir(SD, "/mydir"); 211 | listDir(SD, "/", 2); 212 | tft.println("\n1.WriteFile hello.txt write Hello"); 213 | writeFile(SD, "/hello.txt", "Hello "); 214 | tft.println("\n2.AppendFile hello.txt append World"); 215 | appendFile(SD, "hello.txt", "World!\n"); 216 | tft.println("\n3.ReadFile hello.txt"); 217 | readFile(SD, "/hello.txt"); 218 | tft.println("\n4.DeleteFile foo.txt"); 219 | deleteFile(SD, "/foo.txt"); 220 | tft.println("\n5.RenameFile hello.txt to foo.txt"); 221 | renameFile(SD, "/hello.txt", "/foo.txt"); 222 | tft.println("\n6.ReadFile foo.txt"); 223 | readFile(SD, "/foo.txt"); 224 | tft.println("\n7.TestFileIO test.txt"); 225 | testFileIO(SD, "/test.txt"); 226 | Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024)); 227 | tft.printf("\nTotal space: %lluMB\n", SD.totalBytes() / (1024 * 1024)); 228 | Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024)); 229 | tft.printf("\nUsed space: %lluMB\n", SD.usedBytes() / (1024 * 1024)); 230 | } 231 | 232 | void loop(void) { 233 | 234 | } 235 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=PanelLan 2 | version=0.0.3 3 | author=diudiu 4 | maintainer=PanelLan 5 | sentence=TFT LCD Graphics config with touch for PanelLan board 6 | paragraph=Supports PanelLan displays, SC01, SC01_PLUS(ZX3D50CE08S), SC02(ZX4D30NE01S-UR), SC05(ZX7D00CE01S), KC01(ZX2D10GE01S), BC02(ZX3D95CE01S-TR) 7 | category=Display 8 | url=https://github.com/smartpanle/PanelLan_esp32_arduino 9 | includes=PanelLan.h 10 | architectures=esp32 11 | depends=LovyanGFX (>=1.1.9) 12 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | This repository supports screens and touch functions of development boards sold by Qiming Zhixian, making development faster and more efficient. 4 | 5 | # How to Use 6 | 7 | Supported boards are pre-configured and ready to use. 8 | 9 | ```c++ 10 | #include "PanelLan.h" 11 | 12 | // BOARD_SC01, BOARD_SC01_PLUS, BOARD_SC02, BOARD_SC05, BOARD_KC01, BOARD_BC02 13 | PanelLan tft(BOARD_SC01_PLUS); 14 | 15 | void setup(void) 16 | { 17 | tft.begin(); 18 | tft.setTextDatum(textdatum_t::middle_center); 19 | tft.setFont(&fonts::FreeSerifBold18pt7b); 20 | tft.drawString("HELLO WORLD", tft.width() / 2, tft.height() / 2); 21 | } 22 | ``` 23 | 24 | The screen and touch drivers in the repository rely on [LovyanGFX](https://github.com/lovyan03/LovyanGFX). Examples are at [here](https://github.com/lovyan03/LovyanGFX/tree/master/examples) . 25 | 26 | # Supported Boards 27 | 28 | | Name | Model | LCD Interface | Touch | Other Peripherals | 29 | |------|-------|---------------|-------|--------------------| 30 | | SC01 | - | spi/ST7796 | FT5x06 | - | 31 | | SC01-PLUS | ZX3D50CE08S | 8080-8bit / ST7796 | FT5x06 | sdcard, spk, rs485 | 32 | | SC02 | ZX4D30NE01S-UR | RGB | - | rs485 | 33 | | SC05 | ZX7D00CE01S | RGB | GT911 | - | 34 | | SC05_PLUS | ZX2D80CECOF | 8080-8bit / ST7789 | GT911 | rs485 | 35 | | SC07 | ZX4D30CE08S-4827 | 8080 | CST3240 | rs485, can, buzzer| 36 | | KC01 | ZX2D10GE01S | RGB | - | ab-encoder, motor | 37 | | BC02 | ZX3D95CE01S-TR | RGB | FT5x06 | sht20 | 38 | 39 | # Board Configuration 40 | 41 | | Name | Model | FLASH | PSRAM | 42 | |------|-------|-------|-------| 43 | | SC01 | ESP32 Dev Module | 4MB QIO 80MHz | QSPI PSRAM | 44 | | SC01-PLUS | ESP32S3 Dev Module | 8MB QIO 80MHz | QSPI PSRAM | 45 | | SC02 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 46 | | SC05 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 47 | | SC05_PLUS | ESP32S3 Dev Module | 16MB QIO 80MHz | QSPI PSRAM | 48 | | SC07 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 49 | | KC01 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 50 | | BC02 | ESP32S3 Dev Module | 16MB QIO 80MHz | OPI PSRAM | 51 | 52 | # Dependencies 53 | 54 | | Name | Version | Description | 55 | |------|---------|-------------| 56 | | [LovyanGFX](https://github.com/lovyan03/LovyanGFX) | >= v1.1.9 | SPI LCD graphics library for ESP32 / ESP8266 / SAMD51 | 57 | | [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v2.0.9 | Arduino core for the ESP32, ESP32-S3, etc | 58 | 59 | # Other 60 | If you encounter screen tearing issues with RGB, refer to the following link: 61 | https://github.com/esp-arduino-libs/arduino-esp32-sdk 62 | 63 | 64 | # Acknowledgements 65 | 66 | - Thanks to [lovyan03](https://github.com/lovyan03) for the open-source, user-friendly, and easily extendable driver repository [LovyanGFX](https://github.com/lovyan03/LovyanGFX). 67 | -------------------------------------------------------------------------------- /src/PanelLan.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "board/boards.h" 4 | -------------------------------------------------------------------------------- /src/board/bc02/bc02.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../boards.h" 10 | #include "bc02_pin.h" 11 | #include "bc02_rgb_spi_init.hpp" 12 | 13 | using namespace lgfx::v1; 14 | 15 | #define PanelLan_SCREEN_WIDTH 480 16 | #define PanelLan_SCREEN_HIGHT 480 17 | 18 | #define PanelLan_SCREEN_BK_FREQ 500 19 | 20 | #define PanelLan_RGB_CLK_FREQ (15000000) 21 | #define PanelLan_RGB_HSYNC_PULSE_WIDTH (10) 22 | #define PanelLan_RGB_HSYNC_BACK_PORCH (40) 23 | #define PanelLan_RGB_HSYNC_FRONT_PORCH (8) 24 | #define PanelLan_RGB_VSYNC_PULSE_WIDTH (10) 25 | #define PanelLan_RGB_VSYNC_BACK_PORCH (40) 26 | #define PanelLan_RGB_VSYNC_FRONT_PORCH (8) 27 | 28 | class Panel_BC02_Spec: public Panel_RGB { 29 | bool init(bool use_reset) override { 30 | if (BOARD_RESET_PIN > -1) { 31 | pinMode(BOARD_RESET_PIN, OUTPUT); 32 | digitalWrite(BOARD_RESET_PIN, 0); 33 | vTaskDelay(pdMS_TO_TICKS(2)); 34 | digitalWrite(BOARD_RESET_PIN, 1); 35 | vTaskDelay(pdMS_TO_TICKS(120)); 36 | } 37 | 38 | if (LCD_DISP_EN_GPIO > -1) { 39 | pinMode(LCD_DISP_EN_GPIO, OUTPUT); 40 | digitalWrite(LCD_DISP_EN_GPIO, 1); 41 | vTaskDelay(pdMS_TO_TICKS(10)); 42 | } 43 | 44 | panelLan_rgb_spi_init(); 45 | 46 | if (!Panel_RGB::init(false)) { 47 | return false; 48 | } 49 | 50 | return true; 51 | } 52 | }; 53 | 54 | Panel_Device* panel_load_from_bc02(board_pins_t* pins) { 55 | auto panle = new Panel_BC02_Spec(); 56 | 57 | *pins = { 58 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 59 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 60 | { -1, -1, -1, -1, -1 }, 61 | { -1, -1, -1, -1, -1, -1 }, 62 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 63 | { USB_DP_PIN, USB_DN_PIN }, 64 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, EXTERNAL_I2C_SDA_PIN, EXTERNAL_I2C_SCL_PIN } 65 | }; 66 | 67 | { 68 | auto cfg = panle->config_detail(); 69 | panle->config_detail(cfg); 70 | } 71 | 72 | { 73 | auto _bus_instance = new Bus_RGB(); 74 | auto cfg = _bus_instance->config(); 75 | cfg.panel = panle; 76 | cfg.pin_d0 = LCD_D0_GPIO; // B0 77 | cfg.pin_d1 = LCD_D1_GPIO; // B1 78 | cfg.pin_d2 = LCD_D2_GPIO; // B2 79 | cfg.pin_d3 = LCD_D3_GPIO; // B3 80 | cfg.pin_d4 = LCD_D4_GPIO; // B4 81 | cfg.pin_d5 = LCD_D5_GPIO; // G0 82 | cfg.pin_d6 = LCD_D6_GPIO; // G1 83 | cfg.pin_d7 = LCD_D7_GPIO; // G2 84 | cfg.pin_d8 = LCD_D8_GPIO; // G3 85 | cfg.pin_d9 = LCD_D9_GPIO; // G4 86 | cfg.pin_d10 = LCD_D10_GPIO; // G5 87 | cfg.pin_d11 = LCD_D11_GPIO; // R0 88 | cfg.pin_d12 = LCD_D12_GPIO; // R1 89 | cfg.pin_d13 = LCD_D13_GPIO; // R2 90 | cfg.pin_d14 = LCD_D14_GPIO; // R3 91 | cfg.pin_d15 = LCD_D15_GPIO; // R4 92 | 93 | cfg.pin_pclk = LCD_PCLK_GPIO; 94 | cfg.pin_vsync = LCD_VSYNC_GPIO; 95 | cfg.pin_hsync = LCD_HSYNC_GPIO; 96 | cfg.pin_henable = LCD_DE_GPIO; 97 | 98 | cfg.freq_write = PanelLan_RGB_CLK_FREQ; 99 | 100 | cfg.hsync_polarity = 1; 101 | cfg.hsync_front_porch = PanelLan_RGB_HSYNC_FRONT_PORCH; 102 | cfg.hsync_pulse_width = PanelLan_RGB_HSYNC_PULSE_WIDTH; 103 | cfg.hsync_back_porch = PanelLan_RGB_HSYNC_BACK_PORCH; 104 | cfg.vsync_polarity = 1; 105 | cfg.vsync_front_porch = PanelLan_RGB_VSYNC_FRONT_PORCH; 106 | cfg.vsync_pulse_width = PanelLan_RGB_VSYNC_PULSE_WIDTH; 107 | cfg.vsync_back_porch = PanelLan_RGB_VSYNC_BACK_PORCH; 108 | 109 | cfg.pclk_active_neg = 0; 110 | 111 | _bus_instance->config(cfg); 112 | panle->setBus(_bus_instance); 113 | } 114 | 115 | { 116 | auto cfg = panle->config(); // 117 | 118 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 119 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 120 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 121 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 122 | 123 | cfg.offset_x = 0; 124 | cfg.offset_y = 0; 125 | 126 | panle->config(cfg); 127 | } 128 | 129 | { 130 | auto _touch_instance = new Touch_FT5x06(); 131 | auto cfg = _touch_instance->config(); 132 | cfg.x_min = 0; 133 | cfg.x_max = PanelLan_SCREEN_WIDTH; 134 | cfg.y_min = 0; 135 | cfg.y_max = PanelLan_SCREEN_HIGHT; 136 | cfg.bus_shared = true; 137 | cfg.offset_rotation = 0; 138 | 139 | cfg.i2c_port = I2C_NUM_1; 140 | 141 | cfg.pin_int = TP_I2C_INT_PIN; 142 | cfg.pin_sda = TP_I2C_SDA_PIN; 143 | cfg.pin_scl = TP_I2C_SCL_PIN; 144 | cfg.pin_rst = TP_I2C_RST_PIN; 145 | 146 | cfg.freq = 400000; 147 | _touch_instance->config(cfg); 148 | panle->setTouch(_touch_instance); 149 | } 150 | 151 | { 152 | auto blk = new Light_PWM(); 153 | auto cfg = blk->config(); 154 | 155 | cfg.pin_bl = LCD_BL_PIN; 156 | cfg.invert = false; 157 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 158 | cfg.pwm_channel = 7; 159 | 160 | blk->config(cfg); 161 | panle->setLight(blk); 162 | } 163 | 164 | return panle; 165 | } 166 | 167 | #endif 168 | -------------------------------------------------------------------------------- /src/board/bc02/bc02_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (-1) 5 | #define BOARD_I2C_SDA_PIN (15) 6 | #define BOARD_I2C_SCL_PIN (6) 7 | 8 | // LCD PIN 9 | #define LCD_RST_PIN (-1) 10 | #define LCD_BL_PIN (5) 11 | #define LCD_DISP_EN_GPIO (41) 12 | 13 | // LCD RGB SPI CONFIG PIN 14 | #define LCD_SPI_MOSI (48) 15 | #define LCD_SPI_CLK (45) 16 | #define LCD_SPI_CS (38) 17 | 18 | // LCD RGB565 DRIVER PIN 19 | #define LCD_PCLK_GPIO (39) 20 | #define LCD_VSYNC_GPIO (41) 21 | #define LCD_HSYNC_GPIO (42) 22 | #define LCD_DE_GPIO (40) 23 | 24 | #define LCD_D0_GPIO (45) // B0 25 | #define LCD_D1_GPIO (48) // B1 26 | #define LCD_D2_GPIO (47) // B2 27 | #define LCD_D3_GPIO (0) // B3 28 | #define LCD_D4_GPIO (21) // B4 29 | #define LCD_D5_GPIO (14) // G0 30 | #define LCD_D6_GPIO (13) // G1 31 | #define LCD_D7_GPIO (12) // G2 32 | #define LCD_D8_GPIO (11) // G3 33 | #define LCD_D9_GPIO (16) // G4 34 | #define LCD_D10_GPIO (17) // G5 35 | #define LCD_D11_GPIO (18) // R0 36 | #define LCD_D12_GPIO (8) // R1 37 | #define LCD_D13_GPIO (3) // R2 38 | #define LCD_D14_GPIO (46) // R3 39 | #define LCD_D15_GPIO (10) // R4 40 | 41 | // TOUCH PAD PIN 42 | #define TP_I2C_SDA_PIN (BOARD_I2C_SDA_PIN) 43 | #define TP_I2C_SCL_PIN (BOARD_I2C_SCL_PIN) 44 | #define TP_I2C_INT_PIN (4) 45 | #define TP_I2C_RST_PIN (-1) 46 | 47 | // UART-485 48 | #define RS485_RTS_PIN (-1) 49 | #define RS485_RXD_PIN (1) 50 | #define RS485_TXD_PIN (2) 51 | 52 | // USB 53 | #define USB_DP_PIN (20) 54 | #define USB_DN_PIN (19) 55 | 56 | // SHT20 57 | #define SHT20_I2C_SDA (BOARD_I2C_SDA_PIN) 58 | #define SHT20_I2C_SCL (BOARD_I2C_SCL_PIN) 59 | 60 | // EXTERNAL PIN 61 | #define EXTERNAL_PIN_1 (9) 62 | #define EXTERNAL_PIN_2 (USB_DP_PIN) 63 | #define EXTERNAL_PIN_3 (USB_DN_PIN) 64 | #define EXTERNAL_PIN_4 (7) 65 | #define EXTERNAL_I2C_SDA_PIN (BOARD_I2C_SDA_PIN) 66 | #define EXTERNAL_I2C_SCL_PIN (BOARD_I2C_SCL_PIN) 67 | -------------------------------------------------------------------------------- /src/board/bc02/bc02_rgb_spi_init.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include "freertos/FreeRTOS.h" 8 | #include "freertos/task.h" 9 | #include "soc/soc_caps.h" 10 | #include "driver/gpio.h" 11 | #include "driver/spi_master.h" 12 | 13 | static spi_device_handle_t g_screen_spi; 14 | 15 | static void lcd_cmd(spi_device_handle_t spi, const uint16_t data) { 16 | esp_err_t ret; 17 | uint16_t tmp_cmd = (data | 0x0000); 18 | spi_transaction_ext_t trans = (spi_transaction_ext_t){ 19 | .base = 20 | { 21 | .flags = SPI_TRANS_VARIABLE_CMD, 22 | .cmd = tmp_cmd, 23 | }, 24 | .command_bits = 9, 25 | }; 26 | ret = spi_device_transmit(spi, (spi_transaction_t*)&trans); 27 | assert(ret == ESP_OK); //Should have had no issues. 28 | } 29 | 30 | static void lcd_data(spi_device_handle_t spi, const uint16_t data) { 31 | esp_err_t ret; 32 | uint16_t tmp_cmd = (data | 0x0100); 33 | spi_transaction_ext_t trans = (spi_transaction_ext_t){ 34 | .base = 35 | { 36 | .flags = SPI_TRANS_VARIABLE_CMD, 37 | .cmd = tmp_cmd, 38 | }, 39 | .command_bits = 9, 40 | }; 41 | ret = spi_device_transmit(spi, (spi_transaction_t*)&trans); 42 | 43 | assert(ret == ESP_OK); //Should have had no issues. 44 | } 45 | 46 | static void SPI_WriteComm(uint16_t cmd) { 47 | lcd_cmd(g_screen_spi, cmd); 48 | } 49 | 50 | static void SPI_WriteData(uint16_t data) { 51 | lcd_data(g_screen_spi, data); 52 | } 53 | 54 | static void rgb_driver_init(void) { 55 | SPI_WriteComm(0xF0); 56 | SPI_WriteData(0x55); 57 | SPI_WriteData(0xAA); 58 | SPI_WriteData(0x52); 59 | SPI_WriteData(0x08); 60 | SPI_WriteData(0x00); 61 | 62 | SPI_WriteComm(0xF6); 63 | SPI_WriteData(0x5A); 64 | SPI_WriteData(0x87); 65 | 66 | SPI_WriteComm(0xC1); 67 | SPI_WriteData(0x3F); 68 | 69 | SPI_WriteComm(0xC2); 70 | SPI_WriteData(0x0E); 71 | 72 | SPI_WriteComm(0xC6); 73 | SPI_WriteData(0xF8); 74 | 75 | SPI_WriteComm(0xC9); 76 | SPI_WriteData(0x10); 77 | 78 | SPI_WriteComm(0xCD); 79 | SPI_WriteData(0x25); 80 | 81 | SPI_WriteComm(0xF8); 82 | SPI_WriteData(0x8A); 83 | 84 | SPI_WriteComm(0xAC); 85 | SPI_WriteData(0x45); 86 | 87 | SPI_WriteComm(0xA0); 88 | SPI_WriteData(0xDD); 89 | 90 | SPI_WriteComm(0xA7); 91 | SPI_WriteData(0x47); 92 | 93 | SPI_WriteComm(0xFA); 94 | SPI_WriteData(0x00); 95 | SPI_WriteData(0x00); 96 | SPI_WriteData(0x00); 97 | SPI_WriteData(0x04); 98 | 99 | SPI_WriteComm(0x86); 100 | SPI_WriteData(0x99); 101 | SPI_WriteData(0xa3); 102 | SPI_WriteData(0xa3); 103 | SPI_WriteData(0x51); 104 | 105 | SPI_WriteComm(0xA3); 106 | SPI_WriteData(0xEE); 107 | 108 | SPI_WriteComm(0xFD); 109 | SPI_WriteData(0x28); 110 | SPI_WriteData(0x28); 111 | SPI_WriteData(0x00); 112 | 113 | SPI_WriteComm(0x71); 114 | SPI_WriteData(0x48); 115 | 116 | SPI_WriteComm(0x72); 117 | SPI_WriteData(0x48); 118 | 119 | SPI_WriteComm(0x73); 120 | SPI_WriteData(0x00); 121 | SPI_WriteData(0x44); 122 | 123 | SPI_WriteComm(0x97); 124 | SPI_WriteData(0xEE); 125 | 126 | SPI_WriteComm(0x83); 127 | SPI_WriteData(0x93); 128 | 129 | SPI_WriteComm(0x9A); 130 | SPI_WriteData(0x72); 131 | 132 | SPI_WriteComm(0x9B); 133 | SPI_WriteData(0x5a); 134 | 135 | SPI_WriteComm(0x82); 136 | SPI_WriteData(0x2c); 137 | SPI_WriteData(0x2c); 138 | 139 | SPI_WriteComm(0xB1); 140 | SPI_WriteData(0x10); 141 | 142 | SPI_WriteComm(0x6D); 143 | SPI_WriteData(0x00); 144 | SPI_WriteData(0x1F); 145 | SPI_WriteData(0x19); 146 | SPI_WriteData(0x1A); 147 | SPI_WriteData(0x10); 148 | SPI_WriteData(0x0e); 149 | SPI_WriteData(0x0c); 150 | SPI_WriteData(0x0a); 151 | SPI_WriteData(0x02); 152 | SPI_WriteData(0x07); 153 | SPI_WriteData(0x1E); 154 | SPI_WriteData(0x1E); 155 | SPI_WriteData(0x1E); 156 | SPI_WriteData(0x1E); 157 | SPI_WriteData(0x1E); 158 | SPI_WriteData(0x1E); 159 | SPI_WriteData(0x1E); 160 | SPI_WriteData(0x1E); 161 | SPI_WriteData(0x1E); 162 | SPI_WriteData(0x1E); 163 | SPI_WriteData(0x1E); 164 | SPI_WriteData(0x1E); 165 | SPI_WriteData(0x08); 166 | SPI_WriteData(0x01); 167 | SPI_WriteData(0x09); 168 | SPI_WriteData(0x0b); 169 | SPI_WriteData(0x0D); 170 | SPI_WriteData(0x0F); 171 | SPI_WriteData(0x1a); 172 | SPI_WriteData(0x19); 173 | SPI_WriteData(0x1f); 174 | SPI_WriteData(0x00); 175 | 176 | SPI_WriteComm(0x64); 177 | SPI_WriteData(0x38); 178 | SPI_WriteData(0x05); 179 | SPI_WriteData(0x01); 180 | SPI_WriteData(0xdb); 181 | SPI_WriteData(0x03); 182 | SPI_WriteData(0x03); 183 | SPI_WriteData(0x38); 184 | SPI_WriteData(0x04); 185 | SPI_WriteData(0x01); 186 | SPI_WriteData(0xdc); 187 | SPI_WriteData(0x03); 188 | SPI_WriteData(0x03); 189 | SPI_WriteData(0x7A); 190 | SPI_WriteData(0x7A); 191 | SPI_WriteData(0x7A); 192 | SPI_WriteData(0x7A); 193 | 194 | SPI_WriteComm(0x65); 195 | SPI_WriteData(0x38); 196 | SPI_WriteData(0x03); 197 | SPI_WriteData(0x01); 198 | SPI_WriteData(0xdd); 199 | SPI_WriteData(0x03); 200 | SPI_WriteData(0x03); 201 | SPI_WriteData(0x38); 202 | SPI_WriteData(0x02); 203 | SPI_WriteData(0x01); 204 | SPI_WriteData(0xde); 205 | SPI_WriteData(0x03); 206 | SPI_WriteData(0x03); 207 | SPI_WriteData(0x7A); 208 | SPI_WriteData(0x7A); 209 | SPI_WriteData(0x7A); 210 | SPI_WriteData(0x7A); 211 | 212 | SPI_WriteComm(0x66); 213 | SPI_WriteData(0x38); 214 | SPI_WriteData(0x01); 215 | SPI_WriteData(0x01); 216 | SPI_WriteData(0xdf); 217 | SPI_WriteData(0x03); 218 | SPI_WriteData(0x03); 219 | SPI_WriteData(0x38); 220 | SPI_WriteData(0x00); 221 | SPI_WriteData(0x01); 222 | SPI_WriteData(0xe0); 223 | SPI_WriteData(0x03); 224 | SPI_WriteData(0x03); 225 | SPI_WriteData(0x7A); 226 | SPI_WriteData(0x7A); 227 | SPI_WriteData(0x7A); 228 | SPI_WriteData(0x7A); 229 | 230 | SPI_WriteComm(0x67); 231 | SPI_WriteData(0x30); 232 | SPI_WriteData(0x01); 233 | SPI_WriteData(0x01); 234 | SPI_WriteData(0xe1); 235 | SPI_WriteData(0x03); 236 | SPI_WriteData(0x03); 237 | SPI_WriteData(0x30); 238 | SPI_WriteData(0x02); 239 | SPI_WriteData(0x01); 240 | SPI_WriteData(0xe2); 241 | SPI_WriteData(0x03); 242 | SPI_WriteData(0x03); 243 | SPI_WriteData(0x7A); 244 | SPI_WriteData(0x7A); 245 | SPI_WriteData(0x7A); 246 | SPI_WriteData(0x7A); 247 | 248 | SPI_WriteComm(0x68); 249 | SPI_WriteData(0x00); 250 | SPI_WriteData(0x08); 251 | SPI_WriteData(0x15); 252 | SPI_WriteData(0x08); 253 | SPI_WriteData(0x15); 254 | SPI_WriteData(0x7A); 255 | SPI_WriteData(0x7A); 256 | SPI_WriteData(0x08); 257 | SPI_WriteData(0x15); 258 | SPI_WriteData(0x08); 259 | SPI_WriteData(0x15); 260 | SPI_WriteData(0x7A); 261 | SPI_WriteData(0x7A); 262 | 263 | SPI_WriteComm(0x60); 264 | SPI_WriteData(0x38); 265 | SPI_WriteData(0x08); 266 | SPI_WriteData(0x7A); 267 | SPI_WriteData(0x7A); 268 | SPI_WriteData(0x38); 269 | SPI_WriteData(0x09); 270 | SPI_WriteData(0x7A); 271 | SPI_WriteData(0x7A); 272 | 273 | SPI_WriteComm(0x63); 274 | SPI_WriteData(0x31); 275 | SPI_WriteData(0xe4); 276 | SPI_WriteData(0x7A); 277 | SPI_WriteData(0x7A); 278 | SPI_WriteData(0x31); 279 | SPI_WriteData(0xe5); 280 | SPI_WriteData(0x7A); 281 | SPI_WriteData(0x7A); 282 | 283 | SPI_WriteComm(0x69); 284 | SPI_WriteData(0x04); 285 | SPI_WriteData(0x22); 286 | SPI_WriteData(0x14); 287 | SPI_WriteData(0x22); 288 | SPI_WriteData(0x14); 289 | SPI_WriteData(0x22); 290 | SPI_WriteData(0x08); 291 | 292 | SPI_WriteComm(0x6B); 293 | SPI_WriteData(0x07); 294 | 295 | SPI_WriteComm(0x7A); 296 | SPI_WriteData(0x08); 297 | SPI_WriteData(0x13); 298 | 299 | SPI_WriteComm(0x7B); 300 | SPI_WriteData(0x08); 301 | SPI_WriteData(0x13); 302 | 303 | SPI_WriteComm(0xD1); 304 | SPI_WriteData(0x00); 305 | SPI_WriteData(0x00); 306 | SPI_WriteData(0x00); 307 | SPI_WriteData(0x04); 308 | SPI_WriteData(0x00); 309 | SPI_WriteData(0x12); 310 | SPI_WriteData(0x00); 311 | SPI_WriteData(0x18); 312 | SPI_WriteData(0x00); 313 | SPI_WriteData(0x21); 314 | SPI_WriteData(0x00); 315 | SPI_WriteData(0x2a); 316 | SPI_WriteData(0x00); 317 | SPI_WriteData(0x35); 318 | SPI_WriteData(0x00); 319 | SPI_WriteData(0x47); 320 | SPI_WriteData(0x00); 321 | SPI_WriteData(0x56); 322 | SPI_WriteData(0x00); 323 | SPI_WriteData(0x90); 324 | SPI_WriteData(0x00); 325 | SPI_WriteData(0xe5); 326 | SPI_WriteData(0x01); 327 | SPI_WriteData(0x68); 328 | SPI_WriteData(0x01); 329 | SPI_WriteData(0xd5); 330 | SPI_WriteData(0x01); 331 | SPI_WriteData(0xd7); 332 | SPI_WriteData(0x02); 333 | SPI_WriteData(0x36); 334 | SPI_WriteData(0x02); 335 | SPI_WriteData(0xa6); 336 | SPI_WriteData(0x02); 337 | SPI_WriteData(0xee); 338 | SPI_WriteData(0x03); 339 | SPI_WriteData(0x48); 340 | SPI_WriteData(0x03); 341 | SPI_WriteData(0xa0); 342 | SPI_WriteData(0x03); 343 | SPI_WriteData(0xba); 344 | SPI_WriteData(0x03); 345 | SPI_WriteData(0xc5); 346 | SPI_WriteData(0x03); 347 | SPI_WriteData(0xd0); 348 | SPI_WriteData(0x03); 349 | SPI_WriteData(0xE0); 350 | SPI_WriteData(0x03); 351 | SPI_WriteData(0xea); 352 | SPI_WriteData(0x03); 353 | SPI_WriteData(0xFa); 354 | SPI_WriteData(0x03); 355 | SPI_WriteData(0xFF); 356 | 357 | SPI_WriteComm(0xD2); 358 | SPI_WriteData(0x00); 359 | SPI_WriteData(0x00); 360 | SPI_WriteData(0x00); 361 | SPI_WriteData(0x04); 362 | SPI_WriteData(0x00); 363 | SPI_WriteData(0x12); 364 | SPI_WriteData(0x00); 365 | SPI_WriteData(0x18); 366 | SPI_WriteData(0x00); 367 | SPI_WriteData(0x21); 368 | SPI_WriteData(0x00); 369 | SPI_WriteData(0x2a); 370 | SPI_WriteData(0x00); 371 | SPI_WriteData(0x35); 372 | SPI_WriteData(0x00); 373 | SPI_WriteData(0x47); 374 | SPI_WriteData(0x00); 375 | SPI_WriteData(0x56); 376 | SPI_WriteData(0x00); 377 | SPI_WriteData(0x90); 378 | SPI_WriteData(0x00); 379 | SPI_WriteData(0xe5); 380 | SPI_WriteData(0x01); 381 | SPI_WriteData(0x68); 382 | SPI_WriteData(0x01); 383 | SPI_WriteData(0xd5); 384 | SPI_WriteData(0x01); 385 | SPI_WriteData(0xd7); 386 | SPI_WriteData(0x02); 387 | SPI_WriteData(0x36); 388 | SPI_WriteData(0x02); 389 | SPI_WriteData(0xa6); 390 | SPI_WriteData(0x02); 391 | SPI_WriteData(0xee); 392 | SPI_WriteData(0x03); 393 | SPI_WriteData(0x48); 394 | SPI_WriteData(0x03); 395 | SPI_WriteData(0xa0); 396 | SPI_WriteData(0x03); 397 | SPI_WriteData(0xba); 398 | SPI_WriteData(0x03); 399 | SPI_WriteData(0xc5); 400 | SPI_WriteData(0x03); 401 | SPI_WriteData(0xd0); 402 | SPI_WriteData(0x03); 403 | SPI_WriteData(0xE0); 404 | SPI_WriteData(0x03); 405 | SPI_WriteData(0xea); 406 | SPI_WriteData(0x03); 407 | SPI_WriteData(0xFa); 408 | SPI_WriteData(0x03); 409 | SPI_WriteData(0xFF); 410 | 411 | SPI_WriteComm(0xD3); 412 | SPI_WriteData(0x00); 413 | SPI_WriteData(0x00); 414 | SPI_WriteData(0x00); 415 | SPI_WriteData(0x04); 416 | SPI_WriteData(0x00); 417 | SPI_WriteData(0x12); 418 | SPI_WriteData(0x00); 419 | SPI_WriteData(0x18); 420 | SPI_WriteData(0x00); 421 | SPI_WriteData(0x21); 422 | SPI_WriteData(0x00); 423 | SPI_WriteData(0x2a); 424 | SPI_WriteData(0x00); 425 | SPI_WriteData(0x35); 426 | SPI_WriteData(0x00); 427 | SPI_WriteData(0x47); 428 | SPI_WriteData(0x00); 429 | SPI_WriteData(0x56); 430 | SPI_WriteData(0x00); 431 | SPI_WriteData(0x90); 432 | SPI_WriteData(0x00); 433 | SPI_WriteData(0xe5); 434 | SPI_WriteData(0x01); 435 | SPI_WriteData(0x68); 436 | SPI_WriteData(0x01); 437 | SPI_WriteData(0xd5); 438 | SPI_WriteData(0x01); 439 | SPI_WriteData(0xd7); 440 | SPI_WriteData(0x02); 441 | SPI_WriteData(0x36); 442 | SPI_WriteData(0x02); 443 | SPI_WriteData(0xa6); 444 | SPI_WriteData(0x02); 445 | SPI_WriteData(0xee); 446 | SPI_WriteData(0x03); 447 | SPI_WriteData(0x48); 448 | SPI_WriteData(0x03); 449 | SPI_WriteData(0xa0); 450 | SPI_WriteData(0x03); 451 | SPI_WriteData(0xba); 452 | SPI_WriteData(0x03); 453 | SPI_WriteData(0xc5); 454 | SPI_WriteData(0x03); 455 | SPI_WriteData(0xd0); 456 | SPI_WriteData(0x03); 457 | SPI_WriteData(0xE0); 458 | SPI_WriteData(0x03); 459 | SPI_WriteData(0xea); 460 | SPI_WriteData(0x03); 461 | SPI_WriteData(0xFa); 462 | SPI_WriteData(0x03); 463 | SPI_WriteData(0xFF); 464 | 465 | SPI_WriteComm(0xD4); 466 | SPI_WriteData(0x00); 467 | SPI_WriteData(0x00); 468 | SPI_WriteData(0x00); 469 | SPI_WriteData(0x04); 470 | SPI_WriteData(0x00); 471 | SPI_WriteData(0x12); 472 | SPI_WriteData(0x00); 473 | SPI_WriteData(0x18); 474 | SPI_WriteData(0x00); 475 | SPI_WriteData(0x21); 476 | SPI_WriteData(0x00); 477 | SPI_WriteData(0x2a); 478 | SPI_WriteData(0x00); 479 | SPI_WriteData(0x35); 480 | SPI_WriteData(0x00); 481 | SPI_WriteData(0x47); 482 | SPI_WriteData(0x00); 483 | SPI_WriteData(0x56); 484 | SPI_WriteData(0x00); 485 | SPI_WriteData(0x90); 486 | SPI_WriteData(0x00); 487 | SPI_WriteData(0xe5); 488 | SPI_WriteData(0x01); 489 | SPI_WriteData(0x68); 490 | SPI_WriteData(0x01); 491 | SPI_WriteData(0xd5); 492 | SPI_WriteData(0x01); 493 | SPI_WriteData(0xd7); 494 | SPI_WriteData(0x02); 495 | SPI_WriteData(0x36); 496 | SPI_WriteData(0x02); 497 | SPI_WriteData(0xa6); 498 | SPI_WriteData(0x02); 499 | SPI_WriteData(0xee); 500 | SPI_WriteData(0x03); 501 | SPI_WriteData(0x48); 502 | SPI_WriteData(0x03); 503 | SPI_WriteData(0xa0); 504 | SPI_WriteData(0x03); 505 | SPI_WriteData(0xba); 506 | SPI_WriteData(0x03); 507 | SPI_WriteData(0xc5); 508 | SPI_WriteData(0x03); 509 | SPI_WriteData(0xd0); 510 | SPI_WriteData(0x03); 511 | SPI_WriteData(0xE0); 512 | SPI_WriteData(0x03); 513 | SPI_WriteData(0xea); 514 | SPI_WriteData(0x03); 515 | SPI_WriteData(0xFa); 516 | SPI_WriteData(0x03); 517 | SPI_WriteData(0xFF); 518 | 519 | SPI_WriteComm(0xD5); 520 | SPI_WriteData(0x00); 521 | SPI_WriteData(0x00); 522 | SPI_WriteData(0x00); 523 | SPI_WriteData(0x04); 524 | SPI_WriteData(0x00); 525 | SPI_WriteData(0x12); 526 | SPI_WriteData(0x00); 527 | SPI_WriteData(0x18); 528 | SPI_WriteData(0x00); 529 | SPI_WriteData(0x21); 530 | SPI_WriteData(0x00); 531 | SPI_WriteData(0x2a); 532 | SPI_WriteData(0x00); 533 | SPI_WriteData(0x35); 534 | SPI_WriteData(0x00); 535 | SPI_WriteData(0x47); 536 | SPI_WriteData(0x00); 537 | SPI_WriteData(0x56); 538 | SPI_WriteData(0x00); 539 | SPI_WriteData(0x90); 540 | SPI_WriteData(0x00); 541 | SPI_WriteData(0xe5); 542 | SPI_WriteData(0x01); 543 | SPI_WriteData(0x68); 544 | SPI_WriteData(0x01); 545 | SPI_WriteData(0xd5); 546 | SPI_WriteData(0x01); 547 | SPI_WriteData(0xd7); 548 | SPI_WriteData(0x02); 549 | SPI_WriteData(0x36); 550 | SPI_WriteData(0x02); 551 | SPI_WriteData(0xa6); 552 | SPI_WriteData(0x02); 553 | SPI_WriteData(0xee); 554 | SPI_WriteData(0x03); 555 | SPI_WriteData(0x48); 556 | SPI_WriteData(0x03); 557 | SPI_WriteData(0xa0); 558 | SPI_WriteData(0x03); 559 | SPI_WriteData(0xba); 560 | SPI_WriteData(0x03); 561 | SPI_WriteData(0xc5); 562 | SPI_WriteData(0x03); 563 | SPI_WriteData(0xd0); 564 | SPI_WriteData(0x03); 565 | SPI_WriteData(0xE0); 566 | SPI_WriteData(0x03); 567 | SPI_WriteData(0xea); 568 | SPI_WriteData(0x03); 569 | SPI_WriteData(0xFa); 570 | SPI_WriteData(0x03); 571 | SPI_WriteData(0xFF); 572 | 573 | SPI_WriteComm(0xD6); 574 | SPI_WriteData(0x00); 575 | SPI_WriteData(0x00); 576 | SPI_WriteData(0x00); 577 | SPI_WriteData(0x04); 578 | SPI_WriteData(0x00); 579 | SPI_WriteData(0x12); 580 | SPI_WriteData(0x00); 581 | SPI_WriteData(0x18); 582 | SPI_WriteData(0x00); 583 | SPI_WriteData(0x21); 584 | SPI_WriteData(0x00); 585 | SPI_WriteData(0x2a); 586 | SPI_WriteData(0x00); 587 | SPI_WriteData(0x35); 588 | SPI_WriteData(0x00); 589 | SPI_WriteData(0x47); 590 | SPI_WriteData(0x00); 591 | SPI_WriteData(0x56); 592 | SPI_WriteData(0x00); 593 | SPI_WriteData(0x90); 594 | SPI_WriteData(0x00); 595 | SPI_WriteData(0xe5); 596 | SPI_WriteData(0x01); 597 | SPI_WriteData(0x68); 598 | SPI_WriteData(0x01); 599 | SPI_WriteData(0xd5); 600 | SPI_WriteData(0x01); 601 | SPI_WriteData(0xd7); 602 | SPI_WriteData(0x02); 603 | SPI_WriteData(0x36); 604 | SPI_WriteData(0x02); 605 | SPI_WriteData(0xa6); 606 | SPI_WriteData(0x02); 607 | SPI_WriteData(0xee); 608 | SPI_WriteData(0x03); 609 | SPI_WriteData(0x48); 610 | SPI_WriteData(0x03); 611 | SPI_WriteData(0xa0); 612 | SPI_WriteData(0x03); 613 | SPI_WriteData(0xba); 614 | SPI_WriteData(0x03); 615 | SPI_WriteData(0xc5); 616 | SPI_WriteData(0x03); 617 | SPI_WriteData(0xd0); 618 | SPI_WriteData(0x03); 619 | SPI_WriteData(0xE0); 620 | SPI_WriteData(0x03); 621 | SPI_WriteData(0xea); 622 | SPI_WriteData(0x03); 623 | SPI_WriteData(0xFa); 624 | SPI_WriteData(0x03); 625 | SPI_WriteData(0xFF); 626 | 627 | SPI_WriteComm(0x3a); 628 | SPI_WriteData(0x66); 629 | 630 | SPI_WriteComm(0x11); 631 | vTaskDelay(pdMS_TO_TICKS(200)); 632 | SPI_WriteComm(0x29); 633 | } 634 | 635 | static void panelLan_rgb_spi_init() { 636 | spi_bus_config_t buscfg = { 637 | .mosi_io_num = LCD_SPI_MOSI, 638 | .miso_io_num = -1, 639 | .sclk_io_num = LCD_SPI_CLK, 640 | .quadwp_io_num = -1, 641 | .quadhd_io_num = -1, 642 | .max_transfer_sz = 10 * 1024, 643 | }; 644 | ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO)); 645 | 646 | spi_device_interface_config_t devcfg = { 647 | .mode = 0, //SPI mode 0 648 | .clock_speed_hz = SPI_MASTER_FREQ_10M, //Clock out at 10 MHz 649 | .spics_io_num = LCD_SPI_CS, //CS pin 650 | .queue_size = 7, //We want to be able to queue 7 transactions at a time 651 | }; 652 | 653 | ESP_ERROR_CHECK(spi_bus_add_device(SPI2_HOST, &devcfg, &g_screen_spi)); 654 | rgb_driver_init(); 655 | 656 | spi_bus_remove_device(g_screen_spi); 657 | spi_bus_free(SPI2_HOST); 658 | } 659 | 660 | #endif 661 | -------------------------------------------------------------------------------- /src/board/boards.cpp: -------------------------------------------------------------------------------- 1 | #include "boards.h" 2 | 3 | using namespace lgfx::v1; 4 | 5 | #ifdef CONFIG_IDF_TARGET_ESP32 6 | Panel_Device* panel_load_from_sc01(board_pins_t* pins); 7 | #elif CONFIG_IDF_TARGET_ESP32S3 8 | Panel_Device* panel_load_from_sc01_plus(board_pins_t* pins); 9 | Panel_Device* panel_load_from_sc02(board_pins_t* pins); 10 | Panel_Device* panel_load_from_sc05(board_pins_t* pins); 11 | Panel_Device* panel_load_from_sc05_plus(board_pins_t* pins); 12 | Panel_Device* panel_load_from_bc02(board_pins_t* pins); 13 | Panel_Device* panel_load_from_kc01(board_pins_t* pins); 14 | Panel_Device* panel_load_from_sc07(board_pins_t* pins); 15 | #endif 16 | 17 | PanelLan::PanelLan(panelLan_board_t board) { 18 | _board = board; 19 | setPanel(nullptr); 20 | } 21 | 22 | bool PanelLan::init_impl(bool use_reset, bool use_clear) { 23 | Panel_Device* panel = nullptr; 24 | switch (_board) { 25 | #ifdef CONFIG_IDF_TARGET_ESP32 26 | case BOARD_SC01: panel = panel_load_from_sc01(&pins); break; 27 | #elif CONFIG_IDF_TARGET_ESP32S3 28 | case BOARD_SC01_PLUS: panel = panel_load_from_sc01_plus(&pins); break; 29 | case BOARD_SC02: panel = panel_load_from_sc02(&pins); break; 30 | case BOARD_SC05: panel = panel_load_from_sc05(&pins); break; 31 | case BOARD_SC05_PLUS: panel = panel_load_from_sc05_plus(&pins); break; 32 | case BOARD_KC01: panel = panel_load_from_kc01(&pins); break; 33 | case BOARD_BC02: panel = panel_load_from_bc02(&pins); break; 34 | case BOARD_SC07: panel = panel_load_from_sc07(&pins); break; 35 | #endif 36 | default: break; 37 | } 38 | 39 | if (panel == nullptr) { 40 | assert(0); 41 | } 42 | 43 | setPanel(panel); 44 | return LGFX_Device::init_impl(false, use_clear); 45 | } 46 | -------------------------------------------------------------------------------- /src/board/boards.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum panelLan_board_t { 6 | #ifdef CONFIG_IDF_TARGET_ESP32 7 | BOARD_SC01, // 8 | #elif CONFIG_IDF_TARGET_ESP32S3 9 | BOARD_SC01_PLUS = 0x05, // ZX3D50CE08S 10 | BOARD_SC02, // ZX4D30NE01S-UR-4827 11 | BOARD_SC05, // ZX7D00CE01S 12 | BOARD_SC05_PLUS, // ZX2D80CECOF-2432 13 | BOARD_KC01, // ZX2D10GE01S 14 | BOARD_BC02, // ZX3D95CE01S 15 | BOARD_SC07, // ZX7D00CE01S 16 | #endif 17 | }; 18 | 19 | typedef struct { 20 | // BOARD BASE PIN 21 | int8_t reset; 22 | int8_t i2c_sda; 23 | int8_t i2c_scl; 24 | 25 | // TOUCH PAD PIN 26 | struct { 27 | int8_t i2c_sda, i2c_scl, i2c_int, i2c_rst; 28 | } touchPad; 29 | 30 | // I2S PIN 31 | struct { 32 | int8_t mclk, sclk, lrck, dout, din; 33 | } i2s; 34 | 35 | // SD CARD 36 | struct { 37 | int8_t clk, cmd, d0, d1, d2, d3; 38 | } sd; 39 | 40 | // UART-485 41 | struct { 42 | int8_t rts, rxd, txd; 43 | } rs485; 44 | 45 | // USB 46 | struct { 47 | int8_t dp, dn; 48 | } usb; 49 | 50 | // EXTERNAL PIN 51 | struct { 52 | int8_t pin_1, pin_2, pin_3, pin_4, pin_5, pin_6; 53 | } external; 54 | 55 | } board_pins_t; 56 | 57 | class PanelLan : public lgfx::LGFX_Device { 58 | panelLan_board_t _board; 59 | 60 | public: 61 | PanelLan(panelLan_board_t board); 62 | board_pins_t pins; 63 | bool init_impl(bool use_reset, bool use_clear); 64 | }; 65 | -------------------------------------------------------------------------------- /src/board/kc01/kc01.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../boards.h" 10 | #include "kc01_pin.h" 11 | #include "kc01_rgb_spi_init.hpp" 12 | 13 | using namespace lgfx::v1; 14 | 15 | #define PanelLan_SCREEN_WIDTH 480 16 | #define PanelLan_SCREEN_HIGHT 480 17 | 18 | #define PanelLan_SCREEN_BK_FREQ 22222 19 | 20 | #define PanelLan_RGB_CLK_FREQ (15000000) 21 | #define PanelLan_RGB_HSYNC_PULSE_WIDTH (10) 22 | #define PanelLan_RGB_HSYNC_BACK_PORCH (10) 23 | #define PanelLan_RGB_HSYNC_FRONT_PORCH (10) 24 | #define PanelLan_RGB_VSYNC_PULSE_WIDTH (2) 25 | #define PanelLan_RGB_VSYNC_BACK_PORCH (12) 26 | #define PanelLan_RGB_VSYNC_FRONT_PORCH (14) 27 | 28 | class Panel_KC01_Spec: public Panel_RGB { 29 | bool init(bool use_reset) override { 30 | if (BOARD_RESET_PIN > -1) { 31 | pinMode(BOARD_RESET_PIN, OUTPUT); 32 | digitalWrite(BOARD_RESET_PIN, 0); 33 | vTaskDelay(pdMS_TO_TICKS(2)); 34 | digitalWrite(BOARD_RESET_PIN, 1); 35 | vTaskDelay(pdMS_TO_TICKS(120)); 36 | } 37 | 38 | if (LCD_DISP_EN_GPIO > -1) { 39 | pinMode(LCD_DISP_EN_GPIO, OUTPUT); 40 | digitalWrite(LCD_DISP_EN_GPIO, 1); 41 | vTaskDelay(pdMS_TO_TICKS(10)); 42 | } 43 | 44 | panelLan_rgb_spi_init(); 45 | 46 | if (!Panel_RGB::init(false)) { 47 | return false; 48 | } 49 | 50 | return true; 51 | } 52 | }; 53 | 54 | Panel_Device* panel_load_from_kc01(board_pins_t* pins) { 55 | auto panle = new Panel_KC01_Spec(); 56 | 57 | *pins = { 58 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 59 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 60 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 61 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 62 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 63 | { USB_DP_PIN, USB_DN_PIN }, 64 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, -1, -1 } 65 | }; 66 | 67 | { 68 | auto cfg = panle->config_detail(); 69 | // cfg.use_psram = 1; 70 | panle->config_detail(cfg); 71 | } 72 | 73 | { 74 | auto _bus_instance = new Bus_RGB(); 75 | auto cfg = _bus_instance->config(); 76 | cfg.panel = panle; 77 | cfg.pin_d0 = LCD_D0_GPIO; // B0 78 | cfg.pin_d1 = LCD_D1_GPIO; // B1 79 | cfg.pin_d2 = LCD_D2_GPIO; // B2 80 | cfg.pin_d3 = LCD_D3_GPIO; // B3 81 | cfg.pin_d4 = LCD_D4_GPIO; // B4 82 | cfg.pin_d5 = LCD_D5_GPIO; // G0 83 | cfg.pin_d6 = LCD_D6_GPIO; // G1 84 | cfg.pin_d7 = LCD_D7_GPIO; // G2 85 | cfg.pin_d8 = LCD_D8_GPIO; // G3 86 | cfg.pin_d9 = LCD_D9_GPIO; // G4 87 | cfg.pin_d10 = LCD_D10_GPIO; // G5 88 | cfg.pin_d11 = LCD_D11_GPIO; // R0 89 | cfg.pin_d12 = LCD_D12_GPIO; // R1 90 | cfg.pin_d13 = LCD_D13_GPIO; // R2 91 | cfg.pin_d14 = LCD_D14_GPIO; // R3 92 | cfg.pin_d15 = LCD_D15_GPIO; // R4 93 | 94 | cfg.pin_pclk = LCD_PCLK_GPIO; 95 | cfg.pin_vsync = LCD_VSYNC_GPIO; 96 | cfg.pin_hsync = LCD_HSYNC_GPIO; 97 | cfg.pin_henable = LCD_DE_GPIO; 98 | 99 | cfg.freq_write = PanelLan_RGB_CLK_FREQ; 100 | 101 | cfg.hsync_polarity = 1; 102 | cfg.hsync_front_porch = PanelLan_RGB_HSYNC_FRONT_PORCH; 103 | cfg.hsync_pulse_width = PanelLan_RGB_HSYNC_PULSE_WIDTH; 104 | cfg.hsync_back_porch = PanelLan_RGB_HSYNC_BACK_PORCH; 105 | cfg.vsync_polarity = 1; 106 | cfg.vsync_front_porch = PanelLan_RGB_VSYNC_FRONT_PORCH; 107 | cfg.vsync_pulse_width = PanelLan_RGB_VSYNC_PULSE_WIDTH; 108 | cfg.vsync_back_porch = PanelLan_RGB_VSYNC_BACK_PORCH; 109 | cfg.pclk_active_neg = 0; 110 | _bus_instance->config(cfg); 111 | panle->setBus(_bus_instance); 112 | } 113 | 114 | { 115 | auto cfg = panle->config(); // 116 | 117 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 118 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 119 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 120 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 121 | 122 | cfg.offset_x = 0; 123 | cfg.offset_y = 0; 124 | 125 | panle->config(cfg); 126 | } 127 | 128 | { 129 | auto blk = new Light_PWM(); 130 | auto cfg = blk->config(); 131 | 132 | cfg.pin_bl = LCD_BL_PIN; 133 | cfg.invert = false; 134 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 135 | cfg.pwm_channel = 7; 136 | 137 | blk->config(cfg); 138 | panle->setLight(blk); 139 | } 140 | 141 | return panle; 142 | } 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /src/board/kc01/kc01_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (-1) 5 | #define BOARD_I2C_SDA_PIN (-1) 6 | #define BOARD_I2C_SCL_PIN (-1) 7 | 8 | #define BOARD_BTN_PIN (3) 9 | #define BOARD_MOTOR_PIN (7) 10 | #define BOARD_ENCODER_A_PIN (5) 11 | #define BOARD_ENCODER_B_PIN (6) 12 | #define BOARD_LED_PIN (4) 13 | 14 | // LCD PIN 15 | #define LCD_RST_PIN (-1) 16 | #define LCD_BL_PIN (38) 17 | #define LCD_DISP_EN_GPIO (-1) 18 | 19 | // LCD RGB SPI CONFIG PIN 20 | #define LCD_SPI_MOSI (41) 21 | #define LCD_SPI_CLK (47) 22 | #define LCD_SPI_CS (21) 23 | 24 | // LCD RGB565 DRIVER PIN 25 | #define LCD_PCLK_GPIO (45) 26 | #define LCD_VSYNC_GPIO (48) 27 | #define LCD_HSYNC_GPIO (40) 28 | #define LCD_DE_GPIO (39) 29 | 30 | #define LCD_D0_GPIO (47) // B0 31 | #define LCD_D1_GPIO (41) // B1 32 | #define LCD_D2_GPIO (0) // B2 33 | #define LCD_D3_GPIO (42) // B3 34 | #define LCD_D4_GPIO (14) // B4 35 | #define LCD_D5_GPIO (8) // G0 36 | #define LCD_D6_GPIO (13) // G1 37 | #define LCD_D7_GPIO (18) // G2 38 | #define LCD_D8_GPIO (12) // G3 39 | #define LCD_D9_GPIO (11) // G4 40 | #define LCD_D10_GPIO (17) // G5 41 | #define LCD_D11_GPIO (10) // R0 42 | #define LCD_D12_GPIO (16) // R1 43 | #define LCD_D13_GPIO (9) // R2 44 | #define LCD_D14_GPIO (15) // R3 45 | #define LCD_D15_GPIO (46) // R4 46 | 47 | // I2S PIN 48 | #define I2S_MCLK_PIN (-1) 49 | #define I2S_SCLK_PIN (-1) 50 | #define I2S_LRCK_PIN (-1) 51 | #define I2S_DOUT_PIN (-1) 52 | #define I2S_DIN_PIN (-1) 53 | 54 | // TOUCH PAD PIN 55 | #define TP_I2C_SDA_PIN (-1) 56 | #define TP_I2C_SCL_PIN (-1) 57 | #define TP_I2C_INT_PIN (-1) 58 | #define TP_I2C_RST_PIN (-1) 59 | 60 | // SD CARD 61 | #define SD_CLK_PIN (-1) // CLK 62 | #define SD_CMD_PIN (-1) // MOSI 63 | #define SD_D0_PIN (-1) // MISO 64 | #define SD_D1_PIN (-1) 65 | #define SD_D2_PIN (-1) 66 | #define SD_D3_PIN (-1) // CS 67 | 68 | // UART-485 69 | #define RS485_RTS_PIN (-1) 70 | #define RS485_RXD_PIN (-1) 71 | #define RS485_TXD_PIN (-1) 72 | 73 | // USB 74 | #define USB_DP_PIN (20) 75 | #define USB_DN_PIN (19) 76 | 77 | // EXTERNAL PIN 78 | #define EXTERNAL_PIN_1 (19) 79 | #define EXTERNAL_PIN_2 (20) 80 | #define EXTERNAL_PIN_3 (2) 81 | #define EXTERNAL_PIN_4 (1) 82 | -------------------------------------------------------------------------------- /src/board/kc01/kc01_rgb_spi_init.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include "freertos/FreeRTOS.h" 8 | #include "freertos/task.h" 9 | #include "soc/soc_caps.h" 10 | #include "driver/gpio.h" 11 | #include "driver/spi_master.h" 12 | 13 | static spi_device_handle_t g_screen_spi; 14 | 15 | static void lcd_cmd(spi_device_handle_t spi, const uint16_t data) { 16 | esp_err_t ret; 17 | uint16_t tmp_cmd = (data | 0x0000); 18 | spi_transaction_ext_t trans = (spi_transaction_ext_t){ 19 | .base = 20 | { 21 | .flags = SPI_TRANS_VARIABLE_CMD, 22 | .cmd = tmp_cmd, 23 | }, 24 | .command_bits = 9, 25 | }; 26 | ret = spi_device_transmit(spi, (spi_transaction_t*)&trans); 27 | assert(ret == ESP_OK); //Should have had no issues. 28 | } 29 | 30 | static void lcd_data(spi_device_handle_t spi, const uint16_t data) { 31 | esp_err_t ret; 32 | uint16_t tmp_cmd = (data | 0x0100); 33 | spi_transaction_ext_t trans = (spi_transaction_ext_t){ 34 | .base = 35 | { 36 | .flags = SPI_TRANS_VARIABLE_CMD, 37 | .cmd = tmp_cmd, 38 | }, 39 | .command_bits = 9, 40 | }; 41 | ret = spi_device_transmit(spi, (spi_transaction_t*)&trans); 42 | 43 | assert(ret == ESP_OK); //Should have had no issues. 44 | } 45 | 46 | static void SPI_WriteComm(uint16_t cmd) { 47 | lcd_cmd(g_screen_spi, cmd); 48 | } 49 | 50 | static void SPI_WriteData(uint16_t data) { 51 | lcd_data(g_screen_spi, data); 52 | } 53 | 54 | static void rgb_driver_init(void) { 55 | SPI_WriteComm(0xFF); 56 | SPI_WriteData(0x77); 57 | SPI_WriteData(0x01); 58 | SPI_WriteData(0x00); 59 | SPI_WriteData(0x00); 60 | SPI_WriteData(0x10); 61 | 62 | SPI_WriteComm(0xC0); 63 | SPI_WriteData(0x3B); //Scan line 64 | SPI_WriteData(0x00); 65 | 66 | SPI_WriteComm(0xC1); 67 | SPI_WriteData(0x0B); //VBP 68 | SPI_WriteData(0x02); 69 | 70 | SPI_WriteComm(0xC2); 71 | SPI_WriteData(0x07); 72 | SPI_WriteData(0x02); 73 | 74 | SPI_WriteComm(0xCC); 75 | SPI_WriteData(0x10); 76 | 77 | SPI_WriteComm(0xCD); //RGB format 78 | SPI_WriteData(0x08); 79 | 80 | SPI_WriteComm(0xB0); // IPS 81 | SPI_WriteData(0x00); // 255 82 | SPI_WriteData(0x11); // 251 83 | SPI_WriteData(0x16); // 247 down 84 | SPI_WriteData(0x0e); // 239 85 | SPI_WriteData(0x11); // 231 86 | SPI_WriteData(0x06); // 203 87 | SPI_WriteData(0x05); // 175 88 | SPI_WriteData(0x09); // 147 89 | SPI_WriteData(0x08); // 108 90 | SPI_WriteData(0x21); // 80 91 | SPI_WriteData(0x06); // 52 92 | SPI_WriteData(0x13); // 24 93 | SPI_WriteData(0x10); // 16 94 | SPI_WriteData(0x29); // 8 down 95 | SPI_WriteData(0x31); // 4 96 | SPI_WriteData(0x18); // 0 97 | 98 | SPI_WriteComm(0xB1); // IPS 99 | SPI_WriteData(0x00); // 255 100 | SPI_WriteData(0x11); // 251 101 | SPI_WriteData(0x16); // 247 down 102 | SPI_WriteData(0x0e); // 239 103 | SPI_WriteData(0x11); // 231 104 | SPI_WriteData(0x07); // 203 105 | SPI_WriteData(0x05); // 175 106 | SPI_WriteData(0x09); // 147 107 | SPI_WriteData(0x09); // 108 108 | SPI_WriteData(0x21); // 80 109 | SPI_WriteData(0x05); // 52 110 | SPI_WriteData(0x13); // 24 111 | SPI_WriteData(0x11); // 16 112 | SPI_WriteData(0x2a); // 8 down 113 | SPI_WriteData(0x31); // 4 114 | SPI_WriteData(0x18); // 0 115 | 116 | SPI_WriteComm(0xFF); 117 | SPI_WriteData(0x77); 118 | SPI_WriteData(0x01); 119 | SPI_WriteData(0x00); 120 | SPI_WriteData(0x00); 121 | SPI_WriteData(0x11); 122 | 123 | SPI_WriteComm(0xB0); //VOP 3.5375+ *x 0.0125 124 | SPI_WriteData(0x6d); //5D 125 | 126 | SPI_WriteComm(0xB1); //VCOM amplitude setting 127 | SPI_WriteData(0x37); // 128 | 129 | SPI_WriteComm(0xB2); //VGH Voltage setting 130 | SPI_WriteData(0x81); //12V 131 | 132 | SPI_WriteComm(0xB3); 133 | SPI_WriteData(0x80); 134 | 135 | SPI_WriteComm(0xB5); //VGL Voltage setting 136 | SPI_WriteData(0x43); //-8.3V 137 | 138 | SPI_WriteComm(0xB7); 139 | SPI_WriteData(0x85); 140 | 141 | SPI_WriteComm(0xB8); 142 | SPI_WriteData(0x20); 143 | 144 | SPI_WriteComm(0xC1); 145 | SPI_WriteData(0x78); 146 | 147 | SPI_WriteComm(0xC2); 148 | SPI_WriteData(0x78); 149 | 150 | SPI_WriteComm(0xD0); 151 | SPI_WriteData(0x88); 152 | 153 | SPI_WriteComm(0xE0); 154 | SPI_WriteData(0x00); 155 | SPI_WriteData(0x00); 156 | SPI_WriteData(0x02); 157 | 158 | SPI_WriteComm(0xE1); 159 | SPI_WriteData(0x03); 160 | SPI_WriteData(0xA0); 161 | SPI_WriteData(0x00); 162 | SPI_WriteData(0x00); 163 | SPI_WriteData(0x04); 164 | SPI_WriteData(0xA0); 165 | SPI_WriteData(0x00); 166 | SPI_WriteData(0x00); 167 | SPI_WriteData(0x00); 168 | SPI_WriteData(0x20); 169 | SPI_WriteData(0x20); 170 | 171 | SPI_WriteComm(0xE2); 172 | SPI_WriteData(0x00); 173 | SPI_WriteData(0x00); 174 | SPI_WriteData(0x00); 175 | SPI_WriteData(0x00); 176 | SPI_WriteData(0x00); 177 | SPI_WriteData(0x00); 178 | SPI_WriteData(0x00); 179 | SPI_WriteData(0x00); 180 | SPI_WriteData(0x00); 181 | SPI_WriteData(0x00); 182 | SPI_WriteData(0x00); 183 | SPI_WriteData(0x00); 184 | SPI_WriteData(0x00); 185 | 186 | SPI_WriteComm(0xE3); 187 | SPI_WriteData(0x00); 188 | SPI_WriteData(0x00); 189 | SPI_WriteData(0x11); 190 | SPI_WriteData(0x00); 191 | 192 | SPI_WriteComm(0xE4); 193 | SPI_WriteData(0x22); 194 | SPI_WriteData(0x00); 195 | 196 | SPI_WriteComm(0xE5); 197 | SPI_WriteData(0x05); 198 | SPI_WriteData(0xEC); 199 | SPI_WriteData(0xA0); 200 | SPI_WriteData(0xA0); 201 | SPI_WriteData(0x07); 202 | SPI_WriteData(0xEE); 203 | SPI_WriteData(0xA0); 204 | SPI_WriteData(0xA0); 205 | SPI_WriteData(0x00); 206 | SPI_WriteData(0x00); 207 | SPI_WriteData(0x00); 208 | SPI_WriteData(0x00); 209 | SPI_WriteData(0x00); 210 | SPI_WriteData(0x00); 211 | SPI_WriteData(0x00); 212 | SPI_WriteData(0x00); 213 | 214 | SPI_WriteComm(0xE6); 215 | SPI_WriteData(0x00); 216 | SPI_WriteData(0x00); 217 | SPI_WriteData(0x11); 218 | SPI_WriteData(0x00); 219 | 220 | SPI_WriteComm(0xE7); 221 | SPI_WriteData(0x22); 222 | SPI_WriteData(0x00); 223 | 224 | SPI_WriteComm(0xE8); 225 | SPI_WriteData(0x06); 226 | SPI_WriteData(0xED); 227 | SPI_WriteData(0xA0); 228 | SPI_WriteData(0xA0); 229 | SPI_WriteData(0x08); 230 | SPI_WriteData(0xEF); 231 | SPI_WriteData(0xA0); 232 | SPI_WriteData(0xA0); 233 | SPI_WriteData(0x00); 234 | SPI_WriteData(0x00); 235 | SPI_WriteData(0x00); 236 | SPI_WriteData(0x00); 237 | SPI_WriteData(0x00); 238 | SPI_WriteData(0x00); 239 | SPI_WriteData(0x00); 240 | SPI_WriteData(0x00); 241 | 242 | SPI_WriteComm(0xEB); 243 | SPI_WriteData(0x00); 244 | SPI_WriteData(0x00); 245 | SPI_WriteData(0x40); 246 | SPI_WriteData(0x40); 247 | SPI_WriteData(0x00); 248 | SPI_WriteData(0x00); 249 | SPI_WriteData(0x00); 250 | 251 | SPI_WriteComm(0xED); 252 | SPI_WriteData(0xFF); 253 | SPI_WriteData(0xFF); 254 | SPI_WriteData(0xFF); 255 | SPI_WriteData(0xBA); 256 | SPI_WriteData(0x0A); 257 | SPI_WriteData(0xBF); 258 | SPI_WriteData(0x45); 259 | SPI_WriteData(0xFF); 260 | SPI_WriteData(0xFF); 261 | SPI_WriteData(0x54); 262 | SPI_WriteData(0xFB); 263 | SPI_WriteData(0xA0); 264 | SPI_WriteData(0xAB); 265 | SPI_WriteData(0xFF); 266 | SPI_WriteData(0xFF); 267 | SPI_WriteData(0xFF); 268 | 269 | SPI_WriteComm(0xEF); 270 | SPI_WriteData(0x10); 271 | SPI_WriteData(0x0D); 272 | SPI_WriteData(0x04); 273 | SPI_WriteData(0x08); 274 | SPI_WriteData(0x3F); 275 | SPI_WriteData(0x1F); 276 | 277 | SPI_WriteComm(0xFF); 278 | SPI_WriteData(0x77); 279 | SPI_WriteData(0x01); 280 | SPI_WriteData(0x00); 281 | SPI_WriteData(0x00); 282 | SPI_WriteData(0x13); 283 | 284 | SPI_WriteComm(0xEF); 285 | SPI_WriteData(0x08); 286 | 287 | SPI_WriteComm(0xFF); 288 | SPI_WriteData(0x77); 289 | SPI_WriteData(0x01); 290 | SPI_WriteData(0x00); 291 | SPI_WriteData(0x00); 292 | SPI_WriteData(0x00); 293 | 294 | SPI_WriteComm(0x36); 295 | SPI_WriteData(0x00); 296 | 297 | SPI_WriteComm(0x3a); 298 | SPI_WriteData(0x66); 299 | 300 | SPI_WriteComm(0x11); 301 | 302 | vTaskDelay(pdMS_TO_TICKS(120)); 303 | 304 | SPI_WriteComm(0x29); 305 | } 306 | 307 | void panelLan_rgb_spi_init() { 308 | spi_bus_config_t buscfg = { 309 | .mosi_io_num = LCD_SPI_MOSI, 310 | .miso_io_num = -1, 311 | .sclk_io_num = LCD_SPI_CLK, 312 | .quadwp_io_num = -1, 313 | .quadhd_io_num = -1, 314 | .max_transfer_sz = 10 * 1024, 315 | }; 316 | ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO)); 317 | 318 | spi_device_interface_config_t devcfg = { 319 | .mode = 0, //SPI mode 0 320 | .clock_speed_hz = SPI_MASTER_FREQ_10M, //Clock out at 10 MHz 321 | .spics_io_num = LCD_SPI_CS, //CS pin 322 | .queue_size = 7, //We want to be able to queue 7 transactions at a time 323 | }; 324 | 325 | ESP_ERROR_CHECK(spi_bus_add_device(SPI2_HOST, &devcfg, &g_screen_spi)); 326 | rgb_driver_init(); 327 | 328 | spi_bus_remove_device(g_screen_spi); 329 | spi_bus_free(SPI2_HOST); 330 | } 331 | 332 | #endif 333 | -------------------------------------------------------------------------------- /src/board/sc01/sc01.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32 4 | 5 | #include 6 | #include 7 | #include "../boards.h" 8 | #include "sc01_pin.h" 9 | 10 | using namespace lgfx::v1; 11 | 12 | #define PanelLan_SCREEN_WIDTH 320 13 | #define PanelLan_SCREEN_HIGHT 480 14 | #define PanelLan_SCREEN_BK_FREQ 12000 15 | 16 | Panel_Device* panel_load_from_sc01(board_pins_t* pins) { 17 | auto panle = new lgfx::Panel_ST7796(); 18 | 19 | *pins = { 20 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 21 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 22 | { -1, -1, -1, -1, -1 }, 23 | { -1, -1, -1, -1, -1, -1 }, 24 | { -1, -1, -1 }, 25 | { -1, -1 }, 26 | { -1, -1, -1, -1, -1, -1 } 27 | }; 28 | 29 | { 30 | auto _bus_instance = new Bus_SPI(); 31 | auto cfg = _bus_instance->config(); 32 | cfg.freq_write = 40000000; 33 | cfg.pin_sclk = LCD_CLK_PIN; 34 | cfg.pin_mosi = LCD_MOSI_PIN; 35 | cfg.pin_dc = LCD_DC_PIN; 36 | cfg.pin_miso = LCD_MISO_PIN; 37 | cfg.spi_3wire = true; 38 | _bus_instance->config(cfg); 39 | panle->setBus(_bus_instance); 40 | } 41 | 42 | { 43 | auto cfg = panle->config(); // 44 | cfg.pin_cs = LCD_CS_PIN; 45 | cfg.pin_rst = LCD_RST_PIN; 46 | cfg.readable = false; 47 | cfg.bus_shared = false; 48 | panle->config(cfg); 49 | } 50 | 51 | { 52 | auto _touch_instance = new Touch_FT5x06(); 53 | auto cfg = _touch_instance->config(); 54 | cfg.x_max = PanelLan_SCREEN_WIDTH - 1; 55 | cfg.y_max = PanelLan_SCREEN_HIGHT - 1; 56 | cfg.bus_shared = false; 57 | cfg.offset_rotation = 0; 58 | 59 | cfg.i2c_port = I2C_NUM_1; 60 | 61 | cfg.pin_int = TP_I2C_INT_PIN; 62 | cfg.pin_sda = TP_I2C_SDA_PIN; 63 | cfg.pin_scl = TP_I2C_SCL_PIN; 64 | cfg.pin_rst = TP_I2C_RST_PIN; 65 | 66 | cfg.freq = 400000; 67 | _touch_instance->config(cfg); 68 | panle->setTouch(_touch_instance); 69 | } 70 | 71 | { 72 | auto blk = new Light_PWM(); 73 | auto cfg = blk->config(); 74 | cfg.pin_bl = LCD_BL_PIN; 75 | cfg.invert = false; 76 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 77 | cfg.pwm_channel = 7; 78 | blk->config(cfg); 79 | panle->setLight(blk); 80 | } 81 | 82 | return panle; 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/board/sc01/sc01_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (-1) 5 | #define BOARD_I2C_SDA_PIN (-1) 6 | #define BOARD_I2C_SCL_PIN (-1) 7 | 8 | // LCD PIN 9 | #define LCD_BL_PIN (23) 10 | 11 | // LCD SPI PIN 12 | #define LCD_RST_PIN (22) 13 | #define LCD_CS_PIN (15) 14 | #define LCD_CLK_PIN (14) 15 | #define LCD_MOSI_PIN (13) 16 | #define LCD_MISO_PIN (-1) 17 | #define LCD_DC_PIN (21) 18 | #define LCD_TE_PIN (-1) 19 | 20 | // TOUCH PAD PIN 21 | #define TP_I2C_SDA_PIN (18) 22 | #define TP_I2C_SCL_PIN (19) 23 | #define TP_I2C_INT_PIN (39) 24 | #define TP_I2C_RST_PIN (-1) 25 | -------------------------------------------------------------------------------- /src/board/sc01_plus/sc01_plus.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include "../boards.h" 8 | #include "sc01_plus_pin.h" 9 | 10 | using namespace lgfx::v1; 11 | 12 | #define PanelLan_SCREEN_WIDTH 320 13 | #define PanelLan_SCREEN_HIGHT 480 14 | #define PanelLan_SCREEN_BK_FREQ 21111 15 | #define PanelLan_SCREEN_CLK_SPEED (40 * 1000 * 1000) 16 | 17 | class Panel_SC01PLUS_Spec: public Panel_ST7796 { 18 | protected: 19 | const uint8_t* getInitCommands(uint8_t listno) const override { 20 | static constexpr uint8_t list0[] = { 21 | 0x11, 0+CMD_INIT_DELAY, 120, // Exit sleep mode 22 | 23 | 0x36, 1, 0x48, 24 | 0x3A, 1, 0x55, 25 | 0xf0, 1, 0xc3, 26 | 0xf0, 1, 0x96, 27 | 0xb4, 1, 0x01, 28 | 0xb5, 1, 0x1e, 29 | 0xb6, 3, 0x80, 0x22, 0x3b, 30 | 0xb7, 1, 0xc6, 31 | 0xb9, 2, 0x02, 0xe0, 32 | 0xc0, 2, 0x80, 0x16, 33 | 0xc1, 1, 0x19, 34 | 0xc2, 1, 0xa7, 35 | 0xc5, 1, 0x16, 36 | 0xE8, 8, 0x40, 0x8A, 0x00, 0x00, 0x29, 0x19, 0xA5, 0x33, 37 | 0xe0, 14, 0xF0, 0x07, 0x0D, 0x04, 0x05, 0x14, 0x36, 0x54, 0x4C, 0x38, 0x13, 0x14, 0x2E, 0x34, 38 | 0xe1, 14, 0xF0, 0x10, 0x14, 0x0E, 0x0C, 0x08, 0x35, 0x44, 0x4C, 0x26, 0x10, 0x12, 0x2C, 0x32, 39 | 0xf0, 1, 0x3c, 40 | 0xf0, 1 + CMD_INIT_DELAY, 0x69, 120, 41 | 42 | 0x29, 0, 43 | 0x21, 0, 44 | 0xFF,0xFF, // end 45 | }; 46 | 47 | switch (listno) { 48 | case 0: return list0; 49 | default: return nullptr; 50 | } 51 | } 52 | }; 53 | 54 | Panel_Device* panel_load_from_sc01_plus(board_pins_t* pins) { 55 | auto panle = new Panel_SC01PLUS_Spec(); 56 | 57 | *pins = { 58 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 59 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 60 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 61 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 62 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 63 | { USB_DP_PIN, USB_DN_PIN }, 64 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, EXTERNAL_PIN_5, EXTERNAL_PIN_6 } 65 | }; 66 | 67 | { 68 | auto _bus_instance = new Bus_Parallel8(); 69 | auto cfg = _bus_instance->config(); 70 | cfg.port = 0; 71 | cfg.freq_write = PanelLan_SCREEN_CLK_SPEED; 72 | cfg.pin_wr = LCD_WR_PIN; // WR 73 | cfg.pin_rd = LCD_RD_PIN; // RD 74 | cfg.pin_rs = LCD_RS_PIN; // RS(D/C) 75 | cfg.pin_d0 = LCD_D0_PIN; // D0 76 | cfg.pin_d1 = LCD_D1_PIN; // D1 77 | cfg.pin_d2 = LCD_D2_PIN; // D2 78 | cfg.pin_d3 = LCD_D3_PIN; // D3 79 | cfg.pin_d4 = LCD_D4_PIN; // D4 80 | cfg.pin_d5 = LCD_D5_PIN; // D5 81 | cfg.pin_d6 = LCD_D6_PIN; // D6 82 | cfg.pin_d7 = LCD_D7_PIN; // D7 83 | _bus_instance->config(cfg); 84 | panle->setBus(_bus_instance); 85 | } 86 | 87 | { 88 | auto cfg = panle->config(); // 89 | 90 | cfg.pin_cs = -1; 91 | cfg.pin_rst = BOARD_RESET_PIN; 92 | cfg.pin_busy = -1; 93 | 94 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 95 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 96 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 97 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 98 | cfg.offset_x = 0; 99 | cfg.offset_y = 0; 100 | cfg.offset_rotation = 2; 101 | cfg.dummy_read_pixel = 8; 102 | cfg.dummy_read_bits = 1; 103 | cfg.readable = false; 104 | cfg.invert = true; 105 | cfg.rgb_order = false; 106 | cfg.dlen_16bit = false; 107 | cfg.bus_shared = false; 108 | panle->config(cfg); 109 | } 110 | 111 | { 112 | auto _touch_instance = new Touch_FT5x06(); 113 | auto cfg = _touch_instance->config(); 114 | cfg.x_min = 0; 115 | cfg.x_max = PanelLan_SCREEN_WIDTH; 116 | cfg.y_min = 0; 117 | cfg.y_max = PanelLan_SCREEN_HIGHT; 118 | cfg.bus_shared = false; 119 | cfg.offset_rotation = 0; 120 | 121 | cfg.i2c_port = I2C_NUM_1; 122 | 123 | cfg.pin_int = TP_I2C_INT_PIN; 124 | cfg.pin_sda = TP_I2C_SDA_PIN; 125 | cfg.pin_scl = TP_I2C_SCL_PIN; 126 | cfg.pin_rst = TP_I2C_RST_PIN; 127 | 128 | cfg.freq = 400000; 129 | _touch_instance->config(cfg); 130 | panle->setTouch(_touch_instance); 131 | } 132 | 133 | { 134 | auto blk = new Light_PWM(); 135 | auto cfg = blk->config(); 136 | 137 | cfg.pin_bl = LCD_BL_PIN; 138 | cfg.invert = false; 139 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 140 | cfg.pwm_channel = 7; 141 | 142 | blk->config(cfg); 143 | panle->setLight(blk); 144 | } 145 | 146 | return panle; 147 | } 148 | 149 | #endif -------------------------------------------------------------------------------- /src/board/sc01_plus/sc01_plus_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (4) 5 | #define BOARD_I2C_SDA_PIN (-1) 6 | #define BOARD_I2C_SCL_PIN (-1) 7 | 8 | // LCD PIN 9 | #define LCD_BL_PIN (45) 10 | 11 | // LCD 8080 PIN 12 | #define LCD_RST_PIN (-1) 13 | #define LCD_RS_PIN (0) 14 | #define LCD_CS_PIN (-1) 15 | #define LCD_TE_PIN (48) 16 | #define LCD_WR_PIN (47) 17 | #define LCD_RD_PIN (-1) 18 | 19 | #define LCD_D0_PIN (9) 20 | #define LCD_D1_PIN (46) 21 | #define LCD_D2_PIN (3) 22 | #define LCD_D3_PIN (8) 23 | #define LCD_D4_PIN (18) 24 | #define LCD_D5_PIN (17) 25 | #define LCD_D6_PIN (16) 26 | #define LCD_D7_PIN (15) 27 | 28 | // TOUCH PAD PIN 29 | #define TP_I2C_SDA_PIN (6) 30 | #define TP_I2C_SCL_PIN (5) 31 | #define TP_I2C_INT_PIN (7) 32 | #define TP_I2C_RST_PIN (-1) 33 | 34 | // I2S PIN 35 | #define I2S_MCLK_PIN (-1) 36 | #define I2S_SCLK_PIN (36) 37 | #define I2S_LRCK_PIN (35) 38 | #define I2S_DOUT_PIN (37) 39 | #define I2S_DIN_PIN (-1) 40 | 41 | // SD CARD 42 | #define SD_CLK_PIN (39) // CLK 43 | #define SD_CMD_PIN (40) // MOSI 44 | #define SD_D0_PIN (38) // MISO 45 | #define SD_D1_PIN (-1) 46 | #define SD_D2_PIN (-1) 47 | #define SD_D3_PIN (41) // CS 48 | 49 | // UART-485 50 | #define RS485_RTS_PIN (2) 51 | #define RS485_RXD_PIN (1) 52 | #define RS485_TXD_PIN (42) 53 | 54 | // USB 55 | #define USB_DP_PIN (20) 56 | #define USB_DN_PIN (19) 57 | 58 | // EXTERNAL PIN 59 | #define EXTERNAL_PIN_1 (10) 60 | #define EXTERNAL_PIN_2 (11) 61 | #define EXTERNAL_PIN_3 (12) 62 | #define EXTERNAL_PIN_4 (13) 63 | #define EXTERNAL_PIN_5 (14) 64 | #define EXTERNAL_PIN_6 (21) 65 | -------------------------------------------------------------------------------- /src/board/sc02/sc02.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include 8 | #include "../boards.h" 9 | #include "sc02_pin.h" 10 | 11 | using namespace lgfx::v1; 12 | 13 | #define PanelLan_SCREEN_WIDTH 480 14 | #define PanelLan_SCREEN_HIGHT 272 15 | 16 | #define PanelLan_SCREEN_BK_FREQ 500 17 | 18 | #define PanelLan_RGB_CLK_FREQ (11000000) 19 | #define PanelLan_RGB_HSYNC_PULSE_WIDTH (10) 20 | #define PanelLan_RGB_HSYNC_BACK_PORCH (30) 21 | #define PanelLan_RGB_HSYNC_FRONT_PORCH (20) 22 | #define PanelLan_RGB_VSYNC_PULSE_WIDTH (10) 23 | #define PanelLan_RGB_VSYNC_BACK_PORCH (30) 24 | #define PanelLan_RGB_VSYNC_FRONT_PORCH (10) 25 | 26 | Panel_Device* panel_load_from_sc02(board_pins_t* pins) { 27 | auto panle = new Panel_RGB(); 28 | 29 | *pins = { 30 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 31 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 32 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 33 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 34 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 35 | { USB_DP_PIN, USB_DN_PIN }, 36 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, -1, -1 } 37 | }; 38 | 39 | { 40 | auto cfg = panle->config_detail(); 41 | cfg.use_psram = 1; 42 | panle->config_detail(cfg); 43 | } 44 | 45 | { 46 | auto _bus_instance = new Bus_RGB(); 47 | auto cfg = _bus_instance->config(); 48 | cfg.panel = panle; 49 | cfg.pin_d0 = LCD_D0_GPIO; // B0 50 | cfg.pin_d1 = LCD_D1_GPIO; // B1 51 | cfg.pin_d2 = LCD_D2_GPIO; // B2 52 | cfg.pin_d3 = LCD_D3_GPIO; // B3 53 | cfg.pin_d4 = LCD_D4_GPIO; // B4 54 | cfg.pin_d5 = LCD_D5_GPIO; // G0 55 | cfg.pin_d6 = LCD_D6_GPIO; // G1 56 | cfg.pin_d7 = LCD_D7_GPIO; // G2 57 | cfg.pin_d8 = LCD_D8_GPIO; // G3 58 | cfg.pin_d9 = LCD_D9_GPIO; // G4 59 | cfg.pin_d10 = LCD_D10_GPIO; // G5 60 | cfg.pin_d11 = LCD_D11_GPIO; // R0 61 | cfg.pin_d12 = LCD_D12_GPIO; // R1 62 | cfg.pin_d13 = LCD_D13_GPIO; // R2 63 | cfg.pin_d14 = LCD_D14_GPIO; // R3 64 | cfg.pin_d15 = LCD_D15_GPIO; // R4 65 | 66 | cfg.pin_pclk = LCD_PCLK_GPIO; 67 | cfg.pin_vsync = LCD_VSYNC_GPIO; 68 | cfg.pin_hsync = LCD_HSYNC_GPIO; 69 | cfg.pin_henable = LCD_DE_GPIO; 70 | 71 | cfg.freq_write = PanelLan_RGB_CLK_FREQ; 72 | 73 | cfg.hsync_polarity = 1; 74 | cfg.hsync_front_porch = PanelLan_RGB_HSYNC_FRONT_PORCH; 75 | cfg.hsync_pulse_width = PanelLan_RGB_HSYNC_PULSE_WIDTH; 76 | cfg.hsync_back_porch = PanelLan_RGB_HSYNC_BACK_PORCH; 77 | cfg.vsync_polarity = 1; 78 | cfg.vsync_front_porch = PanelLan_RGB_VSYNC_FRONT_PORCH; 79 | cfg.vsync_pulse_width = PanelLan_RGB_VSYNC_PULSE_WIDTH; 80 | cfg.vsync_back_porch = PanelLan_RGB_VSYNC_BACK_PORCH; 81 | cfg.pclk_active_neg = 0; 82 | cfg.pclk_idle_high = 1; 83 | _bus_instance->config(cfg); 84 | panle->setBus(_bus_instance); 85 | } 86 | 87 | { 88 | auto cfg = panle->config(); // 89 | 90 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 91 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 92 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 93 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 94 | cfg.offset_x = 0; 95 | cfg.offset_y = 0; 96 | panle->config(cfg); 97 | } 98 | 99 | { 100 | auto blk = new Light_PWM(); 101 | auto cfg = blk->config(); 102 | 103 | cfg.pin_bl = LCD_BL_PIN; 104 | cfg.invert = true; 105 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 106 | cfg.pwm_channel = 7; 107 | 108 | blk->config(cfg); 109 | panle->setLight(blk); 110 | } 111 | 112 | if (LCD_DISP_EN_GPIO > -1) { 113 | pinMode(LCD_DISP_EN_GPIO, OUTPUT); 114 | digitalWrite(LCD_DISP_EN_GPIO, 1); 115 | } 116 | 117 | return panle; 118 | } 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /src/board/sc02/sc02_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (-1) 5 | #define BOARD_I2C_SDA_PIN (-1) 6 | #define BOARD_I2C_SCL_PIN (-1) 7 | 8 | // LCD PIN 9 | #define LCD_RST_PIN (-1) 10 | #define LCD_BL_PIN (45) 11 | #define LCD_DISP_EN_GPIO (21) 12 | 13 | // LCD RGB565 DRIVER PIN 14 | #define LCD_PCLK_GPIO (14) 15 | #define LCD_VSYNC_GPIO (48) 16 | #define LCD_HSYNC_GPIO (47) 17 | #define LCD_DE_GPIO (40) 18 | 19 | #define LCD_D0_GPIO (9) // B0 20 | #define LCD_D1_GPIO (10) // B1 21 | #define LCD_D2_GPIO (11) // B2 22 | #define LCD_D3_GPIO (12) // B3 23 | #define LCD_D4_GPIO (13) // B4 24 | #define LCD_D5_GPIO (16) // G0 25 | #define LCD_D6_GPIO (17) // G1 26 | #define LCD_D7_GPIO (18) // G2 27 | #define LCD_D8_GPIO (8) // G3 28 | #define LCD_D9_GPIO (3) // G4 29 | #define LCD_D10_GPIO (46) // G5 30 | #define LCD_D11_GPIO (42) // R0 31 | #define LCD_D12_GPIO (5) // R1 32 | #define LCD_D13_GPIO (6) // R2 33 | #define LCD_D14_GPIO (7) // R3 34 | #define LCD_D15_GPIO (15) // R4 35 | 36 | // TOUCH PAD PIN 37 | #define TP_I2C_SDA_PIN (-1) 38 | #define TP_I2C_SCL_PIN (-1) 39 | #define TP_I2C_INT_PIN (-1) 40 | #define TP_I2C_RST_PIN (-1) 41 | 42 | // I2S PIN 43 | #define I2S_MCLK_PIN (-1) 44 | #define I2S_SCLK_PIN (-1) 45 | #define I2S_LRCK_PIN (-1) 46 | #define I2S_DOUT_PIN (-1) 47 | #define I2S_DIN_PIN (-1) 48 | 49 | // SD CARD 50 | #define SD_CLK_PIN (-1) // CLK 51 | #define SD_CMD_PIN (-1) // MOSI 52 | #define SD_D0_PIN (-1) // MISO 53 | #define SD_D1_PIN (-1) 54 | #define SD_D2_PIN (-1) 55 | #define SD_D3_PIN (-1) // CS 56 | 57 | // UART-485 58 | #define RS485_RTS_PIN (38) 59 | #define RS485_RXD_PIN (39) 60 | #define RS485_TXD_PIN (0) 61 | 62 | // USB 63 | #define USB_DP_PIN (20) 64 | #define USB_DN_PIN (19) 65 | 66 | // EXTERNAL PIN 67 | #define EXTERNAL_PIN_1 (41) 68 | #define EXTERNAL_PIN_2 (4) 69 | #define EXTERNAL_PIN_3 (1) 70 | #define EXTERNAL_PIN_4 (2) 71 | -------------------------------------------------------------------------------- /src/board/sc05/sc05.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "../boards.h" 10 | #include "sc05_pin.h" 11 | 12 | using namespace lgfx::v1; 13 | 14 | #define PanelLan_SCREEN_WIDTH 800 15 | #define PanelLan_SCREEN_HIGHT 480 16 | 17 | #define PanelLan_SCREEN_BK_FREQ 22222 18 | 19 | #define PanelLan_RGB_CLK_FREQ (20000000) 20 | #define PanelLan_RGB_HSYNC_PULSE_WIDTH (1) 21 | #define PanelLan_RGB_HSYNC_BACK_PORCH (87) 22 | #define PanelLan_RGB_HSYNC_FRONT_PORCH (20) 23 | #define PanelLan_RGB_VSYNC_PULSE_WIDTH (1) 24 | #define PanelLan_RGB_VSYNC_BACK_PORCH (31) 25 | #define PanelLan_RGB_VSYNC_FRONT_PORCH (5) 26 | 27 | Panel_Device* panel_load_from_sc05(board_pins_t* pins) { 28 | auto panle = new Panel_RGB(); 29 | 30 | *pins = { 31 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 32 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 33 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 34 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 35 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 36 | { USB_DP_PIN, USB_DN_PIN }, 37 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, -1, -1 } 38 | }; 39 | 40 | { 41 | auto cfg = panle->config_detail(); 42 | // cfg.use_psram = 1; 43 | panle->config_detail(cfg); 44 | } 45 | 46 | { 47 | auto _bus_instance = new Bus_RGB(); 48 | auto cfg = _bus_instance->config(); 49 | cfg.panel = panle; 50 | cfg.pin_d0 = LCD_D0_GPIO; // B0 51 | cfg.pin_d1 = LCD_D1_GPIO; // B1 52 | cfg.pin_d2 = LCD_D2_GPIO; // B2 53 | cfg.pin_d3 = LCD_D3_GPIO; // B3 54 | cfg.pin_d4 = LCD_D4_GPIO; // B4 55 | cfg.pin_d5 = LCD_D5_GPIO; // G0 56 | cfg.pin_d6 = LCD_D6_GPIO; // G1 57 | cfg.pin_d7 = LCD_D7_GPIO; // G2 58 | cfg.pin_d8 = LCD_D8_GPIO; // G3 59 | cfg.pin_d9 = LCD_D9_GPIO; // G4 60 | cfg.pin_d10 = LCD_D10_GPIO; // G5 61 | cfg.pin_d11 = LCD_D11_GPIO; // R0 62 | cfg.pin_d12 = LCD_D12_GPIO; // R1 63 | cfg.pin_d13 = LCD_D13_GPIO; // R2 64 | cfg.pin_d14 = LCD_D14_GPIO; // R3 65 | cfg.pin_d15 = LCD_D15_GPIO; // R4 66 | 67 | cfg.pin_pclk = LCD_PCLK_GPIO; 68 | cfg.pin_vsync = LCD_VSYNC_GPIO; 69 | cfg.pin_hsync = LCD_HSYNC_GPIO; 70 | cfg.pin_henable = LCD_DE_GPIO; 71 | 72 | cfg.freq_write = PanelLan_RGB_CLK_FREQ; 73 | 74 | cfg.hsync_polarity = 1; 75 | cfg.hsync_front_porch = PanelLan_RGB_HSYNC_FRONT_PORCH; 76 | cfg.hsync_pulse_width = PanelLan_RGB_HSYNC_PULSE_WIDTH; 77 | cfg.hsync_back_porch = PanelLan_RGB_HSYNC_BACK_PORCH; 78 | cfg.vsync_polarity = 1; 79 | cfg.vsync_front_porch = PanelLan_RGB_VSYNC_FRONT_PORCH; 80 | cfg.vsync_pulse_width = PanelLan_RGB_VSYNC_PULSE_WIDTH; 81 | cfg.vsync_back_porch = PanelLan_RGB_VSYNC_BACK_PORCH; 82 | cfg.pclk_active_neg = 0; 83 | _bus_instance->config(cfg); 84 | panle->setBus(_bus_instance); 85 | } 86 | 87 | { 88 | auto cfg = panle->config(); // 89 | 90 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 91 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 92 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 93 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 94 | 95 | cfg.offset_x = 0; 96 | cfg.offset_y = 0; 97 | 98 | panle->config(cfg); 99 | } 100 | 101 | { 102 | auto _touch_instance = new Touch_GT911(); 103 | auto cfg = _touch_instance->config(); 104 | cfg.i2c_addr = 0x5d; 105 | cfg.x_min = 0; 106 | cfg.x_max = PanelLan_SCREEN_WIDTH; 107 | cfg.y_min = 0; 108 | cfg.y_max = PanelLan_SCREEN_HIGHT; 109 | cfg.bus_shared = false; 110 | cfg.offset_rotation = 0; 111 | 112 | cfg.i2c_port = I2C_NUM_1; 113 | 114 | cfg.pin_int = TP_I2C_INT_PIN; 115 | cfg.pin_sda = TP_I2C_SDA_PIN; 116 | cfg.pin_scl = TP_I2C_SCL_PIN; 117 | cfg.pin_rst = TP_I2C_RST_PIN; 118 | 119 | cfg.freq = 400000; 120 | _touch_instance->config(cfg); 121 | panle->setTouch(_touch_instance); 122 | } 123 | 124 | { 125 | auto blk = new Light_PWM(); 126 | auto cfg = blk->config(); 127 | 128 | cfg.pin_bl = LCD_BL_PIN; 129 | cfg.invert = false; 130 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 131 | cfg.pwm_channel = 7; 132 | 133 | blk->config(cfg); 134 | panle->setLight(blk); 135 | } 136 | 137 | if (LCD_DISP_EN_GPIO > -1) { 138 | pinMode(LCD_DISP_EN_GPIO, OUTPUT); 139 | digitalWrite(LCD_DISP_EN_GPIO, 1); 140 | } 141 | 142 | return panle; 143 | } 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /src/board/sc05/sc05_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (-1) 5 | #define BOARD_I2C_SDA_PIN (48) 6 | #define BOARD_I2C_SCL_PIN (47) 7 | 8 | // LCD PIN 9 | #define LCD_RST_PIN (-1) 10 | #define LCD_BL_PIN (45) 11 | #define LCD_DISP_EN_GPIO (-1) 12 | 13 | // LCD RGB SPI CONFIG PIN 14 | #define LCD_SPI_MOSI (-1) 15 | #define LCD_SPI_CLK (-1) 16 | #define LCD_SPI_CS (-1) 17 | 18 | // LCD RGB565 DRIVER PIN 19 | #define LCD_PCLK_GPIO (9) 20 | #define LCD_VSYNC_GPIO (38) 21 | #define LCD_HSYNC_GPIO (5) 22 | #define LCD_DE_GPIO (39) 23 | 24 | #define LCD_D0_GPIO (17) // B0 25 | #define LCD_D1_GPIO (16) // B1 26 | #define LCD_D2_GPIO (15) // B2 27 | #define LCD_D3_GPIO (7) // B3 28 | #define LCD_D4_GPIO (6) // B4 29 | #define LCD_D5_GPIO (21) // G0 30 | #define LCD_D6_GPIO (0) // G1 31 | #define LCD_D7_GPIO (46) // G2 32 | #define LCD_D8_GPIO (3) // G3 33 | #define LCD_D9_GPIO (8) // G4 34 | #define LCD_D10_GPIO (18) // G5 35 | #define LCD_D11_GPIO (10) // R0 36 | #define LCD_D12_GPIO (11) // R1 37 | #define LCD_D13_GPIO (12) // R2 38 | #define LCD_D14_GPIO (13) // R3 39 | #define LCD_D15_GPIO (14) // R4 40 | 41 | // TOUCH PAD PIN 42 | #define TP_I2C_SDA_PIN (BOARD_I2C_SDA_PIN) 43 | #define TP_I2C_SCL_PIN (BOARD_I2C_SCL_PIN) 44 | #define TP_I2C_INT_PIN (-1) 45 | #define TP_I2C_RST_PIN (-1) 46 | 47 | // I2S PIN 48 | #define I2S_MCLK_PIN (-1) 49 | #define I2S_SCLK_PIN (-1) 50 | #define I2S_LRCK_PIN (-1) 51 | #define I2S_DOUT_PIN (-1) 52 | #define I2S_DIN_PIN (-1) 53 | 54 | // SD CARD 55 | #define SD_CLK_PIN (-1) // CLK 56 | #define SD_CMD_PIN (-1) // MOSI 57 | #define SD_D0_PIN (-1) // MISO 58 | #define SD_D1_PIN (-1) 59 | #define SD_D2_PIN (-1) 60 | #define SD_D3_PIN (-1) // CS 61 | 62 | // UART-485 63 | #define RS485_RTS_PIN (-1) 64 | #define RS485_RXD_PIN (-1) 65 | #define RS485_TXD_PIN (-1) 66 | 67 | // USB 68 | #define USB_DP_PIN (20) 69 | #define USB_DN_PIN (19) 70 | 71 | // EXTERNAL PIN 72 | #define EXTERNAL_PIN_0 (20) 73 | #define EXTERNAL_PIN_1 (19) 74 | #define EXTERNAL_PIN_2 (41) 75 | #define EXTERNAL_PIN_3 (40) 76 | #define EXTERNAL_PIN_4 (4) 77 | #define EXTERNAL_PIN_5 (42) 78 | #define EXTERNAL_PIN_6 (1) 79 | #define EXTERNAL_PIN_7 (2) 80 | -------------------------------------------------------------------------------- /src/board/sc05_plus/sc05_plus.cpp: -------------------------------------------------------------------------------- 1 | #include "sdkconfig.h" 2 | 3 | #ifdef CONFIG_IDF_TARGET_ESP32S3 4 | 5 | #include 6 | #include 7 | #include "../boards.h" 8 | #include "sc05_plus_pin.h" 9 | 10 | using namespace lgfx::v1; 11 | 12 | #define PanelLan_SCREEN_WIDTH 240 13 | #define PanelLan_SCREEN_HIGHT 320 14 | #define PanelLan_SCREEN_BK_FREQ 21111 15 | #define PanelLan_SCREEN_CLK_SPEED (20 * 1000 * 1000) 16 | 17 | class Panel_SC05PLUS_Spec: public Panel_ST7789 { 18 | protected: 19 | const uint8_t* getInitCommands(uint8_t listno) const override { 20 | static constexpr uint8_t list0[] = { 21 | 0x11, 0+CMD_INIT_DELAY, 120, // Exit sleep mode 22 | 0x36, 1, 0x00, 23 | 0x3A, 1, 0x05, 24 | 0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33, 25 | 0xB7, 1, 0x46, 26 | 0xBB, 1, 0x1B, 27 | 0xC0, 1, 0x2C, 28 | 0xC2, 1, 0x01, 29 | 0xC3, 1, 0x0F, 30 | 0xC4, 1, 0x20, 31 | 0xC6, 1, 0x0F, 32 | 0xD0, 2, 0xA4, 0xA1, 33 | 0xD6, 1, 0xA1, 34 | 0xE0, 14, 0xF0, 0x00, 0x06, 0x04, 0x05, 0x05, 0x31, 0x44, 0x48, 0x36, 0x12, 0x12, 0x2B, 0x34, 35 | 0xE1, 14, 0xF0, 0x0B, 0x0F, 0x0F, 0x0D, 0x26, 0x31, 0x43, 0x47, 0x38, 0x14, 0x14, 0x2C, 0x32, 36 | 0x21, 0, 37 | 0x29, 0, 38 | 0x2C, 0, 39 | 0xFF,0xFF, // end 40 | }; 41 | 42 | switch (listno) { 43 | case 0: return list0; 44 | default: return nullptr; 45 | } 46 | } 47 | }; 48 | 49 | class Touch_GT911_Spec : public ITouch { 50 | 51 | public: 52 | bool init(void) { 53 | lgfx::i2c::init(_cfg.i2c_port, _cfg.pin_sda, _cfg.pin_scl); 54 | if (_cfg.pin_int >= 0) { 55 | lgfx::lgfxPinMode(_cfg.pin_int, pin_mode_t::input); 56 | } 57 | return true; 58 | } 59 | 60 | void wakeup(void) { 61 | 62 | } 63 | 64 | void sleep(void) { 65 | 66 | } 67 | 68 | uint_fast8_t getTouchRaw(touch_point_t *tp, uint_fast8_t count) override { 69 | if ((_cfg.pin_int < 0 || !gpio_in(_cfg.pin_int))) { 70 | if (this->_update_data()) { 71 | tp->x = ((_readdata[1] & 0x0f) << 8) | _readdata[0]; 72 | tp->y = ((_readdata[3] & 0x0f) << 8) | _readdata[2]; 73 | return 1; 74 | } 75 | } 76 | return 0; 77 | } 78 | 79 | private: 80 | enum 81 | { 82 | max_touch_points = 1 83 | }; 84 | uint8_t _readdata[max_touch_points * 8 + 2]; // 5point * 8byte + 2byte 85 | 86 | bool _writeBytes(const uint8_t* data, size_t len) { 87 | return lgfx::i2c::transactionWrite(_cfg.i2c_port, _cfg.i2c_addr, data, len, _cfg.freq).has_value(); 88 | } 89 | 90 | bool _writeReadBytes(const uint8_t* write_data, size_t write_len, uint8_t* read_data, size_t read_len) { 91 | return lgfx::i2c::transactionWriteRead(_cfg.i2c_port, _cfg.i2c_addr, write_data, write_len, read_data, read_len, _cfg.freq).has_value(); 92 | } 93 | 94 | bool _update_data(void) { 95 | uint8_t gt911cmd_getdata[] = { 0x81, 0x4E, 0x00 }; 96 | _writeReadBytes(gt911cmd_getdata, 2, &_readdata[0], 1); 97 | if ((_readdata[0] & 0x80) || (_readdata[0] & 0x0f)) { 98 | _writeBytes(gt911cmd_getdata, 3); 99 | } 100 | 101 | if ((_readdata[0] & 0x0f) == 0) { 102 | return false; 103 | } 104 | 105 | uint8_t gt911cmd_getpoint[] = { 0x81, 0x50, 0x00 }; 106 | _writeReadBytes(gt911cmd_getpoint, 2, &_readdata[0], 4); 107 | return true; 108 | } 109 | }; 110 | 111 | 112 | Panel_Device* panel_load_from_sc05_plus(board_pins_t* pins) { 113 | pinMode(BOARD_RESET_PIN, lgfx::pin_mode_t::output); 114 | pinMode(TP_I2C_INT_PIN, lgfx::pin_mode_t::output); 115 | gpio_lo(BOARD_RESET_PIN); 116 | gpio_lo(TP_I2C_INT_PIN); 117 | lgfx::delay(2); 118 | gpio_hi(BOARD_RESET_PIN); 119 | lgfx::delay(50); 120 | pinMode(TP_I2C_INT_PIN, lgfx::pin_mode_t::input); 121 | 122 | auto panle = new Panel_SC05PLUS_Spec(); 123 | 124 | *pins = { 125 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 126 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 127 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 128 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 129 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 130 | { USB_DP_PIN, USB_DN_PIN }, 131 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, EXTERNAL_PIN_5, EXTERNAL_PIN_6 } 132 | }; 133 | 134 | { 135 | auto _bus_instance = new Bus_Parallel8(); 136 | auto cfg = _bus_instance->config(); 137 | cfg.port = 0; 138 | cfg.freq_write = PanelLan_SCREEN_CLK_SPEED; 139 | cfg.pin_wr = LCD_WR_PIN; // WR 140 | cfg.pin_rd = LCD_RD_PIN; // RD 141 | cfg.pin_rs = LCD_RS_PIN; // RS(D/C) 142 | cfg.pin_d0 = LCD_D0_PIN; // D0 143 | cfg.pin_d1 = LCD_D1_PIN; // D1 144 | cfg.pin_d2 = LCD_D2_PIN; // D2 145 | cfg.pin_d3 = LCD_D3_PIN; // D3 146 | cfg.pin_d4 = LCD_D4_PIN; // D4 147 | cfg.pin_d5 = LCD_D5_PIN; // D5 148 | cfg.pin_d6 = LCD_D6_PIN; // D6 149 | cfg.pin_d7 = LCD_D7_PIN; // D7 150 | _bus_instance->config(cfg); 151 | panle->setBus(_bus_instance); 152 | } 153 | 154 | { 155 | auto cfg = panle->config(); // 156 | 157 | cfg.pin_cs = -1; 158 | cfg.pin_rst = -1; 159 | cfg.pin_busy = -1; 160 | 161 | cfg.memory_width = PanelLan_SCREEN_WIDTH; 162 | cfg.memory_height = PanelLan_SCREEN_HIGHT; 163 | cfg.panel_width = PanelLan_SCREEN_WIDTH; 164 | cfg.panel_height = PanelLan_SCREEN_HIGHT; 165 | cfg.offset_x = 0; 166 | cfg.offset_y = 0; 167 | cfg.offset_rotation = 2; 168 | cfg.dummy_read_pixel = 8; 169 | cfg.dummy_read_bits = 1; 170 | cfg.readable = false; 171 | cfg.invert = true; 172 | cfg.rgb_order = false; 173 | cfg.dlen_16bit = false; 174 | cfg.bus_shared = false; 175 | panle->config(cfg); 176 | } 177 | 178 | { 179 | auto _touch_instance = new Touch_GT911_Spec(); 180 | auto cfg = _touch_instance->config(); 181 | cfg.x_min = 0; 182 | cfg.x_max = PanelLan_SCREEN_WIDTH; 183 | cfg.y_min = 0; 184 | cfg.y_max = PanelLan_SCREEN_HIGHT; 185 | cfg.bus_shared = true; 186 | cfg.offset_rotation = 0; 187 | cfg.i2c_port = I2C_NUM_1; 188 | cfg.pin_int = TP_I2C_INT_PIN; 189 | cfg.pin_sda = TP_I2C_SDA_PIN; 190 | cfg.pin_scl = TP_I2C_SCL_PIN; 191 | cfg.pin_rst = TP_I2C_RST_PIN; 192 | cfg.i2c_addr = 0x5d; 193 | cfg.freq = 400000; 194 | _touch_instance->config(cfg); 195 | panle->setTouch(_touch_instance); 196 | } 197 | 198 | { 199 | auto blk = new Light_PWM(); 200 | auto cfg = blk->config(); 201 | 202 | cfg.pin_bl = LCD_BL_PIN; 203 | cfg.invert = false; 204 | cfg.freq = PanelLan_SCREEN_BK_FREQ; 205 | cfg.pwm_channel = 7; 206 | 207 | blk->config(cfg); 208 | panle->setLight(blk); 209 | } 210 | 211 | return panle; 212 | } 213 | 214 | #endif -------------------------------------------------------------------------------- /src/board/sc05_plus/sc05_plus_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (13) 5 | #define BOARD_I2C_SDA_PIN (18) 6 | #define BOARD_I2C_SCL_PIN (17) 7 | 8 | // LCD PIN 9 | #define LCD_BL_PIN (46) 10 | 11 | // LCD 8080 PIN 12 | #define LCD_RST_PIN (-1) 13 | #define LCD_RS_PIN (45) 14 | #define LCD_CS_PIN (-1) 15 | #define LCD_TE_PIN (42) 16 | #define LCD_WR_PIN (41) 17 | #define LCD_RD_PIN (-1) 18 | 19 | #define LCD_D0_PIN (48) 20 | #define LCD_D1_PIN (47) 21 | #define LCD_D2_PIN (12) 22 | #define LCD_D3_PIN (11) 23 | #define LCD_D4_PIN (10) 24 | #define LCD_D5_PIN (38) 25 | #define LCD_D6_PIN (39) 26 | #define LCD_D7_PIN (40) 27 | 28 | // TOUCH PAD PIN 29 | #define TP_I2C_SDA_PIN (BOARD_I2C_SDA_PIN) 30 | #define TP_I2C_SCL_PIN (BOARD_I2C_SCL_PIN) 31 | #define TP_I2C_INT_PIN (21) 32 | #define TP_I2C_RST_PIN (-1) 33 | 34 | // I2S PIN 35 | #define I2S_MCLK_PIN (-1) 36 | #define I2S_SCLK_PIN (-1) 37 | #define I2S_LRCK_PIN (-1) 38 | #define I2S_DOUT_PIN (-1) 39 | #define I2S_DIN_PIN (-1) 40 | 41 | // SD CARD 42 | #define SD_CLK_PIN (-1) // CLK 43 | #define SD_CMD_PIN (-1) // MOSI 44 | #define SD_D0_PIN (-1) // MISO 45 | #define SD_D1_PIN (-1) 46 | #define SD_D2_PIN (-1) 47 | #define SD_D3_PIN (-1) // CS 48 | 49 | // USB 50 | #define USB_DP_PIN (19) 51 | #define USB_DN_PIN (20) 52 | 53 | // EXTERNAL PIN 54 | #define EXTERNAL_PIN_1 (2) 55 | #define EXTERNAL_PIN_2 (3) 56 | #define EXTERNAL_PIN_3 (4) 57 | #define EXTERNAL_PIN_4 (5) 58 | #define EXTERNAL_PIN_5 (6) 59 | #define EXTERNAL_PIN_6 (7) 60 | #define EXTERNAL_PIN_7 (8) 61 | #define EXTERNAL_PIN_8 (9) 62 | #define EXTERNAL_PIN_9 (USB_DP_PIN) 63 | #define EXTERNAL_PIN_10 (USB_DN_PIN) 64 | 65 | // UART-485 66 | #define RS485_RTS_PIN (EXTERNAL_PIN_1) 67 | #define RS485_RXD_PIN (EXTERNAL_PIN_2) 68 | #define RS485_TXD_PIN (0) -------------------------------------------------------------------------------- /src/board/sc07/Panel_NV3041A.hpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | Lovyan GFX - Graphics library for embedded devices. 3 | 4 | Original Source: 5 | https://github.com/lovyan03/LovyanGFX/ 6 | 7 | Licence: 8 | [FreeBSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt) 9 | 10 | Author: 11 | [lovyan03](https://twitter.com/lovyan03) 12 | 13 | Contributors: 14 | [ciniml](https://github.com/ciniml) 15 | [mongonta0716](https://github.com/mongonta0716) 16 | [tobozo](https://github.com/tobozo) 17 | /----------------------------------------------------------------------------*/ 18 | #pragma once 19 | 20 | // #include "Panel_LCD.hpp" 21 | #include 22 | 23 | namespace lgfx 24 | { 25 | inline namespace v1 26 | { 27 | //---------------------------------------------------------------------------- 28 | 29 | struct Panel_NV3041A : public Panel_LCD 30 | { 31 | Panel_NV3041A(void) 32 | { 33 | _cfg.panel_width = _cfg.memory_width = 480; 34 | _cfg.panel_height = _cfg.memory_height = 272; 35 | 36 | _cfg.dummy_read_pixel = 16; 37 | } 38 | 39 | protected: 40 | 41 | static constexpr uint8_t CMD_FRMCTR1 = 0xB1; 42 | static constexpr uint8_t CMD_FRMCTR2 = 0xB2; 43 | static constexpr uint8_t CMD_FRMCTR3 = 0xB3; 44 | static constexpr uint8_t CMD_INVCTR = 0xB4; 45 | static constexpr uint8_t CMD_DFUNCTR = 0xB6; 46 | static constexpr uint8_t CMD_ETMOD = 0xB7; 47 | static constexpr uint8_t CMD_PWCTR1 = 0xC0; 48 | static constexpr uint8_t CMD_PWCTR2 = 0xC1; 49 | static constexpr uint8_t CMD_PWCTR3 = 0xC2; 50 | static constexpr uint8_t CMD_PWCTR4 = 0xC3; 51 | static constexpr uint8_t CMD_PWCTR5 = 0xC4; 52 | static constexpr uint8_t CMD_VMCTR = 0xC5; 53 | static constexpr uint8_t CMD_GMCTRP1 = 0xE0; // Positive Gamma Correction 54 | static constexpr uint8_t CMD_GMCTRN1 = 0xE1; // Negative Gamma Correction 55 | static constexpr uint8_t CMD_DOCA = 0xE8; // Display Output Ctrl Adjust 56 | static constexpr uint8_t CMD_CSCON = 0xF0; // Command Set Control 57 | 58 | const uint8_t* getInitCommands(uint8_t listno) const override { 59 | static constexpr uint8_t list0[] = { 60 | CMD_CSCON, 1, 0xC3, // Enable extension command 2 partI 61 | CMD_CSCON, 1, 0x96, // Enable extension command 2 partII 62 | CMD_INVCTR, 1, 0x01, //1-dot inversion 63 | CMD_DFUNCTR, 3, 0x80, //Display Function Control //Bypass 64 | 0x22, //Source Output Scan from S1 to S960, Gate Output scan from G1 to G480, scan cycle=2 65 | 0x3B, //LCD Drive Line=8*(59+1) 66 | CMD_DOCA, 8, 0x40, 67 | 0x8A, 68 | 0x00, 69 | 0x00, 70 | 0x29, //Source eqaulizing period time= 22.5 us 71 | 0x19, //Timing for "Gate start"=25 (Tclk) 72 | 0xA5, //Timing for "Gate End"=37 (Tclk), Gate driver EQ function ON 73 | 0x33, 74 | CMD_PWCTR2, 1, 0x06, //Power control2 //VAP(GVDD)=3.85+( vcom+vcom offset), VAN(GVCL)=-3.85+( vcom+vcom offset) 75 | CMD_PWCTR3, 1, 0xA7, //Power control 3 //Source driving current level=low, Gamma driving current level=High 76 | CMD_VMCTR, 1+CMD_INIT_DELAY, 0x18, 120, //VCOM Control //VCOM=0.9 77 | CMD_GMCTRP1,14, 0xF0, 0x09, 0x0B, 0x06, 0x04, 0x15, 0x2F, 78 | 0x54, 0x42, 0x3C, 0x17, 0x14, 0x18, 0x1B, 79 | CMD_GMCTRN1,14+CMD_INIT_DELAY, 80 | 0xE0, 0x09, 0x0B, 0x06, 0x04, 0x03, 0x2B, 81 | 0x43, 0x42, 0x3B, 0x16, 0x14, 0x17, 0x1B, 82 | 120, 83 | CMD_CSCON, 1, 0x3C, //Command Set control // Disable extension command 2 partI 84 | CMD_CSCON, 1, 0x69, //Command Set control // Disable extension command 2 partII 85 | 86 | CMD_SLPOUT, 0+CMD_INIT_DELAY, 130, // Exit sleep mode 87 | CMD_IDMOFF, 0, 88 | CMD_DISPON, 0, 89 | 0xFF,0xFF, // end 90 | }; 91 | switch (listno) { 92 | case 0: return list0; 93 | default: return nullptr; 94 | } 95 | } 96 | 97 | void setColorDepth_impl(color_depth_t depth) override 98 | { 99 | _write_depth = ((int)depth & color_depth_t::bit_mask) > 16 ? rgb888_3Byte : rgb565_2Byte; 100 | _read_depth = _write_depth; // 読込時のデータは書込時と同じ並びになる; 101 | } 102 | }; 103 | 104 | //---------------------------------------------------------------------------- 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/board/sc07/Touch_CST3240.cpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | Lovyan GFX - Graphics library for embedded devices. 3 | 4 | Original Source: 5 | https://github.com/lovyan03/LovyanGFX/ 6 | 7 | Licence: 8 | [FreeBSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt) 9 | 10 | Author: 11 | [lovyan03](https://twitter.com/lovyan03) 12 | 13 | Contributors: 14 | [ciniml](https://github.com/ciniml) 15 | [mongonta0716](https://github.com/mongonta0716) 16 | [tobozo](https://github.com/tobozo) 17 | /----------------------------------------------------------------------------*/ 18 | #include "Touch_CST3240.hpp" 19 | 20 | #include 21 | #include 22 | // #include "../../internal/algorithm.h" 23 | // #include "../platforms/common.hpp" 24 | 25 | namespace lgfx 26 | { 27 | inline namespace v1 28 | { 29 | //--------------------------------------------------------------------------- 30 | 31 | static bool _I2C_Read(uint8_t Driver_addr, uint16_t Reg_addr, uint8_t *Reg_data, uint32_t Length) 32 | { 33 | Wire.beginTransmission(Driver_addr); 34 | Wire.write((uint8_t)(Reg_addr >> 8)); 35 | Wire.write((uint8_t)Reg_addr); 36 | if ( Wire.endTransmission(true)){ 37 | // printf("The I2C transmission fails. - I2C Read\r\n"); 38 | return false; 39 | } 40 | Wire.requestFrom(Driver_addr, Length); 41 | for (int i = 0; i < Length; i++) { 42 | *Reg_data++ = Wire.read(); 43 | } 44 | return true; 45 | } 46 | 47 | static bool _I2C_Write(uint8_t Driver_addr, uint16_t Reg_addr, const uint8_t *Reg_data, uint32_t Length) 48 | { 49 | Wire.beginTransmission(Driver_addr); 50 | Wire.write((uint8_t)(Reg_addr >> 8)); 51 | Wire.write((uint8_t)Reg_addr); 52 | for (int i = 0; i < Length; i++) { 53 | Wire.write(*Reg_data++); 54 | } 55 | if ( Wire.endTransmission(true)) 56 | { 57 | // printf("The I2C transmission fails. - I2C Write\r\n"); 58 | return false; 59 | } 60 | return true; 61 | } 62 | 63 | bool Touch_CST3240::init(void) 64 | { 65 | if (_inited) return true; 66 | 67 | if (isSPI()) return false; 68 | 69 | Wire.begin(_cfg.pin_sda, _cfg.pin_scl, _cfg.freq); 70 | 71 | if (_cfg.pin_rst >= 0) 72 | { 73 | lgfx::pinMode(_cfg.pin_rst, pin_mode_t::output); 74 | lgfx::gpio_lo(_cfg.pin_rst); 75 | lgfx::delay(1); 76 | lgfx::gpio_hi(_cfg.pin_rst); 77 | lgfx::delay(1); 78 | } 79 | 80 | if (_cfg.pin_int >= 0) 81 | { 82 | lgfx::lgfxPinMode(_cfg.pin_int, pin_mode_t::input); 83 | } 84 | 85 | if( _I2C_Write(_cfg.i2c_addr, 0xD109, NULL, 0) == true){ 86 | _inited = true; 87 | return true; 88 | } 89 | 90 | return false; 91 | } 92 | 93 | void Touch_CST3240::wakeup(void) 94 | { 95 | if (!_inited) return; 96 | if (_cfg.pin_int < 0) return; 97 | lgfx::gpio_hi(_cfg.pin_int); 98 | lgfx::lgfxPinMode(_cfg.pin_int, pin_mode_t::output); 99 | delay(5); 100 | lgfx::lgfxPinMode(_cfg.pin_int, pin_mode_t::input); 101 | } 102 | 103 | void Touch_CST3240::sleep(void) 104 | { 105 | if (!_inited) return; 106 | 107 | } 108 | 109 | 110 | uint_fast8_t Touch_CST3240::getTouchRaw(touch_point_t *__restrict tp, uint_fast8_t count) 111 | { 112 | if (!_inited) return 0; 113 | if (count > 5) { count = 5; } 114 | 115 | uint8_t data[7] = {0x0}; 116 | 117 | _I2C_Read(_cfg.i2c_addr, 0xD000, data, 7); 118 | 119 | uint8_t event = (data[0] & 0x04) ? 1 : 0; 120 | if (event == 0) { 121 | return 0; 122 | } 123 | 124 | uint8_t touchPoints = data[0] & 0x0F; 125 | if (count > touchPoints) { count = touchPoints; } 126 | for (size_t idx = 0; idx < count; ++idx) 127 | { 128 | tp[idx].x = (data[1] << 4) | ((data[3] >> 4) & 0x0F); 129 | tp[idx].y = (data[2] << 4) | (data[3] & 0x0F); 130 | tp[idx].size = 1; 131 | tp[idx].id = idx; 132 | // printf("%d %d \n",tp[idx].x, tp[idx].y); 133 | } 134 | 135 | uint8_t Over = 0xAB; 136 | _I2C_Write(_cfg.i2c_addr, 0xD000, &Over, 1); 137 | 138 | return count; 139 | } 140 | 141 | //---------------------------------------------------------------------------- 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/board/sc07/Touch_CST3240.hpp: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------------------------------------/ 2 | Lovyan GFX - Graphics library for embedded devices. 3 | 4 | Original Source: 5 | https://github.com/lovyan03/LovyanGFX/ 6 | 7 | Licence: 8 | [FreeBSD](https://github.com/lovyan03/LovyanGFX/blob/master/license.txt) 9 | 10 | Author: 11 | [lovyan03](https://twitter.com/lovyan03) 12 | 13 | Contributors: 14 | [ciniml](https://github.com/ciniml) 15 | [mongonta0716](https://github.com/mongonta0716) 16 | [tobozo](https://github.com/tobozo) 17 | /----------------------------------------------------------------------------*/ 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace lgfx 23 | { 24 | inline namespace v1 25 | { 26 | //---------------------------------------------------------------------------- 27 | 28 | struct Touch_CST3240 : public ITouch 29 | { 30 | Touch_CST3240(void) 31 | { 32 | _cfg.i2c_addr = 0x5a; 33 | _cfg.x_min = 0; 34 | _cfg.x_max = 2047; 35 | _cfg.y_min = 0; 36 | _cfg.y_max = 2047; 37 | } 38 | 39 | bool init(void) override; 40 | 41 | void wakeup(void) override; 42 | 43 | void sleep(void) override; 44 | 45 | uint_fast8_t getTouchRaw(touch_point_t *tp, uint_fast8_t count) override; 46 | 47 | private: 48 | enum 49 | { 50 | max_touch_points = 5 51 | }; 52 | 53 | }; 54 | 55 | //---------------------------------------------------------------------------- 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/board/sc07/sc07.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "../boards.h" 4 | #include "sc07_pin.h" 5 | #include "Panel_NV3041A.hpp" 6 | #include "Touch_CST3240.hpp" 7 | 8 | using namespace lgfx::v1; 9 | 10 | #define PANLEE_SCREEN_WIDTH 480 11 | #define PANLEE_SCREEN_HIGHT 272 12 | #define PANLEE_SCREEN_BK_FREQ 11111 13 | #define PANLEE_SCREEN_CLK_SPEED (4 * 1000 * 1000) 14 | 15 | class Panel_NV3041A_Spec: public Panel_NV3041A { 16 | protected: 17 | const uint8_t* getInitCommands(uint8_t listno) const override { 18 | static constexpr uint8_t list0[] = { 19 | 0xFF, 1, 0xA5, 20 | 0xE7, 1, 0x10, 21 | 0x35, 1, 0x01, 22 | 0x3A, 1, 0x01, 23 | 0x40, 1, 0x01, 24 | 0x41, 1, 0x01, 25 | 0x55, 1, 0x01, 26 | 0x44, 1, 0x15, 27 | 0x45, 1, 0x15, 28 | 0x7D, 1, 0x03, 29 | 0xC1, 1, 0xAB, 30 | 0xC2, 1, 0x17, 31 | 0xC3, 1, 0x10, 32 | 0xC6, 1, 0x3A, 33 | 0xC7, 1, 0x25, 34 | 0xC8, 1, 0x11, 35 | 0x7A, 1, 0x49, 36 | 0x6F, 1, 0x2F, 37 | 0x78, 1, 0x4B, 38 | 0x73, 1, 0x08, 39 | 0x74, 1, 0x12, 40 | 0xC9, 1, 0x00, 41 | 0x67, 1, 0x11, 42 | 0x51, 1, 0x20, 43 | 0x52, 1, 0x7C, 44 | 0x53, 1, 0x1C, 45 | 0x54, 1, 0x77, 46 | 0x46, 1, 0x0A, 47 | 0x47, 1, 0x2A, 48 | 0x48, 1, 0x0A, 49 | 0x49, 1, 0x1A, 50 | 0x56, 1, 0x43, 51 | 0x57, 1, 0x42, 52 | 0x58, 1, 0x3C, 53 | 0x59, 1, 0x64, 54 | 0x5A, 1, 0x41, 55 | 0x5B, 1, 0x3C, 56 | 0x5C, 1, 0x02, 57 | 0x5D, 1, 0x3C, 58 | 0x5E, 1, 0x1F, 59 | 0x60, 1, 0x80, 60 | 0x61, 1, 0x3F, 61 | 0x62, 1, 0x21, 62 | 0x63, 1, 0x07, 63 | 0x64, 1, 0xE0, 64 | 0x65, 1, 0x01, 65 | 0xCA, 1, 0x20, 66 | 0xCB, 1, 0x52, 67 | 0xCC, 1, 0x10, 68 | 0xCD, 1, 0x42, 69 | 0xD0, 1, 0x20, 70 | 0xD1, 1, 0x52, 71 | 0xD2, 1, 0x10, 72 | 0xD3, 1, 0x42, 73 | 0xD4, 1, 0x0A, 74 | 0xD5, 1, 0x32, 75 | 0xE5, 1, 0x06, 76 | 0xE6, 1, 0x00, 77 | 0x6E, 1, 0x14, 78 | 0x80, 1, 0x04, 79 | 0xA0, 1, 0x00, 80 | 0x81, 1, 0x07, 81 | 0xA1, 1, 0x05, 82 | 0x82, 1, 0x06, 83 | 0xA2, 1, 0x04, 84 | 0x83, 1, 0x39, 85 | 0xA3, 1, 0x39, 86 | 0x84, 1, 0x3A, 87 | 0xA4, 1, 0x3A, 88 | 0x85, 1, 0x3F, 89 | 0xA5, 1, 0x3F, 90 | 0x86, 1, 0x30, 91 | 0xA6, 1, 0x30, 92 | 0x87, 1, 0x3A, 93 | 0xA7, 1, 0x3A, 94 | 0x88, 1, 0x08, 95 | 0xA8, 1, 0x08, 96 | 0x89, 1, 0x0F, 97 | 0xA9, 1, 0x0F, 98 | 0x8A, 1, 0x17, 99 | 0xAA, 1, 0x17, 100 | 0x8B, 1, 0x10, 101 | 0xAB, 1, 0x10, 102 | 0x8C, 1, 0x16, 103 | 0xAC, 1, 0x16, 104 | 0x8D, 1, 0x14, 105 | 0xAD, 1, 0x14, 106 | 0x8E, 1, 0x11, 107 | 0xAE, 1, 0x11, 108 | 0x8F, 1, 0x14, 109 | 0xAF, 1, 0x14, 110 | 0x90, 1, 0x06, 111 | 0xB0, 1, 0x06, 112 | 0x91, 1, 0x0F, 113 | 0xB1, 1, 0x0F, 114 | 0x92, 1, 0x16, 115 | 0xB2, 1, 0x16, 116 | 0xFF, 1, 0x00, 117 | 0x11, 0+CMD_INIT_DELAY, 120, // Exit sleep mode 118 | 119 | 0x29, 0+CMD_INIT_DELAY, 120, 120 | 0xFF,0xFF, // end 121 | }; 122 | 123 | switch (listno) { 124 | case 0: return list0; 125 | default: return nullptr; 126 | } 127 | } 128 | }; 129 | 130 | Panel_Device* panel_load_from_sc07(board_pins_t* pins) { 131 | auto panle = new Panel_NV3041A_Spec(); 132 | 133 | *pins = { 134 | BOARD_RESET_PIN, BOARD_I2C_SDA_PIN, BOARD_I2C_SCL_PIN, 135 | { TP_I2C_SDA_PIN, TP_I2C_SCL_PIN, TP_I2C_INT_PIN, TP_I2C_RST_PIN }, 136 | { I2S_MCLK_PIN, I2S_SCLK_PIN, I2S_LRCK_PIN, I2S_DOUT_PIN, I2S_DIN_PIN }, 137 | { SD_CLK_PIN, SD_CMD_PIN, SD_D0_PIN, SD_D1_PIN, SD_D2_PIN, SD_D3_PIN }, 138 | { RS485_RTS_PIN, RS485_RXD_PIN, RS485_TXD_PIN }, 139 | { USB_DP_PIN, USB_DN_PIN }, 140 | { EXTERNAL_PIN_1, EXTERNAL_PIN_2, EXTERNAL_PIN_3, EXTERNAL_PIN_4, -1, -1 } 141 | }; 142 | 143 | { 144 | auto _bus_instance = new Bus_Parallel8(); 145 | auto cfg = _bus_instance->config(); 146 | cfg.port = 0; 147 | cfg.freq_write = PANLEE_SCREEN_CLK_SPEED; 148 | cfg.pin_wr = LCD_WR_PIN; // WR 149 | cfg.pin_rd = LCD_RD_PIN; // RD 150 | cfg.pin_rs = LCD_RS_PIN; // RS(D/C) 151 | cfg.pin_d0 = LCD_D0_PIN; // D0 152 | cfg.pin_d1 = LCD_D1_PIN; // D1 153 | cfg.pin_d2 = LCD_D2_PIN; // D2 154 | cfg.pin_d3 = LCD_D3_PIN; // D3 155 | cfg.pin_d4 = LCD_D4_PIN; // D4 156 | cfg.pin_d5 = LCD_D5_PIN; // D5 157 | cfg.pin_d6 = LCD_D6_PIN; // D6 158 | cfg.pin_d7 = LCD_D7_PIN; // D7 159 | _bus_instance->config(cfg); 160 | panle->setBus(_bus_instance); 161 | } 162 | 163 | { 164 | auto cfg = panle->config(); // 165 | 166 | cfg.pin_cs = -1; 167 | cfg.pin_rst = BOARD_RESET_PIN; 168 | cfg.pin_busy = -1; 169 | 170 | cfg.memory_width = PANLEE_SCREEN_WIDTH; 171 | cfg.memory_height = PANLEE_SCREEN_HIGHT; 172 | cfg.panel_width = PANLEE_SCREEN_WIDTH; 173 | cfg.panel_height = PANLEE_SCREEN_HIGHT; 174 | cfg.offset_x = 0; 175 | cfg.offset_y = 0; 176 | cfg.offset_rotation = 0; 177 | cfg.dummy_read_pixel = 8; 178 | cfg.dummy_read_bits = 1; 179 | cfg.readable = false; 180 | cfg.invert = false; 181 | cfg.rgb_order = true; 182 | cfg.dlen_16bit = false; 183 | cfg.bus_shared = false; 184 | panle->config(cfg); 185 | } 186 | 187 | { 188 | auto _touch_instance = new Touch_CST3240(); 189 | auto cfg = _touch_instance->config(); 190 | cfg.x_min = PANLEE_SCREEN_WIDTH; 191 | cfg.x_max = 0; 192 | cfg.y_min = PANLEE_SCREEN_HIGHT; 193 | cfg.y_max = 0; 194 | cfg.bus_shared = false; 195 | cfg.offset_rotation = 0; 196 | 197 | cfg.i2c_port = I2C_NUM_1; 198 | 199 | cfg.pin_int = TP_I2C_INT_PIN; 200 | cfg.pin_sda = TP_I2C_SDA_PIN; 201 | cfg.pin_scl = TP_I2C_SCL_PIN; 202 | cfg.pin_rst = TP_I2C_RST_PIN; 203 | 204 | cfg.freq = 400000; 205 | _touch_instance->config(cfg); 206 | panle->setTouch(_touch_instance); 207 | } 208 | 209 | { 210 | auto blk = new Light_PWM(); 211 | auto cfg = blk->config(); 212 | 213 | cfg.pin_bl = LCD_BL_PIN; 214 | cfg.invert = false; 215 | cfg.freq = PANLEE_SCREEN_BK_FREQ; 216 | cfg.pwm_channel = 7; 217 | 218 | blk->config(cfg); 219 | panle->setLight(blk); 220 | } 221 | 222 | return panle; 223 | } 224 | -------------------------------------------------------------------------------- /src/board/sc07/sc07_pin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // BOARD BASE PIN 4 | #define BOARD_RESET_PIN (38) 5 | #define BOARD_I2C_SDA_PIN (-1) 6 | #define BOARD_I2C_SCL_PIN (-1) 7 | 8 | // LCD PIN 9 | #define LCD_BL_PIN (15) 10 | 11 | // LCD 8080 PIN 12 | #define LCD_RST_PIN (-1) 13 | #define LCD_RS_PIN (47) 14 | #define LCD_CS_PIN (-1) 15 | #define LCD_TE_PIN (48) 16 | #define LCD_WR_PIN (21) 17 | #define LCD_RD_PIN (-1) 18 | 19 | #define LCD_D0_PIN (39) 20 | #define LCD_D1_PIN (40) 21 | #define LCD_D2_PIN (41) 22 | #define LCD_D3_PIN (14) 23 | #define LCD_D4_PIN (13) 24 | #define LCD_D5_PIN (12) 25 | #define LCD_D6_PIN (11) 26 | #define LCD_D7_PIN (10) 27 | 28 | // TOUCH PAD PIN 29 | #define TP_I2C_SDA_PIN (9) 30 | #define TP_I2C_SCL_PIN (3) 31 | #define TP_I2C_INT_PIN (42) 32 | #define TP_I2C_RST_PIN (-1) 33 | 34 | // I2S PIN 35 | #define I2S_MCLK_PIN (-1) 36 | #define I2S_SCLK_PIN (-1) 37 | #define I2S_LRCK_PIN (-1) 38 | #define I2S_DOUT_PIN (-1) 39 | #define I2S_DIN_PIN (-1) 40 | 41 | // SD CARD 42 | #define SD_CLK_PIN (-1) // CLK 43 | #define SD_CMD_PIN (-1) // MOSI 44 | #define SD_D0_PIN (-1) // MISO 45 | #define SD_D1_PIN (-1) 46 | #define SD_D2_PIN (-1) 47 | #define SD_D3_PIN (-1) // CS 48 | 49 | // UART-485 50 | #define RS485_RTS_PIN (46) 51 | #define RS485_RXD_PIN (17) 52 | #define RS485_TXD_PIN (16) 53 | 54 | // EXT_UART 55 | #define EXT_UART_TXD_PIN (8) 56 | #define EXT_UART_RXD_PIN (18) 57 | 58 | // USB 59 | #define USB_DP_PIN (20) 60 | #define USB_DN_PIN (19) 61 | 62 | // CAN 63 | #define CAN_TX_PIN (6) 64 | #define CAN_RX_PIN (7) 65 | 66 | // BUZZER 67 | #define BUZZER_PIN (45) 68 | 69 | // EXTERNAL PIN 70 | #define EXTERNAL_PIN_1 (1) 71 | #define EXTERNAL_PIN_2 (2) 72 | #define EXTERNAL_PIN_3 (4) 73 | #define EXTERNAL_PIN_4 (5) 74 | --------------------------------------------------------------------------------