.----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. |
| | ________ | || | _________ | || | ____ ____ | |
| | |_ ___ `. | || | |_ ___ | | || | |_ _||_ _| | |
| | | | `. \ | || | | |_ \_| | || | \ \ / / | |
| | | | | | | || | | _| | || | > `' < | |
| | _| |___.' / | || | _| |_ | || | _/ /'`\ \_ | |
| | |________.' | || | |_____| | || | |____||____| | |
| | | || | | || | | |
| '--------------' || '--------------' || '--------------' |
'----------------' '----------------' '----------------'
DarknessFX @ https://dfx.lv | Twitter: @DrkFX
VSCode Windows project template that allows develop C++ code for Windows (build, compile, debug) and deploy to M5Stack (or other ESP32) using PlatformIO (build, upload, monitor), this project can be useful to develop and test LittlevGL GUI on Windows PC before transfer to your M5Stack (or other ESP32).
This project is based on littlevgl/lv_platformio @ https://github.com/littlevgl/lv_platformio , adapted to be used with MSVC compiler/linker and to allow VSCode Windows to run both CPP Win Native and PlatformIO.
Windows:
- VSCode - https://code.visualstudio.com/
- C/C++ Extension and Compiler - https://code.visualstudio.com/docs/languages/cpp
- PlatfomIO - https://docs.platformio.org/en/latest/ide/vscode.html
- libSDL2 - https://www.libsdl.org/
- libSDL2_Image - https://www.libsdl.org/projects/SDL_image/
- LittlevGL Arduino - https://github.com/littlevgl/lv_arduino
- LittlevGL Drivers - https://github.com/littlevgl/lv_drivers
Arduino/ESP32 PlatformIO Libraries:
- M5Stack - https://docs.platformio.org/en/latest/boards/espressif32/m5stack-core-esp32.html (ignore if using ESP32 with another display).
- LittlevGL Arduino - https://platformio.org/lib/show/6228/lv_arduino
VSCode - working.
C/C++ Extension - (run a basic sample to test) - build and compile working.
PlatformIO - (run a basic sample to test) - build, compile and upload working.
Basic stuff but if any of prerequisites are not working this project will not work either.
Download this project and extract.
Open /tool/build.cmd
and change the CALL
command to your local vcvarsall.bat
path . (to where is your MSVC C++ compiler, ex: C:\Program Files\Microsoft Visual Studio\2019\VC\Auxiliary\Build\vcvarsall.bat
)
Download SDL2 Development Libraries @ SDL2-devel-2.0.10-VC.zip - https://www.libsdl.org/download-2.0.php and extract.
Copy /SDL2-2.0.10/include/*
and /SDL2-2.0.10/lib/x64/*
files to ThisProjectFolder/lib/win/SDL2
, all *.h + *.dll + *.lib will be inside the lib/win/SDL2 folder
.
Download lv_arduino @ https://github.com/littlevgl/lv_arduino and extract.
Copy /src/src
folder to ThisProjectFolder/lvgl
(ex: ThisProjectFolder/lvgl/src
) .
Copy /src/lvgl.h
file to ThisProjectFolder/lvgl/lvgl.h
.
Copy ThisProjectFolder/lv_drv_conf.h
file to ThisProjectFolder/lvgl/src/lv_drv_conf.h
.
Make a new folder ThisProjectFolder/lvgl/src/lv_drivers
.
Download lv_drivers @ https://github.com/littlevgl/lv_drivers and extract. .
Copy /display
and /indev
folders to ThisProjectFolder/lvgl/src/lv_drivers
.
Copy /win_drv.c
and /win_drv.h
files to ThisProjectFolder/lvgl/src/lv_drivers
.
Change ** second line of ** #include "lvgl/lvgl.h"
to #include "../../../lvgl/lvgl.h"
to fix header path in:
/lvgl/src/lv_drivers/win_drv.h
/lvgl/src/lv_drivers/win_drv.c
/lvgl/src/lv_drivers/display/monitor.h
/lvgl/src/lv_drivers/indev/keyboard.h
/lvgl/src/lv_drivers/indev/mouse.h
/lvgl/src/lv_drivers/indev/mousewheel.h
Edit ThisProjectFolder/lvgl/src/lc_drivers/display/monitor.c
:
Line 371: m->window = SDL_CreateWindow("TFT Simulator",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
MONITOR_HOR_RES * MONITOR_ZOOM, MONITOR_VER_RES * MONITOR_ZOOM, SDL_WINDOW_SHOWN);
Line 378: m->renderer = SDL_CreateRenderer(m->window, -1, SDL_RENDERER_SOFTWARE);
If you're not using a M5Stack, then you will need to edit the /.platformio/platformio.ini
and change to your ESP32 board configs.
Always use the "lv_platformio_win.code-workspace"
to open the project.
Change your C/C++ Configuration between Win64 or PlatformIO in VSCode at down-right statusbar.
Change your debug environment (if you have JTAG/debug tools) between Windows or PlatformIO Debug in VSCode at down-left statusbar.
You can use F5 to build+run the windows EXE, F10 and F11 to step through the code in windows debug mode.
You can use the PlatformIO toolbar functions to build, upload, monitor as any other PlatformIO project.
This is a template that runs the same sample code from littlevgl/lv_platformio https://github.com/littlevgl/lv_platformio , after the project is running with your Win builds and ESP32 builds you can use this template to build your own code.
After successfully execute "PlatformIO: Build", open the ".platformIO/.vscode/c_cpp_properties.json"
, copy the IncludePath and BrowsePath node values to ".vscode/c_cpp_properties.json"
. Restart VSCode.
Make sure you're using the right configuration Win64 or PlatformIO in VSCode, check the VSCode bottom-right statusbar to see what is the current configuration.
Open any source code file and change the VSCode Debug configuration to Windows.
You need to change the ** second line of ** #include "lvgl/lvgl.h"
to #include "../../../lvgl/lvgl.h"
.
VSCode sometimes use full paths to refence folders, you need to change the following files and fix folder path references:
.vscode/c_cpp_properties.json
(Win64 node, change IncludePath and CompilerPath to your local paths).
lv_platformio_win.code-workspace
(delete the PATH node to autofix the references on next VSCode start).
tool/build.cmd
(change CALL command to your local vcvarsall.bat path).
Is a small hack that allows VSCode to run as C++ Project (compile, debug, launch) while keeping all the PlatformIO features (build, upload, monitor).
PlatformIO is aggressive in overwriting and owning the VSCode project folder, this hack fix this behaviour.
M5Stack have its own TFT_eSPI code, if you find errors or blank screen uploading your code you may need to remove TFT_eSPI library from PlatformIO folder (%UserProfile%\.platformio\lib\TFT_eSPI_?\
) to avoid conflicts.
Yes, the project is ready to run in SDL2-only mode, just remove LittlevGL references from the source code, platformio.ini lib_deps
and tool/build.cmd
.
v1.0 - Released.
@Copyleft all wrongs reserved.
DarknessFX @ https://dfx.lv | Twitter: @DrkFX
https://github.com/DarknessFX/lv_platformio_win