├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── LICENSE-WASM4.txt ├── README.md ├── components └── st7789 │ ├── CMakeLists.txt │ ├── Kconfig.projbuild │ ├── LICENSE │ ├── component.mk │ ├── fontx.c │ ├── fontx.h │ ├── st7789.c │ └── st7789.h ├── main ├── CMakeLists.txt ├── apu.h ├── control.c ├── control.h ├── display.c ├── framebuffer.c ├── framebuffer.h ├── gamecard.c ├── idf_component.yml ├── lcd.h ├── main.c ├── runtime.c ├── runtime.h ├── strnlen.c ├── util.c ├── util.h ├── wamr.c ├── wamr.h ├── wasm0.h └── window.h ├── sdkconfig ├── sdkconfig.ci └── snake-mbt ├── .gitignore ├── LICENSE ├── game.mbt ├── main.mbt ├── moon.mod.json ├── moon.pkg.json └── snake.mbt /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.vscode 3 | /managed_components 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vendor/wasm-micro-runtime"] 2 | path = vendor/wasm-micro-runtime 3 | url = https://github.com/bytecodealliance/wasm-micro-runtime.git 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's 2 | # CMakeLists in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.16) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(wasm4-esp32) 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 lijunchen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | ## Third-Party Licenses 24 | 25 | This project includes code from the following third-party projects: 26 | 27 | ### WASM-4 License 28 | Copyright (c) Bruno Garcia 29 | 30 | Permission to use, copy, modify, and/or distribute this software for any 31 | purpose with or without fee is hereby granted, provided that the above 32 | copyright notice and this permission notice appear in all copies. 33 | 34 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 35 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 36 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 37 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 38 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 39 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 40 | PERFORMANCE OF THIS SOFTWARE. 41 | 42 | See `./LICENSE-WASM4.txt` for details. 43 | 44 | ### ST7789 License 45 | MIT License 46 | 47 | Copyright (c) 2020 nopnop2002 48 | 49 | Permission is hereby granted, free of charge, to any person obtaining a copy 50 | of this software and associated documentation files (the "Software"), to deal 51 | in the Software without restriction, including without limitation the rights 52 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 53 | copies of the Software, and to permit persons to whom the Software is 54 | furnished to do so, subject to the following conditions: 55 | 56 | The above copyright notice and this permission notice shall be included in all 57 | copies or substantial portions of the Software. 58 | 59 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 60 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 61 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 62 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 63 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 64 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 65 | SOFTWARE. 66 | 67 | 68 | See `./components/st7789/LICENSE` for details. 69 | 70 | ### snake-mbt LICENSE 71 | 72 | See `./snake-mbt/LICENSE` for details. 73 | -------------------------------------------------------------------------------- /LICENSE-WASM4.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Bruno Garcia 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 8 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 9 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 10 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 11 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 12 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 13 | PERFORMANCE OF THIS SOFTWARE. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MoonBit WASM-4 on ESP32 2 | 3 | ![1727189835964](https://github.com/user-attachments/assets/7b271c2b-14e0-44ce-bc88-7dc4b07546a5) 4 | 5 | GPIO should be configured according to your specific ESP32 board. 6 | 7 | ``` 8 | idf.py set-target esp32c6 9 | moon build -C ./snake-mbt --target wasm 10 | xxd -n __game_card -i ./snake-mbt/target/wasm/release/build/snake.wasm > ./main/gamecard.c 11 | idf.py flash 12 | ``` 13 | -------------------------------------------------------------------------------- /components/st7789/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(srcs "st7789.c" "fontx.c") 2 | 3 | idf_component_register(SRCS "${srcs}" 4 | PRIV_REQUIRES driver 5 | INCLUDE_DIRS ".") 6 | -------------------------------------------------------------------------------- /components/st7789/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "ST7789 Configuration" 2 | 3 | config GPIO_RANGE_MAX 4 | int 5 | default 33 if IDF_TARGET_ESP32 6 | default 46 if IDF_TARGET_ESP32S2 7 | default 48 if IDF_TARGET_ESP32S3 8 | default 18 if IDF_TARGET_ESP32C2 9 | default 19 if IDF_TARGET_ESP32C3 10 | default 30 if IDF_TARGET_ESP32C6 11 | 12 | config WIDTH 13 | int "SCREEN WIDTH" 14 | range 0 999 15 | default 240 16 | help 17 | The width resolution of the screen. 18 | 19 | config HEIGHT 20 | int "SCREEN HEIGHT" 21 | range 0 999 22 | default 240 23 | help 24 | The height resolution of the screen. 25 | 26 | config OFFSETX 27 | int "GRAM X OFFSET" 28 | range 0 99 29 | default 0 30 | help 31 | When your TFT have offset(X), set it. 32 | 33 | config OFFSETY 34 | int "GRAM Y OFFSET" 35 | range 0 99 36 | default 0 37 | help 38 | When your TFT have offset(Y), set it. 39 | 40 | config MOSI_GPIO 41 | int "MOSI GPIO number" 42 | range 0 GPIO_RANGE_MAX 43 | default 23 if IDF_TARGET_ESP32 44 | default 35 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 45 | default 0 # C3 and others 46 | help 47 | GPIO number (IOxx) to SPI MOSI. 48 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to MOSI. 49 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 50 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 51 | 52 | config SCLK_GPIO 53 | int "SCLK GPIO number" 54 | range 0 GPIO_RANGE_MAX 55 | default 18 if IDF_TARGET_ESP32 56 | default 36 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 57 | default 1 # C3 and others 58 | help 59 | GPIO number (IOxx) to SPI SCLK. 60 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to SCLK. 61 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 62 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 63 | 64 | config CS_GPIO 65 | int "CS GPIO number" 66 | range -1 GPIO_RANGE_MAX 67 | default -1 68 | help 69 | GPIO number (IOxx) to SPI CS. 70 | When it is -1, CS isn't performed. 71 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to CS. 72 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 73 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 74 | 75 | config DC_GPIO 76 | int "DC GPIO number" 77 | range 0 GPIO_RANGE_MAX 78 | default 27 if IDF_TARGET_ESP32 79 | default 37 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 80 | default 2 # C3 and others 81 | help 82 | GPIO number (IOxx) to SPI DC. 83 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to DC. 84 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 85 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 86 | 87 | config RESET_GPIO 88 | int "RESET GPIO number" 89 | range 0 GPIO_RANGE_MAX 90 | default 33 if IDF_TARGET_ESP32 91 | default 38 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 92 | default 3 # C3 and others 93 | help 94 | GPIO number (IOxx) to RESET. 95 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to RESET. 96 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 97 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 98 | 99 | config BL_GPIO 100 | int "BACKLIGHT GPIO number" 101 | range -1 GPIO_RANGE_MAX 102 | default 32 if IDF_TARGET_ESP32 103 | default 33 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 104 | default 4 # C3 and others 105 | help 106 | GPIO number (IOxx) to BACKLIGHT. 107 | When it is -1, BACKLIGHT isn't performed. 108 | Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to BACKLIGHT. 109 | On the ESP32, GPIOs 35-39 are input-only so cannot be used as outputs. 110 | On the ESP32-S2, GPIO 46 is input-only so cannot be used as outputs. 111 | 112 | config INVERSION 113 | bool "Enable Display Inversion" 114 | default false 115 | help 116 | Enable Display Inversion. 117 | 118 | choice SPI_HOST 119 | prompt "SPI peripheral that controls this bus" 120 | default SPI2_HOST 121 | help 122 | Select SPI peripheral that controls this bus. 123 | config SPI2_HOST 124 | bool "SPI2_HOST" 125 | help 126 | Use SPI2_HOST. This is also called HSPI_HOST. 127 | config SPI3_HOST 128 | depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 129 | bool "SPI3_HOST" 130 | help 131 | USE SPI3_HOST. This is also called VSPI_HOST 132 | endchoice 133 | 134 | config FRAME_BUFFER 135 | bool "Enable Frame Buffer" 136 | depends on !IDF_TARGET_ESP32C2 137 | default false 138 | help 139 | Enable Frame Buffer. 140 | 141 | endmenu 142 | -------------------------------------------------------------------------------- /components/st7789/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 nopnop2002 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /components/st7789/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | -------------------------------------------------------------------------------- /components/st7789/fontx.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "esp_err.h" 8 | #include "esp_log.h" 9 | //#include "esp_spiffs.h" 10 | 11 | #include "fontx.h" 12 | 13 | #define FontxDebug 0 // for Debug 14 | 15 | // フォントファイルパスを構造体に保存 16 | void AddFontx(FontxFile *fx, const char *path) 17 | { 18 | memset(fx, 0, sizeof(FontxFile)); 19 | fx->path = path; 20 | fx->opened = false; 21 | } 22 | 23 | // フォント構造体を初期化 24 | void InitFontx(FontxFile *fxs, const char *f0, const char *f1) 25 | { 26 | AddFontx(&fxs[0], f0); 27 | AddFontx(&fxs[1], f1); 28 | } 29 | 30 | // フォントファイルをOPEN 31 | bool OpenFontx(FontxFile *fx) 32 | { 33 | FILE *f; 34 | if(!fx->opened){ 35 | if(FontxDebug)printf("[openFont]fx->path=[%s]\n",fx->path); 36 | f = fopen(fx->path, "r"); 37 | if(FontxDebug)printf("[openFont]fopen=%p\n",f); 38 | if (f == NULL) { 39 | fx->valid = false; 40 | printf("Fontx:%s not found.\n",fx->path); 41 | return fx->valid ; 42 | } 43 | fx->opened = true; 44 | fx->file = f; 45 | char buf[18]; 46 | if (fread(buf, 1, sizeof(buf), fx->file) != sizeof(buf)) { 47 | fx->valid = false; 48 | printf("Fontx:%s not FONTX format.\n",fx->path); 49 | fclose(fx->file); 50 | return fx->valid ; 51 | } 52 | 53 | if(FontxDebug) { 54 | for(int i=0;ifxname, &buf[6], 8); 59 | fx->w = buf[14]; 60 | fx->h = buf[15]; 61 | fx->is_ank = (buf[16] == 0); 62 | fx->bc = buf[17]; 63 | fx->fsz = (fx->w + 7)/8 * fx->h; 64 | if(fx->fsz > FontxGlyphBufSize){ 65 | printf("Fontx:%s is too big font size.\n",fx->path); 66 | fx->valid = false; 67 | fclose(fx->file); 68 | return fx->valid ; 69 | } 70 | fx->valid = true; 71 | } 72 | return fx->valid; 73 | } 74 | 75 | // フォントファイルをCLOSE 76 | void CloseFontx(FontxFile *fx) 77 | { 78 | if(fx->opened){ 79 | fclose(fx->file); 80 | fx->opened = false; 81 | } 82 | } 83 | 84 | // フォント構造体の表示 85 | void DumpFontx(FontxFile *fxs) 86 | { 87 | for(int i=0;i<2;i++) { 88 | printf("fxs[%d]->path=%s\n",i,fxs[i].path); 89 | printf("fxs[%d]->opened=%d\n",i,fxs[i].opened); 90 | printf("fxs[%d]->fxname=%s\n",i,fxs[i].fxname); 91 | printf("fxs[%d]->valid=%d\n",i,fxs[i].valid); 92 | printf("fxs[%d]->is_ank=%d\n",i,fxs[i].is_ank); 93 | printf("fxs[%d]->w=%d\n",i,fxs[i].w); 94 | printf("fxs[%d]->h=%d\n",i,fxs[i].h); 95 | printf("fxs[%d]->fsz=%d\n",i,fxs[i].fsz); 96 | printf("fxs[%d]->bc=%d\n",i,fxs[i].bc); 97 | } 98 | } 99 | 100 | uint8_t getFortWidth(FontxFile *fx) { 101 | printf("fx->w=%d\n",fx->w); 102 | return(fx->w); 103 | } 104 | 105 | uint8_t getFortHeight(FontxFile *fx) { 106 | printf("fx->h=%d\n",fx->h); 107 | return(fx->h); 108 | } 109 | 110 | 111 | /* 112 | フォントファイルからフォントパターンを取り出す 113 | 114 | フォントの並び(16X16ドット) 115 | 00000000 01111111 116 | 12345678 90123456 117 | 01 pGlyph[000] pGlyph[001] 118 | 02 pGlyph[002] pGlyph[003] 119 | 03 pGlyph[004] pGlyph[005] 120 | 04 pGlyph[006] pGlyph[007] 121 | 05 pGlyph[008] pGlyph[009] 122 | 06 pGlyph[010] pGlyph[011] 123 | 07 pGlyph[012] pGlyph[013] 124 | 08 pGlyph[014] pGlyph[015] 125 | 09 pGlyph[016] pGlyph[017] 126 | 10 pGlyph[018] pGlyph[019] 127 | 11 pGlyph[020] pGlyph[021] 128 | 12 pGlyph[022] pGlyph[023] 129 | 13 pGlyph[024] pGlyph[025] 130 | 14 pGlyph[026] pGlyph[027] 131 | 15 pGlyph[028] pGlyph[029] 132 | 16 pGlyph[030] pGlyph[031] 133 | 134 | フォントの並び(24X24ドット) 135 | 00000000 01111111 11122222 136 | 12345678 90123456 78901234 137 | 01 pGlyph[000] pGlyph[001] pGlyph[002] 138 | 02 pGlyph[003] pGlyph[004] pGlyph[005] 139 | 03 pGlyph[006] pGlyph[007] pGlyph[008] 140 | 04 pGlyph[009] pGlyph[010] pGlyph[011] 141 | 05 pGlyph[012] pGlyph[013] pGlyph[014] 142 | 06 pGlyph[015] pGlyph[016] pGlyph[017] 143 | 07 pGlyph[018] pGlyph[019] pGlyph[020] 144 | 08 pGlyph[021] pGlyph[022] pGlyph[023] 145 | 09 pGlyph[024] pGlyph[025] pGlyph[026] 146 | 10 pGlyph[027] pGlyph[028] pGlyph[029] 147 | 11 pGlyph[030] pGlyph[031] pGlyph[032] 148 | 12 pGlyph[033] pGlyph[034] pGlyph[035] 149 | 13 pGlyph[036] pGlyph[037] pGlyph[038] 150 | 14 pGlyph[039] pGlyph[040] pGlyph[041] 151 | 15 pGlyph[042] pGlyph[043] pGlyph[044] 152 | 16 pGlyph[045] pGlyph[046] pGlyph[047] 153 | 17 pGlyph[048] pGlyph[049] pGlyph[050] 154 | 18 pGlyph[051] pGlyph[052] pGlyph[053] 155 | 19 pGlyph[054] pGlyph[055] pGlyph[056] 156 | 20 pGlyph[057] pGlyph[058] pGlyph[059] 157 | 21 pGlyph[060] pGlyph[061] pGlyph[062] 158 | 22 pGlyph[063] pGlyph[064] pGlyph[065] 159 | 23 pGlyph[066] pGlyph[067] pGlyph[068] 160 | 24 pGlyph[069] pGlyph[070] pGlyph[071] 161 | 162 | フォントの並び(32X32ドット) 163 | 00000000 01111111 11122222 22222333 164 | 12345678 90123456 78901234 56789012 165 | 01 pGlyph[000] pGlyph[001] pGlyph[002] pGlyph[003] 166 | 02 pGlyph[004] pGlyph[005] pGlyph[006] pGlyph[007] 167 | 03 pGlyph[008] pGlyph[009] pGlyph[010] pGlyph[011] 168 | 04 pGlyph[012] pGlyph[013] pGlyph[014] pGlyph[015] 169 | 05 pGlyph[016] pGlyph[017] pGlyph[018] pGlyph[019] 170 | 06 pGlyph[020] pGlyph[021] pGlyph[022] pGlyph[023] 171 | 07 pGlyph[024] pGlyph[025] pGlyph[026] pGlyph[027] 172 | 08 pGlyph[028] pGlyph[029] pGlyph[030] pGlyph[031] 173 | 09 pGlyph[032] pGlyph[033] pGlyph[034] pGlyph[035] 174 | 10 pGlyph[036] pGlyph[037] pGlyph[038] pGlyph[039] 175 | 11 pGlyph[040] pGlyph[041] pGlyph[042] pGlyph[043] 176 | 12 pGlyph[044] pGlyph[045] pGlyph[046] pGlyph[047] 177 | 13 pGlyph[048] pGlyph[049] pGlyph[050] pGlyph[051] 178 | 14 pGlyph[052] pGlyph[053] pGlyph[054] pGlyph[055] 179 | 15 pGlyph[056] pGlyph[057] pGlyph[058] pGlyph[059] 180 | 16 pGlyph[060] pGlyph[061] pGlyph[062] pGlyph[063] 181 | 17 pGlyph[064] pGlyph[065] pGlyph[066] pGlyph[067] 182 | 18 pGlyph[068] pGlyph[069] pGlyph[070] pGlyph[071] 183 | 19 pGlyph[072] pGlyph[073] pGlyph[074] pGlyph[075] 184 | 20 pGlyph[076] pGlyph[077] pGlyph[078] pGlyph[079] 185 | 21 pGlyph[080] pGlyph[081] pGlyph[082] pGlyph[083] 186 | 22 pGlyph[084] pGlyph[085] pGlyph[086] pGlyph[087] 187 | 23 pGlyph[088] pGlyph[089] pGlyph[090] pGlyph[091] 188 | 24 pGlyph[092] pGlyph[093] pGlyph[094] pGlyph[095] 189 | 25 pGlyph[096] pGlyph[097] pGlyph[098] pGlyph[099] 190 | 26 pGlyph[100] pGlyph[101] pGlyph[102] pGlyph[103] 191 | 27 pGlyph[104] pGlyph[105] pGlyph[106] pGlyph[107] 192 | 28 pGlyph[108] pGlyph[109] pGlyph[110] pGlyph[111] 193 | 29 pGlyph[112] pGlyph[113] pGlyph[114] pGlyph[115] 194 | 30 pGlyph[116] pGlyph[117] pGlyph[118] pGlyph[119] 195 | 31 pGlyph[120] pGlyph[121] pGlyph[122] pGlyph[123] 196 | 32 pGlyph[124] pGlyph[125] pGlyph[127] pGlyph[128] 197 | 198 | */ 199 | 200 | bool GetFontx(FontxFile *fxs, uint8_t ascii , uint8_t *pGlyph, uint8_t *pw, uint8_t *ph) 201 | { 202 | 203 | int i; 204 | uint32_t offset; 205 | 206 | if(FontxDebug)printf("[GetFontx]ascii=0x%x\n",ascii); 207 | for(i=0; i<2; i++){ 208 | //for(i=0; i<1; i++){ 209 | if(!OpenFontx(&fxs[i])) continue; 210 | if(FontxDebug)printf("[GetFontx]openFontxFile[%d] ok\n",i); 211 | 212 | //if(ascii < 0xFF){ 213 | if(fxs[i].is_ank){ 214 | if(FontxDebug)printf("[GetFontx]fxs.is_ank fxs.fsz=%d\n",fxs[i].fsz); 215 | offset = 17 + ascii * fxs[i].fsz; 216 | if(FontxDebug)printf("[GetFontx]offset=%"PRIu32"\n",offset); 217 | if(fseek(fxs[i].file, offset, SEEK_SET)) { 218 | printf("Fontx:seek(%"PRIu32") failed.\n",offset); 219 | return false; 220 | } 221 | if(fread(pGlyph, 1, fxs[i].fsz, fxs[i].file) != fxs[i].fsz) { 222 | printf("Fontx:fread failed.\n"); 223 | return false; 224 | } 225 | if(pw) *pw = fxs[i].w; 226 | if(ph) *ph = fxs[i].h; 227 | return true; 228 | } 229 | //} 230 | } 231 | return false; 232 | } 233 | 234 | 235 | /* 236 | フォントパターンをビットマップイメージに変換する 237 | 238 | fonts(16X16ドット) 239 | 00000000 01111111 240 | 12345678 90123456 241 | 01 pGlyph[000] pGlyph[001] 242 | 02 pGlyph[002] pGlyph[003] 243 | 03 pGlyph[004] pGlyph[005] 244 | 04 pGlyph[006] pGlyph[007] 245 | 05 pGlyph[008] pGlyph[009] 246 | 06 pGlyph[010] pGlyph[011] 247 | 07 pGlyph[012] pGlyph[013] 248 | 08 pGlyph[014] pGlyph[015] 249 | 09 pGlyph[016] pGlyph[017] 250 | 10 pGlyph[018] pGlyph[019] 251 | 11 pGlyph[020] pGlyph[021] 252 | 12 pGlyph[022] pGlyph[023] 253 | 13 pGlyph[024] pGlyph[025] 254 | 14 pGlyph[026] pGlyph[027] 255 | 15 pGlyph[028] pGlyph[029] 256 | 16 pGlyph[030] pGlyph[031] 257 | 258 | line[32*4] 259 | 01 line[000] line[001] line[002] .... line[014] line[015] line[016-031](Not use) 260 | | 261 | 07 line[000] line[001] line[002] .... line[014] line[015] line[016-031](Not use) 262 | 263 | 08 line[032] line[033] line[034] .... line[046] line[047] line[048-063](Not use) 264 | | 265 | 16 line[032] line[033] line[034] .... line[046] line[047] line[048-063](Not use) 266 | 267 | 268 | 269 | fonts(24X24ドット) 270 | 00000000 01111111 11122222 271 | 12345678 90123456 78901234 272 | 01 pGlyph[000] pGlyph[001] pGlyph[002] 273 | 02 pGlyph[003] pGlyph[004] pGlyph[005] 274 | 03 pGlyph[006] pGlyph[007] pGlyph[008] 275 | 04 pGlyph[009] pGlyph[010] pGlyph[011] 276 | 05 pGlyph[012] pGlyph[013] pGlyph[014] 277 | 06 pGlyph[015] pGlyph[016] pGlyph[017] 278 | 07 pGlyph[018] pGlyph[019] pGlyph[020] 279 | 08 pGlyph[021] pGlyph[022] pGlyph[023] 280 | 09 pGlyph[024] pGlyph[025] pGlyph[026] 281 | 10 pGlyph[027] pGlyph[028] pGlyph[029] 282 | 11 pGlyph[030] pGlyph[031] pGlyph[032] 283 | 12 pGlyph[033] pGlyph[034] pGlyph[035] 284 | 13 pGlyph[036] pGlyph[037] pGlyph[038] 285 | 14 pGlyph[039] pGlyph[040] pGlyph[041] 286 | 15 pGlyph[042] pGlyph[043] pGlyph[044] 287 | 16 pGlyph[045] pGlyph[046] pGlyph[047] 288 | 17 pGlyph[048] pGlyph[049] pGlyph[050] 289 | 18 pGlyph[051] pGlyph[052] pGlyph[053] 290 | 19 pGlyph[054] pGlyph[055] pGlyph[056] 291 | 20 pGlyph[057] pGlyph[058] pGlyph[059] 292 | 21 pGlyph[060] pGlyph[061] pGlyph[062] 293 | 22 pGlyph[063] pGlyph[064] pGlyph[065] 294 | 23 pGlyph[066] pGlyph[067] pGlyph[068] 295 | 24 pGlyph[069] pGlyph[070] pGlyph[071] 296 | 297 | line[32*4] 298 | 01 line[000] line[001] line[002] .... line[022] line[023] line[024-031](Not use) 299 | | 300 | 08 line[000] line[001] line[002] .... line[022] line[023] line[024-031](Not use) 301 | 302 | 09 line[032] line[033] line[034] .... line[054] line[055] line[056-063](Not use) 303 | | 304 | 16 line[032] line[033] line[034] .... line[054] line[055] line[056-063](Not use) 305 | 306 | 17 line[064] line[065] line[066] .... line[086] line[087] line[088-095](Not use) 307 | | 308 | 24 line[064] line[065] line[066] .... line[086] line[087] line[088-095](Not use) 309 | 310 | 311 | fonts(32X32ドット) 312 | 00000000 01111111 11122222 22222333 313 | 12345678 90123456 78901234 56789012 314 | 01 pGlyph[000] pGlyph[001] pGlyph[002] pGlyph[003] 315 | 02 pGlyph[004] pGlyph[005] pGlyph[006] pGlyph[007] 316 | 03 pGlyph[008] pGlyph[009] pGlyph[010] pGlyph[011] 317 | 04 pGlyph[012] pGlyph[013] pGlyph[014] pGlyph[015] 318 | 05 pGlyph[016] pGlyph[017] pGlyph[018] pGlyph[019] 319 | 06 pGlyph[020] pGlyph[021] pGlyph[022] pGlyph[023] 320 | 07 pGlyph[024] pGlyph[025] pGlyph[026] pGlyph[027] 321 | 08 pGlyph[028] pGlyph[029] pGlyph[030] pGlyph[031] 322 | 09 pGlyph[032] pGlyph[033] pGlyph[034] pGlyph[035] 323 | 10 pGlyph[036] pGlyph[037] pGlyph[038] pGlyph[039] 324 | 11 pGlyph[040] pGlyph[041] pGlyph[042] pGlyph[043] 325 | 12 pGlyph[044] pGlyph[045] pGlyph[046] pGlyph[047] 326 | 13 pGlyph[048] pGlyph[049] pGlyph[050] pGlyph[051] 327 | 14 pGlyph[052] pGlyph[053] pGlyph[054] pGlyph[055] 328 | 15 pGlyph[056] pGlyph[057] pGlyph[058] pGlyph[059] 329 | 16 pGlyph[060] pGlyph[061] pGlyph[062] pGlyph[063] 330 | 17 pGlyph[064] pGlyph[065] pGlyph[066] pGlyph[067] 331 | 18 pGlyph[068] pGlyph[069] pGlyph[070] pGlyph[071] 332 | 19 pGlyph[072] pGlyph[073] pGlyph[074] pGlyph[075] 333 | 20 pGlyph[076] pGlyph[077] pGlyph[078] pGlyph[079] 334 | 21 pGlyph[080] pGlyph[081] pGlyph[082] pGlyph[083] 335 | 22 pGlyph[084] pGlyph[085] pGlyph[086] pGlyph[087] 336 | 23 pGlyph[088] pGlyph[089] pGlyph[090] pGlyph[091] 337 | 24 pGlyph[092] pGlyph[093] pGlyph[094] pGlyph[095] 338 | 25 pGlyph[096] pGlyph[097] pGlyph[098] pGlyph[099] 339 | 26 pGlyph[100] pGlyph[101] pGlyph[102] pGlyph[103] 340 | 27 pGlyph[104] pGlyph[105] pGlyph[106] pGlyph[107] 341 | 28 pGlyph[108] pGlyph[109] pGlyph[110] pGlyph[111] 342 | 29 pGlyph[112] pGlyph[113] pGlyph[114] pGlyph[115] 343 | 30 pGlyph[116] pGlyph[117] pGlyph[118] pGlyph[119] 344 | 31 pGlyph[120] pGlyph[121] pGlyph[122] pGlyph[123] 345 | 32 pGlyph[124] pGlyph[125] pGlyph[127] pGlyph[128] 346 | 347 | line[32*4] 348 | 01 line[000] line[001] line[002] .... line[030] line[031] 349 | | 350 | 08 line[000] line[001] line[002] .... line[030] line[031] 351 | 352 | 09 line[032] line[033] line[034] .... line[062] line[063] 353 | | 354 | 16 line[032] line[033] line[034] .... line[062] line[063] 355 | 356 | 17 line[064] line[065] line[066] .... line[094] line[095] 357 | | 358 | 24 line[064] line[065] line[066] .... line[094] line[095] 359 | 360 | 25 line[096] line[097] line[098] .... line[126] line[127] 361 | | 362 | 32 line[096] line[097] line[098] .... line[126] line[127] 363 | 364 | */ 365 | void Font2Bitmap(uint8_t *fonts, uint8_t *line, uint8_t w, uint8_t h, uint8_t inverse) { 366 | int x,y; 367 | for(y=0; y<(h/8); y++){ 368 | for(x=0; x> (x % 8))) line[linep] = line[linep] + (1 << mask); 381 | } 382 | mask--; 383 | if (mask < 0) mask = 7; 384 | fontp += (w + 7)/8; 385 | } 386 | 387 | if (inverse) { 388 | for(y=0; y<(h/8); y++){ 389 | for(x=0; x> (x % 8))) { 429 | printf("*"); 430 | } else { 431 | printf("."); 432 | } 433 | } 434 | printf("\n"); 435 | fpos=fpos+(pw+7)/8; 436 | } 437 | printf("\n"); 438 | } 439 | 440 | // Bitmapの表示 441 | void ShowBitmap(uint8_t *bitmap, uint8_t pw, uint8_t ph) { 442 | int x,y,fpos; 443 | printf("[ShowBitmap pw=%d ph=%d]\n",pw,ph); 444 | #if 0 445 | for (y=0;y<(ph+7)/8;y++) { 446 | for (x=0;x> fpos); 458 | if (bitmap[x+(y/8)*32] & (0x80 >> fpos)) { 459 | printf("*"); 460 | } else { 461 | printf("."); 462 | } 463 | } 464 | printf("\n"); 465 | fpos++; 466 | if (fpos > 7) fpos = 0; 467 | } 468 | printf("\n"); 469 | } 470 | 471 | 472 | // 8ビットデータを反転 473 | uint8_t RotateByte(uint8_t ch1) { 474 | uint8_t ch2 = 0; 475 | int j; 476 | for (j=0;j<8;j++) { 477 | ch2 = (ch2 << 1) + (ch1 & 0x01); 478 | ch1 = ch1 >> 1; 479 | } 480 | return ch2; 481 | } 482 | 483 | 484 | #if 0 485 | // UTF code(3Byte) を SJIS Code(2 Byte) に変換 486 | // https://www.mgo-tec.com/blog-entry-utf8sjis01.html 487 | uint16_t UTF2SJIS(spiffs_file fd, uint8_t *utf8) { 488 | 489 | uint32_t offset = 0; 490 | uint32_t ret; 491 | uint32_t UTF8uint = utf8[0]*256*256 + utf8[1]*256 + utf8[2]; 492 | 493 | if(utf8[0]>=0xC2 && utf8[0]<=0xD1){ //0xB0からS_JISコード実データ。0x00-0xAFまではライセンス文ヘッダなのでそれをカット。 494 | offset = ((utf8[0]*256 + utf8[1])-0xC2A2)*2 + 0xB0; //文字"¢" UTF8コード C2A2~、S_jisコード8191 495 | }else if(utf8[0]==0xE2 && utf8[1]>=0x80){ 496 | offset = (UTF8uint-0xE28090)*2 + 0x1EEC; //文字"‐" UTF8コード E28090~、S_jisコード815D 497 | }else if(utf8[0]==0xE3 && utf8[1]>=0x80){ 498 | offset = (UTF8uint-0xE38080)*2 + 0x9DCC; //スペース UTF8コード E38080~、S_jisコード8140 499 | }else if(utf8[0]==0xE4 && utf8[1]>=0x80){ 500 | offset = (UTF8uint-0xE4B880)*2 + 0x11CCC; //文字"一" UTF8コード E4B880~、S_jisコード88EA 501 | }else if(utf8[0]==0xE5 && utf8[1]>=0x80){ 502 | offset = (UTF8uint-0xE58085)*2 + 0x12BCC; //文字"倅" UTF8コード E58085~、S_jisコード98E4 503 | }else if(utf8[0]==0xE6 && utf8[1]>=0x80){ 504 | offset = (UTF8uint-0xE6808E)*2 + 0x1AAC2; //文字"怎" UTF8コード E6808E~、S_jisコード9C83 505 | }else if(utf8[0]==0xE7 && utf8[1]>=0x80){ 506 | offset = (UTF8uint-0xE78081)*2 + 0x229A6; //文字"瀁" UTF8コード E78081~、S_jisコードE066 507 | }else if(utf8[0]==0xE8 && utf8[1]>=0x80){ 508 | offset = (UTF8uint-0xE88080)*2 + 0x2A8A4; //文字"耀" UTF8コード E88080~、S_jisコード9773 509 | }else if(utf8[0]==0xE9 && utf8[1]>=0x80){ 510 | offset = (UTF8uint-0xE98080)*2 + 0x327A4; //文字"退" UTF8コード E98080~、S_jisコード91DE 511 | }else if(utf8[0]>=0xEF && utf8[1]>=0xBC){ 512 | offset = (UTF8uint-0xEFBC81)*2 + 0x3A6A4; //文字"!" UTF8コード EFBC81~、S_jisコード8149 513 | if(utf8[0]==0xEF && utf8[1]==0xBD && utf8[2]==0x9E){ 514 | offset = 0x3A8DE; // "~" UTF8コード EFBD9E、S_jisコード8160 515 | } 516 | } 517 | 518 | if(FontxDebug)printf("[UTF2SJIS] offset=%d\n",offset); 519 | char buf[2]; 520 | ret = SPIFFS_lseek(&fs, fd, offset, SPIFFS_SEEK_SET); 521 | if(FontxDebug)printf("[UTF2SJIS] lseek ret=%d\n",ret); 522 | if (ret != offset) { 523 | printf("UTF2SJIS:seek(%u) failed.\n",offset); 524 | return 0; 525 | } 526 | if (SPIFFS_read(&fs, fd, buf, sizeof(buf)) != sizeof(buf)) { 527 | printf("UTF2SJIS:read failed.\n"); 528 | return 0; 529 | } 530 | if(FontxDebug)printf("[UTF2SJIS] sjis=0x%x%x\n",buf[0],buf[1]); 531 | return buf[0]*256+buf[1]; 532 | } 533 | 534 | 535 | // UTFを含む文字列をSJISに変換 536 | int String2SJIS(spiffs_file fd, unsigned char *str_in, size_t stlen, 537 | uint16_t *sjis, size_t ssize) { 538 | int i; 539 | uint8_t sp; 540 | uint8_t c1 = 0; 541 | uint8_t c2 = 0; 542 | uint8_t utf8[3]; 543 | uint16_t sjis2; 544 | int spos = 0; 545 | 546 | for(i=0;i 2 | #include 3 | #include 4 | 5 | #include "freertos/FreeRTOS.h" 6 | #include "freertos/task.h" 7 | 8 | #include 9 | #include 10 | #include "esp_log.h" 11 | 12 | #include "st7789.h" 13 | 14 | #define TAG "ST7789" 15 | #define _DEBUG_ 0 16 | 17 | #if 0 18 | #ifdef CONFIG_IDF_TARGET_ESP32 19 | #define LCD_HOST HSPI_HOST 20 | #elif defined CONFIG_IDF_TARGET_ESP32S2 21 | #define LCD_HOST SPI2_HOST 22 | #elif defined CONFIG_IDF_TARGET_ESP32S3 23 | #define LCD_HOST SPI2_HOST 24 | #elif defined CONFIG_IDF_TARGET_ESP32C3 25 | #define LCD_HOST SPI2_HOST 26 | #endif 27 | #endif 28 | 29 | #if CONFIG_SPI2_HOST 30 | #define HOST_ID SPI2_HOST 31 | #elif CONFIG_SPI3_HOST 32 | #define HOST_ID SPI3_HOST 33 | #endif 34 | 35 | #define SPI_DEFAULT_FREQUENCY SPI_MASTER_FREQ_20M; // 20MHz 36 | 37 | static const int SPI_Command_Mode = 0; 38 | static const int SPI_Data_Mode = 1; 39 | //static const int SPI_Frequency = SPI_MASTER_FREQ_20M; 40 | //static const int SPI_Frequency = SPI_MASTER_FREQ_26M; 41 | //static const int SPI_Frequency = SPI_MASTER_FREQ_40M; 42 | //static const int SPI_Frequency = 60000000; 43 | //static const int SPI_Frequency = SPI_MASTER_FREQ_80M; 44 | 45 | int clock_speed_hz = SPI_DEFAULT_FREQUENCY; 46 | 47 | void spi_clock_speed(int speed) { 48 | ESP_LOGI(TAG, "SPI clock speed=%d MHz", speed/1000000); 49 | clock_speed_hz = speed; 50 | } 51 | 52 | void spi_master_init(TFT_t * dev, int16_t GPIO_MOSI, int16_t GPIO_SCLK, int16_t GPIO_CS, int16_t GPIO_DC, int16_t GPIO_RESET, int16_t GPIO_BL) 53 | { 54 | esp_err_t ret; 55 | 56 | ESP_LOGI(TAG, "GPIO_CS=%d",GPIO_CS); 57 | if ( GPIO_CS >= 0 ) { 58 | //gpio_pad_select_gpio( GPIO_CS ); 59 | gpio_reset_pin( GPIO_CS ); 60 | gpio_set_direction( GPIO_CS, GPIO_MODE_OUTPUT ); 61 | gpio_set_level( GPIO_CS, 0 ); 62 | } 63 | 64 | ESP_LOGI(TAG, "GPIO_DC=%d",GPIO_DC); 65 | //gpio_pad_select_gpio( GPIO_DC ); 66 | gpio_reset_pin( GPIO_DC ); 67 | gpio_set_direction( GPIO_DC, GPIO_MODE_OUTPUT ); 68 | gpio_set_level( GPIO_DC, 0 ); 69 | 70 | ESP_LOGI(TAG, "GPIO_RESET=%d",GPIO_RESET); 71 | if ( GPIO_RESET >= 0 ) { 72 | //gpio_pad_select_gpio( GPIO_RESET ); 73 | gpio_reset_pin( GPIO_RESET ); 74 | gpio_set_direction( GPIO_RESET, GPIO_MODE_OUTPUT ); 75 | gpio_set_level( GPIO_RESET, 1 ); 76 | delayMS(100); 77 | gpio_set_level( GPIO_RESET, 0 ); 78 | delayMS(100); 79 | gpio_set_level( GPIO_RESET, 1 ); 80 | delayMS(100); 81 | } 82 | 83 | ESP_LOGI(TAG, "GPIO_BL=%d",GPIO_BL); 84 | if ( GPIO_BL >= 0 ) { 85 | //gpio_pad_select_gpio(GPIO_BL); 86 | gpio_reset_pin(GPIO_BL); 87 | gpio_set_direction( GPIO_BL, GPIO_MODE_OUTPUT ); 88 | gpio_set_level( GPIO_BL, 0 ); 89 | } 90 | 91 | ESP_LOGI(TAG, "GPIO_MOSI=%d",GPIO_MOSI); 92 | ESP_LOGI(TAG, "GPIO_SCLK=%d",GPIO_SCLK); 93 | spi_bus_config_t buscfg = { 94 | .mosi_io_num = GPIO_MOSI, 95 | .miso_io_num = -1, 96 | .sclk_io_num = GPIO_SCLK, 97 | .quadwp_io_num = -1, 98 | .quadhd_io_num = -1, 99 | .max_transfer_sz = 0, 100 | .flags = 0 101 | }; 102 | 103 | ret = spi_bus_initialize( HOST_ID, &buscfg, SPI_DMA_CH_AUTO ); 104 | ESP_LOGD(TAG, "spi_bus_initialize=%d",ret); 105 | assert(ret==ESP_OK); 106 | 107 | spi_device_interface_config_t devcfg; 108 | memset(&devcfg, 0, sizeof(devcfg)); 109 | //devcfg.clock_speed_hz = SPI_Frequency; 110 | devcfg.clock_speed_hz = clock_speed_hz; 111 | devcfg.queue_size = 7; 112 | //devcfg.mode = 2; 113 | devcfg.mode = 3; 114 | devcfg.flags = SPI_DEVICE_NO_DUMMY; 115 | 116 | if ( GPIO_CS >= 0 ) { 117 | devcfg.spics_io_num = GPIO_CS; 118 | } else { 119 | devcfg.spics_io_num = -1; 120 | } 121 | 122 | spi_device_handle_t handle; 123 | ret = spi_bus_add_device( HOST_ID, &devcfg, &handle); 124 | ESP_LOGD(TAG, "spi_bus_add_device=%d",ret); 125 | assert(ret==ESP_OK); 126 | dev->_dc = GPIO_DC; 127 | dev->_bl = GPIO_BL; 128 | dev->_SPIHandle = handle; 129 | } 130 | 131 | bool spi_master_write_byte(spi_device_handle_t SPIHandle, const uint8_t* Data, size_t DataLength) 132 | { 133 | spi_transaction_t SPITransaction; 134 | esp_err_t ret; 135 | 136 | if ( DataLength > 0 ) { 137 | memset( &SPITransaction, 0, sizeof( spi_transaction_t ) ); 138 | SPITransaction.length = DataLength * 8; 139 | SPITransaction.tx_buffer = Data; 140 | #if 1 141 | ret = spi_device_transmit( SPIHandle, &SPITransaction ); 142 | #else 143 | ret = spi_device_polling_transmit( SPIHandle, &SPITransaction ); 144 | #endif 145 | assert(ret==ESP_OK); 146 | } 147 | 148 | return true; 149 | } 150 | 151 | bool spi_master_write_command(TFT_t * dev, uint8_t cmd) 152 | { 153 | static uint8_t Byte = 0; 154 | Byte = cmd; 155 | gpio_set_level( dev->_dc, SPI_Command_Mode ); 156 | return spi_master_write_byte( dev->_SPIHandle, &Byte, 1 ); 157 | } 158 | 159 | bool spi_master_write_data_byte(TFT_t * dev, uint8_t data) 160 | { 161 | static uint8_t Byte = 0; 162 | Byte = data; 163 | gpio_set_level( dev->_dc, SPI_Data_Mode ); 164 | return spi_master_write_byte( dev->_SPIHandle, &Byte, 1 ); 165 | } 166 | 167 | 168 | bool spi_master_write_data_word(TFT_t * dev, uint16_t data) 169 | { 170 | static uint8_t Byte[2]; 171 | Byte[0] = (data >> 8) & 0xFF; 172 | Byte[1] = data & 0xFF; 173 | gpio_set_level( dev->_dc, SPI_Data_Mode ); 174 | return spi_master_write_byte( dev->_SPIHandle, Byte, 2); 175 | } 176 | 177 | bool spi_master_write_addr(TFT_t * dev, uint16_t addr1, uint16_t addr2) 178 | { 179 | static uint8_t Byte[4]; 180 | Byte[0] = (addr1 >> 8) & 0xFF; 181 | Byte[1] = addr1 & 0xFF; 182 | Byte[2] = (addr2 >> 8) & 0xFF; 183 | Byte[3] = addr2 & 0xFF; 184 | gpio_set_level( dev->_dc, SPI_Data_Mode ); 185 | return spi_master_write_byte( dev->_SPIHandle, Byte, 4); 186 | } 187 | 188 | bool spi_master_write_color(TFT_t * dev, uint16_t color, uint16_t size) 189 | { 190 | static uint8_t Byte[1024]; 191 | int index = 0; 192 | for(int i=0;i> 8) & 0xFF; 194 | Byte[index++] = color & 0xFF; 195 | } 196 | gpio_set_level( dev->_dc, SPI_Data_Mode ); 197 | return spi_master_write_byte( dev->_SPIHandle, Byte, size*2); 198 | } 199 | 200 | // Add 202001 201 | bool spi_master_write_colors(TFT_t * dev, uint16_t * colors, uint16_t size) 202 | { 203 | static uint8_t Byte[1024]; 204 | int index = 0; 205 | for(int i=0;i> 8) & 0xFF; 207 | Byte[index++] = colors[i] & 0xFF; 208 | } 209 | gpio_set_level( dev->_dc, SPI_Data_Mode ); 210 | return spi_master_write_byte( dev->_SPIHandle, Byte, size*2); 211 | } 212 | 213 | void delayMS(int ms) { 214 | int _ms = ms + (portTICK_PERIOD_MS - 1); 215 | TickType_t xTicksToDelay = _ms / portTICK_PERIOD_MS; 216 | ESP_LOGD(TAG, "ms=%d _ms=%d portTICK_PERIOD_MS=%"PRIu32" xTicksToDelay=%"PRIu32,ms,_ms,portTICK_PERIOD_MS,xTicksToDelay); 217 | vTaskDelay(xTicksToDelay); 218 | } 219 | 220 | 221 | void lcdInit(TFT_t * dev, int width, int height, int offsetx, int offsety) 222 | { 223 | dev->_width = width; 224 | dev->_height = height; 225 | dev->_offsetx = offsetx; 226 | dev->_offsety = offsety; 227 | dev->_font_direction = DIRECTION0; 228 | dev->_font_fill = false; 229 | dev->_font_underline = false; 230 | 231 | spi_master_write_command(dev, 0x01); //Software Reset 232 | delayMS(150); 233 | 234 | spi_master_write_command(dev, 0x11); //Sleep Out 235 | delayMS(255); 236 | 237 | spi_master_write_command(dev, 0x3A); //Interface Pixel Format 238 | spi_master_write_data_byte(dev, 0x55); 239 | delayMS(10); 240 | 241 | spi_master_write_command(dev, 0x36); //Memory Data Access Control 242 | spi_master_write_data_byte(dev, 0x00); 243 | 244 | spi_master_write_command(dev, 0x2A); //Column Address Set 245 | spi_master_write_data_byte(dev, 0x00); 246 | spi_master_write_data_byte(dev, 0x00); 247 | spi_master_write_data_byte(dev, 0x00); 248 | spi_master_write_data_byte(dev, 0xF0); 249 | 250 | spi_master_write_command(dev, 0x2B); //Row Address Set 251 | spi_master_write_data_byte(dev, 0x00); 252 | spi_master_write_data_byte(dev, 0x00); 253 | spi_master_write_data_byte(dev, 0x00); 254 | spi_master_write_data_byte(dev, 0xF0); 255 | 256 | spi_master_write_command(dev, 0x21); //Display Inversion On 257 | delayMS(10); 258 | 259 | spi_master_write_command(dev, 0x13); //Normal Display Mode On 260 | delayMS(10); 261 | 262 | spi_master_write_command(dev, 0x29); //Display ON 263 | delayMS(255); 264 | 265 | if(dev->_bl >= 0) { 266 | gpio_set_level( dev->_bl, 1 ); 267 | } 268 | 269 | dev->_use_frame_buffer = false; 270 | #if CONFIG_FRAME_BUFFER 271 | dev->_frame_buffer = heap_caps_malloc(sizeof(uint16_t)*width*height, MALLOC_CAP_DMA); 272 | if (dev->_frame_buffer == NULL) { 273 | ESP_LOGE(TAG, "heap_caps_malloc fail"); 274 | } else { 275 | ESP_LOGI(TAG, "heap_caps_malloc success"); 276 | dev->_use_frame_buffer = true; 277 | } 278 | 279 | #endif 280 | } 281 | 282 | 283 | // Draw pixel 284 | // x:X coordinate 285 | // y:Y coordinate 286 | // color:color 287 | void lcdDrawPixel(TFT_t * dev, uint16_t x, uint16_t y, uint16_t color){ 288 | if (x >= dev->_width) return; 289 | if (y >= dev->_height) return; 290 | 291 | if (dev->_use_frame_buffer) { 292 | dev->_frame_buffer[y*dev->_width+x] = color; 293 | } else { 294 | uint16_t _x = x + dev->_offsetx; 295 | uint16_t _y = y + dev->_offsety; 296 | 297 | spi_master_write_command(dev, 0x2A); // set column(x) address 298 | spi_master_write_addr(dev, _x, _x); 299 | spi_master_write_command(dev, 0x2B); // set Page(y) address 300 | spi_master_write_addr(dev, _y, _y); 301 | spi_master_write_command(dev, 0x2C); // Memory Write 302 | //spi_master_write_data_word(dev, color); 303 | spi_master_write_colors(dev, &color, 1); 304 | } 305 | } 306 | 307 | 308 | // Draw multi pixel 309 | // x:X coordinate 310 | // y:Y coordinate 311 | // size:Number of colors 312 | // colors:colors 313 | void lcdDrawMultiPixels(TFT_t * dev, uint16_t x, uint16_t y, uint16_t size, uint16_t * colors) { 314 | if (x+size > dev->_width) return; 315 | if (y >= dev->_height) return; 316 | 317 | if (dev->_use_frame_buffer) { 318 | uint16_t _x1 = x; 319 | uint16_t _x2 = _x1 + (size-1); 320 | uint16_t _y1 = y; 321 | uint16_t _y2 = _y1; 322 | int16_t index = 0; 323 | for (int16_t j = _y1; j <= _y2; j++){ 324 | for(int16_t i = _x1; i <= _x2; i++){ 325 | dev->_frame_buffer[j*dev->_width+i] = colors[index++]; 326 | } 327 | } 328 | } else { 329 | uint16_t _x1 = x + dev->_offsetx; 330 | uint16_t _x2 = _x1 + (size-1); 331 | uint16_t _y1 = y + dev->_offsety; 332 | uint16_t _y2 = _y1; 333 | 334 | spi_master_write_command(dev, 0x2A); // set column(x) address 335 | spi_master_write_addr(dev, _x1, _x2); 336 | spi_master_write_command(dev, 0x2B); // set Page(y) address 337 | spi_master_write_addr(dev, _y1, _y2); 338 | spi_master_write_command(dev, 0x2C); // Memory Write 339 | spi_master_write_colors(dev, colors, size); 340 | } 341 | } 342 | 343 | // Draw rectangle of filling 344 | // x1:Start X coordinate 345 | // y1:Start Y coordinate 346 | // x2:End X coordinate 347 | // y2:End Y coordinate 348 | // color:color 349 | void lcdDrawFillRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { 350 | if (x1 >= dev->_width) return; 351 | if (x2 >= dev->_width) x2=dev->_width-1; 352 | if (y1 >= dev->_height) return; 353 | if (y2 >= dev->_height) y2=dev->_height-1; 354 | 355 | ESP_LOGD(TAG,"offset(x)=%d offset(y)=%d",dev->_offsetx,dev->_offsety); 356 | 357 | if (dev->_use_frame_buffer) { 358 | for (int16_t j = y1; j <= y2; j++){ 359 | for(int16_t i = x1; i <= x2; i++){ 360 | dev->_frame_buffer[j*dev->_width+i] = color; 361 | } 362 | } 363 | } else { 364 | uint16_t _x1 = x1 + dev->_offsetx; 365 | uint16_t _x2 = x2 + dev->_offsetx; 366 | uint16_t _y1 = y1 + dev->_offsety; 367 | uint16_t _y2 = y2 + dev->_offsety; 368 | 369 | spi_master_write_command(dev, 0x2A); // set column(x) address 370 | spi_master_write_addr(dev, _x1, _x2); 371 | spi_master_write_command(dev, 0x2B); // set Page(y) address 372 | spi_master_write_addr(dev, _y1, _y2); 373 | spi_master_write_command(dev, 0x2C); // Memory Write 374 | for(int i=_x1;i<=_x2;i++){ 375 | uint16_t size = _y2-_y1+1; 376 | spi_master_write_color(dev, color, size); 377 | } 378 | } 379 | } 380 | 381 | // Display OFF 382 | void lcdDisplayOff(TFT_t * dev) { 383 | spi_master_write_command(dev, 0x28); // Display off 384 | } 385 | 386 | // Display ON 387 | void lcdDisplayOn(TFT_t * dev) { 388 | spi_master_write_command(dev, 0x29); // Display on 389 | } 390 | 391 | // Fill screen 392 | // color:color 393 | void lcdFillScreen(TFT_t * dev, uint16_t color) { 394 | lcdDrawFillRect(dev, 0, 0, dev->_width-1, dev->_height-1, color); 395 | } 396 | 397 | // Draw line 398 | // x1:Start X coordinate 399 | // y1:Start Y coordinate 400 | // x2:End X coordinate 401 | // y2:End Y coordinate 402 | // color:color 403 | void lcdDrawLine(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { 404 | int i; 405 | int dx,dy; 406 | int sx,sy; 407 | int E; 408 | 409 | /* distance between two points */ 410 | dx = ( x2 > x1 ) ? x2 - x1 : x1 - x2; 411 | dy = ( y2 > y1 ) ? y2 - y1 : y1 - y2; 412 | 413 | /* direction of two point */ 414 | sx = ( x2 > x1 ) ? 1 : -1; 415 | sy = ( y2 > y1 ) ? 1 : -1; 416 | 417 | /* inclination < 1 */ 418 | if ( dx > dy ) { 419 | E = -dx; 420 | for ( i = 0 ; i <= dx ; i++ ) { 421 | lcdDrawPixel(dev, x1, y1, color); 422 | x1 += sx; 423 | E += 2 * dy; 424 | if ( E >= 0 ) { 425 | y1 += sy; 426 | E -= 2 * dx; 427 | } 428 | } 429 | 430 | /* inclination >= 1 */ 431 | } else { 432 | E = -dy; 433 | for ( i = 0 ; i <= dy ; i++ ) { 434 | lcdDrawPixel(dev, x1, y1, color); 435 | y1 += sy; 436 | E += 2 * dx; 437 | if ( E >= 0 ) { 438 | x1 += sx; 439 | E -= 2 * dy; 440 | } 441 | } 442 | } 443 | } 444 | 445 | // Draw rectangle 446 | // x1:Start X coordinate 447 | // y1:Start Y coordinate 448 | // x2:End X coordinate 449 | // y2:End Y coordinate 450 | // color:color 451 | void lcdDrawRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { 452 | lcdDrawLine(dev, x1, y1, x2, y1, color); 453 | lcdDrawLine(dev, x2, y1, x2, y2, color); 454 | lcdDrawLine(dev, x2, y2, x1, y2, color); 455 | lcdDrawLine(dev, x1, y2, x1, y1, color); 456 | } 457 | 458 | // Draw rectangle with angle 459 | // xc:Center X coordinate 460 | // yc:Center Y coordinate 461 | // w:Width of rectangle 462 | // h:Height of rectangle 463 | // angle:Angle of rectangle 464 | // color:color 465 | 466 | //When the origin is (0, 0), the point (x1, y1) after rotating the point (x, y) by the angle is obtained by the following calculation. 467 | // x1 = x * cos(angle) - y * sin(angle) 468 | // y1 = x * sin(angle) + y * cos(angle) 469 | void lcdDrawRectAngle(TFT_t * dev, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color) { 470 | double xd,yd,rd; 471 | int x1,y1; 472 | int x2,y2; 473 | int x3,y3; 474 | int x4,y4; 475 | rd = -angle * M_PI / 180.0; 476 | xd = 0.0 - w/2; 477 | yd = h/2; 478 | x1 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 479 | y1 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 480 | 481 | yd = 0.0 - yd; 482 | x2 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 483 | y2 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 484 | 485 | xd = w/2; 486 | yd = h/2; 487 | x3 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 488 | y3 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 489 | 490 | yd = 0.0 - yd; 491 | x4 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 492 | y4 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 493 | 494 | lcdDrawLine(dev, x1, y1, x2, y2, color); 495 | lcdDrawLine(dev, x1, y1, x3, y3, color); 496 | lcdDrawLine(dev, x2, y2, x4, y4, color); 497 | lcdDrawLine(dev, x3, y3, x4, y4, color); 498 | } 499 | 500 | // Draw triangle 501 | // xc:Center X coordinate 502 | // yc:Center Y coordinate 503 | // w:Width of triangle 504 | // h:Height of triangle 505 | // angle:Angle of triangle 506 | // color:color 507 | 508 | //When the origin is (0, 0), the point (x1, y1) after rotating the point (x, y) by the angle is obtained by the following calculation. 509 | // x1 = x * cos(angle) - y * sin(angle) 510 | // y1 = x * sin(angle) + y * cos(angle) 511 | void lcdDrawTriangle(TFT_t * dev, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color) { 512 | double xd,yd,rd; 513 | int x1,y1; 514 | int x2,y2; 515 | int x3,y3; 516 | rd = -angle * M_PI / 180.0; 517 | xd = 0.0; 518 | yd = h/2; 519 | x1 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 520 | y1 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 521 | 522 | xd = w/2; 523 | yd = 0.0 - yd; 524 | x2 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 525 | y2 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 526 | 527 | xd = 0.0 - w/2; 528 | x3 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 529 | y3 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 530 | 531 | lcdDrawLine(dev, x1, y1, x2, y2, color); 532 | lcdDrawLine(dev, x1, y1, x3, y3, color); 533 | lcdDrawLine(dev, x2, y2, x3, y3, color); 534 | } 535 | 536 | // Draw regular polygon 537 | // xc:Center X coordinate 538 | // yc:Center Y coordinate 539 | // n:Number of slides 540 | // r:radius 541 | // angle:Angle of regular polygon 542 | // color:color 543 | void lcdDrawRegularPolygon(TFT_t *dev, uint16_t xc, uint16_t yc, uint16_t n, uint16_t r, uint16_t angle, uint16_t color) 544 | { 545 | double xd, yd, rd; 546 | int x1, y1; 547 | int x2, y2; 548 | int i; 549 | 550 | rd = -angle * M_PI / 180.0; 551 | for (i = 0; i < n; i++) 552 | { 553 | xd = r * cos(2 * M_PI * i / n); 554 | yd = r * sin(2 * M_PI * i / n); 555 | x1 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 556 | y1 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 557 | 558 | xd = r * cos(2 * M_PI * (i + 1) / n); 559 | yd = r * sin(2 * M_PI * (i + 1) / n); 560 | x2 = (int)(xd * cos(rd) - yd * sin(rd) + xc); 561 | y2 = (int)(xd * sin(rd) + yd * cos(rd) + yc); 562 | 563 | lcdDrawLine(dev, x1, y1, x2, y2, color); 564 | } 565 | } 566 | 567 | // Draw circle 568 | // x0:Central X coordinate 569 | // y0:Central Y coordinate 570 | // r:radius 571 | // color:color 572 | void lcdDrawCircle(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t r, uint16_t color) { 573 | int x; 574 | int y; 575 | int err; 576 | int old_err; 577 | 578 | x=0; 579 | y=-r; 580 | err=2-2*r; 581 | do{ 582 | lcdDrawPixel(dev, x0-x, y0+y, color); 583 | lcdDrawPixel(dev, x0-y, y0-x, color); 584 | lcdDrawPixel(dev, x0+x, y0-y, color); 585 | lcdDrawPixel(dev, x0+y, y0+x, color); 586 | if ((old_err=err)<=x) err+=++x*2+1; 587 | if (old_err>y || err>x) err+=++y*2+1; 588 | } while(y<0); 589 | } 590 | 591 | // Draw circle of filling 592 | // x0:Central X coordinate 593 | // y0:Central Y coordinate 594 | // r:radius 595 | // color:color 596 | void lcdDrawFillCircle(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t r, uint16_t color) { 597 | int x; 598 | int y; 599 | int err; 600 | int old_err; 601 | int ChangeX; 602 | 603 | x=0; 604 | y=-r; 605 | err=2-2*r; 606 | ChangeX=1; 607 | do{ 608 | if(ChangeX) { 609 | lcdDrawLine(dev, x0-x, y0-y, x0-x, y0+y, color); 610 | lcdDrawLine(dev, x0+x, y0-y, x0+x, y0+y, color); 611 | } // endif 612 | ChangeX=(old_err=err)<=x; 613 | if (ChangeX) err+=++x*2+1; 614 | if (old_err>y || err>x) err+=++y*2+1; 615 | } while(y<=0); 616 | } 617 | 618 | // Draw rectangle with round corner 619 | // x1:Start X coordinate 620 | // y1:Start Y coordinate 621 | // x2:End X coordinate 622 | // y2:End Y coordinate 623 | // r:radius 624 | // color:color 625 | void lcdDrawRoundRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t r, uint16_t color) { 626 | int x; 627 | int y; 628 | int err; 629 | int old_err; 630 | unsigned char temp; 631 | 632 | if(x1>x2) { 633 | temp=x1; x1=x2; x2=temp; 634 | } // endif 635 | 636 | if(y1>y2) { 637 | temp=y1; y1=y2; y2=temp; 638 | } // endif 639 | 640 | ESP_LOGD(TAG, "x1=%d x2=%d delta=%d r=%d",x1, x2, x2-x1, r); 641 | ESP_LOGD(TAG, "y1=%d y2=%d delta=%d r=%d",y1, y2, y2-y1, r); 642 | if (x2-x1 < r) return; // Add 20190517 643 | if (y2-y1 < r) return; // Add 20190517 644 | 645 | x=0; 646 | y=-r; 647 | err=2-2*r; 648 | 649 | do{ 650 | if(x) { 651 | lcdDrawPixel(dev, x1+r-x, y1+r+y, color); 652 | lcdDrawPixel(dev, x2-r+x, y1+r+y, color); 653 | lcdDrawPixel(dev, x1+r-x, y2-r-y, color); 654 | lcdDrawPixel(dev, x2-r+x, y2-r-y, color); 655 | } // endif 656 | if ((old_err=err)<=x) err+=++x*2+1; 657 | if (old_err>y || err>x) err+=++y*2+1; 658 | } while(y<0); 659 | 660 | ESP_LOGD(TAG, "x1+r=%d x2-r=%d",x1+r, x2-r); 661 | lcdDrawLine(dev, x1+r,y1 ,x2-r,y1 ,color); 662 | lcdDrawLine(dev, x1+r,y2 ,x2-r,y2 ,color); 663 | ESP_LOGD(TAG, "y1+r=%d y2-r=%d",y1+r, y2-r); 664 | lcdDrawLine(dev, x1 ,y1+r,x1 ,y2-r,color); 665 | lcdDrawLine(dev, x2 ,y1+r,x2 ,y2-r,color); 666 | } 667 | 668 | // Draw arrow 669 | // x1:Start X coordinate 670 | // y1:Start Y coordinate 671 | // x2:End X coordinate 672 | // y2:End Y coordinate 673 | // w:Width of the botom 674 | // color:color 675 | // Thanks http://k-hiura.cocolog-nifty.com/blog/2010/11/post-2a62.html 676 | void lcdDrawArrow(TFT_t * dev, uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint16_t w,uint16_t color) { 677 | double Vx= x1 - x0; 678 | double Vy= y1 - y0; 679 | double v = sqrt(Vx*Vx+Vy*Vy); 680 | // printf("v=%f\n",v); 681 | double Ux= Vx/v; 682 | double Uy= Vy/v; 683 | 684 | uint16_t L[2],R[2]; 685 | L[0]= x1 - Uy*w - Ux*v; 686 | L[1]= y1 + Ux*w - Uy*v; 687 | R[0]= x1 + Uy*w - Ux*v; 688 | R[1]= y1 - Ux*w - Uy*v; 689 | //printf("L=%d-%d R=%d-%d\n",L[0],L[1],R[0],R[1]); 690 | 691 | //lcdDrawLine(x0,y0,x1,y1,color); 692 | lcdDrawLine(dev, x1, y1, L[0], L[1], color); 693 | lcdDrawLine(dev, x1, y1, R[0], R[1], color); 694 | lcdDrawLine(dev, L[0], L[1], R[0], R[1], color); 695 | } 696 | 697 | 698 | // Draw arrow of filling 699 | // x1:Start X coordinate 700 | // y1:Start Y coordinate 701 | // x2:End X coordinate 702 | // y2:End Y coordinate 703 | // w:Width of the botom 704 | // color:color 705 | void lcdDrawFillArrow(TFT_t * dev, uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint16_t w,uint16_t color) { 706 | double Vx= x1 - x0; 707 | double Vy= y1 - y0; 708 | double v = sqrt(Vx*Vx+Vy*Vy); 709 | //printf("v=%f\n",v); 710 | double Ux= Vx/v; 711 | double Uy= Vy/v; 712 | 713 | uint16_t L[2],R[2]; 714 | L[0]= x1 - Uy*w - Ux*v; 715 | L[1]= y1 + Ux*w - Uy*v; 716 | R[0]= x1 + Uy*w - Ux*v; 717 | R[1]= y1 - Ux*w - Uy*v; 718 | //printf("L=%d-%d R=%d-%d\n",L[0],L[1],R[0],R[1]); 719 | 720 | lcdDrawLine(dev, x0, y0, x1, y1, color); 721 | lcdDrawLine(dev, x1, y1, L[0], L[1], color); 722 | lcdDrawLine(dev, x1, y1, R[0], R[1], color); 723 | lcdDrawLine(dev, L[0], L[1], R[0], R[1], color); 724 | 725 | int ww; 726 | for(ww=w-1;ww>0;ww--) { 727 | L[0]= x1 - Uy*ww - Ux*v; 728 | L[1]= y1 + Ux*ww - Uy*v; 729 | R[0]= x1 + Uy*ww - Ux*v; 730 | R[1]= y1 - Ux*ww - Uy*v; 731 | //printf("Fill>L=%d-%d R=%d-%d\n",L[0],L[1],R[0],R[1]); 732 | lcdDrawLine(dev, x1, y1, L[0], L[1], color); 733 | lcdDrawLine(dev, x1, y1, R[0], R[1], color); 734 | } 735 | } 736 | 737 | 738 | // Draw ASCII character 739 | // x:X coordinate 740 | // y:Y coordinate 741 | // ascii: ascii code 742 | // color:color 743 | int lcdDrawChar(TFT_t * dev, FontxFile *fxs, uint16_t x, uint16_t y, uint8_t ascii, uint16_t color) { 744 | uint16_t xx,yy,bit,ofs; 745 | unsigned char fonts[128]; // font pattern 746 | unsigned char pw, ph; 747 | int h,w; 748 | uint16_t mask; 749 | bool rc; 750 | 751 | if(_DEBUG_)printf("_font_direction=%d\n",dev->_font_direction); 752 | rc = GetFontx(fxs, ascii, fonts, &pw, &ph); 753 | if(_DEBUG_)printf("GetFontx rc=%d pw=%d ph=%d\n",rc,pw,ph); 754 | if (!rc) return 0; 755 | 756 | int16_t xd1 = 0; 757 | int16_t yd1 = 0; 758 | int16_t xd2 = 0; 759 | int16_t yd2 = 0; 760 | uint16_t xss = 0; 761 | uint16_t yss = 0; 762 | int16_t xsd = 0; 763 | int16_t ysd = 0; 764 | int16_t next = 0; 765 | uint16_t x0 = 0; 766 | uint16_t x1 = 0; 767 | uint16_t y0 = 0; 768 | uint16_t y1 = 0; 769 | if (dev->_font_direction == 0) { 770 | xd1 = +1; 771 | yd1 = +1; //-1; 772 | xd2 = 0; 773 | yd2 = 0; 774 | xss = x; 775 | yss = y - (ph - 1); 776 | xsd = 1; 777 | ysd = 0; 778 | next = x + pw; 779 | 780 | x0 = x; 781 | y0 = y - (ph-1); 782 | x1 = x + (pw-1); 783 | y1 = y; 784 | } else if (dev->_font_direction == 2) { 785 | xd1 = -1; 786 | yd1 = -1; //+1; 787 | xd2 = 0; 788 | yd2 = 0; 789 | xss = x; 790 | yss = y + ph + 1; 791 | xsd = 1; 792 | ysd = 0; 793 | next = x - pw; 794 | 795 | x0 = x - (pw-1); 796 | y0 = y; 797 | x1 = x; 798 | y1 = y + (ph-1); 799 | } else if (dev->_font_direction == 1) { 800 | xd1 = 0; 801 | yd1 = 0; 802 | xd2 = -1; 803 | yd2 = +1; //-1; 804 | xss = x + ph; 805 | yss = y; 806 | xsd = 0; 807 | ysd = 1; 808 | next = y + pw; //y - pw; 809 | 810 | x0 = x; 811 | y0 = y; 812 | x1 = x + (ph-1); 813 | y1 = y + (pw-1); 814 | } else if (dev->_font_direction == 3) { 815 | xd1 = 0; 816 | yd1 = 0; 817 | xd2 = +1; 818 | yd2 = -1; //+1; 819 | xss = x - (ph - 1); 820 | yss = y; 821 | xsd = 0; 822 | ysd = 1; 823 | next = y - pw; //y + pw; 824 | 825 | x0 = x - (ph-1); 826 | y0 = y - (pw-1); 827 | x1 = x; 828 | y1 = y; 829 | } 830 | 831 | if (dev->_font_fill) lcdDrawFillRect(dev, x0, y0, x1, y1, dev->_font_fill_color); 832 | 833 | int bits; 834 | if(_DEBUG_)printf("xss=%d yss=%d\n",xss,yss); 835 | ofs = 0; 836 | yy = yss; 837 | xx = xss; 838 | for(h=0;h_font_fill) lcdDrawPixel(dev, xx, yy, dev->_font_fill_color); 853 | } 854 | if (h == (ph-2) && dev->_font_underline) 855 | lcdDrawPixel(dev, xx, yy, dev->_font_underline_color); 856 | if (h == (ph-1) && dev->_font_underline) 857 | lcdDrawPixel(dev, xx, yy, dev->_font_underline_color); 858 | xx = xx + xd1; 859 | yy = yy + yd2; 860 | mask = mask >> 1; 861 | } 862 | ofs++; 863 | } 864 | yy = yy + yd1; 865 | xx = xx + xd2; 866 | } 867 | 868 | if (next < 0) next = 0; 869 | return next; 870 | } 871 | 872 | int lcdDrawString(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t * ascii, uint16_t color) { 873 | int length = strlen((char *)ascii); 874 | if(_DEBUG_)printf("lcdDrawString length=%d\n",length); 875 | for(int i=0;i_font_direction == 0) 878 | x = lcdDrawChar(dev, fx, x, y, ascii[i], color); 879 | if (dev->_font_direction == 1) 880 | y = lcdDrawChar(dev, fx, x, y, ascii[i], color); 881 | if (dev->_font_direction == 2) 882 | x = lcdDrawChar(dev, fx, x, y, ascii[i], color); 883 | if (dev->_font_direction == 3) 884 | y = lcdDrawChar(dev, fx, x, y, ascii[i], color); 885 | } 886 | if (dev->_font_direction == 0) return x; 887 | if (dev->_font_direction == 2) return x; 888 | if (dev->_font_direction == 1) return y; 889 | if (dev->_font_direction == 3) return y; 890 | return 0; 891 | } 892 | 893 | 894 | // Draw Non-Alphanumeric character 895 | // x:X coordinate 896 | // y:Y coordinate 897 | // code:character code 898 | // color:color 899 | int lcdDrawCode(TFT_t * dev, FontxFile *fx, uint16_t x,uint16_t y,uint8_t code,uint16_t color) { 900 | if(_DEBUG_)printf("code=%x x=%d y=%d\n",code,x,y); 901 | if (dev->_font_direction == 0) 902 | x = lcdDrawChar(dev, fx, x, y, code, color); 903 | if (dev->_font_direction == 1) 904 | y = lcdDrawChar(dev, fx, x, y, code, color); 905 | if (dev->_font_direction == 2) 906 | x = lcdDrawChar(dev, fx, x, y, code, color); 907 | if (dev->_font_direction == 3) 908 | y = lcdDrawChar(dev, fx, x, y, code, color); 909 | if (dev->_font_direction == 0) return x; 910 | if (dev->_font_direction == 2) return x; 911 | if (dev->_font_direction == 1) return y; 912 | if (dev->_font_direction == 3) return y; 913 | return 0; 914 | } 915 | 916 | #if 0 917 | // Draw UTF8 character 918 | // x:X coordinate 919 | // y:Y coordinate 920 | // utf8:UTF8 code 921 | // color:color 922 | int lcdDrawUTF8Char(TFT_t * dev, FontxFile *fx, uint16_t x,uint16_t y,uint8_t *utf8,uint16_t color) { 923 | uint16_t sjis[1]; 924 | 925 | sjis[0] = UTF2SJIS(utf8); 926 | if(_DEBUG_)printf("sjis=%04x\n",sjis[0]); 927 | return lcdDrawSJISChar(dev, fx, x, y, sjis[0], color); 928 | } 929 | 930 | // Draw UTF8 string 931 | // x:X coordinate 932 | // y:Y coordinate 933 | // utfs:UTF8 string 934 | // color:color 935 | int lcdDrawUTF8String(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, unsigned char *utfs, uint16_t color) { 936 | 937 | int i; 938 | int spos; 939 | uint16_t sjis[64]; 940 | spos = String2SJIS(utfs, strlen((char *)utfs), sjis, 64); 941 | if(_DEBUG_)printf("spos=%d\n",spos); 942 | for(i=0;i_font_direction == 0) 945 | x = lcdDrawSJISChar(dev, fx, x, y, sjis[i], color); 946 | if (dev->_font_direction == 1) 947 | y = lcdDrawSJISChar(dev, fx, x, y, sjis[i], color); 948 | if (dev->_font_direction == 2) 949 | x = lcdDrawSJISChar(dev, fx, x, y, sjis[i], color); 950 | if (dev->_font_direction == 3) 951 | y = lcdDrawSJISChar(dev, fx, x, y, sjis[i], color); 952 | } 953 | if (dev->_font_direction == 0) return x; 954 | if (dev->_font_direction == 2) return x; 955 | if (dev->_font_direction == 1) return y; 956 | if (dev->_font_direction == 3) return y; 957 | return 0; 958 | } 959 | #endif 960 | 961 | // Set font direction 962 | // dir:Direction 963 | void lcdSetFontDirection(TFT_t * dev, uint16_t dir) { 964 | dev->_font_direction = dir; 965 | } 966 | 967 | // Set font filling 968 | // color:fill color 969 | void lcdSetFontFill(TFT_t * dev, uint16_t color) { 970 | dev->_font_fill = true; 971 | dev->_font_fill_color = color; 972 | } 973 | 974 | // UnSet font filling 975 | void lcdUnsetFontFill(TFT_t * dev) { 976 | dev->_font_fill = false; 977 | } 978 | 979 | // Set font underline 980 | // color:frame color 981 | void lcdSetFontUnderLine(TFT_t * dev, uint16_t color) { 982 | dev->_font_underline = true; 983 | dev->_font_underline_color = color; 984 | } 985 | 986 | // UnSet font underline 987 | void lcdUnsetFontUnderLine(TFT_t * dev) { 988 | dev->_font_underline = false; 989 | } 990 | 991 | // Backlight OFF 992 | void lcdBacklightOff(TFT_t * dev) { 993 | if(dev->_bl >= 0) { 994 | gpio_set_level( dev->_bl, 0 ); 995 | } 996 | } 997 | 998 | // Backlight ON 999 | void lcdBacklightOn(TFT_t * dev) { 1000 | if(dev->_bl >= 0) { 1001 | gpio_set_level( dev->_bl, 1 ); 1002 | } 1003 | } 1004 | 1005 | // Display Inversion Off 1006 | void lcdInversionOff(TFT_t * dev) { 1007 | spi_master_write_command(dev, 0x20); // Display Inversion Off 1008 | } 1009 | 1010 | // Display Inversion On 1011 | void lcdInversionOn(TFT_t * dev) { 1012 | spi_master_write_command(dev, 0x21); // Display Inversion On 1013 | } 1014 | 1015 | void lcdWrapArround(TFT_t * dev, SCROLL_TYPE_t scroll, int start, int end) { 1016 | if (dev->_use_frame_buffer == false) return; 1017 | 1018 | int _width = dev->_width; 1019 | int _height = dev->_height; 1020 | int32_t index1; 1021 | int32_t index2; 1022 | 1023 | if (scroll == SCROLL_RIGHT) { 1024 | uint16_t wk[_width]; 1025 | for (int i=start;i_frame_buffer[index1], _width*2); 1028 | index2 = index1 + _width - 1; 1029 | dev->_frame_buffer[index1] = dev->_frame_buffer[index2]; 1030 | memcpy((char *)&dev->_frame_buffer[index1+1], (char *)&wk[0], (_width-1)*2); 1031 | } 1032 | } else if (scroll == SCROLL_LEFT) { 1033 | uint16_t wk[_width]; 1034 | for (int i=start;i_frame_buffer[index1], _width*2); 1037 | index2 = index1 + _width - 1; 1038 | dev->_frame_buffer[index2] = dev->_frame_buffer[index1]; 1039 | memcpy((char *)&dev->_frame_buffer[index1], (char *)&wk[1], (_width-1)*2); 1040 | } 1041 | } else if (scroll == SCROLL_UP) { 1042 | uint16_t wk; 1043 | for (int i=start;i<=end;i++) { 1044 | wk = dev->_frame_buffer[i]; 1045 | for (int j=0;j<_height-1;j++) { 1046 | index1 = j * _width + i; 1047 | index2 = (j+1) * _width + i; 1048 | dev->_frame_buffer[index1] = dev->_frame_buffer[index2]; 1049 | } 1050 | index2 = (_height-1) * _width + i; 1051 | dev->_frame_buffer[index2] = wk; 1052 | } 1053 | } else if (scroll == SCROLL_DOWN) { 1054 | uint16_t wk; 1055 | for (int i=start;i<=end;i++) { 1056 | index2 = (_height-1) * _width + i; 1057 | wk = dev->_frame_buffer[index2]; 1058 | for (int j=_height-2;j>=0;j--) { 1059 | index1 = j * _width + i; 1060 | index2 = (j+1) * _width + i; 1061 | dev->_frame_buffer[index2] = dev->_frame_buffer[index1]; 1062 | } 1063 | dev->_frame_buffer[i] = wk; 1064 | } 1065 | } 1066 | } 1067 | 1068 | // Draw Frame Buffer 1069 | void lcdDrawFinish(TFT_t *dev) 1070 | { 1071 | if (dev->_use_frame_buffer == false) return; 1072 | 1073 | spi_master_write_command(dev, 0x2A); // set column(x) address 1074 | spi_master_write_addr(dev, dev->_offsetx, dev->_offsetx+dev->_width-1); 1075 | spi_master_write_command(dev, 0x2B); // set Page(y) address 1076 | spi_master_write_addr(dev, dev->_offsety, dev->_offsety+dev->_height-1); 1077 | spi_master_write_command(dev, 0x2C); // Memory Write 1078 | 1079 | //uint16_t size = dev->_width*dev->_height; 1080 | uint32_t size = dev->_width*dev->_height; 1081 | uint16_t *image = dev->_frame_buffer; 1082 | while (size > 0) { 1083 | // 1024 bytes per time. 1084 | uint16_t bs = (size > 1024) ? 1024 : size; 1085 | spi_master_write_colors(dev, image, bs); 1086 | size -= bs; 1087 | image += bs; 1088 | } 1089 | return; 1090 | } 1091 | -------------------------------------------------------------------------------- /components/st7789/st7789.h: -------------------------------------------------------------------------------- 1 | #ifndef MAIN_ST7789_H_ 2 | #define MAIN_ST7789_H_ 3 | 4 | #include "driver/spi_master.h" 5 | #include "fontx.h" 6 | 7 | #define rgb565(r, g, b) (((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3)) 8 | 9 | #define RED rgb565(255, 0, 0) // 0xf800 10 | #define GREEN rgb565( 0, 255, 0) // 0x07e0 11 | #define BLUE rgb565( 0, 0, 255) // 0x001f 12 | #define BLACK rgb565( 0, 0, 0) // 0x0000 13 | #define WHITE rgb565(255, 255, 255) // 0xffff 14 | #define GRAY rgb565(128, 128, 128) // 0x8410 15 | #define YELLOW rgb565(255, 255, 0) // 0xFFE0 16 | #define CYAN rgb565( 0, 156, 209) // 0x04FA 17 | #define PURPLE rgb565(128, 0, 128) // 0x8010 18 | 19 | typedef enum {DIRECTION0, DIRECTION90, DIRECTION180, DIRECTION270} DIRECTION; 20 | 21 | typedef enum { 22 | SCROLL_RIGHT = 1, 23 | SCROLL_LEFT = 2, 24 | SCROLL_DOWN = 3, 25 | SCROLL_UP = 4, 26 | } SCROLL_TYPE_t; 27 | 28 | typedef struct { 29 | uint16_t _width; 30 | uint16_t _height; 31 | uint16_t _offsetx; 32 | uint16_t _offsety; 33 | uint16_t _font_direction; 34 | uint16_t _font_fill; 35 | uint16_t _font_fill_color; 36 | uint16_t _font_underline; 37 | uint16_t _font_underline_color; 38 | int16_t _dc; 39 | int16_t _bl; 40 | spi_device_handle_t _SPIHandle; 41 | bool _use_frame_buffer; 42 | uint16_t *_frame_buffer; 43 | } TFT_t; 44 | 45 | void spi_clock_speed(int speed); 46 | void spi_master_init(TFT_t * dev, int16_t GPIO_MOSI, int16_t GPIO_SCLK, int16_t GPIO_CS, int16_t GPIO_DC, int16_t GPIO_RESET, int16_t GPIO_BL); 47 | bool spi_master_write_byte(spi_device_handle_t SPIHandle, const uint8_t* Data, size_t DataLength); 48 | bool spi_master_write_command(TFT_t * dev, uint8_t cmd); 49 | bool spi_master_write_data_byte(TFT_t * dev, uint8_t data); 50 | bool spi_master_write_data_word(TFT_t * dev, uint16_t data); 51 | bool spi_master_write_addr(TFT_t * dev, uint16_t addr1, uint16_t addr2); 52 | bool spi_master_write_color(TFT_t * dev, uint16_t color, uint16_t size); 53 | bool spi_master_write_colors(TFT_t * dev, uint16_t * colors, uint16_t size); 54 | 55 | void delayMS(int ms); 56 | void lcdInit(TFT_t * dev, int width, int height, int offsetx, int offsety); 57 | void lcdDrawPixel(TFT_t * dev, uint16_t x, uint16_t y, uint16_t color); 58 | void lcdDrawMultiPixels(TFT_t * dev, uint16_t x, uint16_t y, uint16_t size, uint16_t * colors); 59 | void lcdDrawFillRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); 60 | void lcdDisplayOff(TFT_t * dev); 61 | void lcdDisplayOn(TFT_t * dev); 62 | void lcdFillScreen(TFT_t * dev, uint16_t color); 63 | void lcdDrawLine(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); 64 | void lcdDrawRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); 65 | void lcdDrawRectAngle(TFT_t * dev, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color); 66 | void lcdDrawTriangle(TFT_t * dev, uint16_t xc, uint16_t yc, uint16_t w, uint16_t h, uint16_t angle, uint16_t color); 67 | void lcdDrawRegularPolygon(TFT_t *dev, uint16_t xc, uint16_t yc, uint16_t n, uint16_t r, uint16_t angle, uint16_t color); 68 | void lcdDrawCircle(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t r, uint16_t color); 69 | void lcdDrawFillCircle(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t r, uint16_t color); 70 | void lcdDrawRoundRect(TFT_t * dev, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t r, uint16_t color); 71 | void lcdDrawArrow(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t w, uint16_t color); 72 | void lcdDrawFillArrow(TFT_t * dev, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t w, uint16_t color); 73 | int lcdDrawChar(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t ascii, uint16_t color); 74 | int lcdDrawString(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t * ascii, uint16_t color); 75 | int lcdDrawCode(TFT_t * dev, FontxFile *fx, uint16_t x,uint16_t y,uint8_t code,uint16_t color); 76 | //int lcdDrawUTF8Char(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, uint8_t *utf8, uint16_t color); 77 | //int lcdDrawUTF8String(TFT_t * dev, FontxFile *fx, uint16_t x, uint16_t y, unsigned char *utfs, uint16_t color); 78 | void lcdSetFontDirection(TFT_t * dev, uint16_t); 79 | void lcdSetFontFill(TFT_t * dev, uint16_t color); 80 | void lcdUnsetFontFill(TFT_t * dev); 81 | void lcdSetFontUnderLine(TFT_t * dev, uint16_t color); 82 | void lcdUnsetFontUnderLine(TFT_t * dev); 83 | void lcdBacklightOff(TFT_t * dev); 84 | void lcdBacklightOn(TFT_t * dev); 85 | void lcdInversionOff(TFT_t * dev); 86 | void lcdInversionOn(TFT_t * dev); 87 | void lcdWrapArround(TFT_t * dev, SCROLL_TYPE_t scroll, int start, int end); 88 | void lcdDrawFinish(TFT_t *dev); 89 | #endif /* MAIN_ST7789_H_ */ 90 | 91 | -------------------------------------------------------------------------------- /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(idf_ver "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}") 2 | 3 | 4 | set(APP_SOURCES 5 | "main.c" 6 | "display.c" 7 | "framebuffer.c" 8 | "runtime.c" 9 | "strnlen.c" 10 | "gamecard.c" 11 | "util.c" 12 | "control.c" 13 | "wamr.c" 14 | ) 15 | 16 | idf_component_register(SRCS ${APP_SOURCES} 17 | INCLUDE_DIRS "" 18 | INCLUDE_DIRS ".") 19 | 20 | 21 | target_compile_options(${COMPONENT_LIB} PRIVATE 22 | -Wno-pointer-sign 23 | -Wno-error=format 24 | -Wno-error=return-type 25 | -Wno-error=unused-variable 26 | -Wno-error=type-limits 27 | ) 28 | 29 | if(DEFINED ENV{ESP_WIFI_PASSWORD}) 30 | add_definitions(-DESP_WIFI_PASSWORD="$ENV{ESP_WIFI_PASSWORD}") 31 | else() 32 | message(FATAL_ERROR "Environment variable ESP_WIFI_PASSWORD is not set") 33 | endif() 34 | 35 | if(DEFINED ENV{ESP_WIFI_SSID}) 36 | add_definitions(-DESP_WIFI_SSID="$ENV{ESP_WIFI_SSID}") 37 | else() 38 | message(FATAL_ERROR "Environment variable ESP_WIFI_SSID is not set") 39 | endif() 40 | -------------------------------------------------------------------------------- /main/apu.h: -------------------------------------------------------------------------------- 1 | #ifndef APU_H 2 | #define APU_H 3 | 4 | #include 5 | #include 6 | 7 | void w4_apuInit() { 8 | // not imp yet 9 | } 10 | 11 | void w4_apuTick() { 12 | // not imp yet 13 | } 14 | 15 | void w4_apuTone(int frequency, int duration, int volume, int flags) { 16 | // not imp yet 17 | } 18 | 19 | void w4_apuWriteSamples(int16_t* output, unsigned long frames) { 20 | // not imp yet 21 | } 22 | 23 | #endif -------------------------------------------------------------------------------- /main/control.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "iot_button.h" 3 | 4 | uint8_t gamepads[4] = {0}; 5 | 6 | void set_player_state(int player, uint8_t state) { 7 | gamepads[player] = state; 8 | } 9 | 10 | uint8_t get_player_state(int player) { 11 | return gamepads[player]; 12 | } 13 | 14 | void clear_all_player_state() { 15 | gamepads[0] = 0; 16 | gamepads[1] = 0; 17 | gamepads[2] = 0; 18 | gamepads[3] = 0; 19 | } 20 | 21 | extern void set_player_state(int player, uint8_t state); 22 | 23 | static void button_left(void* arg, void* usr_data) 24 | { 25 | set_player_state(0, 16); 26 | } 27 | 28 | static void button_right(void* arg, void* usr_data) 29 | { 30 | set_player_state(0, 32); 31 | } 32 | 33 | static void button_up(void* arg, void* usr_data) 34 | { 35 | set_player_state(0, 64); 36 | } 37 | 38 | static void button_down(void* arg, void* usr_data) 39 | { 40 | set_player_state(0, 128); 41 | } 42 | 43 | static void button_x(void* arg, void* usr_data) 44 | { 45 | set_player_state(0, 1); 46 | } 47 | 48 | void init_button() { 49 | // create gpio button 50 | { 51 | button_config_t gpio_btn_cfg = { 52 | .type = BUTTON_TYPE_GPIO, 53 | .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS, 54 | .short_press_time = 100, 55 | .gpio_button_config = { 56 | .gpio_num = GPIO_NUM_2, 57 | .active_level = 0, 58 | }, 59 | }; 60 | button_handle_t gpio_btn = iot_button_create(&gpio_btn_cfg); 61 | if (NULL == gpio_btn) { 62 | printf("Button create failed\n"); 63 | } 64 | iot_button_register_cb(gpio_btn, BUTTON_SINGLE_CLICK, button_up, (void *)BUTTON_SINGLE_CLICK); 65 | } 66 | { 67 | button_config_t gpio_btn_cfg = { 68 | .type = BUTTON_TYPE_GPIO, 69 | .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS, 70 | .short_press_time = 100, 71 | .gpio_button_config = { 72 | .gpio_num = GPIO_NUM_3, 73 | .active_level = 0, 74 | }, 75 | }; 76 | button_handle_t gpio_btn = iot_button_create(&gpio_btn_cfg); 77 | if (NULL == gpio_btn) { 78 | printf("Button create failed\n"); 79 | } 80 | iot_button_register_cb(gpio_btn, BUTTON_SINGLE_CLICK, button_right, (void *)BUTTON_SINGLE_CLICK); 81 | } 82 | { 83 | button_config_t gpio_btn_cfg = { 84 | .type = BUTTON_TYPE_GPIO, 85 | .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS, 86 | .short_press_time = 100, 87 | .gpio_button_config = { 88 | .gpio_num = GPIO_NUM_10, 89 | .active_level = 0, 90 | }, 91 | }; 92 | button_handle_t gpio_btn = iot_button_create(&gpio_btn_cfg); 93 | if (NULL == gpio_btn) { 94 | printf("Button create failed\n"); 95 | } 96 | iot_button_register_cb(gpio_btn, BUTTON_SINGLE_CLICK, button_left, (void *)BUTTON_SINGLE_CLICK); 97 | } 98 | { 99 | button_config_t gpio_btn_cfg = { 100 | .type = BUTTON_TYPE_GPIO, 101 | .long_press_time = CONFIG_BUTTON_LONG_PRESS_TIME_MS, 102 | .short_press_time = 100, 103 | .gpio_button_config = { 104 | .gpio_num = GPIO_NUM_11, 105 | .active_level = 0, 106 | }, 107 | }; 108 | button_handle_t gpio_btn = iot_button_create(&gpio_btn_cfg); 109 | if (NULL == gpio_btn) { 110 | printf("Button create failed\n"); 111 | } 112 | iot_button_register_cb(gpio_btn, BUTTON_SINGLE_CLICK, button_down, (void *)BUTTON_SINGLE_CLICK); 113 | } 114 | printf("unused button_x: %p\n", button_x); 115 | } 116 | -------------------------------------------------------------------------------- /main/control.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTROL_H 2 | #define CONTROL_H 3 | 4 | #include 5 | 6 | extern uint8_t gamepads[4]; 7 | 8 | void set_player_state(int player, uint8_t state); 9 | uint8_t get_player_state(int player); 10 | void clear_all_player_state(); 11 | void init_button(); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /main/display.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "runtime.h" 4 | 5 | #include "freertos/FreeRTOS.h" 6 | #include "freertos/task.h" 7 | #include "st7789.h" 8 | #include "lcd.h" 9 | #include "esp_task_wdt.h" 10 | #include "control.h" 11 | #include "wasm_export.h" 12 | #include "esp_log.h" 13 | 14 | // static uint32_t pixels[160*160]; 15 | 16 | static int viewportX = 0; 17 | static int viewportY = 0; 18 | static int viewportSize = 3*160; 19 | 20 | 21 | extern wasm_module_t wasm_module; 22 | extern wasm_module_inst_t wasm_module_inst; 23 | extern wasm_function_inst_t start; 24 | extern wasm_function_inst_t update; 25 | extern wasm_exec_env_t exec_env; 26 | 27 | void w4_windowBoot () { 28 | int counter = 0; 29 | do { 30 | if (!wasm_module_inst || !start || !update || !exec_env) { 31 | continue; 32 | } 33 | // Player 1 34 | uint8_t gamepad = get_player_state(0); 35 | // printf("player 1 state: %d\n", gamepad); 36 | w4_runtimeSetGamepad(0, gamepad); 37 | 38 | // Player 2 39 | gamepad = get_player_state(1); 40 | // printf("player 2 state: %d\n", gamepad); 41 | w4_runtimeSetGamepad(1, gamepad); 42 | 43 | clear_all_player_state(); 44 | 45 | 46 | // Mouse handling 47 | uint8_t mouseButtons = 0; 48 | int mouseX = 0; 49 | int mouseY = 0; 50 | w4_runtimeSetMouse(160*(mouseX-viewportX)/viewportSize, 160*(mouseY-viewportY)/viewportSize, mouseButtons); 51 | w4_runtimeUpdate(); 52 | } while (1); 53 | } 54 | 55 | int counter = 0; 56 | 57 | uint16_t convert(uint32_t c) { 58 | uint16_t color = rgb565( 59 | (c & 0xff0000) >> 16, 60 | (c & 0xff00) >> 8, 61 | c & 0xff 62 | ); 63 | return color; 64 | } 65 | 66 | 67 | void w4_windowComposite (const uint32_t* palette, const uint8_t* framebuffer) { 68 | // Convert indexed 2bpp framebuffer to XRGB output 69 | // uint32_t* out = pixels; 70 | for (int n = 0; n < 160*160/4; ++n) { 71 | uint8_t quartet = framebuffer[n]; 72 | int color1 = (quartet & 0b00000011) >> 0; 73 | int color2 = (quartet & 0b00001100) >> 2; 74 | int color3 = (quartet & 0b00110000) >> 4; 75 | int color4 = (quartet & 0b11000000) >> 6; 76 | 77 | uint16_t c1 = convert(palette[color1]); 78 | uint16_t c2 = convert(palette[color2]); 79 | uint16_t c3 = convert(palette[color3]); 80 | uint16_t c4 = convert(palette[color4]); 81 | uint16_t cs[4] = {c1, c2, c3, c4}; 82 | 83 | for (int i = n * 4; i < n * 4 + 4; i++) { 84 | int x = i % 160; 85 | int y = i / 160; 86 | uint16_t c = cs[i - n * 4]; 87 | if (c != last[i]) { 88 | lcdDrawPixel(&dev, x + 40, y + 40, c); 89 | last[i] = c; 90 | } 91 | } 92 | } 93 | } 94 | 95 | TickType_t FillTest(TFT_t * dev, int width, int height) { 96 | TickType_t startTick, endTick, diffTick; 97 | startTick = xTaskGetTickCount(); 98 | 99 | { 100 | for (int i = 0; i < 2; i++) { 101 | TickType_t startTick, endTick, diffTick; 102 | startTick = xTaskGetTickCount(); 103 | lcdFillScreen(dev, WHITE); 104 | lcdFillScreen(dev, GREEN); 105 | lcdFillScreen(dev, BLACK); 106 | endTick = xTaskGetTickCount(); 107 | diffTick = endTick - startTick; 108 | ESP_LOGI(__FUNCTION__, "write a line elapsed time[ms]:%"PRIu32,diffTick*portTICK_PERIOD_MS); 109 | } 110 | } 111 | 112 | 113 | endTick = xTaskGetTickCount(); 114 | diffTick = endTick - startTick; 115 | ESP_LOGI(__FUNCTION__, "elapsed time[ms]:%"PRIu32,diffTick*portTICK_PERIOD_MS); 116 | return diffTick; 117 | } 118 | 119 | TFT_t dev; 120 | 121 | #define CUSTOM_MOSI_GPIO 23 122 | #define CUSTOM_SCLK_GPIO 20 123 | #define CUSTOM_CS_GPIO -1 124 | #define CUSTOM_DC_GPIO 21 125 | #define CUSTOM_RESET_GPIO 22 126 | #define CUSTOM_BL_GPIO -1 127 | 128 | void ST7789(void *pvParameters) 129 | { 130 | // set font file 131 | FontxFile fx16G[2]; 132 | FontxFile fx24G[2]; 133 | FontxFile fx32G[2]; 134 | FontxFile fx32L[2]; 135 | InitFontx(fx16G,"/spiffs/ILGH16XB.FNT",""); // 8x16Dot Gothic 136 | InitFontx(fx24G,"/spiffs/ILGH24XB.FNT",""); // 12x24Dot Gothic 137 | InitFontx(fx32G,"/spiffs/ILGH32XB.FNT",""); // 16x32Dot Gothic 138 | InitFontx(fx32L,"/spiffs/LATIN32B.FNT",""); // 16x32Dot Latin 139 | 140 | FontxFile fx16M[2]; 141 | FontxFile fx24M[2]; 142 | FontxFile fx32M[2]; 143 | InitFontx(fx16M,"/spiffs/ILMH16XB.FNT",""); // 8x16Dot Mincyo 144 | InitFontx(fx24M,"/spiffs/ILMH24XB.FNT",""); // 12x24Dot Mincyo 145 | InitFontx(fx32M,"/spiffs/ILMH32XB.FNT",""); // 16x32Dot Mincyo 146 | 147 | // Change SPI Clock Frequency 148 | //spi_clock_speed(40000000); // 40MHz 149 | //spi_clock_speed(60000000); // 60MHz 150 | 151 | spi_master_init(&dev, CUSTOM_MOSI_GPIO, CUSTOM_SCLK_GPIO, CUSTOM_CS_GPIO, CUSTOM_DC_GPIO, CUSTOM_RESET_GPIO, CUSTOM_BL_GPIO); 152 | lcdInit(&dev, CONFIG_WIDTH, CONFIG_HEIGHT, CONFIG_OFFSETX, CONFIG_OFFSETY); 153 | 154 | lcdFillScreen(&dev, BLACK); 155 | } -------------------------------------------------------------------------------- /main/framebuffer.c: -------------------------------------------------------------------------------- 1 | #include "framebuffer.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "util.h" 7 | 8 | static const uint8_t font[1792] = { 9 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 10 | 0xc7, 0xc7, 0xc7, 0xcf, 0xcf, 0xff, 0xcf, 0xff, 11 | 0x93, 0x93, 0x93, 0xff, 0xff, 0xff, 0xff, 0xff, 12 | 0x93, 0x01, 0x93, 0x93, 0x93, 0x01, 0x93, 0xff, 13 | 0xef, 0x83, 0x2f, 0x83, 0xe9, 0x03, 0xef, 0xff, 14 | 0x9d, 0x5b, 0x37, 0xef, 0xd9, 0xb5, 0x73, 0xff, 15 | 0x8f, 0x27, 0x27, 0x8f, 0x25, 0x33, 0x81, 0xff, 16 | 0xcf, 0xcf, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 17 | 0xf3, 0xe7, 0xcf, 0xcf, 0xcf, 0xe7, 0xf3, 0xff, 18 | 0x9f, 0xcf, 0xe7, 0xe7, 0xe7, 0xcf, 0x9f, 0xff, 19 | 0xff, 0x93, 0xc7, 0x01, 0xc7, 0x93, 0xff, 0xff, 20 | 0xff, 0xe7, 0xe7, 0x81, 0xe7, 0xe7, 0xff, 0xff, 21 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xcf, 0x9f, 22 | 0xff, 0xff, 0xff, 0x81, 0xff, 0xff, 0xff, 0xff, 23 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xcf, 0xff, 24 | 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f, 0xff, 25 | 0xc7, 0xb3, 0x39, 0x39, 0x39, 0x9b, 0xc7, 0xff, 26 | 0xe7, 0xc7, 0xe7, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 27 | 0x83, 0x39, 0xf1, 0xc3, 0x87, 0x1f, 0x01, 0xff, 28 | 0x81, 0xf3, 0xe7, 0xc3, 0xf9, 0x39, 0x83, 0xff, 29 | 0xe3, 0xc3, 0x93, 0x33, 0x01, 0xf3, 0xf3, 0xff, 30 | 0x03, 0x3f, 0x03, 0xf9, 0xf9, 0x39, 0x83, 0xff, 31 | 0xc3, 0x9f, 0x3f, 0x03, 0x39, 0x39, 0x83, 0xff, 32 | 0x01, 0x39, 0xf3, 0xe7, 0xcf, 0xcf, 0xcf, 0xff, 33 | 0x87, 0x3b, 0x1b, 0x87, 0x61, 0x79, 0x83, 0xff, 34 | 0x83, 0x39, 0x39, 0x81, 0xf9, 0xf3, 0x87, 0xff, 35 | 0xff, 0xcf, 0xcf, 0xff, 0xcf, 0xcf, 0xff, 0xff, 36 | 0xff, 0xcf, 0xcf, 0xff, 0xcf, 0xcf, 0x9f, 0xff, 37 | 0xf3, 0xe7, 0xcf, 0x9f, 0xcf, 0xe7, 0xf3, 0xff, 38 | 0xff, 0xff, 0x01, 0xff, 0x01, 0xff, 0xff, 0xff, 39 | 0x9f, 0xcf, 0xe7, 0xf3, 0xe7, 0xcf, 0x9f, 0xff, 40 | 0x83, 0x01, 0x39, 0xf3, 0xc7, 0xff, 0xc7, 0xff, 41 | 0x83, 0x7d, 0x45, 0x55, 0x41, 0x7f, 0x83, 0xff, 42 | 0xc7, 0x93, 0x39, 0x39, 0x01, 0x39, 0x39, 0xff, 43 | 0x03, 0x39, 0x39, 0x03, 0x39, 0x39, 0x03, 0xff, 44 | 0xc3, 0x99, 0x3f, 0x3f, 0x3f, 0x99, 0xc3, 0xff, 45 | 0x07, 0x33, 0x39, 0x39, 0x39, 0x33, 0x07, 0xff, 46 | 0x01, 0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x01, 0xff, 47 | 0x01, 0x3f, 0x3f, 0x03, 0x3f, 0x3f, 0x3f, 0xff, 48 | 0xc1, 0x9f, 0x3f, 0x31, 0x39, 0x99, 0xc1, 0xff, 49 | 0x39, 0x39, 0x39, 0x01, 0x39, 0x39, 0x39, 0xff, 50 | 0x81, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 51 | 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x39, 0x83, 0xff, 52 | 0x39, 0x33, 0x27, 0x0f, 0x07, 0x23, 0x31, 0xff, 53 | 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x81, 0xff, 54 | 0x39, 0x11, 0x01, 0x01, 0x29, 0x39, 0x39, 0xff, 55 | 0x39, 0x19, 0x09, 0x01, 0x21, 0x31, 0x39, 0xff, 56 | 0x83, 0x39, 0x39, 0x39, 0x39, 0x39, 0x83, 0xff, 57 | 0x03, 0x39, 0x39, 0x39, 0x03, 0x3f, 0x3f, 0xff, 58 | 0x83, 0x39, 0x39, 0x39, 0x21, 0x33, 0x85, 0xff, 59 | 0x03, 0x39, 0x39, 0x31, 0x07, 0x23, 0x31, 0xff, 60 | 0x87, 0x33, 0x3f, 0x83, 0xf9, 0x39, 0x83, 0xff, 61 | 0x81, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xff, 62 | 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x83, 0xff, 63 | 0x39, 0x39, 0x39, 0x11, 0x83, 0xc7, 0xef, 0xff, 64 | 0x39, 0x39, 0x29, 0x01, 0x01, 0x11, 0x39, 0xff, 65 | 0x39, 0x11, 0x83, 0xc7, 0x83, 0x11, 0x39, 0xff, 66 | 0x99, 0x99, 0x99, 0xc3, 0xe7, 0xe7, 0xe7, 0xff, 67 | 0x01, 0xf1, 0xe3, 0xc7, 0x8f, 0x1f, 0x01, 0xff, 68 | 0xc3, 0xcf, 0xcf, 0xcf, 0xcf, 0xcf, 0xc3, 0xff, 69 | 0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xff, 70 | 0x87, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0x87, 0xff, 71 | 0xc7, 0x93, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 72 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 73 | 0xef, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 74 | 0xff, 0xff, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 75 | 0x3f, 0x3f, 0x03, 0x39, 0x39, 0x39, 0x83, 0xff, 76 | 0xff, 0xff, 0x81, 0x3f, 0x3f, 0x3f, 0x81, 0xff, 77 | 0xf9, 0xf9, 0x81, 0x39, 0x39, 0x39, 0x81, 0xff, 78 | 0xff, 0xff, 0x83, 0x39, 0x01, 0x3f, 0x83, 0xff, 79 | 0xf1, 0xe7, 0x81, 0xe7, 0xe7, 0xe7, 0xe7, 0xff, 80 | 0xff, 0xff, 0x81, 0x39, 0x39, 0x81, 0xf9, 0x83, 81 | 0x3f, 0x3f, 0x03, 0x39, 0x39, 0x39, 0x39, 0xff, 82 | 0xe7, 0xff, 0xc7, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 83 | 0xf3, 0xff, 0xe3, 0xf3, 0xf3, 0xf3, 0xf3, 0x87, 84 | 0x3f, 0x3f, 0x31, 0x03, 0x07, 0x23, 0x31, 0xff, 85 | 0xc7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 86 | 0xff, 0xff, 0x03, 0x49, 0x49, 0x49, 0x49, 0xff, 87 | 0xff, 0xff, 0x03, 0x39, 0x39, 0x39, 0x39, 0xff, 88 | 0xff, 0xff, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 89 | 0xff, 0xff, 0x03, 0x39, 0x39, 0x03, 0x3f, 0x3f, 90 | 0xff, 0xff, 0x81, 0x39, 0x39, 0x81, 0xf9, 0xf9, 91 | 0xff, 0xff, 0x91, 0x8f, 0x9f, 0x9f, 0x9f, 0xff, 92 | 0xff, 0xff, 0x83, 0x3f, 0x83, 0xf9, 0x03, 0xff, 93 | 0xe7, 0xe7, 0x81, 0xe7, 0xe7, 0xe7, 0xe7, 0xff, 94 | 0xff, 0xff, 0x39, 0x39, 0x39, 0x39, 0x81, 0xff, 95 | 0xff, 0xff, 0x99, 0x99, 0x99, 0xc3, 0xe7, 0xff, 96 | 0xff, 0xff, 0x49, 0x49, 0x49, 0x49, 0x81, 0xff, 97 | 0xff, 0xff, 0x39, 0x01, 0xc7, 0x01, 0x39, 0xff, 98 | 0xff, 0xff, 0x39, 0x39, 0x39, 0x81, 0xf9, 0x83, 99 | 0xff, 0xff, 0x01, 0xe3, 0xc7, 0x8f, 0x01, 0xff, 100 | 0xf3, 0xe7, 0xe7, 0xcf, 0xe7, 0xe7, 0xf3, 0xff, 101 | 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7, 0xff, 102 | 0x9f, 0xcf, 0xcf, 0xe7, 0xcf, 0xcf, 0x9f, 0xff, 103 | 0xff, 0xff, 0x8f, 0x45, 0xe3, 0xff, 0xff, 0xff, 104 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x93, 0x93, 0xff, 105 | 0x83, 0x29, 0x29, 0x11, 0x29, 0x29, 0x83, 0xff, 106 | 0x83, 0x39, 0x09, 0x11, 0x21, 0x39, 0x83, 0xff, 107 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 108 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 109 | 0x83, 0x11, 0x21, 0x7d, 0x21, 0x11, 0x83, 0xff, 110 | 0x83, 0x11, 0x09, 0x7d, 0x09, 0x11, 0x83, 0xff, 111 | 0x83, 0x11, 0x39, 0x55, 0x11, 0x11, 0x83, 0xff, 112 | 0x83, 0x11, 0x11, 0x55, 0x39, 0x11, 0x83, 0xff, 113 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 114 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 115 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 116 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 117 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 118 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 119 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 120 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 121 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 122 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 123 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 124 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 125 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 126 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 127 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 128 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 129 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 130 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 131 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 132 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 133 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 134 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 135 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 136 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 137 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 138 | 0xe7, 0xff, 0xe7, 0xe7, 0xc7, 0xc7, 0xc7, 0xff, 139 | 0xef, 0x83, 0x29, 0x2f, 0x29, 0x83, 0xef, 0xff, 140 | 0xc3, 0x99, 0x9f, 0x03, 0x9f, 0x9f, 0x01, 0xff, 141 | 0xff, 0xa5, 0xdb, 0xdb, 0xdb, 0xa5, 0xff, 0xff, 142 | 0x99, 0x99, 0xc3, 0x81, 0xe7, 0x81, 0xe7, 0xff, 143 | 0xe7, 0xe7, 0xe7, 0xff, 0xe7, 0xe7, 0xe7, 0xff, 144 | 0xc3, 0x99, 0x87, 0xdb, 0xe1, 0x99, 0xc3, 0xff, 145 | 0x93, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 146 | 0xc3, 0xbd, 0x66, 0x5e, 0x5e, 0x66, 0xbd, 0xc3, 147 | 0x87, 0xc3, 0x93, 0xc3, 0xff, 0xff, 0xff, 0xff, 148 | 0xff, 0xc9, 0x93, 0x27, 0x93, 0xc9, 0xff, 0xff, 149 | 0xff, 0xff, 0x81, 0xf9, 0xf9, 0xff, 0xff, 0xff, 150 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 151 | 0xc3, 0xbd, 0x46, 0x5a, 0x46, 0x5a, 0xbd, 0xc3, 152 | 0x83, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 153 | 0xef, 0xd7, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 154 | 0xe7, 0xe7, 0x81, 0xe7, 0xe7, 0xff, 0x81, 0xff, 155 | 0xc7, 0xf3, 0xe7, 0xc3, 0xff, 0xff, 0xff, 0xff, 156 | 0xc3, 0xe7, 0xf3, 0xc7, 0xff, 0xff, 0xff, 0xff, 157 | 0xf7, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 158 | 0xff, 0xff, 0x33, 0x33, 0x33, 0x33, 0x09, 0x3f, 159 | 0xc1, 0x95, 0xb5, 0x95, 0xc1, 0xf5, 0xf5, 0xff, 160 | 0xff, 0xff, 0xff, 0xcf, 0xcf, 0xff, 0xff, 0xff, 161 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xcf, 162 | 0xe7, 0xc7, 0xe7, 0xc3, 0xff, 0xff, 0xff, 0xff, 163 | 0xc7, 0x93, 0x93, 0xc7, 0xff, 0xff, 0xff, 0xff, 164 | 0xff, 0x27, 0x93, 0xc9, 0x93, 0x27, 0xff, 0xff, 165 | 0xbd, 0x3b, 0xb7, 0xad, 0xd9, 0xb1, 0x7d, 0xff, 166 | 0xbd, 0x3b, 0xb7, 0xa9, 0xdd, 0xbb, 0x71, 0xff, 167 | 0x1d, 0xbb, 0xd7, 0x2d, 0xd9, 0xb1, 0x7d, 0xff, 168 | 0xc7, 0xff, 0xc7, 0x9f, 0x39, 0x01, 0x83, 0xff, 169 | 0xdf, 0xef, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 170 | 0xf7, 0xef, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 171 | 0xc7, 0x93, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 172 | 0xcb, 0xa7, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 173 | 0x93, 0xff, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 174 | 0xef, 0xd7, 0xc7, 0x93, 0x39, 0x01, 0x39, 0xff, 175 | 0xc1, 0x87, 0x27, 0x21, 0x07, 0x27, 0x21, 0xff, 176 | 0xc3, 0x99, 0x3f, 0x3f, 0x99, 0xc3, 0xf7, 0xcf, 177 | 0xdf, 0xef, 0x01, 0x3f, 0x03, 0x3f, 0x01, 0xff, 178 | 0xf7, 0xef, 0x01, 0x3f, 0x03, 0x3f, 0x01, 0xff, 179 | 0xc7, 0x93, 0x01, 0x3f, 0x03, 0x3f, 0x01, 0xff, 180 | 0x93, 0xff, 0x01, 0x3f, 0x03, 0x3f, 0x01, 0xff, 181 | 0xef, 0xf7, 0x81, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 182 | 0xf7, 0xef, 0x81, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 183 | 0xe7, 0xc3, 0x81, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 184 | 0x99, 0xff, 0x81, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 185 | 0x87, 0x93, 0x99, 0x09, 0x99, 0x93, 0x87, 0xff, 186 | 0xcb, 0xa7, 0x19, 0x09, 0x01, 0x21, 0x31, 0xff, 187 | 0xdf, 0xef, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 188 | 0xf7, 0xef, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 189 | 0xc7, 0x93, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 190 | 0xcb, 0xa7, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 191 | 0x93, 0xff, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 192 | 0xff, 0xbb, 0xd7, 0xef, 0xd7, 0xbb, 0xff, 0xff, 193 | 0x83, 0x39, 0x31, 0x29, 0x19, 0x39, 0x83, 0xff, 194 | 0xdf, 0xef, 0x39, 0x39, 0x39, 0x39, 0x83, 0xff, 195 | 0xf7, 0xef, 0x39, 0x39, 0x39, 0x39, 0x83, 0xff, 196 | 0xc7, 0x93, 0xff, 0x39, 0x39, 0x39, 0x83, 0xff, 197 | 0x93, 0xff, 0x39, 0x39, 0x39, 0x39, 0x83, 0xff, 198 | 0xf7, 0xef, 0x99, 0x99, 0xc3, 0xe7, 0xe7, 0xff, 199 | 0x3f, 0x03, 0x39, 0x39, 0x39, 0x03, 0x3f, 0xff, 200 | 0xc3, 0x99, 0x99, 0x93, 0x99, 0x89, 0x93, 0xff, 201 | 0xdf, 0xef, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 202 | 0xf7, 0xef, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 203 | 0xc7, 0x93, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 204 | 0xcb, 0xa7, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 205 | 0x93, 0xff, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 206 | 0xef, 0xd7, 0x83, 0xf9, 0x81, 0x39, 0x81, 0xff, 207 | 0xff, 0xff, 0x83, 0xe9, 0x81, 0x2f, 0x83, 0xff, 208 | 0xff, 0xff, 0x81, 0x3f, 0x3f, 0x81, 0xf7, 0xcf, 209 | 0xdf, 0xef, 0x83, 0x39, 0x01, 0x3f, 0x83, 0xff, 210 | 0xf7, 0xef, 0x83, 0x39, 0x01, 0x3f, 0x83, 0xff, 211 | 0xc7, 0x93, 0x83, 0x39, 0x01, 0x3f, 0x83, 0xff, 212 | 0x93, 0xff, 0x83, 0x39, 0x01, 0x3f, 0x83, 0xff, 213 | 0xdf, 0xef, 0xff, 0xc7, 0xe7, 0xe7, 0x81, 0xff, 214 | 0xf7, 0xef, 0xff, 0xc7, 0xe7, 0xe7, 0x81, 0xff, 215 | 0xc7, 0x93, 0xff, 0xc7, 0xe7, 0xe7, 0x81, 0xff, 216 | 0x93, 0xff, 0xc7, 0xe7, 0xe7, 0xe7, 0x81, 0xff, 217 | 0x9b, 0x87, 0x67, 0x83, 0x39, 0x39, 0x83, 0xff, 218 | 0xcb, 0xa7, 0x03, 0x39, 0x39, 0x39, 0x39, 0xff, 219 | 0xdf, 0xef, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 220 | 0xf7, 0xef, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 221 | 0xc7, 0x93, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 222 | 0xcb, 0xa7, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 223 | 0x93, 0xff, 0x83, 0x39, 0x39, 0x39, 0x83, 0xff, 224 | 0xff, 0xe7, 0xff, 0x81, 0xff, 0xe7, 0xff, 0xff, 225 | 0xff, 0xff, 0x83, 0x31, 0x29, 0x19, 0x83, 0xff, 226 | 0xdf, 0xef, 0x39, 0x39, 0x39, 0x39, 0x81, 0xff, 227 | 0xf7, 0xef, 0x39, 0x39, 0x39, 0x39, 0x81, 0xff, 228 | 0xc7, 0x93, 0xff, 0x39, 0x39, 0x39, 0x81, 0xff, 229 | 0x93, 0xff, 0x39, 0x39, 0x39, 0x39, 0x81, 0xff, 230 | 0xf7, 0xef, 0x39, 0x39, 0x39, 0x81, 0xf9, 0x83, 231 | 0x3f, 0x3f, 0x03, 0x39, 0x39, 0x03, 0x3f, 0x3f, 232 | 0x93, 0xff, 0x39, 0x39, 0x39, 0x81, 0xf9, 0x83 233 | }; 234 | 235 | static const uint8_t* drawColors; 236 | static uint8_t* framebuffer; 237 | 238 | static int w4_min (int a, int b) { 239 | return a < b ? a : b; 240 | } 241 | 242 | static int w4_max (int a, int b) { 243 | return a > b ? a : b; 244 | } 245 | 246 | static void drawPoint (uint8_t color, int x, int y) { 247 | int idx = (WIDTH * y + x) >> 2; 248 | int shift = (x & 0x3) << 1; 249 | int mask = 0x3 << shift; 250 | framebuffer[idx] = (color << shift) | (framebuffer[idx] & ~mask); 251 | } 252 | 253 | static void drawPointUnclipped (uint8_t color, int x, int y) { 254 | if (x >= 0 && x < WIDTH && y >= 0 && y < HEIGHT) { 255 | drawPoint(color, x, y); 256 | } 257 | } 258 | 259 | static void drawHLine (uint8_t color, int startX, int y, int endX) { 260 | int fillEnd = endX - (endX & 3); 261 | int fillStart = w4_min((startX + 3) & ~3, fillEnd); 262 | 263 | if (fillEnd - fillStart > 3) { 264 | for (int xx = startX; xx < fillStart; xx++) { 265 | drawPoint(color, xx, y); 266 | } 267 | 268 | int from = (WIDTH * y + fillStart) >> 2; 269 | int to = (WIDTH * y + fillEnd) >> 2; 270 | uint8_t fillColor = color * 0x55; 271 | 272 | memset(framebuffer+from, fillColor, to-from); 273 | startX = fillEnd; 274 | } 275 | 276 | for (int xx = startX; xx < endX; xx++) { 277 | drawPoint(color, xx, y); 278 | } 279 | } 280 | 281 | static void drawHLineUnclipped (uint8_t color, int startX, int y, int endX) { 282 | if (y >= 0 && y < HEIGHT) { 283 | if (startX < 0) { 284 | startX = 0; 285 | } 286 | if (endX > WIDTH) { 287 | endX = WIDTH; 288 | } 289 | if (startX < endX) { 290 | drawHLine(color, startX, y, endX); 291 | } 292 | } 293 | } 294 | 295 | void w4_framebufferInit (const uint8_t* drawColors_, uint8_t* framebuffer_) { 296 | drawColors = drawColors_; 297 | framebuffer = framebuffer_; 298 | } 299 | 300 | void w4_framebufferClear () { 301 | memset(framebuffer, 0, WIDTH*HEIGHT >> 2); 302 | } 303 | 304 | void w4_framebufferHLine (int x, int y, int len) { 305 | uint8_t dc0 = drawColors[0] & 0xf; 306 | if (dc0 == 0) { 307 | return; 308 | } 309 | 310 | uint8_t strokeColor = (dc0 - 1) & 0x3; 311 | drawHLineUnclipped(strokeColor, x, y, x + len); 312 | } 313 | 314 | void w4_framebufferVLine (int x, int y, int len) { 315 | if (y + len <= 0 || x < 0 || x >= WIDTH) { 316 | return; 317 | } 318 | 319 | uint8_t dc0 = drawColors[0] & 0xf; 320 | if (dc0 == 0) { 321 | return; 322 | } 323 | 324 | int startY = w4_max(0, y); 325 | int endY = w4_min(HEIGHT, y + len); 326 | uint8_t strokeColor = (dc0 - 1) & 0x3; 327 | for (int yy = startY; yy < endY; yy++) { 328 | drawPoint(strokeColor, x, yy); 329 | } 330 | } 331 | 332 | void w4_framebufferRect (int x, int y, int width, int height) { 333 | int startX = w4_max(0, x); 334 | int startY = w4_max(0, y); 335 | int endXUnclamped = x + width; 336 | int endYUnclamped = y + height; 337 | int endX = w4_max(0, w4_min(endXUnclamped, WIDTH)); 338 | int endY = w4_max(0, w4_min(endYUnclamped, HEIGHT)); 339 | 340 | uint8_t dc01 = drawColors[0]; 341 | uint8_t dc0 = dc01 & 0xf; 342 | uint8_t dc1 = (dc01 >> 4) & 0xf; 343 | 344 | if (dc0 != 0) { 345 | uint8_t fillColor = (dc0 - 1) & 0x3; 346 | for (int yy = startY; yy < endY; ++yy) { 347 | drawHLine(fillColor, startX, yy, endX); 348 | } 349 | } 350 | 351 | if (dc1 != 0) { 352 | uint8_t strokeColor = (dc1 - 1) & 0x3; 353 | 354 | // Left edge 355 | if (x >= 0 && x < WIDTH) { 356 | for (int yy = startY; yy < endY; ++yy) { 357 | drawPoint(strokeColor, x, yy); 358 | } 359 | } 360 | 361 | // Right edge 362 | if (endXUnclamped > 0 && endXUnclamped <= WIDTH) { 363 | for (int yy = startY; yy < endY; ++yy) { 364 | drawPoint(strokeColor, endXUnclamped - 1, yy); 365 | } 366 | } 367 | 368 | // Top edge 369 | if (y >= 0 && y < HEIGHT) { 370 | drawHLine(strokeColor, startX, y, endX); 371 | } 372 | 373 | // Bottom edge 374 | if (endYUnclamped > 0 && endYUnclamped <= HEIGHT) { 375 | drawHLine(strokeColor, startX, endYUnclamped - 1, endX); 376 | } 377 | } 378 | } 379 | 380 | // Oval drawing function using a variation on the midpoint algorithm. 381 | // TIC-80's ellipse drawing function used as reference. 382 | // https://github.com/nesbox/TIC-80/blob/main/src/core/draw.c 383 | // 384 | // Javatpoint has a in depth academic explanation that mostly went over my head: 385 | // https://www.javatpoint.com/computer-graphics-midpoint-ellipse-algorithm 386 | // 387 | // Draws the ellipse by "scanning" along the edge in one quadrant, and mirroring 388 | // the movement for the other four quadrants. 389 | // 390 | // There are a lot of details to get correct while implementing this algorithm, 391 | // so ensure the edge cases are covered when changing it. Long, thin ellipses 392 | // are particularly susceptible to being drawn incorrectly. 393 | void w4_framebufferOval (int x, int y, int width, int height) { 394 | uint8_t dc01 = drawColors[0]; 395 | uint8_t dc0 = dc01 & 0xf; 396 | uint8_t dc1 = (dc01 >> 4) & 0xf; 397 | 398 | if (dc1 == 0xf) { 399 | return; 400 | } 401 | 402 | uint8_t strokeColor = (dc1 - 1) & 0x3; 403 | uint8_t fillColor = (dc0 - 1) & 0x3; 404 | 405 | int a = width - 1; 406 | int b = height - 1; 407 | int b1 = b % 2; // Compensates for precision loss when dividing 408 | 409 | int north = y + height / 2; // Precision loss here 410 | int west = x; 411 | int east = x + width - 1; 412 | int south = north - b1; // Compensation here. Moves the bottom line up by 413 | // one (overlapping the top line) for even heights 414 | 415 | // Error increments. Also known as the decision parameters 416 | const int a2 = a * a; 417 | const int b2 = b * b; 418 | 419 | int dx = 4 * (1 - a) * b2; 420 | int dy = 4 * (b1 + 1) * a2; 421 | 422 | // Error of 1 step 423 | int err = dx + dy + b1 * a2; 424 | 425 | a = 8 * a2; 426 | b1 = 8 * b2; 427 | 428 | do { 429 | drawPointUnclipped(strokeColor, east, north); /* I. Quadrant */ 430 | drawPointUnclipped(strokeColor, west, north); /* II. Quadrant */ 431 | drawPointUnclipped(strokeColor, west, south); /* III. Quadrant */ 432 | drawPointUnclipped(strokeColor, east, south); /* IV. Quadrant */ 433 | 434 | const int start = west + 1; 435 | const int len = east - start; 436 | 437 | if (dc0 != 0 && len > 0) { // Only draw fill if the length from west to east is not 0 438 | drawHLineUnclipped(fillColor, start, north, east); /* I and III. Quadrant */ 439 | drawHLineUnclipped(fillColor, start, south, east); /* II and IV. Quadrant */ 440 | } 441 | 442 | const int err2 = 2 * err; 443 | 444 | if (err2 <= dy) { 445 | // Move vertical scan 446 | north += 1; 447 | south -= 1; 448 | dy += a; 449 | err += dy; 450 | } 451 | 452 | if (err2 >= dx || err2 > dy) { 453 | // Move horizontal scan 454 | west += 1; 455 | east -= 1; 456 | dx += b1; 457 | err += dx; 458 | } 459 | } while (west <= east); 460 | 461 | // Make sure north and south have moved the entire way so top/bottom aren't missing 462 | while (north - south < height) { 463 | drawPointUnclipped(strokeColor, west - 1, north); /* II. Quadrant */ 464 | drawPointUnclipped(strokeColor, east + 1, north); /* I. Quadrant */ 465 | north += 1; 466 | drawPointUnclipped(strokeColor, west - 1, south); /* III. Quadrant */ 467 | drawPointUnclipped(strokeColor, east + 1, south); /* IV. Quadrant */ 468 | south -= 1; 469 | } 470 | } 471 | 472 | void w4_framebufferLine (int x1, int y1, int x2, int y2) { 473 | uint8_t dc0 = drawColors[0] & 0xf; 474 | if (dc0 == 0) { 475 | return; 476 | } 477 | uint8_t strokeColor = (dc0 - 1) & 0x3; 478 | 479 | if (y1 > y2) { 480 | int swap = x1; 481 | x1 = x2; 482 | x2 = swap; 483 | 484 | swap = y1; 485 | y1 = y2; 486 | y2 = swap; 487 | } 488 | 489 | int dx = abs(x2 - x1), sx = x1 < x2 ? 1 : -1; 490 | int dy = y2 - y1; 491 | int err = (dx > dy ? dx : -dy) / 2, e2; 492 | 493 | for (;;) { 494 | drawPointUnclipped(strokeColor, x1, y1); 495 | if (x1 == x2 && y1 == y2) { 496 | break; 497 | } 498 | e2 = err; 499 | if (e2 > -dx) { 500 | err -= dy; 501 | x1 += sx; 502 | } 503 | if (e2 < dy) { 504 | err += dx; 505 | y1++; 506 | } 507 | } 508 | } 509 | 510 | void w4_framebufferText (const uint8_t* str, int x, int y) { 511 | for (int currentX = x; *str; ++str) { 512 | if (*str == 10) { 513 | y += 8; 514 | currentX = x; 515 | } else if (*str >= 32 && *str <= 255) { 516 | w4_framebufferBlit(font, currentX, y, 8, 8, 0, (*str - 32) << 3, 8, 517 | false, false, false, false); 518 | currentX += 8; 519 | } else { 520 | currentX += 8; 521 | } 522 | } 523 | } 524 | 525 | void w4_framebufferTextUtf8 (const uint8_t* str, int byteLength, int x, int y) { 526 | for (int currentX = x; byteLength > 0 && *str; ++str, --byteLength) { 527 | if (*str == 10) { 528 | y += 8; 529 | currentX = x; 530 | } else if (*str >= 32 && *str <= 255) { 531 | w4_framebufferBlit(font, currentX, y, 8, 8, 0, (*str - 32) << 3, 8, 532 | false, false, false, false); 533 | currentX += 8; 534 | } else { 535 | currentX += 8; 536 | } 537 | } 538 | } 539 | 540 | void w4_framebufferTextUtf16 (const uint16_t* str, int byteLength, int x, int y) { 541 | for (int currentX = x; byteLength > 0 && *str; ++str, byteLength -= 2) { 542 | uint16_t c = w4_read16LE(str); 543 | if (c == 10) { 544 | y += 8; 545 | currentX = x; 546 | } else if (c >= 32 && c <= 255) { 547 | w4_framebufferBlit(font, currentX, y, 8, 8, 0, (c - 32) << 3, 8, 548 | false, false, false, false); 549 | currentX += 8; 550 | } else { 551 | currentX += 8; 552 | } 553 | } 554 | } 555 | 556 | void w4_framebufferBlit (const uint8_t* sprite, int dstX, int dstY, int width, int height, 557 | int srcX, int srcY, int srcStride, bool bpp2, bool flipX, bool flipY, bool rotate) { 558 | 559 | uint16_t colors = drawColors[0] | (drawColors[1] << 8); 560 | 561 | // Clip rectangle to screen 562 | int clipXMin, clipYMin, clipXMax, clipYMax; 563 | if (rotate) { 564 | flipX = !flipX; 565 | clipXMin = w4_max(0, dstY) - dstY; 566 | clipYMin = w4_max(0, dstX) - dstX; 567 | clipXMax = w4_min(width, HEIGHT - dstY); 568 | clipYMax = w4_min(height, WIDTH - dstX); 569 | } else { 570 | clipXMin = w4_max(0, dstX) - dstX; 571 | clipYMin = w4_max(0, dstY) - dstY; 572 | clipXMax = w4_min(width, WIDTH - dstX); 573 | clipYMax = w4_min(height, HEIGHT - dstY); 574 | } 575 | 576 | // Iterate pixels in rectangle 577 | for (int y = clipYMin; y < clipYMax; y++) { 578 | for (int x = clipXMin; x < clipXMax; x++) { 579 | // Calculate sprite target coords 580 | const int tx = dstX + (rotate ? y : x); 581 | const int ty = dstY + (rotate ? x : y); 582 | 583 | // Calculate sprite source coords 584 | const int sx = srcX + (flipX ? width - x - 1 : x); 585 | const int sy = srcY + (flipY ? height - y - 1 : y); 586 | 587 | // Sample the sprite to get a color index 588 | int colorIdx; 589 | int bitIndex = sy * srcStride + sx; 590 | if (bpp2) { 591 | uint8_t byte = sprite[bitIndex >> 2]; 592 | int shift = 6 - ((bitIndex & 0x03) << 1); 593 | colorIdx = (byte >> shift) & 0x3; 594 | 595 | } else { 596 | uint8_t byte = sprite[bitIndex >> 3]; 597 | int shift = 7 - (bitIndex & 0x07); 598 | colorIdx = (byte >> shift) & 0x1; 599 | } 600 | 601 | // Get the final color using the drawColors indirection 602 | uint8_t dc = (colors >> (colorIdx << 2)) & 0x0f; 603 | if (dc != 0) { 604 | drawPoint((dc - 1) & 0x03, tx, ty); 605 | } 606 | } 607 | } 608 | } 609 | -------------------------------------------------------------------------------- /main/framebuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef FRAMEBUFFER_H 2 | #define FRAMEBUFFER_H 3 | 4 | #include 5 | #include 6 | 7 | #define WIDTH 160 8 | #define HEIGHT 160 9 | 10 | void w4_framebufferInit (const uint8_t* drawColors, uint8_t* framebuffer); 11 | 12 | void w4_framebufferClear (); 13 | 14 | void w4_framebufferHLine (int x, int y, int length); 15 | 16 | void w4_framebufferVLine (int x, int y, int length); 17 | 18 | void w4_framebufferRect (int x, int y, int width, int height); 19 | 20 | void w4_framebufferLine (int x1, int y1, int x2, int y2); 21 | 22 | void w4_framebufferOval (int x, int y, int width, int height); 23 | 24 | void w4_framebufferText (const uint8_t* str, int x, int y); 25 | void w4_framebufferTextUtf8 (const uint8_t* str, int byteLength, int x, int y); 26 | void w4_framebufferTextUtf16 (const uint16_t* str, int byteLength, int x, int y); 27 | 28 | void w4_framebufferBlit (const uint8_t* sprite, int dstX, int dstY, int width, int height, 29 | int srcX, int srcY, int srcStride, bool bpp2, bool flipX, bool flipY, bool rotate); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/button: "^3.3.1" 4 | wasm-micro-runtime: 5 | version: "^2" 6 | override_path: "../vendor/wasm-micro-runtime" 7 | idf: 8 | version: ">=4.4" -------------------------------------------------------------------------------- /main/lcd.h: -------------------------------------------------------------------------------- 1 | #ifndef LCD_H 2 | #define LCD_H 3 | 4 | #include "st7789.h" 5 | 6 | extern TFT_t dev; 7 | extern uint16_t last[160*160]; 8 | 9 | void ST7789(void *pvParameters); 10 | TickType_t FillTest(TFT_t * dev, int width, int height); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /main/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sdkconfig.h" 4 | #include "freertos/FreeRTOS.h" 5 | #include "freertos/task.h" 6 | #include "esp_chip_info.h" 7 | #include "esp_flash.h" 8 | #include "esp_system.h" 9 | #include "esp_log.h" 10 | #include "st7789.h" 11 | #include 12 | 13 | #include "runtime.h" 14 | #include "wasm0.h" 15 | #include "window.h" 16 | #include "util.h" 17 | #include "lcd.h" 18 | #include 19 | #include 20 | #include "wamr.h" 21 | #include "control.h" 22 | 23 | 24 | #define INTERVAL 400 25 | #define WAIT vTaskDelay(INTERVAL) 26 | 27 | #define IWASM_MAIN_STACK_SIZE 5120 28 | 29 | #define FATAL(msg, ...) { printf("Fatal: " msg "\n", ##__VA_ARGS__); return; } 30 | 31 | 32 | extern unsigned char __game_card[]; 33 | extern unsigned int __game_card_len; 34 | 35 | void w4_windowBoot (); 36 | 37 | uint16_t last[160*160]; 38 | 39 | extern void* wamr_get_phy_memory(); 40 | 41 | void run_wasm4(void *pvParameters) { 42 | w4_Disk disk = {0}; 43 | uint8_t* memory = wamr_get_phy_memory(); 44 | w4_runtimeInit(memory, &disk); 45 | // w4_wasmLoadModule(__tinypong_wasm, len); 46 | w4_windowBoot(); 47 | } 48 | 49 | void app_main(void) 50 | { 51 | /* Print chip information */ 52 | esp_chip_info_t chip_info; 53 | uint32_t flash_size; 54 | esp_chip_info(&chip_info); 55 | printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", 56 | CONFIG_IDF_TARGET, 57 | chip_info.cores, 58 | (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "", 59 | (chip_info.features & CHIP_FEATURE_BT) ? "BT" : "", 60 | (chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "", 61 | (chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : ""); 62 | 63 | unsigned major_rev = chip_info.revision / 100; 64 | unsigned minor_rev = chip_info.revision % 100; 65 | printf("silicon revision v%d.%d, ", major_rev, minor_rev); 66 | if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { 67 | printf("Get flash size failed"); 68 | return; 69 | } 70 | 71 | printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024), 72 | (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); 73 | printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); 74 | init_button(); 75 | nvs_flash_init(); 76 | ST7789(NULL); 77 | FillTest(&dev, CONFIG_WIDTH, CONFIG_HEIGHT); 78 | pthread_t t; 79 | int res; 80 | pthread_attr_t tattr; 81 | pthread_attr_init(&tattr); 82 | pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE); 83 | pthread_attr_setstacksize(&tattr, IWASM_MAIN_STACK_SIZE); 84 | res = pthread_create(&t, &tattr, init_wamr, (void *)NULL); 85 | assert(res == 0); 86 | res = pthread_join(t, NULL); 87 | assert(res == 0); 88 | xTaskCreate(run_wasm4, "wasm4", 1024*6, NULL, 2, NULL); 89 | while (1) { 90 | printf("Main loop is running\n"); 91 | vTaskDelay(2000 / portTICK_PERIOD_MS); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /main/runtime.c: -------------------------------------------------------------------------------- 1 | #include "runtime.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "apu.h" 7 | #include "framebuffer.h" 8 | #include "util.h" 9 | #include "wasm0.h" 10 | #include "window.h" 11 | 12 | #define WIDTH 160 13 | #define HEIGHT 160 14 | 15 | #define SYSTEM_PRESERVE_FRAMEBUFFER 1 16 | 17 | #pragma pack(1) 18 | typedef struct { 19 | uint8_t _padding[4]; 20 | uint32_t palette[4]; 21 | uint8_t drawColors[2]; 22 | uint8_t gamepads[4]; 23 | int16_t mouseX; 24 | int16_t mouseY; 25 | uint8_t mouseButtons; 26 | uint8_t systemFlags; 27 | uint8_t _reserved[128]; 28 | uint8_t framebuffer[WIDTH*HEIGHT>>2]; 29 | uint8_t _user[58976]; 30 | } Memory; 31 | #pragma pack() 32 | 33 | typedef struct { 34 | Memory memory; 35 | w4_Disk disk; 36 | bool firstFrame; 37 | } SerializedState; 38 | 39 | static Memory* memory; 40 | static w4_Disk* disk; 41 | static bool firstFrame; 42 | 43 | void w4_runtimeInit (uint8_t* memoryBytes, w4_Disk* diskBytes) { 44 | memory = (Memory*)memoryBytes; 45 | disk = diskBytes; 46 | firstFrame = true; 47 | 48 | // Set memory to initial state 49 | memset(memory, 0, 6560); 50 | w4_write32LE(&memory->palette[0], 0xe0f8cf); 51 | w4_write32LE(&memory->palette[1], 0x86c06c); 52 | w4_write32LE(&memory->palette[2], 0x306850); 53 | w4_write32LE(&memory->palette[3], 0x071821); 54 | memory->drawColors[0] = 0x03; 55 | memory->drawColors[1] = 0x12; 56 | w4_write16LE(&memory->mouseX, 0x7fff); 57 | w4_write16LE(&memory->mouseY, 0x7fff); 58 | 59 | w4_apuInit(); 60 | w4_framebufferInit(memory->drawColors, memory->framebuffer); 61 | } 62 | 63 | void w4_runtimeSetGamepad (int idx, uint8_t gamepad) { 64 | memory->gamepads[idx] = gamepad; 65 | } 66 | 67 | void w4_runtimeSetMouse (int16_t x, int16_t y, uint8_t buttons) { 68 | w4_write16LE(&memory->mouseX, x); 69 | w4_write16LE(&memory->mouseY, y); 70 | memory->mouseButtons = buttons; 71 | } 72 | 73 | void w4_runtimeBlit (const uint8_t* sprite, int x, int y, int width, int height, int flags) { 74 | // printf("blit: %p, %d, %d, %d, %d, %d\n", sprite, x, y, width, height, flags); 75 | 76 | w4_runtimeBlitSub(sprite, x, y, width, height, 0, 0, width, flags); 77 | } 78 | 79 | void w4_runtimeBlitSub (const uint8_t* sprite, int x, int y, int width, int height, int srcX, int srcY, int stride, int flags) { 80 | // printf("blitSub: %p, %d, %d, %d, %d, %d, %d, %d, %d\n", sprite, x, y, width, height, srcX, srcY, stride, flags); 81 | 82 | bool bpp2 = (flags & 1); 83 | bool flipX = (flags & 2); 84 | bool flipY = (flags & 4); 85 | bool rotate = (flags & 8); 86 | w4_framebufferBlit(sprite, x, y, width, height, srcX, srcY, stride, bpp2, flipX, flipY, rotate); 87 | } 88 | 89 | void w4_runtimeLine (int x1, int y1, int x2, int y2) { 90 | // printf("line: %d, %d, %d, %d\n", x1, y1, x2, y2); 91 | w4_framebufferLine(x1, y1, x2, y2); 92 | } 93 | 94 | void w4_runtimeHLine (int x, int y, int len) { 95 | // printf("hline: %d, %d, %d\n", x, y, len); 96 | w4_framebufferHLine(x, y, len); 97 | } 98 | 99 | void w4_runtimeVLine (int x, int y, int len) { 100 | // printf("vline: %d, %d, %d\n", x, y, len); 101 | w4_framebufferVLine(x, y, len); 102 | } 103 | 104 | void w4_runtimeOval (int x, int y, int width, int height) { 105 | // printf("oval: %d, %d, %d, %d\n", x, y, width, height); 106 | w4_framebufferOval(x, y, width, height); 107 | } 108 | 109 | void w4_runtimeRect (int x, int y, int width, int height) { 110 | // printf("rect: %d, %d, %d, %d\n", x, y, width, height); 111 | w4_framebufferRect(x, y, width, height); 112 | } 113 | 114 | void w4_runtimeText (const uint8_t* str, int x, int y) { 115 | // printf("text: %s, %d, %d\n", str, x, y); 116 | w4_framebufferText(str, x, y); 117 | } 118 | 119 | void w4_runtimeTextUtf8 (const uint8_t* str, int byteLength, int x, int y) { 120 | // printf("textUtf8: %p, %d, %d, %d\n", str, byteLength, x, y); 121 | w4_framebufferTextUtf8(str, byteLength, x, y); 122 | } 123 | 124 | void w4_runtimeTextUtf16 (const uint16_t* str, int byteLength, int x, int y) { 125 | // printf("textUtf16: %p, %d, %d, %d\n", str, byteLength, x, y); 126 | w4_framebufferTextUtf16(str, byteLength, x, y); 127 | } 128 | 129 | void w4_runtimeTone (int frequency, int duration, int volume, int flags) { 130 | // printf("tone: %d, %d, %d, %d\n", frequency, duration, volume, flags); 131 | w4_apuTone(frequency, duration, volume, flags); 132 | } 133 | 134 | int w4_runtimeDiskr (uint8_t* dest, int size) { 135 | if (!disk) { 136 | return 0; 137 | } 138 | 139 | if (size > disk->size) { 140 | size = disk->size; 141 | } 142 | memcpy(dest, disk->data, size); 143 | return size; 144 | } 145 | 146 | int w4_runtimeDiskw (const uint8_t* src, int size) { 147 | if (!disk) { 148 | return 0; 149 | } 150 | 151 | if (size > 1024) { 152 | size = 1024; 153 | } 154 | disk->size = size; 155 | memcpy(disk->data, src, size); 156 | return size; 157 | } 158 | 159 | void w4_runtimeTrace (const uint8_t* str) { 160 | puts(str); 161 | } 162 | 163 | void w4_runtimeTraceUtf8 (const uint8_t* str, int byteLength) { 164 | printf("%.*s\n", byteLength, str); 165 | } 166 | 167 | void w4_runtimeTraceUtf16 (const uint16_t* str, int byteLength) { 168 | printf("TODO: traceUtf16: %p, %d\n", str, byteLength); 169 | } 170 | 171 | void w4_runtimeTracef (const uint8_t* str, const void* stack) { 172 | const uint8_t* argPtr = stack; 173 | uint32_t strPtr; 174 | for (; *str != 0; ++str) { 175 | if (*str == '%') { 176 | const uint8_t sym = *(++str); 177 | switch (sym) { 178 | case 0: 179 | return; // Interrupted 180 | case '%': 181 | putc('%', stdout); 182 | break; 183 | case 'c': 184 | putc(*(char*)argPtr, stdout); 185 | argPtr += 4; 186 | break; 187 | case 'd': 188 | printf("%d", *(int32_t*)argPtr); 189 | argPtr += 4; 190 | break; 191 | case 'x': 192 | printf("%x", *(uint32_t*)argPtr); 193 | argPtr += 4; 194 | break; 195 | case 's': 196 | strPtr = *(uint32_t*)argPtr; 197 | argPtr += 4; 198 | if (strPtr > 0 && strPtr < sizeof(*memory)) { 199 | printf("%.*s", (int)(sizeof(*memory) - strPtr), (char*)memory + strPtr); 200 | } else { 201 | printf(""); 202 | } 203 | break; 204 | case 'f': 205 | printf("%lg", *(double*)argPtr); 206 | argPtr += 8; 207 | break; 208 | default: 209 | printf("%%%c", sym); 210 | } 211 | } else { 212 | putc(*str, stdout); 213 | } 214 | } 215 | putc('\n', stdout); 216 | } 217 | 218 | void w4_runtimeUpdate () { 219 | if (firstFrame) { 220 | firstFrame = false; 221 | w4_wasmCallStart(); 222 | } else if (!(memory->systemFlags & SYSTEM_PRESERVE_FRAMEBUFFER)) { 223 | w4_framebufferClear(); 224 | } 225 | w4_wasmCallUpdate(); 226 | w4_apuTick(); 227 | uint32_t palette[4] = { 228 | w4_read32LE(&memory->palette[0]), 229 | w4_read32LE(&memory->palette[1]), 230 | w4_read32LE(&memory->palette[2]), 231 | w4_read32LE(&memory->palette[3]), 232 | }; 233 | w4_windowComposite(palette, memory->framebuffer); 234 | } 235 | 236 | int w4_runtimeSerializeSize () { 237 | return sizeof(SerializedState); 238 | } 239 | 240 | void w4_runtimeSerialize (void* dest) { 241 | SerializedState* state = dest; 242 | memcpy(&state->memory, memory, 1 << 16); 243 | memcpy(&state->disk, disk, sizeof(w4_Disk)); 244 | state->firstFrame = firstFrame; 245 | } 246 | 247 | void w4_runtimeUnserialize (const void* src) { 248 | const SerializedState* state = src; 249 | memcpy(memory, &state->memory, 1 << 16); 250 | memcpy(disk, &state->disk, sizeof(w4_Disk)); 251 | firstFrame = state->firstFrame; 252 | } 253 | -------------------------------------------------------------------------------- /main/runtime.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNTIME_H 2 | #define RUNTIME_H 3 | 4 | #include 5 | 6 | #define W4_BUTTON_X 1 7 | #define W4_BUTTON_Z 2 8 | // #define W4_BUTTON_RESERVED 4 9 | // #define W4_BUTTON_RESERVED 8 10 | #define W4_BUTTON_LEFT 16 11 | #define W4_BUTTON_RIGHT 32 12 | #define W4_BUTTON_UP 64 13 | #define W4_BUTTON_DOWN 128 14 | 15 | #define W4_MOUSE_LEFT 1 16 | #define W4_MOUSE_RIGHT 2 17 | #define W4_MOUSE_MIDDLE 4 18 | 19 | typedef struct { 20 | uint16_t size; 21 | uint8_t data[1024]; 22 | } w4_Disk; 23 | 24 | void w4_runtimeInit (uint8_t* memory, w4_Disk* disk); 25 | 26 | void w4_runtimeSetGamepad (int idx, uint8_t gamepad); 27 | void w4_runtimeSetMouse (int16_t x, int16_t y, uint8_t buttons); 28 | 29 | void w4_runtimeBlit (const uint8_t* sprite, int x, int y, int width, int height, int flags); 30 | void w4_runtimeBlitSub (const uint8_t* sprite, int x, int y, int width, int height, int srcX, int srcY, int stride, int flags); 31 | void w4_runtimeLine (int x1, int y1, int x2, int y2); 32 | void w4_runtimeHLine (int x, int y, int len); 33 | void w4_runtimeVLine (int x, int y, int len); 34 | void w4_runtimeOval (int x, int y, int width, int height); 35 | void w4_runtimeRect (int x, int y, int width, int height); 36 | void w4_runtimeText (const uint8_t* str, int x, int y); 37 | void w4_runtimeTextUtf8 (const uint8_t* str, int byteLength, int x, int y); 38 | void w4_runtimeTextUtf16 (const uint16_t* str, int byteLength, int x, int y); 39 | 40 | void w4_runtimeTone (int frequency, int duration, int volume, int flags); 41 | 42 | int w4_runtimeDiskr (uint8_t* dest, int size); 43 | int w4_runtimeDiskw (const uint8_t* src, int size); 44 | 45 | void w4_runtimeTrace (const uint8_t* str); 46 | void w4_runtimeTraceUtf8 (const uint8_t* str, int byteLength); 47 | void w4_runtimeTraceUtf16 (const uint16_t* str, int byteLength); 48 | void w4_runtimeTracef (const uint8_t* str, const void* stack); 49 | 50 | void w4_runtimeUpdate (); 51 | 52 | int w4_runtimeSerializeSize (); 53 | void w4_runtimeSerialize (void* dest); 54 | void w4_runtimeUnserialize (const void* src); 55 | 56 | #endif -------------------------------------------------------------------------------- /main/strnlen.c: -------------------------------------------------------------------------------- 1 | // 2 | // A strnlen polyfill for some platforms where it's missing (OSX PPC, maybe others) 3 | 4 | #include 5 | 6 | size_t strnlen (const char *s, size_t maxlen) { 7 | size_t i; 8 | for (i = 0; i < maxlen; ++i) 9 | if (s[i] == '\0') 10 | break; 11 | return i; 12 | } 13 | -------------------------------------------------------------------------------- /main/util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | #include 3 | #include 4 | 5 | #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 6 | # define W4_BIG_ENDIAN 7 | #endif 8 | 9 | void* xmalloc(size_t size) { 10 | void* ptr = malloc(size); 11 | if (ptr == NULL) { 12 | fputs("Allocation failed.\n", stderr); 13 | abort(); 14 | } 15 | return ptr; 16 | } 17 | 18 | void* xrealloc(void* ptr, size_t size) { 19 | ptr = realloc(ptr, size); 20 | if (ptr == NULL) { 21 | fputs("Allocation failed.\n", stderr); 22 | abort(); 23 | } 24 | } 25 | 26 | uint16_t bswap16(uint16_t x) { 27 | return ((( x >> 8 ) & 0xffu ) | (( x & 0xffu ) << 8 )); 28 | } 29 | 30 | uint32_t bswap32(uint32_t x) { 31 | return ((( x & 0xff000000u ) >> 24 ) | 32 | (( x & 0x00ff0000u ) >> 8 ) | 33 | (( x & 0x0000ff00u ) << 8 ) | 34 | (( x & 0x000000ffu ) << 24 )); 35 | } 36 | 37 | uint16_t w4_read16LE (const uint16_t* ptr) { 38 | #ifdef W4_BIG_ENDIAN 39 | return bswap16(*ptr); 40 | #else 41 | return *ptr; 42 | #endif 43 | } 44 | 45 | uint32_t w4_read32LE (const uint32_t* ptr) { 46 | #ifdef W4_BIG_ENDIAN 47 | return bswap32(*ptr); 48 | #else 49 | return *ptr; 50 | #endif 51 | } 52 | 53 | void w4_write16LE (uint16_t* ptr, uint16_t value) { 54 | #ifdef W4_BIG_ENDIAN 55 | *ptr = bswap16(value); 56 | #else 57 | *ptr = value; 58 | #endif 59 | } 60 | 61 | void w4_write32LE (uint32_t* ptr, uint32_t value) { 62 | #ifdef W4_BIG_ENDIAN 63 | *ptr = bswap32(value); 64 | #else 65 | *ptr = value; 66 | #endif 67 | } 68 | -------------------------------------------------------------------------------- /main/util.h: -------------------------------------------------------------------------------- 1 | #ifndef UTIL_H 2 | #define UTIL_H 3 | 4 | #include 5 | #include 6 | 7 | // Safe versions of malloc and realloc that abort on failure, and never return null. 8 | void* xmalloc(size_t size); 9 | void* xrealloc(void* ptr, size_t size); 10 | 11 | uint16_t w4_read16LE (const uint16_t* ptr); 12 | uint32_t w4_read32LE (const uint32_t* ptr); 13 | 14 | void w4_write16LE (uint16_t* ptr, uint16_t value); 15 | void w4_write32LE (uint32_t* ptr, uint32_t value); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /main/wamr.c: -------------------------------------------------------------------------------- 1 | #include "wamr.h" 2 | #include "runtime.h" 3 | 4 | void wrap_w4_runtimeBlit(wasm_exec_env_t exec_env, const uint8_t* sprite, int x, int y, int width, int height, int flags) { 5 | // printf("Call wrap_w4_runtimeBlit\n"); 6 | w4_runtimeBlit(sprite, x, y, width, height, flags); 7 | } 8 | void wrap_w4_runtimeBlitSub(wasm_exec_env_t exec_env, const uint8_t* sprite, int x, int y, int width, int height, int srcX, int srcY, int stride, int flags) { 9 | // printf("Call wrap_w4_runtimeBlitSub\n"); 10 | w4_runtimeBlitSub(sprite, x, y, width, height, srcX, srcY, stride, flags); 11 | } 12 | void wrap_w4_runtimeLine(wasm_exec_env_t exec_env, int x1, int y1, int x2, int y2) { 13 | // printf("Call wrap_w4_runtimeLine\n"); 14 | w4_runtimeLine(x1, y1, x2, y2); 15 | } 16 | void wrap_w4_runtimeHLine(wasm_exec_env_t exec_env, int x, int y, int len) { 17 | // printf("Call wrap_w4_runtimeHLine\n"); 18 | w4_runtimeHLine(x, y, len); 19 | } 20 | void wrap_w4_runtimeVLine(wasm_exec_env_t exec_env, int x, int y, int len) { 21 | // printf("Call wrap_w4_runtimeVLine\n"); 22 | w4_runtimeVLine(x, y, len); 23 | } 24 | void wrap_w4_runtimeOval(wasm_exec_env_t exec_env, int x, int y, int width, int height) { 25 | // printf("Call wrap_w4_runtimeOval\n"); 26 | w4_runtimeOval(x, y, width, height); 27 | } 28 | void wrap_w4_runtimeRect(wasm_exec_env_t exec_env, int x, int y, int width, int height) { 29 | // printf("Call wrap_w4_runtimeRect\n"); 30 | w4_runtimeRect(x, y, width, height); 31 | } 32 | void wrap_w4_runtimeText(wasm_exec_env_t exec_env, const uint8_t* str, int x, int y) { 33 | // printf("Call wrap_w4_runtimeText\n"); 34 | w4_runtimeText(str, x, y); 35 | } 36 | void wrap_w4_runtimeTextUtf8(wasm_exec_env_t exec_env, const uint8_t* str, int byteLength, int x, int y) { 37 | // printf("Call wrap_w4_runtimeTextUtf8\n"); 38 | w4_runtimeTextUtf8(str, byteLength, x, y); 39 | } 40 | void wrap_w4_runtimeTextUtf16(wasm_exec_env_t exec_env, const uint16_t* str, int byteLength, int x, int y) { 41 | // printf("Call wrap_w4_runtimeTextUtf16\n"); 42 | w4_runtimeTextUtf16(str, byteLength, x, y); 43 | } 44 | void wrap_w4_runtimeTone(wasm_exec_env_t exec_env, int frequency, int duration, int volume, int flags) { 45 | // printf("Call wrap_w4_runtimeTone\n"); 46 | w4_runtimeTone(frequency, duration, volume, flags); 47 | } 48 | int wrap_w4_runtimeDiskr(wasm_exec_env_t exec_env, uint8_t* dest, int size) { 49 | // printf("Call wrap_w4_runtimeDiskr\n"); 50 | return w4_runtimeDiskr(dest, size); 51 | } 52 | int wrap_w4_runtimeDiskw(wasm_exec_env_t exec_env, const uint8_t* src, int size) { 53 | // printf("Call wrap_w4_runtimeDiskw\n"); 54 | return w4_runtimeDiskw(src, size); 55 | } 56 | void wrap_w4_runtimeTrace(wasm_exec_env_t exec_env, const uint8_t* str) { 57 | // printf("Call wrap_w4_runtimeTrace\n"); 58 | w4_runtimeTrace(str); 59 | } 60 | void wrap_w4_runtimeTraceUtf8(wasm_exec_env_t exec_env, const uint8_t* str, int byteLength) { 61 | // printf("Call wrap_w4_runtimeTraceUtf8\n"); 62 | w4_runtimeTraceUtf8(str, byteLength); 63 | } 64 | void wrap_w4_runtimeTraceUtf16(wasm_exec_env_t exec_env, const uint16_t* str, int byteLength) { 65 | // printf("Call wrap_w4_runtimeTraceUtf16\n"); 66 | w4_runtimeTraceUtf16(str, byteLength); 67 | } 68 | void wrap_w4_runtimeTracef(wasm_exec_env_t exec_env, const uint8_t* str, const void* stack) { 69 | // printf("Call wrap_w4_runtimeTracef\n"); 70 | w4_runtimeTracef(str, stack); 71 | } 72 | 73 | void just_print_int(wasm_exec_env_t exec_env, int a) { 74 | printf("JUST PRINT INT %d\n", a); 75 | } 76 | 77 | static NativeSymbol native_symbols[] = 78 | { 79 | { 80 | "just_print_int", 81 | just_print_int, 82 | "(i)" 83 | }, 84 | { 85 | "blit", 86 | wrap_w4_runtimeBlit, 87 | "(*iiiii)" 88 | }, 89 | { 90 | "blitSub", 91 | wrap_w4_runtimeBlitSub, 92 | "(*iiiiiiii)" 93 | }, 94 | { 95 | "line", 96 | wrap_w4_runtimeLine, 97 | "(iiii)" 98 | }, 99 | { 100 | "hline", 101 | wrap_w4_runtimeHLine, 102 | "(iii)" 103 | }, 104 | { 105 | "vline", 106 | wrap_w4_runtimeVLine, 107 | "(iii)" 108 | }, 109 | { 110 | "oval", 111 | wrap_w4_runtimeOval, 112 | "(iiii)" 113 | }, 114 | { 115 | "rect", 116 | wrap_w4_runtimeRect, 117 | "(iiii)" 118 | }, 119 | { 120 | "text", 121 | wrap_w4_runtimeText, 122 | "(*ii)" 123 | }, 124 | 125 | { 126 | "textUtf8", 127 | wrap_w4_runtimeTextUtf8, 128 | "(iiii)" 129 | }, 130 | { 131 | "textUtf16", 132 | wrap_w4_runtimeTextUtf16, 133 | "(iiii)" 134 | }, 135 | 136 | { 137 | "tone", 138 | wrap_w4_runtimeTone, 139 | "(iiii)" 140 | }, 141 | 142 | { 143 | "diskr", 144 | wrap_w4_runtimeDiskr, 145 | "(ii)i" 146 | }, 147 | { 148 | "diskw", 149 | wrap_w4_runtimeDiskw, 150 | "(ii)i" 151 | }, 152 | 153 | { 154 | "trace", 155 | wrap_w4_runtimeTrace, 156 | "(i)" 157 | }, 158 | 159 | { 160 | "traceUtf8", 161 | wrap_w4_runtimeTraceUtf8, 162 | "(ii)" 163 | }, 164 | { 165 | "traceUtf16", 166 | wrap_w4_runtimeTraceUtf16, 167 | "(ii)" 168 | }, 169 | { 170 | "tracef", 171 | wrap_w4_runtimeTracef, 172 | "(ii)" 173 | }, 174 | }; 175 | 176 | extern unsigned char __game_card[]; 177 | extern unsigned int __game_card_len; 178 | 179 | wasm_module_t wasm_module = NULL; 180 | wasm_module_inst_t wasm_module_inst = NULL; 181 | wasm_function_inst_t start = NULL; 182 | wasm_function_inst_t update = NULL; 183 | wasm_exec_env_t exec_env = NULL; 184 | wasm_exec_env_t exec_env2 = NULL; 185 | 186 | extern void run_wasm4(void *pvParameters); 187 | 188 | void load_tinypong() { 189 | char error_buf[128]; 190 | wasm_module = wasm_runtime_load(__game_card, __game_card_len, error_buf, sizeof(error_buf)); 191 | if (!wasm_module) { 192 | printf("Failed to load wasm module: %s\n", error_buf); 193 | return; 194 | } 195 | 196 | printf("Instantiate the wasm module\n"); 197 | wasm_module_inst = wasm_runtime_instantiate(wasm_module, 16 * 1024, 64 * 1024, error_buf, sizeof(error_buf)); 198 | if (!wasm_module_inst) { 199 | printf("Failed to instantiate wasm module: %s\n", error_buf); 200 | wasm_runtime_unload(wasm_module); 201 | return; 202 | } 203 | 204 | start = wasm_runtime_lookup_function(wasm_module_inst, "start"); 205 | printf("start: %p\n", start); 206 | 207 | update = wasm_runtime_lookup_function(wasm_module_inst, "update"); 208 | printf("update: %p\n", update); 209 | 210 | 211 | exec_env = wasm_runtime_create_exec_env(wasm_module_inst, 2 * 1024); 212 | } 213 | 214 | void init_wamr() { 215 | /* Setup variables for instantiating and running the wasm module */ 216 | 217 | char error_buf[128]; 218 | RuntimeInitArgs init_args; 219 | 220 | /* Configure memory allocation */ 221 | memset(&init_args, 0, sizeof(RuntimeInitArgs)); 222 | init_args.mem_alloc_type = Alloc_With_Allocator; 223 | init_args.mem_alloc_option.allocator.malloc_func = (void *)os_malloc; 224 | init_args.mem_alloc_option.allocator.realloc_func = (void *)os_realloc; 225 | init_args.mem_alloc_option.allocator.free_func = (void *)os_free; 226 | 227 | init_args.native_module_name = "env"; 228 | init_args.native_symbols = native_symbols; 229 | init_args.n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol); 230 | 231 | heap_caps_print_heap_info(MALLOC_CAP_8BIT); 232 | 233 | printf("Initialize WASM runtime\n"); 234 | /* Initialize runtime environment */ 235 | if (!wasm_runtime_full_init(&init_args)) { 236 | printf("Init runtime failed.\n"); 237 | return; 238 | } 239 | 240 | printf("Load the wasm module from memory\n"); 241 | printf("tinywasm: %p, len: %d\n", __game_card, __game_card_len); 242 | int count = 0; 243 | printf("count: %d\n", count); 244 | printf("memory test done\n"); 245 | heap_caps_print_heap_info(MALLOC_CAP_8BIT); 246 | 247 | load_tinypong(); 248 | 249 | run_wasm4(NULL); 250 | 251 | /* Clean up */ 252 | // wasm_runtime_deinstantiate(wasm_module_inst); 253 | // wasm_runtime_unload(wasm_module); 254 | // wasm_runtime_destroy(); 255 | // printf("WASM runtime destroyed.\n"); 256 | } 257 | 258 | void* wamr_get_phy_memory() { 259 | return wasm_runtime_addr_app_to_native(wasm_module_inst, 0); 260 | } 261 | 262 | void w4_wasmCallStart () { 263 | if (start) { 264 | printf("Call start %p\n", start); 265 | wasm_runtime_call_wasm(exec_env, start, 0, NULL); 266 | } 267 | } 268 | 269 | void w4_wasmCallUpdate () { 270 | update = wasm_runtime_lookup_function(wasm_module_inst, "update"); 271 | if (!exec_env2) { 272 | exec_env2 = wasm_runtime_create_exec_env(wasm_module_inst, 10 * 1024); 273 | } 274 | wasm_runtime_call_wasm(exec_env2, update, 0, NULL); 275 | } -------------------------------------------------------------------------------- /main/wamr.h: -------------------------------------------------------------------------------- 1 | #ifndef WAMR_H 2 | #define WAMR_H 3 | 4 | #include "wasm_export.h" 5 | #include "bh_platform.h" 6 | 7 | void init_wamr(); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /main/wasm0.h: -------------------------------------------------------------------------------- 1 | #ifndef WASM0_H 2 | #define WASM0_H 3 | 4 | #include 5 | 6 | uint8_t* w4_wasmInit (); 7 | void w4_wasmDestroy (); 8 | 9 | void w4_wasmLoadModule (const uint8_t* wasmBuffer, int byteLength); 10 | 11 | void w4_wasmCallStart (); 12 | void w4_wasmCallUpdate (); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /main/window.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOW_H 2 | #define WINDOW_H 3 | 4 | #include 5 | 6 | void w4_windowComposite (const uint32_t* palette, const uint8_t* framebuffer); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /sdkconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file. DO NOT EDIT. 3 | # Espressif IoT Development Framework (ESP-IDF) 5.3.0 Project Configuration 4 | # 5 | CONFIG_SOC_ADC_SUPPORTED=y 6 | CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y 7 | CONFIG_SOC_UART_SUPPORTED=y 8 | CONFIG_SOC_GDMA_SUPPORTED=y 9 | CONFIG_SOC_AHB_GDMA_SUPPORTED=y 10 | CONFIG_SOC_GPTIMER_SUPPORTED=y 11 | CONFIG_SOC_PCNT_SUPPORTED=y 12 | CONFIG_SOC_MCPWM_SUPPORTED=y 13 | CONFIG_SOC_TWAI_SUPPORTED=y 14 | CONFIG_SOC_ETM_SUPPORTED=y 15 | CONFIG_SOC_PARLIO_SUPPORTED=y 16 | CONFIG_SOC_BT_SUPPORTED=y 17 | CONFIG_SOC_IEEE802154_SUPPORTED=y 18 | CONFIG_SOC_ASYNC_MEMCPY_SUPPORTED=y 19 | CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y 20 | CONFIG_SOC_TEMP_SENSOR_SUPPORTED=y 21 | CONFIG_SOC_PHY_SUPPORTED=y 22 | CONFIG_SOC_WIFI_SUPPORTED=y 23 | CONFIG_SOC_SUPPORTS_SECURE_DL_MODE=y 24 | CONFIG_SOC_ULP_SUPPORTED=y 25 | CONFIG_SOC_LP_CORE_SUPPORTED=y 26 | CONFIG_SOC_EFUSE_KEY_PURPOSE_FIELD=y 27 | CONFIG_SOC_EFUSE_SUPPORTED=y 28 | CONFIG_SOC_RTC_FAST_MEM_SUPPORTED=y 29 | CONFIG_SOC_RTC_MEM_SUPPORTED=y 30 | CONFIG_SOC_I2S_SUPPORTED=y 31 | CONFIG_SOC_RMT_SUPPORTED=y 32 | CONFIG_SOC_SDM_SUPPORTED=y 33 | CONFIG_SOC_GPSPI_SUPPORTED=y 34 | CONFIG_SOC_LEDC_SUPPORTED=y 35 | CONFIG_SOC_I2C_SUPPORTED=y 36 | CONFIG_SOC_SYSTIMER_SUPPORTED=y 37 | CONFIG_SOC_SUPPORT_COEXISTENCE=y 38 | CONFIG_SOC_AES_SUPPORTED=y 39 | CONFIG_SOC_MPI_SUPPORTED=y 40 | CONFIG_SOC_SHA_SUPPORTED=y 41 | CONFIG_SOC_HMAC_SUPPORTED=y 42 | CONFIG_SOC_DIG_SIGN_SUPPORTED=y 43 | CONFIG_SOC_ECC_SUPPORTED=y 44 | CONFIG_SOC_FLASH_ENC_SUPPORTED=y 45 | CONFIG_SOC_SECURE_BOOT_SUPPORTED=y 46 | CONFIG_SOC_SDIO_SLAVE_SUPPORTED=y 47 | CONFIG_SOC_BOD_SUPPORTED=y 48 | CONFIG_SOC_APM_SUPPORTED=y 49 | CONFIG_SOC_PMU_SUPPORTED=y 50 | CONFIG_SOC_PAU_SUPPORTED=y 51 | CONFIG_SOC_LP_TIMER_SUPPORTED=y 52 | CONFIG_SOC_LP_AON_SUPPORTED=y 53 | CONFIG_SOC_LP_PERIPHERALS_SUPPORTED=y 54 | CONFIG_SOC_LP_I2C_SUPPORTED=y 55 | CONFIG_SOC_ULP_LP_UART_SUPPORTED=y 56 | CONFIG_SOC_CLK_TREE_SUPPORTED=y 57 | CONFIG_SOC_ASSIST_DEBUG_SUPPORTED=y 58 | CONFIG_SOC_WDT_SUPPORTED=y 59 | CONFIG_SOC_SPI_FLASH_SUPPORTED=y 60 | CONFIG_SOC_RNG_SUPPORTED=y 61 | CONFIG_SOC_LIGHT_SLEEP_SUPPORTED=y 62 | CONFIG_SOC_DEEP_SLEEP_SUPPORTED=y 63 | CONFIG_SOC_MODEM_CLOCK_SUPPORTED=y 64 | CONFIG_SOC_PM_SUPPORTED=y 65 | CONFIG_SOC_XTAL_SUPPORT_40M=y 66 | CONFIG_SOC_AES_SUPPORT_DMA=y 67 | CONFIG_SOC_AES_GDMA=y 68 | CONFIG_SOC_AES_SUPPORT_AES_128=y 69 | CONFIG_SOC_AES_SUPPORT_AES_256=y 70 | CONFIG_SOC_ADC_DIG_CTRL_SUPPORTED=y 71 | CONFIG_SOC_ADC_DIG_IIR_FILTER_SUPPORTED=y 72 | CONFIG_SOC_ADC_MONITOR_SUPPORTED=y 73 | CONFIG_SOC_ADC_DMA_SUPPORTED=y 74 | CONFIG_SOC_ADC_PERIPH_NUM=1 75 | CONFIG_SOC_ADC_MAX_CHANNEL_NUM=7 76 | CONFIG_SOC_ADC_ATTEN_NUM=4 77 | CONFIG_SOC_ADC_DIGI_CONTROLLER_NUM=1 78 | CONFIG_SOC_ADC_PATT_LEN_MAX=8 79 | CONFIG_SOC_ADC_DIGI_MAX_BITWIDTH=12 80 | CONFIG_SOC_ADC_DIGI_MIN_BITWIDTH=12 81 | CONFIG_SOC_ADC_DIGI_IIR_FILTER_NUM=2 82 | CONFIG_SOC_ADC_DIGI_MONITOR_NUM=2 83 | CONFIG_SOC_ADC_DIGI_RESULT_BYTES=4 84 | CONFIG_SOC_ADC_DIGI_DATA_BYTES_PER_CONV=4 85 | CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_HIGH=83333 86 | CONFIG_SOC_ADC_SAMPLE_FREQ_THRES_LOW=611 87 | CONFIG_SOC_ADC_RTC_MIN_BITWIDTH=12 88 | CONFIG_SOC_ADC_RTC_MAX_BITWIDTH=12 89 | CONFIG_SOC_ADC_CALIBRATION_V1_SUPPORTED=y 90 | CONFIG_SOC_ADC_SELF_HW_CALI_SUPPORTED=y 91 | CONFIG_SOC_ADC_CALIB_CHAN_COMPENS_SUPPORTED=y 92 | CONFIG_SOC_ADC_TEMPERATURE_SHARE_INTR=y 93 | CONFIG_SOC_ADC_SHARED_POWER=y 94 | CONFIG_SOC_BROWNOUT_RESET_SUPPORTED=y 95 | CONFIG_SOC_SHARED_IDCACHE_SUPPORTED=y 96 | CONFIG_SOC_CACHE_FREEZE_SUPPORTED=y 97 | CONFIG_SOC_CPU_CORES_NUM=1 98 | CONFIG_SOC_CPU_INTR_NUM=32 99 | CONFIG_SOC_CPU_HAS_FLEXIBLE_INTC=y 100 | CONFIG_SOC_INT_PLIC_SUPPORTED=y 101 | CONFIG_SOC_CPU_HAS_CSR_PC=y 102 | CONFIG_SOC_CPU_BREAKPOINTS_NUM=4 103 | CONFIG_SOC_CPU_WATCHPOINTS_NUM=4 104 | CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x80000000 105 | CONFIG_SOC_CPU_HAS_PMA=y 106 | CONFIG_SOC_CPU_IDRAM_SPLIT_USING_PMP=y 107 | CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=3072 108 | CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16 109 | CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100 110 | CONFIG_SOC_AHB_GDMA_VERSION=1 111 | CONFIG_SOC_GDMA_NUM_GROUPS_MAX=1 112 | CONFIG_SOC_GDMA_PAIRS_PER_GROUP_MAX=3 113 | CONFIG_SOC_GDMA_SUPPORT_ETM=y 114 | CONFIG_SOC_GDMA_SUPPORT_SLEEP_RETENTION=y 115 | CONFIG_SOC_ETM_GROUPS=1 116 | CONFIG_SOC_ETM_CHANNELS_PER_GROUP=50 117 | CONFIG_SOC_GPIO_PORT=1 118 | CONFIG_SOC_GPIO_PIN_COUNT=31 119 | CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER=y 120 | CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM=8 121 | CONFIG_SOC_GPIO_SUPPORT_ETM=y 122 | CONFIG_SOC_GPIO_SUPPORT_RTC_INDEPENDENT=y 123 | CONFIG_SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP=y 124 | CONFIG_SOC_LP_IO_CLOCK_IS_INDEPENDENT=y 125 | CONFIG_SOC_GPIO_IN_RANGE_MAX=30 126 | CONFIG_SOC_GPIO_OUT_RANGE_MAX=30 127 | CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK=0 128 | CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT=8 129 | CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x000000007FFFFF00 130 | CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y 131 | CONFIG_SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP=y 132 | CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y 133 | CONFIG_SOC_CLOCKOUT_HAS_SOURCE_GATE=y 134 | CONFIG_SOC_GPIO_CLOCKOUT_CHANNEL_NUM=3 135 | CONFIG_SOC_RTCIO_PIN_COUNT=8 136 | CONFIG_SOC_RTCIO_INPUT_OUTPUT_SUPPORTED=y 137 | CONFIG_SOC_RTCIO_HOLD_SUPPORTED=y 138 | CONFIG_SOC_RTCIO_WAKE_SUPPORTED=y 139 | CONFIG_SOC_RTCIO_VALID_RTCIO_MASK=0xFF 140 | CONFIG_SOC_DEDIC_GPIO_OUT_CHANNELS_NUM=8 141 | CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8 142 | CONFIG_SOC_DEDIC_PERIPH_ALWAYS_ENABLE=y 143 | CONFIG_SOC_I2C_NUM=2 144 | CONFIG_SOC_HP_I2C_NUM=1 145 | CONFIG_SOC_I2C_FIFO_LEN=32 146 | CONFIG_SOC_I2C_CMD_REG_NUM=8 147 | CONFIG_SOC_I2C_SUPPORT_SLAVE=y 148 | CONFIG_SOC_I2C_SUPPORT_HW_FSM_RST=y 149 | CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y 150 | CONFIG_SOC_I2C_SUPPORT_XTAL=y 151 | CONFIG_SOC_I2C_SUPPORT_RTC=y 152 | CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR=y 153 | CONFIG_SOC_I2C_SLAVE_SUPPORT_BROADCAST=y 154 | CONFIG_SOC_I2C_SLAVE_CAN_GET_STRETCH_CAUSE=y 155 | CONFIG_SOC_I2C_SLAVE_SUPPORT_I2CRAM_ACCESS=y 156 | CONFIG_SOC_I2C_SLAVE_SUPPORT_SLAVE_UNMATCH=y 157 | CONFIG_SOC_LP_I2C_NUM=1 158 | CONFIG_SOC_LP_I2C_FIFO_LEN=16 159 | CONFIG_SOC_I2S_NUM=1 160 | CONFIG_SOC_I2S_HW_VERSION_2=y 161 | CONFIG_SOC_I2S_SUPPORTS_XTAL=y 162 | CONFIG_SOC_I2S_SUPPORTS_PLL_F160M=y 163 | CONFIG_SOC_I2S_SUPPORTS_PCM=y 164 | CONFIG_SOC_I2S_SUPPORTS_PDM=y 165 | CONFIG_SOC_I2S_SUPPORTS_PDM_TX=y 166 | CONFIG_SOC_I2S_PDM_MAX_TX_LINES=2 167 | CONFIG_SOC_I2S_SUPPORTS_TDM=y 168 | CONFIG_SOC_LEDC_SUPPORT_PLL_DIV_CLOCK=y 169 | CONFIG_SOC_LEDC_SUPPORT_XTAL_CLOCK=y 170 | CONFIG_SOC_LEDC_CHANNEL_NUM=6 171 | CONFIG_SOC_LEDC_TIMER_BIT_WIDTH=20 172 | CONFIG_SOC_LEDC_SUPPORT_FADE_STOP=y 173 | CONFIG_SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED=y 174 | CONFIG_SOC_LEDC_GAMMA_CURVE_FADE_RANGE_MAX=16 175 | CONFIG_SOC_LEDC_FADE_PARAMS_BIT_WIDTH=10 176 | CONFIG_SOC_MMU_PAGE_SIZE_CONFIGURABLE=y 177 | CONFIG_SOC_MMU_PERIPH_NUM=1 178 | CONFIG_SOC_MMU_LINEAR_ADDRESS_REGION_NUM=1 179 | CONFIG_SOC_MMU_DI_VADDR_SHARED=y 180 | CONFIG_SOC_MPU_MIN_REGION_SIZE=0x20000000 181 | CONFIG_SOC_MPU_REGIONS_MAX_NUM=8 182 | CONFIG_SOC_PCNT_GROUPS=1 183 | CONFIG_SOC_PCNT_UNITS_PER_GROUP=4 184 | CONFIG_SOC_PCNT_CHANNELS_PER_UNIT=2 185 | CONFIG_SOC_PCNT_THRES_POINT_PER_UNIT=2 186 | CONFIG_SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE=y 187 | CONFIG_SOC_RMT_GROUPS=1 188 | CONFIG_SOC_RMT_TX_CANDIDATES_PER_GROUP=2 189 | CONFIG_SOC_RMT_RX_CANDIDATES_PER_GROUP=2 190 | CONFIG_SOC_RMT_CHANNELS_PER_GROUP=4 191 | CONFIG_SOC_RMT_MEM_WORDS_PER_CHANNEL=48 192 | CONFIG_SOC_RMT_SUPPORT_RX_PINGPONG=y 193 | CONFIG_SOC_RMT_SUPPORT_RX_DEMODULATION=y 194 | CONFIG_SOC_RMT_SUPPORT_TX_ASYNC_STOP=y 195 | CONFIG_SOC_RMT_SUPPORT_TX_LOOP_COUNT=y 196 | CONFIG_SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP=y 197 | CONFIG_SOC_RMT_SUPPORT_TX_SYNCHRO=y 198 | CONFIG_SOC_RMT_SUPPORT_TX_CARRIER_DATA_ONLY=y 199 | CONFIG_SOC_RMT_SUPPORT_XTAL=y 200 | CONFIG_SOC_RMT_SUPPORT_RC_FAST=y 201 | CONFIG_SOC_MCPWM_GROUPS=1 202 | CONFIG_SOC_MCPWM_TIMERS_PER_GROUP=3 203 | CONFIG_SOC_MCPWM_OPERATORS_PER_GROUP=3 204 | CONFIG_SOC_MCPWM_COMPARATORS_PER_OPERATOR=2 205 | CONFIG_SOC_MCPWM_GENERATORS_PER_OPERATOR=2 206 | CONFIG_SOC_MCPWM_TRIGGERS_PER_OPERATOR=2 207 | CONFIG_SOC_MCPWM_GPIO_FAULTS_PER_GROUP=3 208 | CONFIG_SOC_MCPWM_CAPTURE_TIMERS_PER_GROUP=y 209 | CONFIG_SOC_MCPWM_CAPTURE_CHANNELS_PER_TIMER=3 210 | CONFIG_SOC_MCPWM_GPIO_SYNCHROS_PER_GROUP=3 211 | CONFIG_SOC_MCPWM_SWSYNC_CAN_PROPAGATE=y 212 | CONFIG_SOC_MCPWM_SUPPORT_ETM=y 213 | CONFIG_SOC_MCPWM_CAPTURE_CLK_FROM_GROUP=y 214 | CONFIG_SOC_PARLIO_GROUPS=1 215 | CONFIG_SOC_PARLIO_TX_UNITS_PER_GROUP=1 216 | CONFIG_SOC_PARLIO_RX_UNITS_PER_GROUP=1 217 | CONFIG_SOC_PARLIO_TX_UNIT_MAX_DATA_WIDTH=16 218 | CONFIG_SOC_PARLIO_RX_UNIT_MAX_DATA_WIDTH=16 219 | CONFIG_SOC_PARLIO_TX_RX_SHARE_INTERRUPT=y 220 | CONFIG_SOC_MPI_MEM_BLOCKS_NUM=4 221 | CONFIG_SOC_MPI_OPERATIONS_NUM=3 222 | CONFIG_SOC_RSA_MAX_BIT_LEN=3072 223 | CONFIG_SOC_SHA_DMA_MAX_BUFFER_SIZE=3968 224 | CONFIG_SOC_SHA_SUPPORT_DMA=y 225 | CONFIG_SOC_SHA_SUPPORT_RESUME=y 226 | CONFIG_SOC_SHA_GDMA=y 227 | CONFIG_SOC_SHA_SUPPORT_SHA1=y 228 | CONFIG_SOC_SHA_SUPPORT_SHA224=y 229 | CONFIG_SOC_SHA_SUPPORT_SHA256=y 230 | CONFIG_SOC_SDM_GROUPS=1 231 | CONFIG_SOC_SDM_CHANNELS_PER_GROUP=4 232 | CONFIG_SOC_SDM_CLK_SUPPORT_PLL_F80M=y 233 | CONFIG_SOC_SDM_CLK_SUPPORT_XTAL=y 234 | CONFIG_SOC_SPI_PERIPH_NUM=2 235 | CONFIG_SOC_SPI_MAX_CS_NUM=6 236 | CONFIG_SOC_SPI_MAXIMUM_BUFFER_SIZE=64 237 | CONFIG_SOC_SPI_SUPPORT_DDRCLK=y 238 | CONFIG_SOC_SPI_SLAVE_SUPPORT_SEG_TRANS=y 239 | CONFIG_SOC_SPI_SUPPORT_CD_SIG=y 240 | CONFIG_SOC_SPI_SUPPORT_CONTINUOUS_TRANS=y 241 | CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2=y 242 | CONFIG_SOC_SPI_SUPPORT_CLK_XTAL=y 243 | CONFIG_SOC_SPI_SUPPORT_CLK_PLL_F80M=y 244 | CONFIG_SOC_SPI_SUPPORT_CLK_RC_FAST=y 245 | CONFIG_SOC_SPI_SCT_SUPPORTED=y 246 | CONFIG_SOC_SPI_SCT_REG_NUM=14 247 | CONFIG_SOC_SPI_SCT_BUFFER_NUM_MAX=y 248 | CONFIG_SOC_SPI_SCT_CONF_BITLEN_MAX=0x3FFFA 249 | CONFIG_SOC_MEMSPI_IS_INDEPENDENT=y 250 | CONFIG_SOC_SPI_MAX_PRE_DIVIDER=16 251 | CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_WAIT_IDLE=y 252 | CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_SUSPEND=y 253 | CONFIG_SOC_SPI_MEM_SUPPORT_AUTO_RESUME=y 254 | CONFIG_SOC_SPI_MEM_SUPPORT_IDLE_INTR=y 255 | CONFIG_SOC_SPI_MEM_SUPPORT_SW_SUSPEND=y 256 | CONFIG_SOC_SPI_MEM_SUPPORT_CHECK_SUS=y 257 | CONFIG_SOC_SPI_MEM_SUPPORT_WRAP=y 258 | CONFIG_SOC_MEMSPI_SRC_FREQ_80M_SUPPORTED=y 259 | CONFIG_SOC_MEMSPI_SRC_FREQ_40M_SUPPORTED=y 260 | CONFIG_SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED=y 261 | CONFIG_SOC_SYSTIMER_COUNTER_NUM=2 262 | CONFIG_SOC_SYSTIMER_ALARM_NUM=3 263 | CONFIG_SOC_SYSTIMER_BIT_WIDTH_LO=32 264 | CONFIG_SOC_SYSTIMER_BIT_WIDTH_HI=20 265 | CONFIG_SOC_SYSTIMER_FIXED_DIVIDER=y 266 | CONFIG_SOC_SYSTIMER_SUPPORT_RC_FAST=y 267 | CONFIG_SOC_SYSTIMER_INT_LEVEL=y 268 | CONFIG_SOC_SYSTIMER_ALARM_MISS_COMPENSATE=y 269 | CONFIG_SOC_SYSTIMER_SUPPORT_ETM=y 270 | CONFIG_SOC_LP_TIMER_BIT_WIDTH_LO=32 271 | CONFIG_SOC_LP_TIMER_BIT_WIDTH_HI=16 272 | CONFIG_SOC_TIMER_GROUPS=2 273 | CONFIG_SOC_TIMER_GROUP_TIMERS_PER_GROUP=1 274 | CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54 275 | CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y 276 | CONFIG_SOC_TIMER_GROUP_SUPPORT_RC_FAST=y 277 | CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=2 278 | CONFIG_SOC_TIMER_SUPPORT_ETM=y 279 | CONFIG_SOC_TIMER_SUPPORT_SLEEP_RETENTION=y 280 | CONFIG_SOC_MWDT_SUPPORT_XTAL=y 281 | CONFIG_SOC_TWAI_CONTROLLER_NUM=2 282 | CONFIG_SOC_TWAI_CLK_SUPPORT_XTAL=y 283 | CONFIG_SOC_TWAI_BRP_MIN=2 284 | CONFIG_SOC_TWAI_BRP_MAX=32768 285 | CONFIG_SOC_TWAI_SUPPORTS_RX_STATUS=y 286 | CONFIG_SOC_EFUSE_DIS_DOWNLOAD_ICACHE=y 287 | CONFIG_SOC_EFUSE_DIS_PAD_JTAG=y 288 | CONFIG_SOC_EFUSE_DIS_USB_JTAG=y 289 | CONFIG_SOC_EFUSE_DIS_DIRECT_BOOT=y 290 | CONFIG_SOC_EFUSE_SOFT_DIS_JTAG=y 291 | CONFIG_SOC_EFUSE_DIS_ICACHE=y 292 | CONFIG_SOC_EFUSE_BLOCK9_KEY_PURPOSE_QUIRK=y 293 | CONFIG_SOC_SECURE_BOOT_V2_RSA=y 294 | CONFIG_SOC_SECURE_BOOT_V2_ECC=y 295 | CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS=3 296 | CONFIG_SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS=y 297 | CONFIG_SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY=y 298 | CONFIG_SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX=64 299 | CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES=y 300 | CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128=y 301 | CONFIG_SOC_CRYPTO_DPA_PROTECTION_SUPPORTED=y 302 | CONFIG_SOC_UART_NUM=3 303 | CONFIG_SOC_UART_HP_NUM=2 304 | CONFIG_SOC_UART_LP_NUM=1 305 | CONFIG_SOC_UART_FIFO_LEN=128 306 | CONFIG_SOC_LP_UART_FIFO_LEN=16 307 | CONFIG_SOC_UART_BITRATE_MAX=5000000 308 | CONFIG_SOC_UART_SUPPORT_PLL_F80M_CLK=y 309 | CONFIG_SOC_UART_SUPPORT_RTC_CLK=y 310 | CONFIG_SOC_UART_SUPPORT_XTAL_CLK=y 311 | CONFIG_SOC_UART_SUPPORT_WAKEUP_INT=y 312 | CONFIG_SOC_UART_HAS_LP_UART=y 313 | CONFIG_SOC_UART_SUPPORT_FSM_TX_WAIT_SEND=y 314 | CONFIG_SOC_COEX_HW_PTI=y 315 | CONFIG_SOC_EXTERNAL_COEX_ADVANCE=y 316 | CONFIG_SOC_PHY_DIG_REGS_MEM_SIZE=21 317 | CONFIG_SOC_WIFI_LIGHT_SLEEP_CLK_WIDTH=12 318 | CONFIG_SOC_PM_SUPPORT_WIFI_WAKEUP=y 319 | CONFIG_SOC_PM_SUPPORT_BEACON_WAKEUP=y 320 | CONFIG_SOC_PM_SUPPORT_BT_WAKEUP=y 321 | CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP=y 322 | CONFIG_SOC_PM_SUPPORT_EXT1_WAKEUP_MODE_PER_PIN=y 323 | CONFIG_SOC_PM_SUPPORT_CPU_PD=y 324 | CONFIG_SOC_PM_SUPPORT_MODEM_PD=y 325 | CONFIG_SOC_PM_SUPPORT_XTAL32K_PD=y 326 | CONFIG_SOC_PM_SUPPORT_RC32K_PD=y 327 | CONFIG_SOC_PM_SUPPORT_RC_FAST_PD=y 328 | CONFIG_SOC_PM_SUPPORT_VDDSDIO_PD=y 329 | CONFIG_SOC_PM_SUPPORT_TOP_PD=y 330 | CONFIG_SOC_PM_SUPPORT_HP_AON_PD=y 331 | CONFIG_SOC_PM_SUPPORT_MAC_BB_PD=y 332 | CONFIG_SOC_PM_SUPPORT_RTC_PERIPH_PD=y 333 | CONFIG_SOC_PM_SUPPORT_PMU_MODEM_STATE=y 334 | CONFIG_SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY=y 335 | CONFIG_SOC_PM_CPU_RETENTION_BY_SW=y 336 | CONFIG_SOC_PM_MODEM_RETENTION_BY_REGDMA=y 337 | CONFIG_SOC_PM_RETENTION_HAS_CLOCK_BUG=y 338 | CONFIG_SOC_PM_PAU_LINK_NUM=4 339 | CONFIG_SOC_CLK_RC_FAST_SUPPORT_CALIBRATION=y 340 | CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT=y 341 | CONFIG_SOC_CLK_XTAL32K_SUPPORTED=y 342 | CONFIG_SOC_CLK_OSC_SLOW_SUPPORTED=y 343 | CONFIG_SOC_CLK_RC32K_SUPPORTED=y 344 | CONFIG_SOC_RCC_IS_INDEPENDENT=y 345 | CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_FAST_RC=y 346 | CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_XTAL=y 347 | CONFIG_SOC_TEMPERATURE_SENSOR_INTR_SUPPORT=y 348 | CONFIG_SOC_TEMPERATURE_SENSOR_SUPPORT_ETM=y 349 | CONFIG_SOC_RNG_CLOCK_IS_INDEPENDENT=y 350 | CONFIG_SOC_WIFI_HW_TSF=y 351 | CONFIG_SOC_WIFI_FTM_SUPPORT=y 352 | CONFIG_SOC_WIFI_GCMP_SUPPORT=y 353 | CONFIG_SOC_WIFI_WAPI_SUPPORT=y 354 | CONFIG_SOC_WIFI_CSI_SUPPORT=y 355 | CONFIG_SOC_WIFI_MESH_SUPPORT=y 356 | CONFIG_SOC_WIFI_HE_SUPPORT=y 357 | CONFIG_SOC_BLE_SUPPORTED=y 358 | CONFIG_SOC_BLE_MESH_SUPPORTED=y 359 | CONFIG_SOC_ESP_NIMBLE_CONTROLLER=y 360 | CONFIG_SOC_BLE_50_SUPPORTED=y 361 | CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y 362 | CONFIG_SOC_BLE_POWER_CONTROL_SUPPORTED=y 363 | CONFIG_SOC_BLE_PERIODIC_ADV_ENH_SUPPORTED=y 364 | CONFIG_SOC_BLUFI_SUPPORTED=y 365 | CONFIG_SOC_BLE_MULTI_CONN_OPTIMIZATION=y 366 | CONFIG_SOC_BLE_USE_WIFI_PWR_CLK_WORKAROUND=y 367 | CONFIG_SOC_PHY_COMBO_MODULE=y 368 | CONFIG_SOC_CAPS_NO_RESET_BY_ANA_BOD=y 369 | CONFIG_SOC_LP_CORE_SINGLE_INTERRUPT_VECTOR=y 370 | CONFIG_IDF_CMAKE=y 371 | CONFIG_IDF_TOOLCHAIN="gcc" 372 | CONFIG_IDF_TARGET_ARCH_RISCV=y 373 | CONFIG_IDF_TARGET_ARCH="riscv" 374 | CONFIG_IDF_TARGET="esp32c6" 375 | CONFIG_IDF_INIT_VERSION="5.3.0" 376 | CONFIG_IDF_TARGET_ESP32C6=y 377 | CONFIG_IDF_FIRMWARE_CHIP_ID=0x000D 378 | 379 | # 380 | # Build type 381 | # 382 | CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y 383 | # CONFIG_APP_BUILD_TYPE_RAM is not set 384 | CONFIG_APP_BUILD_GENERATE_BINARIES=y 385 | CONFIG_APP_BUILD_BOOTLOADER=y 386 | CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y 387 | # CONFIG_APP_REPRODUCIBLE_BUILD is not set 388 | # CONFIG_APP_NO_BLOBS is not set 389 | # end of Build type 390 | 391 | # 392 | # Bootloader config 393 | # 394 | 395 | # 396 | # Bootloader manager 397 | # 398 | CONFIG_BOOTLOADER_COMPILE_TIME_DATE=y 399 | CONFIG_BOOTLOADER_PROJECT_VER=1 400 | # end of Bootloader manager 401 | 402 | CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x0 403 | CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y 404 | # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set 405 | # CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set 406 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set 407 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set 408 | # CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set 409 | CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 410 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set 411 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set 412 | CONFIG_BOOTLOADER_LOG_LEVEL=3 413 | 414 | # 415 | # Serial Flash Configurations 416 | # 417 | # CONFIG_BOOTLOADER_FLASH_DC_AWARE is not set 418 | CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y 419 | # end of Serial Flash Configurations 420 | 421 | # CONFIG_BOOTLOADER_FACTORY_RESET is not set 422 | # CONFIG_BOOTLOADER_APP_TEST is not set 423 | CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y 424 | CONFIG_BOOTLOADER_WDT_ENABLE=y 425 | # CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set 426 | CONFIG_BOOTLOADER_WDT_TIME_MS=9000 427 | # CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set 428 | # CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set 429 | # CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set 430 | # CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set 431 | CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 432 | # CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set 433 | # end of Bootloader config 434 | 435 | # 436 | # Security features 437 | # 438 | CONFIG_SECURE_BOOT_V2_RSA_SUPPORTED=y 439 | CONFIG_SECURE_BOOT_V2_ECC_SUPPORTED=y 440 | CONFIG_SECURE_BOOT_V2_PREFERRED=y 441 | # CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set 442 | # CONFIG_SECURE_BOOT is not set 443 | # CONFIG_SECURE_FLASH_ENC_ENABLED is not set 444 | CONFIG_SECURE_ROM_DL_MODE_ENABLED=y 445 | # end of Security features 446 | 447 | # 448 | # Application manager 449 | # 450 | CONFIG_APP_COMPILE_TIME_DATE=y 451 | # CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set 452 | # CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set 453 | # CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set 454 | CONFIG_APP_RETRIEVE_LEN_ELF_SHA=9 455 | # end of Application manager 456 | 457 | CONFIG_ESP_ROM_HAS_CRC_LE=y 458 | CONFIG_ESP_ROM_HAS_CRC_BE=y 459 | CONFIG_ESP_ROM_HAS_JPEG_DECODE=y 460 | CONFIG_ESP_ROM_UART_CLK_IS_XTAL=y 461 | CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM=3 462 | CONFIG_ESP_ROM_HAS_RETARGETABLE_LOCKING=y 463 | CONFIG_ESP_ROM_GET_CLK_FREQ=y 464 | CONFIG_ESP_ROM_HAS_RVFPLIB=y 465 | CONFIG_ESP_ROM_HAS_HAL_WDT=y 466 | CONFIG_ESP_ROM_HAS_HAL_SYSTIMER=y 467 | CONFIG_ESP_ROM_HAS_HEAP_TLSF=y 468 | CONFIG_ESP_ROM_TLSF_CHECK_PATCH=y 469 | CONFIG_ESP_ROM_MULTI_HEAP_WALK_PATCH=y 470 | CONFIG_ESP_ROM_HAS_LAYOUT_TABLE=y 471 | CONFIG_ESP_ROM_HAS_SPI_FLASH=y 472 | CONFIG_ESP_ROM_HAS_REGI2C_BUG=y 473 | CONFIG_ESP_ROM_HAS_NEWLIB=y 474 | CONFIG_ESP_ROM_HAS_NEWLIB_NORMAL_FORMAT=y 475 | CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE=y 476 | CONFIG_ESP_ROM_WDT_INIT_PATCH=y 477 | CONFIG_ESP_ROM_NEEDS_SET_CACHE_MMU_SIZE=y 478 | CONFIG_ESP_ROM_RAM_APP_NEEDS_MMU_INIT=y 479 | CONFIG_ESP_ROM_HAS_SW_FLOAT=y 480 | CONFIG_ESP_ROM_USB_OTG_NUM=-1 481 | CONFIG_ESP_ROM_HAS_VERSION=y 482 | CONFIG_ESP_ROM_SUPPORT_DEEP_SLEEP_WAKEUP_STUB=y 483 | 484 | # 485 | # Boot ROM Behavior 486 | # 487 | CONFIG_BOOT_ROM_LOG_ALWAYS_ON=y 488 | # CONFIG_BOOT_ROM_LOG_ALWAYS_OFF is not set 489 | # CONFIG_BOOT_ROM_LOG_ON_GPIO_HIGH is not set 490 | # CONFIG_BOOT_ROM_LOG_ON_GPIO_LOW is not set 491 | # end of Boot ROM Behavior 492 | 493 | # 494 | # Serial flasher config 495 | # 496 | # CONFIG_ESPTOOLPY_NO_STUB is not set 497 | # CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set 498 | # CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set 499 | CONFIG_ESPTOOLPY_FLASHMODE_DIO=y 500 | # CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set 501 | CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y 502 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 503 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 504 | # CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set 505 | # CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set 506 | CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y 507 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 508 | # CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set 509 | # CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set 510 | # CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set 511 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y 512 | # CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set 513 | # CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set 514 | # CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set 515 | # CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set 516 | CONFIG_ESPTOOLPY_FLASHSIZE="8MB" 517 | # CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set 518 | CONFIG_ESPTOOLPY_BEFORE_RESET=y 519 | # CONFIG_ESPTOOLPY_BEFORE_NORESET is not set 520 | CONFIG_ESPTOOLPY_BEFORE="default_reset" 521 | CONFIG_ESPTOOLPY_AFTER_RESET=y 522 | # CONFIG_ESPTOOLPY_AFTER_NORESET is not set 523 | CONFIG_ESPTOOLPY_AFTER="hard_reset" 524 | CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 525 | # end of Serial flasher config 526 | 527 | # 528 | # Partition Table 529 | # 530 | CONFIG_PARTITION_TABLE_SINGLE_APP=y 531 | # CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set 532 | # CONFIG_PARTITION_TABLE_TWO_OTA is not set 533 | # CONFIG_PARTITION_TABLE_CUSTOM is not set 534 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 535 | CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" 536 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 537 | CONFIG_PARTITION_TABLE_MD5=y 538 | # end of Partition Table 539 | 540 | # 541 | # ST7789 Configuration 542 | # 543 | CONFIG_GPIO_RANGE_MAX=30 544 | CONFIG_WIDTH=240 545 | CONFIG_HEIGHT=240 546 | CONFIG_OFFSETX=0 547 | CONFIG_OFFSETY=0 548 | CONFIG_MOSI_GPIO=23 549 | CONFIG_SCLK_GPIO=20 550 | CONFIG_CS_GPIO=-1 551 | CONFIG_DC_GPIO=21 552 | CONFIG_RESET_GPIO=22 553 | CONFIG_BL_GPIO=-1 554 | # CONFIG_INVERSION is not set 555 | CONFIG_SPI2_HOST=y 556 | # CONFIG_FRAME_BUFFER is not set 557 | # end of ST7789 Configuration 558 | 559 | # 560 | # Compiler options 561 | # 562 | CONFIG_COMPILER_OPTIMIZATION_DEBUG=y 563 | # CONFIG_COMPILER_OPTIMIZATION_SIZE is not set 564 | # CONFIG_COMPILER_OPTIMIZATION_PERF is not set 565 | # CONFIG_COMPILER_OPTIMIZATION_NONE is not set 566 | CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y 567 | # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set 568 | # CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set 569 | # CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB is not set 570 | CONFIG_COMPILER_FLOAT_LIB_FROM_RVFPLIB=y 571 | CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 572 | # CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set 573 | CONFIG_COMPILER_HIDE_PATHS_MACROS=y 574 | # CONFIG_COMPILER_CXX_EXCEPTIONS is not set 575 | # CONFIG_COMPILER_CXX_RTTI is not set 576 | CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y 577 | # CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set 578 | # CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set 579 | # CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set 580 | # CONFIG_COMPILER_WARN_WRITE_STRINGS is not set 581 | # CONFIG_COMPILER_SAVE_RESTORE_LIBCALLS is not set 582 | # CONFIG_COMPILER_DISABLE_GCC12_WARNINGS is not set 583 | # CONFIG_COMPILER_DISABLE_GCC13_WARNINGS is not set 584 | # CONFIG_COMPILER_DUMP_RTL_FILES is not set 585 | CONFIG_COMPILER_RT_LIB_GCCLIB=y 586 | CONFIG_COMPILER_RT_LIB_NAME="gcc" 587 | # CONFIG_COMPILER_ORPHAN_SECTIONS_WARNING is not set 588 | CONFIG_COMPILER_ORPHAN_SECTIONS_PLACE=y 589 | # end of Compiler options 590 | 591 | # 592 | # Component config 593 | # 594 | 595 | # 596 | # Application Level Tracing 597 | # 598 | # CONFIG_APPTRACE_DEST_JTAG is not set 599 | CONFIG_APPTRACE_DEST_NONE=y 600 | # CONFIG_APPTRACE_DEST_UART1 is not set 601 | # CONFIG_APPTRACE_DEST_UART2 is not set 602 | CONFIG_APPTRACE_DEST_UART_NONE=y 603 | CONFIG_APPTRACE_UART_TASK_PRIO=1 604 | CONFIG_APPTRACE_LOCK_ENABLE=y 605 | # end of Application Level Tracing 606 | 607 | # 608 | # Bluetooth 609 | # 610 | # CONFIG_BT_ENABLED is not set 611 | CONFIG_BT_ALARM_MAX_NUM=50 612 | # end of Bluetooth 613 | 614 | # 615 | # Console Library 616 | # 617 | # CONFIG_CONSOLE_SORTED_HELP is not set 618 | # end of Console Library 619 | 620 | # 621 | # Driver Configurations 622 | # 623 | 624 | # 625 | # TWAI Configuration 626 | # 627 | # CONFIG_TWAI_ISR_IN_IRAM is not set 628 | # end of TWAI Configuration 629 | 630 | # 631 | # Legacy ADC Driver Configuration 632 | # 633 | # CONFIG_ADC_SUPPRESS_DEPRECATE_WARN is not set 634 | 635 | # 636 | # Legacy ADC Calibration Configuration 637 | # 638 | # CONFIG_ADC_CALI_SUPPRESS_DEPRECATE_WARN is not set 639 | # end of Legacy ADC Calibration Configuration 640 | # end of Legacy ADC Driver Configuration 641 | 642 | # 643 | # Legacy MCPWM Driver Configurations 644 | # 645 | # CONFIG_MCPWM_SUPPRESS_DEPRECATE_WARN is not set 646 | # end of Legacy MCPWM Driver Configurations 647 | 648 | # 649 | # Legacy Timer Group Driver Configurations 650 | # 651 | # CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set 652 | # end of Legacy Timer Group Driver Configurations 653 | 654 | # 655 | # Legacy RMT Driver Configurations 656 | # 657 | # CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set 658 | # end of Legacy RMT Driver Configurations 659 | 660 | # 661 | # Legacy I2S Driver Configurations 662 | # 663 | # CONFIG_I2S_SUPPRESS_DEPRECATE_WARN is not set 664 | # end of Legacy I2S Driver Configurations 665 | 666 | # 667 | # Legacy PCNT Driver Configurations 668 | # 669 | # CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN is not set 670 | # end of Legacy PCNT Driver Configurations 671 | 672 | # 673 | # Legacy SDM Driver Configurations 674 | # 675 | # CONFIG_SDM_SUPPRESS_DEPRECATE_WARN is not set 676 | # end of Legacy SDM Driver Configurations 677 | 678 | # 679 | # Legacy Temperature Sensor Driver Configurations 680 | # 681 | # CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN is not set 682 | # end of Legacy Temperature Sensor Driver Configurations 683 | # end of Driver Configurations 684 | 685 | # 686 | # eFuse Bit Manager 687 | # 688 | # CONFIG_EFUSE_CUSTOM_TABLE is not set 689 | # CONFIG_EFUSE_VIRTUAL is not set 690 | CONFIG_EFUSE_MAX_BLK_LEN=256 691 | # end of eFuse Bit Manager 692 | 693 | # 694 | # ESP-TLS 695 | # 696 | CONFIG_ESP_TLS_USING_MBEDTLS=y 697 | CONFIG_ESP_TLS_USE_DS_PERIPHERAL=y 698 | # CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set 699 | # CONFIG_ESP_TLS_SERVER_SESSION_TICKETS is not set 700 | # CONFIG_ESP_TLS_SERVER_CERT_SELECT_HOOK is not set 701 | # CONFIG_ESP_TLS_SERVER_MIN_AUTH_MODE_OPTIONAL is not set 702 | # CONFIG_ESP_TLS_PSK_VERIFICATION is not set 703 | # CONFIG_ESP_TLS_INSECURE is not set 704 | # end of ESP-TLS 705 | 706 | # 707 | # ADC and ADC Calibration 708 | # 709 | # CONFIG_ADC_ONESHOT_CTRL_FUNC_IN_IRAM is not set 710 | # CONFIG_ADC_CONTINUOUS_ISR_IRAM_SAFE is not set 711 | # CONFIG_ADC_ENABLE_DEBUG_LOG is not set 712 | # end of ADC and ADC Calibration 713 | 714 | # 715 | # Wireless Coexistence 716 | # 717 | CONFIG_ESP_COEX_ENABLED=y 718 | CONFIG_ESP_COEX_SW_COEXIST_ENABLE=y 719 | # CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE is not set 720 | # CONFIG_ESP_COEX_POWER_MANAGEMENT is not set 721 | # end of Wireless Coexistence 722 | 723 | # 724 | # Common ESP-related 725 | # 726 | CONFIG_ESP_ERR_TO_NAME_LOOKUP=y 727 | # end of Common ESP-related 728 | 729 | # 730 | # ESP-Driver:GPIO Configurations 731 | # 732 | # CONFIG_GPIO_CTRL_FUNC_IN_IRAM is not set 733 | # end of ESP-Driver:GPIO Configurations 734 | 735 | # 736 | # ESP-Driver:GPTimer Configurations 737 | # 738 | CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y 739 | # CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set 740 | # CONFIG_GPTIMER_ISR_IRAM_SAFE is not set 741 | # CONFIG_GPTIMER_ENABLE_DEBUG_LOG is not set 742 | # end of ESP-Driver:GPTimer Configurations 743 | 744 | # 745 | # ESP-Driver:I2C Configurations 746 | # 747 | # CONFIG_I2C_ISR_IRAM_SAFE is not set 748 | # CONFIG_I2C_ENABLE_DEBUG_LOG is not set 749 | # end of ESP-Driver:I2C Configurations 750 | 751 | # 752 | # ESP-Driver:I2S Configurations 753 | # 754 | # CONFIG_I2S_ISR_IRAM_SAFE is not set 755 | # CONFIG_I2S_ENABLE_DEBUG_LOG is not set 756 | # end of ESP-Driver:I2S Configurations 757 | 758 | # 759 | # ESP-Driver:LEDC Configurations 760 | # 761 | # CONFIG_LEDC_CTRL_FUNC_IN_IRAM is not set 762 | # end of ESP-Driver:LEDC Configurations 763 | 764 | # 765 | # ESP-Driver:MCPWM Configurations 766 | # 767 | # CONFIG_MCPWM_ISR_IRAM_SAFE is not set 768 | # CONFIG_MCPWM_CTRL_FUNC_IN_IRAM is not set 769 | # CONFIG_MCPWM_ENABLE_DEBUG_LOG is not set 770 | # end of ESP-Driver:MCPWM Configurations 771 | 772 | # 773 | # ESP-Driver:Parallel IO Configurations 774 | # 775 | # CONFIG_PARLIO_ENABLE_DEBUG_LOG is not set 776 | # CONFIG_PARLIO_ISR_IRAM_SAFE is not set 777 | # end of ESP-Driver:Parallel IO Configurations 778 | 779 | # 780 | # ESP-Driver:PCNT Configurations 781 | # 782 | # CONFIG_PCNT_CTRL_FUNC_IN_IRAM is not set 783 | # CONFIG_PCNT_ISR_IRAM_SAFE is not set 784 | # CONFIG_PCNT_ENABLE_DEBUG_LOG is not set 785 | # end of ESP-Driver:PCNT Configurations 786 | 787 | # 788 | # ESP-Driver:RMT Configurations 789 | # 790 | # CONFIG_RMT_ISR_IRAM_SAFE is not set 791 | # CONFIG_RMT_RECV_FUNC_IN_IRAM is not set 792 | # CONFIG_RMT_ENABLE_DEBUG_LOG is not set 793 | # end of ESP-Driver:RMT Configurations 794 | 795 | # 796 | # ESP-Driver:Sigma Delta Modulator Configurations 797 | # 798 | # CONFIG_SDM_CTRL_FUNC_IN_IRAM is not set 799 | # CONFIG_SDM_ENABLE_DEBUG_LOG is not set 800 | # end of ESP-Driver:Sigma Delta Modulator Configurations 801 | 802 | # 803 | # ESP-Driver:SPI Configurations 804 | # 805 | # CONFIG_SPI_MASTER_IN_IRAM is not set 806 | CONFIG_SPI_MASTER_ISR_IN_IRAM=y 807 | # CONFIG_SPI_SLAVE_IN_IRAM is not set 808 | CONFIG_SPI_SLAVE_ISR_IN_IRAM=y 809 | # end of ESP-Driver:SPI Configurations 810 | 811 | # 812 | # ESP-Driver:Temperature Sensor Configurations 813 | # 814 | # CONFIG_TEMP_SENSOR_ENABLE_DEBUG_LOG is not set 815 | # CONFIG_TEMP_SENSOR_ISR_IRAM_SAFE is not set 816 | # end of ESP-Driver:Temperature Sensor Configurations 817 | 818 | # 819 | # ESP-Driver:UART Configurations 820 | # 821 | # CONFIG_UART_ISR_IN_IRAM is not set 822 | # end of ESP-Driver:UART Configurations 823 | 824 | # 825 | # ESP-Driver:USB Serial/JTAG Configuration 826 | # 827 | CONFIG_USJ_ENABLE_USB_SERIAL_JTAG=y 828 | # end of ESP-Driver:USB Serial/JTAG Configuration 829 | 830 | # 831 | # Ethernet 832 | # 833 | CONFIG_ETH_ENABLED=y 834 | CONFIG_ETH_USE_SPI_ETHERNET=y 835 | # CONFIG_ETH_SPI_ETHERNET_DM9051 is not set 836 | # CONFIG_ETH_SPI_ETHERNET_W5500 is not set 837 | # CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set 838 | # CONFIG_ETH_USE_OPENETH is not set 839 | # CONFIG_ETH_TRANSMIT_MUTEX is not set 840 | # end of Ethernet 841 | 842 | # 843 | # Event Loop Library 844 | # 845 | # CONFIG_ESP_EVENT_LOOP_PROFILING is not set 846 | CONFIG_ESP_EVENT_POST_FROM_ISR=y 847 | CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y 848 | # end of Event Loop Library 849 | 850 | # 851 | # GDB Stub 852 | # 853 | CONFIG_ESP_GDBSTUB_ENABLED=y 854 | # CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set 855 | CONFIG_ESP_GDBSTUB_SUPPORT_TASKS=y 856 | CONFIG_ESP_GDBSTUB_MAX_TASKS=32 857 | # end of GDB Stub 858 | 859 | # 860 | # ESP HTTP client 861 | # 862 | CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y 863 | # CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set 864 | # CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH is not set 865 | # CONFIG_ESP_HTTP_CLIENT_ENABLE_CUSTOM_TRANSPORT is not set 866 | # end of ESP HTTP client 867 | 868 | # 869 | # HTTP Server 870 | # 871 | CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 872 | CONFIG_HTTPD_MAX_URI_LEN=512 873 | CONFIG_HTTPD_ERR_RESP_NO_DELAY=y 874 | CONFIG_HTTPD_PURGE_BUF_LEN=32 875 | # CONFIG_HTTPD_LOG_PURGE_DATA is not set 876 | # CONFIG_HTTPD_WS_SUPPORT is not set 877 | # CONFIG_HTTPD_QUEUE_WORK_BLOCKING is not set 878 | # end of HTTP Server 879 | 880 | # 881 | # ESP HTTPS OTA 882 | # 883 | # CONFIG_ESP_HTTPS_OTA_DECRYPT_CB is not set 884 | # CONFIG_ESP_HTTPS_OTA_ALLOW_HTTP is not set 885 | # end of ESP HTTPS OTA 886 | 887 | # 888 | # ESP HTTPS server 889 | # 890 | # CONFIG_ESP_HTTPS_SERVER_ENABLE is not set 891 | # end of ESP HTTPS server 892 | 893 | # 894 | # Hardware Settings 895 | # 896 | 897 | # 898 | # Chip revision 899 | # 900 | CONFIG_ESP32C6_REV_MIN_0=y 901 | # CONFIG_ESP32C6_REV_MIN_1 is not set 902 | CONFIG_ESP32C6_REV_MIN_FULL=0 903 | CONFIG_ESP_REV_MIN_FULL=0 904 | 905 | # 906 | # Maximum Supported ESP32-C6 Revision (Rev v0.99) 907 | # 908 | CONFIG_ESP32C6_REV_MAX_FULL=99 909 | CONFIG_ESP_REV_MAX_FULL=99 910 | # end of Chip revision 911 | 912 | # 913 | # MAC Config 914 | # 915 | CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y 916 | CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y 917 | CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y 918 | CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y 919 | CONFIG_ESP_MAC_ADDR_UNIVERSE_IEEE802154=y 920 | CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y 921 | CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES=4 922 | # CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES_TWO is not set 923 | CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES_FOUR=y 924 | CONFIG_ESP32C6_UNIVERSAL_MAC_ADDRESSES=4 925 | # CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set 926 | # end of MAC Config 927 | 928 | # 929 | # Sleep Config 930 | # 931 | # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set 932 | CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y 933 | # CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU is not set 934 | CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y 935 | CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=0 936 | # CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION is not set 937 | # CONFIG_ESP_SLEEP_DEBUG is not set 938 | CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y 939 | # end of Sleep Config 940 | 941 | # 942 | # RTC Clock Config 943 | # 944 | CONFIG_RTC_CLK_SRC_INT_RC=y 945 | # CONFIG_RTC_CLK_SRC_EXT_CRYS is not set 946 | # CONFIG_RTC_CLK_SRC_EXT_OSC is not set 947 | # CONFIG_RTC_CLK_SRC_INT_RC32K is not set 948 | CONFIG_RTC_CLK_CAL_CYCLES=1024 949 | # end of RTC Clock Config 950 | 951 | # 952 | # Peripheral Control 953 | # 954 | CONFIG_PERIPH_CTRL_FUNC_IN_IRAM=y 955 | # end of Peripheral Control 956 | 957 | # 958 | # ETM Configuration 959 | # 960 | # CONFIG_ETM_ENABLE_DEBUG_LOG is not set 961 | # end of ETM Configuration 962 | 963 | # 964 | # GDMA Configurations 965 | # 966 | CONFIG_GDMA_CTRL_FUNC_IN_IRAM=y 967 | # CONFIG_GDMA_ISR_IRAM_SAFE is not set 968 | # CONFIG_GDMA_ENABLE_DEBUG_LOG is not set 969 | # end of GDMA Configurations 970 | 971 | # 972 | # Main XTAL Config 973 | # 974 | CONFIG_XTAL_FREQ_40=y 975 | CONFIG_XTAL_FREQ=40 976 | # end of Main XTAL Config 977 | 978 | # 979 | # Crypto DPA Protection 980 | # 981 | CONFIG_ESP_CRYPTO_DPA_PROTECTION_AT_STARTUP=y 982 | CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_LOW=y 983 | # CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_MEDIUM is not set 984 | # CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL_HIGH is not set 985 | CONFIG_ESP_CRYPTO_DPA_PROTECTION_LEVEL=1 986 | # end of Crypto DPA Protection 987 | 988 | CONFIG_ESP_SPI_BUS_LOCK_ISR_FUNCS_IN_IRAM=y 989 | # end of Hardware Settings 990 | 991 | # 992 | # LCD and Touch Panel 993 | # 994 | 995 | # 996 | # LCD Touch Drivers are maintained in the IDF Component Registry 997 | # 998 | 999 | # 1000 | # LCD Peripheral Configuration 1001 | # 1002 | # CONFIG_LCD_ENABLE_DEBUG_LOG is not set 1003 | # end of LCD Peripheral Configuration 1004 | # end of LCD and Touch Panel 1005 | 1006 | # 1007 | # ESP NETIF Adapter 1008 | # 1009 | CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 1010 | CONFIG_ESP_NETIF_TCPIP_LWIP=y 1011 | # CONFIG_ESP_NETIF_LOOPBACK is not set 1012 | CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y 1013 | # CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set 1014 | # CONFIG_ESP_NETIF_L2_TAP is not set 1015 | # CONFIG_ESP_NETIF_BRIDGE_EN is not set 1016 | # end of ESP NETIF Adapter 1017 | 1018 | # 1019 | # Partition API Configuration 1020 | # 1021 | # end of Partition API Configuration 1022 | 1023 | # 1024 | # PHY 1025 | # 1026 | CONFIG_ESP_PHY_ENABLED=y 1027 | CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y 1028 | # CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set 1029 | CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 1030 | CONFIG_ESP_PHY_MAX_TX_POWER=20 1031 | # CONFIG_ESP_PHY_REDUCE_TX_POWER is not set 1032 | CONFIG_ESP_PHY_RF_CAL_PARTIAL=y 1033 | # CONFIG_ESP_PHY_RF_CAL_NONE is not set 1034 | # CONFIG_ESP_PHY_RF_CAL_FULL is not set 1035 | CONFIG_ESP_PHY_CALIBRATION_MODE=0 1036 | # CONFIG_ESP_PHY_PLL_TRACK_DEBUG is not set 1037 | # end of PHY 1038 | 1039 | # 1040 | # Power Management 1041 | # 1042 | # CONFIG_PM_ENABLE is not set 1043 | CONFIG_PM_SLP_DEFAULT_PARAMS_OPT=y 1044 | CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y 1045 | # CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP is not set 1046 | # end of Power Management 1047 | 1048 | # 1049 | # ESP PSRAM 1050 | # 1051 | 1052 | # 1053 | # ESP Ringbuf 1054 | # 1055 | # CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH is not set 1056 | # end of ESP Ringbuf 1057 | 1058 | # 1059 | # ESP System Settings 1060 | # 1061 | # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set 1062 | # CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_120 is not set 1063 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y 1064 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160 1065 | # CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set 1066 | CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y 1067 | # CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set 1068 | # CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set 1069 | CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0 1070 | CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y 1071 | CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y 1072 | CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y 1073 | # CONFIG_ESP_SYSTEM_USE_EH_FRAME is not set 1074 | 1075 | # 1076 | # Memory protection 1077 | # 1078 | CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT=y 1079 | # end of Memory protection 1080 | 1081 | CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 1082 | CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 1083 | CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 1084 | CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y 1085 | # CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set 1086 | CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 1087 | CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 1088 | CONFIG_ESP_CONSOLE_UART_DEFAULT=y 1089 | # CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set 1090 | # CONFIG_ESP_CONSOLE_UART_CUSTOM is not set 1091 | # CONFIG_ESP_CONSOLE_NONE is not set 1092 | # CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set 1093 | CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y 1094 | CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y 1095 | CONFIG_ESP_CONSOLE_UART=y 1096 | CONFIG_ESP_CONSOLE_UART_NUM=0 1097 | CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM=0 1098 | CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 1099 | CONFIG_ESP_INT_WDT=y 1100 | CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 1101 | CONFIG_ESP_TASK_WDT_EN=y 1102 | CONFIG_ESP_TASK_WDT_INIT=y 1103 | # CONFIG_ESP_TASK_WDT_PANIC is not set 1104 | CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 1105 | CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y 1106 | # CONFIG_ESP_PANIC_HANDLER_IRAM is not set 1107 | # CONFIG_ESP_DEBUG_STUBS_ENABLE is not set 1108 | CONFIG_ESP_DEBUG_OCDAWARE=y 1109 | CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y 1110 | 1111 | # 1112 | # Brownout Detector 1113 | # 1114 | CONFIG_ESP_BROWNOUT_DET=y 1115 | CONFIG_ESP_BROWNOUT_DET_LVL_SEL_7=y 1116 | # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_6 is not set 1117 | # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_5 is not set 1118 | # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_4 is not set 1119 | # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_3 is not set 1120 | # CONFIG_ESP_BROWNOUT_DET_LVL_SEL_2 is not set 1121 | CONFIG_ESP_BROWNOUT_DET_LVL=7 1122 | # end of Brownout Detector 1123 | 1124 | CONFIG_ESP_SYSTEM_BROWNOUT_INTR=y 1125 | CONFIG_ESP_SYSTEM_HW_STACK_GUARD=y 1126 | CONFIG_ESP_SYSTEM_BBPLL_RECALIB=y 1127 | CONFIG_ESP_SYSTEM_HW_PC_RECORD=y 1128 | # end of ESP System Settings 1129 | 1130 | # 1131 | # IPC (Inter-Processor Call) 1132 | # 1133 | CONFIG_ESP_IPC_TASK_STACK_SIZE=1024 1134 | # end of IPC (Inter-Processor Call) 1135 | 1136 | # 1137 | # ESP Timer (High Resolution Timer) 1138 | # 1139 | # CONFIG_ESP_TIMER_PROFILING is not set 1140 | CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y 1141 | CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y 1142 | CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 1143 | CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 1144 | # CONFIG_ESP_TIMER_SHOW_EXPERIMENTAL is not set 1145 | CONFIG_ESP_TIMER_TASK_AFFINITY=0x0 1146 | CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0=y 1147 | CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0=y 1148 | # CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set 1149 | CONFIG_ESP_TIMER_IMPL_SYSTIMER=y 1150 | # end of ESP Timer (High Resolution Timer) 1151 | 1152 | # 1153 | # Wi-Fi 1154 | # 1155 | CONFIG_ESP_WIFI_ENABLED=y 1156 | CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10 1157 | CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32 1158 | # CONFIG_ESP_WIFI_STATIC_TX_BUFFER is not set 1159 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y 1160 | CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1 1161 | CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32 1162 | CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y 1163 | # CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set 1164 | CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0 1165 | CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5 1166 | # CONFIG_ESP_WIFI_CSI_ENABLED is not set 1167 | CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y 1168 | CONFIG_ESP_WIFI_TX_BA_WIN=6 1169 | CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y 1170 | CONFIG_ESP_WIFI_RX_BA_WIN=6 1171 | CONFIG_ESP_WIFI_NVS_ENABLED=y 1172 | CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752 1173 | CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32 1174 | CONFIG_ESP_WIFI_IRAM_OPT=y 1175 | CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y 1176 | CONFIG_ESP_WIFI_RX_IRAM_OPT=y 1177 | # CONFIG_ESP_WIFI_ENABLE_WPA3_SAE is not set 1178 | CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA=y 1179 | CONFIG_ESP_WIFI_SLP_IRAM_OPT=y 1180 | CONFIG_ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME=50 1181 | CONFIG_ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME=10 1182 | CONFIG_ESP_WIFI_SLP_DEFAULT_WAIT_BROADCAST_DATA_TIME=15 1183 | # CONFIG_ESP_WIFI_FTM_ENABLE is not set 1184 | CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE=y 1185 | # CONFIG_ESP_WIFI_GCMP_SUPPORT is not set 1186 | CONFIG_ESP_WIFI_GMAC_SUPPORT=y 1187 | # CONFIG_ESP_WIFI_SOFTAP_SUPPORT is not set 1188 | # CONFIG_ESP_WIFI_SLP_BEACON_LOST_OPT is not set 1189 | CONFIG_ESP_WIFI_ESPNOW_MAX_ENCRYPT_NUM=7 1190 | CONFIG_ESP_WIFI_MBEDTLS_CRYPTO=y 1191 | # CONFIG_ESP_WIFI_WAPI_PSK is not set 1192 | # CONFIG_ESP_WIFI_SUITE_B_192 is not set 1193 | # CONFIG_ESP_WIFI_11KV_SUPPORT is not set 1194 | # CONFIG_ESP_WIFI_MBO_SUPPORT is not set 1195 | # CONFIG_ESP_WIFI_DPP_SUPPORT is not set 1196 | # CONFIG_ESP_WIFI_11R_SUPPORT is not set 1197 | # CONFIG_ESP_WIFI_ENABLE_WIFI_TX_STATS is not set 1198 | # CONFIG_ESP_WIFI_ENABLE_WIFI_RX_STATS is not set 1199 | CONFIG_ESP_WIFI_TX_HETB_QUEUE_NUM=3 1200 | 1201 | # 1202 | # WPS Configuration Options 1203 | # 1204 | # CONFIG_ESP_WIFI_WPS_STRICT is not set 1205 | # CONFIG_ESP_WIFI_WPS_PASSPHRASE is not set 1206 | # end of WPS Configuration Options 1207 | 1208 | # CONFIG_ESP_WIFI_DEBUG_PRINT is not set 1209 | # CONFIG_ESP_WIFI_TESTING_OPTIONS is not set 1210 | # CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT is not set 1211 | # end of Wi-Fi 1212 | 1213 | # 1214 | # Core dump 1215 | # 1216 | # CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set 1217 | # CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set 1218 | CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y 1219 | # end of Core dump 1220 | 1221 | # 1222 | # FAT Filesystem support 1223 | # 1224 | CONFIG_FATFS_VOLUME_COUNT=2 1225 | CONFIG_FATFS_LFN_NONE=y 1226 | # CONFIG_FATFS_LFN_HEAP is not set 1227 | # CONFIG_FATFS_LFN_STACK is not set 1228 | # CONFIG_FATFS_SECTOR_512 is not set 1229 | CONFIG_FATFS_SECTOR_4096=y 1230 | # CONFIG_FATFS_CODEPAGE_DYNAMIC is not set 1231 | CONFIG_FATFS_CODEPAGE_437=y 1232 | # CONFIG_FATFS_CODEPAGE_720 is not set 1233 | # CONFIG_FATFS_CODEPAGE_737 is not set 1234 | # CONFIG_FATFS_CODEPAGE_771 is not set 1235 | # CONFIG_FATFS_CODEPAGE_775 is not set 1236 | # CONFIG_FATFS_CODEPAGE_850 is not set 1237 | # CONFIG_FATFS_CODEPAGE_852 is not set 1238 | # CONFIG_FATFS_CODEPAGE_855 is not set 1239 | # CONFIG_FATFS_CODEPAGE_857 is not set 1240 | # CONFIG_FATFS_CODEPAGE_860 is not set 1241 | # CONFIG_FATFS_CODEPAGE_861 is not set 1242 | # CONFIG_FATFS_CODEPAGE_862 is not set 1243 | # CONFIG_FATFS_CODEPAGE_863 is not set 1244 | # CONFIG_FATFS_CODEPAGE_864 is not set 1245 | # CONFIG_FATFS_CODEPAGE_865 is not set 1246 | # CONFIG_FATFS_CODEPAGE_866 is not set 1247 | # CONFIG_FATFS_CODEPAGE_869 is not set 1248 | # CONFIG_FATFS_CODEPAGE_932 is not set 1249 | # CONFIG_FATFS_CODEPAGE_936 is not set 1250 | # CONFIG_FATFS_CODEPAGE_949 is not set 1251 | # CONFIG_FATFS_CODEPAGE_950 is not set 1252 | CONFIG_FATFS_CODEPAGE=437 1253 | CONFIG_FATFS_FS_LOCK=0 1254 | CONFIG_FATFS_TIMEOUT_MS=10000 1255 | CONFIG_FATFS_PER_FILE_CACHE=y 1256 | # CONFIG_FATFS_USE_FASTSEEK is not set 1257 | CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0 1258 | # CONFIG_FATFS_IMMEDIATE_FSYNC is not set 1259 | # CONFIG_FATFS_USE_LABEL is not set 1260 | CONFIG_FATFS_LINK_LOCK=y 1261 | # end of FAT Filesystem support 1262 | 1263 | # 1264 | # FreeRTOS 1265 | # 1266 | 1267 | # 1268 | # Kernel 1269 | # 1270 | # CONFIG_FREERTOS_SMP is not set 1271 | CONFIG_FREERTOS_UNICORE=y 1272 | CONFIG_FREERTOS_HZ=100 1273 | CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y 1274 | # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set 1275 | # CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set 1276 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y 1277 | CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 1278 | CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 1279 | # CONFIG_FREERTOS_USE_IDLE_HOOK is not set 1280 | # CONFIG_FREERTOS_USE_TICK_HOOK is not set 1281 | CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 1282 | # CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY is not set 1283 | CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME="Tmr Svc" 1284 | # CONFIG_FREERTOS_TIMER_TASK_AFFINITY_CPU0 is not set 1285 | CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY=y 1286 | CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY=0x7FFFFFFF 1287 | CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 1288 | CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 1289 | CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 1290 | CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 1291 | CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES=1 1292 | # CONFIG_FREERTOS_USE_TRACE_FACILITY is not set 1293 | # CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES is not set 1294 | # CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set 1295 | # CONFIG_FREERTOS_USE_APPLICATION_TASK_TAG is not set 1296 | # end of Kernel 1297 | 1298 | # 1299 | # Port 1300 | # 1301 | CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y 1302 | # CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set 1303 | CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS=y 1304 | # CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK is not set 1305 | # CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set 1306 | CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y 1307 | CONFIG_FREERTOS_ISR_STACKSIZE=1536 1308 | CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y 1309 | CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER=y 1310 | CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1=y 1311 | # CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL3 is not set 1312 | CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER=y 1313 | # CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set 1314 | # CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set 1315 | # end of Port 1316 | 1317 | CONFIG_FREERTOS_PORT=y 1318 | CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF 1319 | CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y 1320 | CONFIG_FREERTOS_DEBUG_OCDAWARE=y 1321 | CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y 1322 | CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y 1323 | CONFIG_FREERTOS_NUMBER_OF_CORES=1 1324 | # end of FreeRTOS 1325 | 1326 | # 1327 | # Hardware Abstraction Layer (HAL) and Low Level (LL) 1328 | # 1329 | CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y 1330 | # CONFIG_HAL_ASSERTION_DISABLE is not set 1331 | # CONFIG_HAL_ASSERTION_SILENT is not set 1332 | # CONFIG_HAL_ASSERTION_ENABLE is not set 1333 | CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 1334 | CONFIG_HAL_SYSTIMER_USE_ROM_IMPL=y 1335 | CONFIG_HAL_WDT_USE_ROM_IMPL=y 1336 | CONFIG_HAL_SPI_MASTER_FUNC_IN_IRAM=y 1337 | CONFIG_HAL_SPI_SLAVE_FUNC_IN_IRAM=y 1338 | # end of Hardware Abstraction Layer (HAL) and Low Level (LL) 1339 | 1340 | # 1341 | # Heap memory debugging 1342 | # 1343 | CONFIG_HEAP_POISONING_DISABLED=y 1344 | # CONFIG_HEAP_POISONING_LIGHT is not set 1345 | # CONFIG_HEAP_POISONING_COMPREHENSIVE is not set 1346 | CONFIG_HEAP_TRACING_OFF=y 1347 | # CONFIG_HEAP_TRACING_STANDALONE is not set 1348 | # CONFIG_HEAP_TRACING_TOHOST is not set 1349 | # CONFIG_HEAP_USE_HOOKS is not set 1350 | # CONFIG_HEAP_TASK_TRACKING is not set 1351 | # CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set 1352 | CONFIG_HEAP_TLSF_USE_ROM_IMPL=y 1353 | # end of Heap memory debugging 1354 | 1355 | # 1356 | # IEEE 802.15.4 1357 | # 1358 | CONFIG_IEEE802154_ENABLED=y 1359 | CONFIG_IEEE802154_RX_BUFFER_SIZE=20 1360 | # CONFIG_IEEE802154_CCA_CARRIER is not set 1361 | CONFIG_IEEE802154_CCA_ED=y 1362 | # CONFIG_IEEE802154_CCA_CARRIER_OR_ED is not set 1363 | # CONFIG_IEEE802154_CCA_CARRIER_AND_ED is not set 1364 | CONFIG_IEEE802154_CCA_MODE=1 1365 | CONFIG_IEEE802154_CCA_THRESHOLD=-60 1366 | CONFIG_IEEE802154_PENDING_TABLE_SIZE=20 1367 | # CONFIG_IEEE802154_MULTI_PAN_ENABLE is not set 1368 | # CONFIG_IEEE802154_TIMING_OPTIMIZATION is not set 1369 | # CONFIG_IEEE802154_DEBUG is not set 1370 | # end of IEEE 802.15.4 1371 | 1372 | # 1373 | # Log output 1374 | # 1375 | # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set 1376 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set 1377 | # CONFIG_LOG_DEFAULT_LEVEL_WARN is not set 1378 | CONFIG_LOG_DEFAULT_LEVEL_INFO=y 1379 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set 1380 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set 1381 | CONFIG_LOG_DEFAULT_LEVEL=3 1382 | CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y 1383 | # CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set 1384 | # CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set 1385 | CONFIG_LOG_MAXIMUM_LEVEL=3 1386 | # CONFIG_LOG_MASTER_LEVEL is not set 1387 | CONFIG_LOG_COLORS=y 1388 | CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y 1389 | # CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set 1390 | # end of Log output 1391 | 1392 | # 1393 | # LWIP 1394 | # 1395 | CONFIG_LWIP_ENABLE=y 1396 | CONFIG_LWIP_LOCAL_HOSTNAME="espressif" 1397 | # CONFIG_LWIP_NETIF_API is not set 1398 | CONFIG_LWIP_TCPIP_TASK_PRIO=18 1399 | # CONFIG_LWIP_TCPIP_CORE_LOCKING is not set 1400 | # CONFIG_LWIP_CHECK_THREAD_SAFETY is not set 1401 | CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y 1402 | # CONFIG_LWIP_L2_TO_L3_COPY is not set 1403 | # CONFIG_LWIP_IRAM_OPTIMIZATION is not set 1404 | # CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set 1405 | CONFIG_LWIP_TIMERS_ONDEMAND=y 1406 | CONFIG_LWIP_MAX_SOCKETS=10 1407 | # CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set 1408 | # CONFIG_LWIP_SO_LINGER is not set 1409 | CONFIG_LWIP_SO_REUSE=y 1410 | CONFIG_LWIP_SO_REUSE_RXTOALL=y 1411 | # CONFIG_LWIP_SO_RCVBUF is not set 1412 | # CONFIG_LWIP_NETBUF_RECVINFO is not set 1413 | CONFIG_LWIP_IP_DEFAULT_TTL=64 1414 | CONFIG_LWIP_IP4_FRAG=y 1415 | # CONFIG_LWIP_IP4_REASSEMBLY is not set 1416 | CONFIG_LWIP_IP_REASS_MAX_PBUFS=10 1417 | # CONFIG_LWIP_IP_FORWARD is not set 1418 | # CONFIG_LWIP_STATS is not set 1419 | CONFIG_LWIP_ESP_GRATUITOUS_ARP=y 1420 | CONFIG_LWIP_GARP_TMR_INTERVAL=60 1421 | CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 1422 | CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y 1423 | # CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set 1424 | CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y 1425 | # CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set 1426 | CONFIG_LWIP_DHCP_OPTIONS_LEN=68 1427 | CONFIG_LWIP_NUM_NETIF_CLIENT_DATA=0 1428 | CONFIG_LWIP_DHCP_COARSE_TIMER_SECS=1 1429 | 1430 | # 1431 | # DHCP server 1432 | # 1433 | CONFIG_LWIP_DHCPS=y 1434 | CONFIG_LWIP_DHCPS_LEASE_UNIT=60 1435 | CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 1436 | CONFIG_LWIP_DHCPS_STATIC_ENTRIES=y 1437 | # end of DHCP server 1438 | 1439 | # CONFIG_LWIP_AUTOIP is not set 1440 | CONFIG_LWIP_IPV4=y 1441 | # CONFIG_LWIP_IPV6 is not set 1442 | # CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set 1443 | CONFIG_LWIP_NETIF_LOOPBACK=y 1444 | CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 1445 | 1446 | # 1447 | # TCP 1448 | # 1449 | CONFIG_LWIP_MAX_ACTIVE_TCP=16 1450 | CONFIG_LWIP_MAX_LISTENING_TCP=16 1451 | CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y 1452 | CONFIG_LWIP_TCP_MAXRTX=12 1453 | CONFIG_LWIP_TCP_SYNMAXRTX=12 1454 | CONFIG_LWIP_TCP_MSS=1440 1455 | CONFIG_LWIP_TCP_TMR_INTERVAL=250 1456 | CONFIG_LWIP_TCP_MSL=60000 1457 | CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=20000 1458 | CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5760 1459 | CONFIG_LWIP_TCP_WND_DEFAULT=5760 1460 | CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 1461 | CONFIG_LWIP_TCP_ACCEPTMBOX_SIZE=6 1462 | CONFIG_LWIP_TCP_QUEUE_OOSEQ=y 1463 | CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6 1464 | CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4 1465 | # CONFIG_LWIP_TCP_SACK_OUT is not set 1466 | CONFIG_LWIP_TCP_OVERSIZE_MSS=y 1467 | # CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set 1468 | # CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set 1469 | CONFIG_LWIP_TCP_RTO_TIME=1500 1470 | # end of TCP 1471 | 1472 | # 1473 | # UDP 1474 | # 1475 | CONFIG_LWIP_MAX_UDP_PCBS=16 1476 | CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 1477 | # end of UDP 1478 | 1479 | # 1480 | # Checksums 1481 | # 1482 | # CONFIG_LWIP_CHECKSUM_CHECK_IP is not set 1483 | # CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set 1484 | CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y 1485 | # end of Checksums 1486 | 1487 | CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 1488 | CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y 1489 | # CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set 1490 | CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF 1491 | # CONFIG_LWIP_PPP_SUPPORT is not set 1492 | # CONFIG_LWIP_SLIP_SUPPORT is not set 1493 | 1494 | # 1495 | # ICMP 1496 | # 1497 | CONFIG_LWIP_ICMP=y 1498 | # CONFIG_LWIP_MULTICAST_PING is not set 1499 | # CONFIG_LWIP_BROADCAST_PING is not set 1500 | # end of ICMP 1501 | 1502 | # 1503 | # LWIP RAW API 1504 | # 1505 | CONFIG_LWIP_MAX_RAW_PCBS=16 1506 | # end of LWIP RAW API 1507 | 1508 | # 1509 | # SNTP 1510 | # 1511 | CONFIG_LWIP_SNTP_MAX_SERVERS=1 1512 | # CONFIG_LWIP_DHCP_GET_NTP_SRV is not set 1513 | CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 1514 | CONFIG_LWIP_SNTP_STARTUP_DELAY=y 1515 | CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY=5000 1516 | # end of SNTP 1517 | 1518 | # 1519 | # DNS 1520 | # 1521 | CONFIG_LWIP_DNS_MAX_SERVERS=3 1522 | # CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set 1523 | # end of DNS 1524 | 1525 | CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7 1526 | CONFIG_LWIP_ESP_LWIP_ASSERT=y 1527 | 1528 | # 1529 | # Hooks 1530 | # 1531 | # CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set 1532 | CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y 1533 | # CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set 1534 | CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y 1535 | # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set 1536 | # CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set 1537 | # end of Hooks 1538 | 1539 | # CONFIG_LWIP_DEBUG is not set 1540 | # end of LWIP 1541 | 1542 | # 1543 | # mbedTLS 1544 | # 1545 | CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y 1546 | # CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set 1547 | # CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set 1548 | CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y 1549 | CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 1550 | CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 1551 | # CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set 1552 | # CONFIG_MBEDTLS_DEBUG is not set 1553 | 1554 | # 1555 | # mbedTLS v3.x related 1556 | # 1557 | # CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 is not set 1558 | # CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set 1559 | # CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set 1560 | # CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set 1561 | CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y 1562 | CONFIG_MBEDTLS_PKCS7_C=y 1563 | # end of mbedTLS v3.x related 1564 | 1565 | # 1566 | # Certificate Bundle 1567 | # 1568 | CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y 1569 | CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y 1570 | # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set 1571 | # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set 1572 | # CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set 1573 | # CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEPRECATED_LIST is not set 1574 | CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 1575 | # end of Certificate Bundle 1576 | 1577 | # CONFIG_MBEDTLS_ECP_RESTARTABLE is not set 1578 | CONFIG_MBEDTLS_CMAC_C=y 1579 | CONFIG_MBEDTLS_HARDWARE_AES=y 1580 | CONFIG_MBEDTLS_AES_USE_INTERRUPT=y 1581 | CONFIG_MBEDTLS_AES_INTERRUPT_LEVEL=0 1582 | CONFIG_MBEDTLS_GCM_SUPPORT_NON_AES_CIPHER=y 1583 | CONFIG_MBEDTLS_HARDWARE_MPI=y 1584 | CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y 1585 | CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y 1586 | CONFIG_MBEDTLS_MPI_INTERRUPT_LEVEL=0 1587 | CONFIG_MBEDTLS_HARDWARE_SHA=y 1588 | CONFIG_MBEDTLS_HARDWARE_ECC=y 1589 | CONFIG_MBEDTLS_ECC_OTHER_CURVES_SOFT_FALLBACK=y 1590 | CONFIG_MBEDTLS_ROM_MD5=y 1591 | # CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set 1592 | # CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set 1593 | CONFIG_MBEDTLS_HAVE_TIME=y 1594 | # CONFIG_MBEDTLS_PLATFORM_TIME_ALT is not set 1595 | # CONFIG_MBEDTLS_HAVE_TIME_DATE is not set 1596 | CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y 1597 | CONFIG_MBEDTLS_SHA512_C=y 1598 | CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y 1599 | # CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set 1600 | # CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set 1601 | # CONFIG_MBEDTLS_TLS_DISABLED is not set 1602 | CONFIG_MBEDTLS_TLS_SERVER=y 1603 | CONFIG_MBEDTLS_TLS_CLIENT=y 1604 | CONFIG_MBEDTLS_TLS_ENABLED=y 1605 | 1606 | # 1607 | # TLS Key Exchange Methods 1608 | # 1609 | # CONFIG_MBEDTLS_PSK_MODES is not set 1610 | CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y 1611 | CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y 1612 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y 1613 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y 1614 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y 1615 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y 1616 | # end of TLS Key Exchange Methods 1617 | 1618 | CONFIG_MBEDTLS_SSL_RENEGOTIATION=y 1619 | CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y 1620 | # CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set 1621 | # CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set 1622 | CONFIG_MBEDTLS_SSL_ALPN=y 1623 | CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y 1624 | CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y 1625 | 1626 | # 1627 | # Symmetric Ciphers 1628 | # 1629 | CONFIG_MBEDTLS_AES_C=y 1630 | # CONFIG_MBEDTLS_CAMELLIA_C is not set 1631 | # CONFIG_MBEDTLS_DES_C is not set 1632 | # CONFIG_MBEDTLS_BLOWFISH_C is not set 1633 | # CONFIG_MBEDTLS_XTEA_C is not set 1634 | CONFIG_MBEDTLS_CCM_C=y 1635 | CONFIG_MBEDTLS_GCM_C=y 1636 | # CONFIG_MBEDTLS_NIST_KW_C is not set 1637 | # end of Symmetric Ciphers 1638 | 1639 | # CONFIG_MBEDTLS_RIPEMD160_C is not set 1640 | 1641 | # 1642 | # Certificates 1643 | # 1644 | CONFIG_MBEDTLS_PEM_PARSE_C=y 1645 | CONFIG_MBEDTLS_PEM_WRITE_C=y 1646 | CONFIG_MBEDTLS_X509_CRL_PARSE_C=y 1647 | CONFIG_MBEDTLS_X509_CSR_PARSE_C=y 1648 | # end of Certificates 1649 | 1650 | CONFIG_MBEDTLS_ECP_C=y 1651 | # CONFIG_MBEDTLS_DHM_C is not set 1652 | CONFIG_MBEDTLS_ECDH_C=y 1653 | CONFIG_MBEDTLS_ECDSA_C=y 1654 | # CONFIG_MBEDTLS_ECJPAKE_C is not set 1655 | CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y 1656 | CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y 1657 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 1658 | CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y 1659 | CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y 1660 | CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y 1661 | CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y 1662 | CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y 1663 | CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y 1664 | CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y 1665 | CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y 1666 | CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y 1667 | CONFIG_MBEDTLS_ECP_NIST_OPTIM=y 1668 | CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y 1669 | # CONFIG_MBEDTLS_POLY1305_C is not set 1670 | # CONFIG_MBEDTLS_CHACHA20_C is not set 1671 | # CONFIG_MBEDTLS_HKDF_C is not set 1672 | # CONFIG_MBEDTLS_THREADING_C is not set 1673 | CONFIG_MBEDTLS_ERROR_STRINGS=y 1674 | # end of mbedTLS 1675 | 1676 | # 1677 | # ESP-MQTT Configurations 1678 | # 1679 | CONFIG_MQTT_PROTOCOL_311=y 1680 | # CONFIG_MQTT_PROTOCOL_5 is not set 1681 | CONFIG_MQTT_TRANSPORT_SSL=y 1682 | CONFIG_MQTT_TRANSPORT_WEBSOCKET=y 1683 | CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y 1684 | # CONFIG_MQTT_MSG_ID_INCREMENTAL is not set 1685 | # CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set 1686 | # CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set 1687 | # CONFIG_MQTT_USE_CUSTOM_CONFIG is not set 1688 | # CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set 1689 | # CONFIG_MQTT_CUSTOM_OUTBOX is not set 1690 | # end of ESP-MQTT Configurations 1691 | 1692 | # 1693 | # Newlib 1694 | # 1695 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y 1696 | # CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set 1697 | # CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set 1698 | # CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set 1699 | # CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set 1700 | CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y 1701 | # CONFIG_NEWLIB_NANO_FORMAT is not set 1702 | CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y 1703 | # CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC is not set 1704 | # CONFIG_NEWLIB_TIME_SYSCALL_USE_HRT is not set 1705 | # CONFIG_NEWLIB_TIME_SYSCALL_USE_NONE is not set 1706 | # end of Newlib 1707 | 1708 | # 1709 | # NVS 1710 | # 1711 | # CONFIG_NVS_ENCRYPTION is not set 1712 | # CONFIG_NVS_ASSERT_ERROR_CHECK is not set 1713 | # CONFIG_NVS_LEGACY_DUP_KEYS_COMPATIBILITY is not set 1714 | # end of NVS 1715 | 1716 | # 1717 | # OpenThread 1718 | # 1719 | # CONFIG_OPENTHREAD_ENABLED is not set 1720 | 1721 | # 1722 | # Thread Operational Dataset 1723 | # 1724 | CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP" 1725 | CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64" 1726 | CONFIG_OPENTHREAD_NETWORK_CHANNEL=15 1727 | CONFIG_OPENTHREAD_NETWORK_PANID=0x1234 1728 | CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe" 1729 | CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff" 1730 | CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53" 1731 | # end of Thread Operational Dataset 1732 | 1733 | CONFIG_OPENTHREAD_XTAL_ACCURACY=130 1734 | # CONFIG_OPENTHREAD_SPINEL_ONLY is not set 1735 | # CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE is not set 1736 | 1737 | # 1738 | # Thread Address Query Config 1739 | # 1740 | # end of Thread Address Query Config 1741 | # end of OpenThread 1742 | 1743 | # 1744 | # Protocomm 1745 | # 1746 | CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y 1747 | CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y 1748 | CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_2=y 1749 | # end of Protocomm 1750 | 1751 | # 1752 | # PThreads 1753 | # 1754 | CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 1755 | CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 1756 | CONFIG_PTHREAD_STACK_MIN=768 1757 | CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 1758 | CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" 1759 | # end of PThreads 1760 | 1761 | # 1762 | # MMU Config 1763 | # 1764 | CONFIG_MMU_PAGE_SIZE_64KB=y 1765 | CONFIG_MMU_PAGE_MODE="64KB" 1766 | CONFIG_MMU_PAGE_SIZE=0x10000 1767 | # end of MMU Config 1768 | 1769 | # 1770 | # Main Flash configuration 1771 | # 1772 | 1773 | # 1774 | # SPI Flash behavior when brownout 1775 | # 1776 | CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC=y 1777 | CONFIG_SPI_FLASH_BROWNOUT_RESET=y 1778 | # end of SPI Flash behavior when brownout 1779 | 1780 | # 1781 | # Optional and Experimental Features (READ DOCS FIRST) 1782 | # 1783 | 1784 | # 1785 | # Features here require specific hardware (READ DOCS FIRST!) 1786 | # 1787 | CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US=50 1788 | # end of Optional and Experimental Features (READ DOCS FIRST) 1789 | # end of Main Flash configuration 1790 | 1791 | # 1792 | # SPI Flash driver 1793 | # 1794 | # CONFIG_SPI_FLASH_VERIFY_WRITE is not set 1795 | # CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set 1796 | CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y 1797 | # CONFIG_SPI_FLASH_ROM_IMPL is not set 1798 | CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y 1799 | # CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set 1800 | # CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set 1801 | # CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set 1802 | CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y 1803 | CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 1804 | CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 1805 | CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 1806 | # CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set 1807 | # CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set 1808 | # CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set 1809 | 1810 | # 1811 | # Auto-detect flash chips 1812 | # 1813 | CONFIG_SPI_FLASH_VENDOR_XMC_SUPPORTED=y 1814 | # CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP is not set 1815 | # CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP is not set 1816 | # CONFIG_SPI_FLASH_SUPPORT_GD_CHIP is not set 1817 | # CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP is not set 1818 | # CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP is not set 1819 | # CONFIG_SPI_FLASH_SUPPORT_TH_CHIP is not set 1820 | # end of Auto-detect flash chips 1821 | 1822 | CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y 1823 | # end of SPI Flash driver 1824 | 1825 | # 1826 | # SPIFFS Configuration 1827 | # 1828 | CONFIG_SPIFFS_MAX_PARTITIONS=3 1829 | 1830 | # 1831 | # SPIFFS Cache Configuration 1832 | # 1833 | CONFIG_SPIFFS_CACHE=y 1834 | CONFIG_SPIFFS_CACHE_WR=y 1835 | # CONFIG_SPIFFS_CACHE_STATS is not set 1836 | # end of SPIFFS Cache Configuration 1837 | 1838 | CONFIG_SPIFFS_PAGE_CHECK=y 1839 | CONFIG_SPIFFS_GC_MAX_RUNS=10 1840 | # CONFIG_SPIFFS_GC_STATS is not set 1841 | CONFIG_SPIFFS_PAGE_SIZE=256 1842 | CONFIG_SPIFFS_OBJ_NAME_LEN=32 1843 | # CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set 1844 | CONFIG_SPIFFS_USE_MAGIC=y 1845 | CONFIG_SPIFFS_USE_MAGIC_LENGTH=y 1846 | CONFIG_SPIFFS_META_LENGTH=4 1847 | CONFIG_SPIFFS_USE_MTIME=y 1848 | 1849 | # 1850 | # Debug Configuration 1851 | # 1852 | # CONFIG_SPIFFS_DBG is not set 1853 | # CONFIG_SPIFFS_API_DBG is not set 1854 | # CONFIG_SPIFFS_GC_DBG is not set 1855 | # CONFIG_SPIFFS_CACHE_DBG is not set 1856 | # CONFIG_SPIFFS_CHECK_DBG is not set 1857 | # CONFIG_SPIFFS_TEST_VISUALISATION is not set 1858 | # end of Debug Configuration 1859 | # end of SPIFFS Configuration 1860 | 1861 | # 1862 | # TCP Transport 1863 | # 1864 | 1865 | # 1866 | # Websocket 1867 | # 1868 | CONFIG_WS_TRANSPORT=y 1869 | CONFIG_WS_BUFFER_SIZE=1024 1870 | # CONFIG_WS_DYNAMIC_BUFFER is not set 1871 | # end of Websocket 1872 | # end of TCP Transport 1873 | 1874 | # 1875 | # Ultra Low Power (ULP) Co-processor 1876 | # 1877 | # CONFIG_ULP_COPROC_ENABLED is not set 1878 | 1879 | # 1880 | # ULP Debugging Options 1881 | # 1882 | # end of ULP Debugging Options 1883 | # end of Ultra Low Power (ULP) Co-processor 1884 | 1885 | # 1886 | # Unity unit testing library 1887 | # 1888 | CONFIG_UNITY_ENABLE_FLOAT=y 1889 | CONFIG_UNITY_ENABLE_DOUBLE=y 1890 | # CONFIG_UNITY_ENABLE_64BIT is not set 1891 | # CONFIG_UNITY_ENABLE_COLOR is not set 1892 | CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y 1893 | # CONFIG_UNITY_ENABLE_FIXTURE is not set 1894 | # CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set 1895 | # end of Unity unit testing library 1896 | 1897 | # 1898 | # Virtual file system 1899 | # 1900 | CONFIG_VFS_SUPPORT_IO=y 1901 | CONFIG_VFS_SUPPORT_DIR=y 1902 | CONFIG_VFS_SUPPORT_SELECT=y 1903 | CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y 1904 | # CONFIG_VFS_SELECT_IN_RAM is not set 1905 | CONFIG_VFS_SUPPORT_TERMIOS=y 1906 | CONFIG_VFS_MAX_COUNT=8 1907 | 1908 | # 1909 | # Host File System I/O (Semihosting) 1910 | # 1911 | CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 1912 | # end of Host File System I/O (Semihosting) 1913 | # end of Virtual file system 1914 | 1915 | # 1916 | # Wear Levelling 1917 | # 1918 | # CONFIG_WL_SECTOR_SIZE_512 is not set 1919 | CONFIG_WL_SECTOR_SIZE_4096=y 1920 | CONFIG_WL_SECTOR_SIZE=4096 1921 | # end of Wear Levelling 1922 | 1923 | # 1924 | # Wi-Fi Provisioning Manager 1925 | # 1926 | CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 1927 | CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 1928 | # CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set 1929 | CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y 1930 | # CONFIG_WIFI_PROV_STA_FAST_SCAN is not set 1931 | # end of Wi-Fi Provisioning Manager 1932 | 1933 | # 1934 | # IoT Button 1935 | # 1936 | CONFIG_BUTTON_PERIOD_TIME_MS=5 1937 | CONFIG_BUTTON_DEBOUNCE_TICKS=2 1938 | CONFIG_BUTTON_SHORT_PRESS_TIME_MS=180 1939 | CONFIG_BUTTON_LONG_PRESS_TIME_MS=1500 1940 | CONFIG_BUTTON_LONG_PRESS_TOLERANCE_MS=20 1941 | CONFIG_BUTTON_SERIAL_TIME_MS=20 1942 | # CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE is not set 1943 | CONFIG_ADC_BUTTON_MAX_CHANNEL=3 1944 | CONFIG_ADC_BUTTON_MAX_BUTTON_PER_CHANNEL=8 1945 | CONFIG_ADC_BUTTON_SAMPLE_TIMES=1 1946 | # end of IoT Button 1947 | 1948 | # 1949 | # CMake Utilities 1950 | # 1951 | # CONFIG_CU_RELINKER_ENABLE is not set 1952 | # CONFIG_CU_DIAGNOSTICS_COLOR_NEVER is not set 1953 | CONFIG_CU_DIAGNOSTICS_COLOR_ALWAYS=y 1954 | # CONFIG_CU_DIAGNOSTICS_COLOR_AUTO is not set 1955 | # CONFIG_CU_GCC_LTO_ENABLE is not set 1956 | # CONFIG_CU_GCC_STRING_1BYTE_ALIGN is not set 1957 | # end of CMake Utilities 1958 | 1959 | # 1960 | # WASM Micro Runtime 1961 | # 1962 | CONFIG_WAMR_BUILD_RELEASE=y 1963 | # CONFIG_WAMR_BUILD_DEBUG is not set 1964 | CONFIG_WAMR_ENABLE_AOT=y 1965 | CONFIG_WAMR_ENABLE_INTERP=y 1966 | # CONFIG_WAMR_INTERP_CLASSIC is not set 1967 | CONFIG_WAMR_INTERP_FAST=y 1968 | CONFIG_WAMR_INTERP_LOADER_NORMAL=y 1969 | # CONFIG_WAMR_INTERP_LOADER_MINI is not set 1970 | CONFIG_WAMR_ENABLE_LIB_PTHREAD=y 1971 | CONFIG_WAMR_ENABLE_LIBC_BUILTIN=y 1972 | CONFIG_WAMR_ENABLE_LIBC_WASI=y 1973 | # CONFIG_WAMR_ENABLE_MEMORY_PROFILING is not set 1974 | # CONFIG_WAMR_ENABLE_MULTI_MODULE is not set 1975 | # CONFIG_WAMR_ENABLE_PERF_PROFILING is not set 1976 | # CONFIG_WAMR_ENABLE_REF_TYPES is not set 1977 | # CONFIG_WAMR_ENABLE_SHARED_MEMORY is not set 1978 | # end of WASM Micro Runtime 1979 | # end of Component config 1980 | 1981 | # CONFIG_IDF_EXPERIMENTAL_FEATURES is not set 1982 | 1983 | # Deprecated options for backward compatibility 1984 | # CONFIG_APP_BUILD_TYPE_ELF_RAM is not set 1985 | # CONFIG_NO_BLOBS is not set 1986 | # CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set 1987 | # CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set 1988 | # CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set 1989 | CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y 1990 | # CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set 1991 | # CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set 1992 | CONFIG_LOG_BOOTLOADER_LEVEL=3 1993 | # CONFIG_APP_ROLLBACK_ENABLE is not set 1994 | # CONFIG_FLASH_ENCRYPTION_ENABLED is not set 1995 | # CONFIG_FLASHMODE_QIO is not set 1996 | # CONFIG_FLASHMODE_QOUT is not set 1997 | CONFIG_FLASHMODE_DIO=y 1998 | # CONFIG_FLASHMODE_DOUT is not set 1999 | CONFIG_MONITOR_BAUD=115200 2000 | CONFIG_OPTIMIZATION_LEVEL_DEBUG=y 2001 | CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y 2002 | CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y 2003 | # CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set 2004 | # CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set 2005 | CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y 2006 | # CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set 2007 | # CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set 2008 | CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 2009 | # CONFIG_CXX_EXCEPTIONS is not set 2010 | CONFIG_STACK_CHECK_NONE=y 2011 | # CONFIG_STACK_CHECK_NORM is not set 2012 | # CONFIG_STACK_CHECK_STRONG is not set 2013 | # CONFIG_STACK_CHECK_ALL is not set 2014 | # CONFIG_WARN_WRITE_STRINGS is not set 2015 | # CONFIG_ESP32_APPTRACE_DEST_TRAX is not set 2016 | CONFIG_ESP32_APPTRACE_DEST_NONE=y 2017 | CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y 2018 | CONFIG_SW_COEXIST_ENABLE=y 2019 | CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y 2020 | CONFIG_ESP_WIFI_SW_COEXIST_ENABLE=y 2021 | # CONFIG_EXTERNAL_COEX_ENABLE is not set 2022 | # CONFIG_ESP_WIFI_EXTERNAL_COEXIST_ENABLE is not set 2023 | # CONFIG_MCPWM_ISR_IN_IRAM is not set 2024 | # CONFIG_EVENT_LOOP_PROFILING is not set 2025 | CONFIG_POST_EVENTS_FROM_ISR=y 2026 | CONFIG_POST_EVENTS_FROM_IRAM_ISR=y 2027 | CONFIG_GDBSTUB_SUPPORT_TASKS=y 2028 | CONFIG_GDBSTUB_MAX_TASKS=32 2029 | # CONFIG_OTA_ALLOW_HTTP is not set 2030 | # CONFIG_ESP_SYSTEM_PD_FLASH is not set 2031 | CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y 2032 | # CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set 2033 | CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 2034 | CONFIG_ESP32_PHY_MAX_TX_POWER=20 2035 | # CONFIG_REDUCE_PHY_TX_POWER is not set 2036 | # CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set 2037 | CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y 2038 | CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 2039 | CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 2040 | CONFIG_MAIN_TASK_STACK_SIZE=3584 2041 | CONFIG_CONSOLE_UART_DEFAULT=y 2042 | # CONFIG_CONSOLE_UART_CUSTOM is not set 2043 | # CONFIG_CONSOLE_UART_NONE is not set 2044 | # CONFIG_ESP_CONSOLE_UART_NONE is not set 2045 | CONFIG_CONSOLE_UART=y 2046 | CONFIG_CONSOLE_UART_NUM=0 2047 | CONFIG_CONSOLE_UART_BAUDRATE=115200 2048 | CONFIG_INT_WDT=y 2049 | CONFIG_INT_WDT_TIMEOUT_MS=300 2050 | CONFIG_TASK_WDT=y 2051 | CONFIG_ESP_TASK_WDT=y 2052 | # CONFIG_TASK_WDT_PANIC is not set 2053 | CONFIG_TASK_WDT_TIMEOUT_S=5 2054 | CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y 2055 | # CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set 2056 | CONFIG_BROWNOUT_DET=y 2057 | CONFIG_BROWNOUT_DET_LVL_SEL_7=y 2058 | # CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set 2059 | # CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set 2060 | # CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set 2061 | # CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set 2062 | # CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set 2063 | CONFIG_BROWNOUT_DET_LVL=7 2064 | CONFIG_IPC_TASK_STACK_SIZE=1024 2065 | CONFIG_TIMER_TASK_STACK_SIZE=3584 2066 | CONFIG_ESP32_WIFI_ENABLED=y 2067 | CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 2068 | CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 2069 | # CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set 2070 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y 2071 | CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 2072 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 2073 | # CONFIG_ESP32_WIFI_CSI_ENABLED is not set 2074 | CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y 2075 | CONFIG_ESP32_WIFI_TX_BA_WIN=6 2076 | CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y 2077 | CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y 2078 | CONFIG_ESP32_WIFI_RX_BA_WIN=6 2079 | CONFIG_ESP32_WIFI_RX_BA_WIN=6 2080 | CONFIG_ESP32_WIFI_NVS_ENABLED=y 2081 | CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 2082 | CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 2083 | CONFIG_ESP32_WIFI_IRAM_OPT=y 2084 | CONFIG_ESP32_WIFI_RX_IRAM_OPT=y 2085 | # CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set 2086 | CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA=y 2087 | CONFIG_WPA_MBEDTLS_CRYPTO=y 2088 | # CONFIG_WPA_WAPI_PSK is not set 2089 | # CONFIG_WPA_SUITE_B_192 is not set 2090 | # CONFIG_WPA_11KV_SUPPORT is not set 2091 | # CONFIG_WPA_MBO_SUPPORT is not set 2092 | # CONFIG_WPA_DPP_SUPPORT is not set 2093 | # CONFIG_WPA_11R_SUPPORT is not set 2094 | # CONFIG_WPA_WPS_STRICT is not set 2095 | # CONFIG_WPA_DEBUG_PRINT is not set 2096 | # CONFIG_WPA_TESTING_OPTIONS is not set 2097 | # CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set 2098 | # CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set 2099 | CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y 2100 | CONFIG_TIMER_TASK_PRIORITY=1 2101 | CONFIG_TIMER_TASK_STACK_DEPTH=2048 2102 | CONFIG_TIMER_QUEUE_LENGTH=10 2103 | # CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set 2104 | # CONFIG_HAL_ASSERTION_SILIENT is not set 2105 | # CONFIG_L2_TO_L3_COPY is not set 2106 | CONFIG_ESP_GRATUITOUS_ARP=y 2107 | CONFIG_GARP_TMR_INTERVAL=60 2108 | CONFIG_TCPIP_RECVMBOX_SIZE=32 2109 | CONFIG_TCP_MAXRTX=12 2110 | CONFIG_TCP_SYNMAXRTX=12 2111 | CONFIG_TCP_MSS=1440 2112 | CONFIG_TCP_MSL=60000 2113 | CONFIG_TCP_SND_BUF_DEFAULT=5760 2114 | CONFIG_TCP_WND_DEFAULT=5760 2115 | CONFIG_TCP_RECVMBOX_SIZE=6 2116 | CONFIG_TCP_QUEUE_OOSEQ=y 2117 | CONFIG_TCP_OVERSIZE_MSS=y 2118 | # CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set 2119 | # CONFIG_TCP_OVERSIZE_DISABLE is not set 2120 | CONFIG_UDP_RECVMBOX_SIZE=6 2121 | CONFIG_TCPIP_TASK_STACK_SIZE=3072 2122 | CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y 2123 | # CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set 2124 | CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF 2125 | # CONFIG_PPP_SUPPORT is not set 2126 | CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 2127 | CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 2128 | CONFIG_ESP32_PTHREAD_STACK_MIN=768 2129 | CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 2130 | CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" 2131 | CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y 2132 | # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set 2133 | # CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set 2134 | CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y 2135 | CONFIG_SUPPORT_TERMIOS=y 2136 | CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 2137 | # End of deprecated options 2138 | -------------------------------------------------------------------------------- /sdkconfig.ci: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lijunchen/moonbit-wasm4-esp32/34c14cc849d638896667e3dfdc658d244e6d1916/sdkconfig.ci -------------------------------------------------------------------------------- /snake-mbt/.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /.mooncakes 3 | -------------------------------------------------------------------------------- /snake-mbt/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright 2024 International Digital Economy Academy 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /snake-mbt/game.mbt: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Bruno Garcia 2 | // Copyright 2024 International Digital Economy Academy 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | let random : @random.Rand = @random.new() 17 | 18 | let fruit : @wasm4.Sprite = @wasm4.sprite( 19 | b"\x00\xa0\x02\x00\x0e\xf0\x36\x5c\xd6\x57\xd5\x57\x35\x5c\x0f\xf0", 20 | ) 21 | 22 | pub struct Game { 23 | snake : Snake 24 | mut frame_count : UInt 25 | mut prev_gamepad : @wasm4.GamePad 26 | mut fruit : Point 27 | } 28 | 29 | pub fn Game::new() -> Game { 30 | { 31 | snake: Snake::new(), 32 | frame_count: 0, 33 | prev_gamepad: @wasm4.GamePad::default(), 34 | fruit: Point::{ 35 | x: random.int(~limit=20), 36 | y: random.int(~limit=20), 37 | }, 38 | } 39 | } 40 | 41 | pub fn update(self : Game) -> Unit { 42 | self.frame_count += 1 43 | self.input() 44 | if self.snake.is_dead() { 45 | @wasm4.trace("Game Over...Or not?") 46 | @wasm4.tone_note_mode( 47 | (@wasm4.Note::new(60, bend=0), None), 48 | @wasm4.ADSR::new(60), 49 | @wasm4.ADSRVolume::new(100), 50 | @wasm4.ToneFlag::new(), 51 | ) 52 | } 53 | if self.frame_count % 30 == 0 { 54 | let dropped_pos = self.snake.update() 55 | if self.snake.body.front() == Some(self.fruit) { 56 | match dropped_pos { 57 | Some(pos) => self.snake.body.push_back(pos) 58 | None => () 59 | } 60 | self.fruit = Point::{ 61 | x: random.int(limit=20), 62 | y: random.int(limit=20), 63 | } 64 | } 65 | } 66 | self.snake.draw() 67 | @wasm4.set_draw_colors(0, index=1) 68 | @wasm4.set_draw_colors(2, index=2) 69 | @wasm4.set_draw_colors(3, index=3) 70 | @wasm4.set_draw_colors(4, index=4) 71 | fruit.blit( 72 | self.fruit.x * 8, 73 | self.fruit.y * 8, 74 | 8, 75 | 8, 76 | { one_bit_per_pixel: false, flip_x: false, flip_y: false, rotate: false }, 77 | ) 78 | } 79 | 80 | pub fn input(self : Game) -> Unit { 81 | let gamepad = @wasm4.get_gamepad() 82 | if gamepad != self.prev_gamepad { 83 | if gamepad.button_down { 84 | self.snake.down() 85 | } 86 | if gamepad.button_left { 87 | self.snake.left() 88 | } 89 | if gamepad.button_right { 90 | self.snake.right() 91 | } 92 | if gamepad.button_up { 93 | self.snake.up() 94 | } 95 | } 96 | self.prev_gamepad = gamepad 97 | } 98 | -------------------------------------------------------------------------------- /snake-mbt/main.mbt: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Bruno Garcia 2 | // Copyright 2024 International Digital Economy Academy 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // fn just_print_int(x: Int) = "env" "just_print_int" 17 | 18 | pub fn start() -> Unit { 19 | @wasm4.set_palette(1, @wasm4.rgb(0xfbf7f3)) 20 | @wasm4.set_palette(2, @wasm4.rgb(0xe5b083)) 21 | @wasm4.set_palette(3, @wasm4.rgb(0x426e5d)) 22 | @wasm4.set_palette(4, @wasm4.rgb(0x20283d)) 23 | } 24 | 25 | let game : Game = Game::new() 26 | 27 | pub fn upd() -> Unit { 28 | game.update() 29 | } 30 | -------------------------------------------------------------------------------- /snake-mbt/moon.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "snake", 3 | "deps": { 4 | "moonbitlang/wasm4": "0.2.1" 5 | }, 6 | "license": "ISC" 7 | } -------------------------------------------------------------------------------- /snake-mbt/moon.pkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "import": [ 3 | "moonbitlang/wasm4" 4 | ], 5 | "link": { 6 | "wasm": { 7 | "exports": [ 8 | "start", 9 | "upd:update" 10 | ], 11 | "export-memory-name": "memory", 12 | "heap-start-address": 6560 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /snake-mbt/snake.mbt: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Bruno Garcia 2 | // Copyright 2024 International Digital Economy Academy 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | pub struct Point { 17 | x : Int 18 | y : Int 19 | } derive(Eq) 20 | 21 | pub struct Snake { 22 | body : @deque.T[Point] 23 | mut direction : Point 24 | } 25 | 26 | pub fn Snake::new() -> Snake { 27 | { 28 | body: @deque.of( 29 | [Point::{ x: 2, y: 0 }, Point::{ x: 1, y: 0 }, Point::{ x: 0, y: 0 }], 30 | ), 31 | direction: Point::{ x: 1, y: 0 }, 32 | } 33 | } 34 | 35 | pub fn draw(self : Snake) -> Unit { 36 | @wasm4.set_draw_colors(4, index=2) 37 | @wasm4.set_draw_colors(3) 38 | self.body.iter().each(fn { { x, y } => @wasm4.rect(x * 8, y * 8, 8, 8) }) 39 | @wasm4.set_draw_colors(4) 40 | self.body.front().map(fn { { x, y } => @wasm4.rect(x * 8, y * 8, 8, 8) }) 41 | |> ignore 42 | } 43 | 44 | pub fn update(self : Snake) -> Point? { 45 | let head = self.body.front().unwrap() 46 | self.body.push_front( 47 | Point::{ 48 | x: (head.x + self.direction.x + 20) % 20, 49 | y: (head.y + self.direction.y + 20) % 20, 50 | }, 51 | ) 52 | self.body.pop_back() 53 | } 54 | 55 | pub fn up(self : Snake) -> Unit { 56 | if self.direction.y == 0 { 57 | self.direction = Point::{ x: 0, y: -1 } 58 | } 59 | } 60 | 61 | pub fn down(self : Snake) -> Unit { 62 | if self.direction.y == 0 { 63 | self.direction = Point::{ x: 0, y: 1 } 64 | } 65 | } 66 | 67 | pub fn left(self : Snake) -> Unit { 68 | if self.direction.x == 0 { 69 | self.direction = Point::{ x: -1, y: 0 } 70 | } 71 | } 72 | 73 | pub fn right(self : Snake) -> Unit { 74 | if self.direction.x == 0 { 75 | self.direction = Point::{ x: 1, y: 0 } 76 | } 77 | } 78 | 79 | pub fn is_dead(self : Snake) -> Bool { 80 | self.body.iter().drop(1).find_first( 81 | fn { point => point == self.body.front().unwrap() }, 82 | ).is_empty().not() 83 | } 84 | --------------------------------------------------------------------------------