|
| 1 | + |
| 2 | +## Steps to use LovyanGFX in Visual Studio Code + PlatformIO + SDL2 environment |
| 3 | + |
| 4 | +First, install Visual Studio Code and install its PlatformIO extension. |
| 5 | + |
| 6 | + --- |
| 7 | + |
| 8 | +### Install tools for PlatformIO `platform = native` builds |
| 9 | + |
| 10 | +`Installation` Follow the installation steps from this URL |
| 11 | +https://docs.platformio.org/en/latest/platforms/native.html#installation |
| 12 | + |
| 13 | +The instructions below repeat the instructions given by the URL above with additional clarifications. |
| 14 | + |
| 15 | +#### For Linux |
| 16 | + |
| 17 | +Use `apt` to install the basic compilation tools from a shell prompt |
| 18 | +``` |
| 19 | +sudo apt update |
| 20 | +sudo apt install build-essential |
| 21 | +``` |
| 22 | + |
| 23 | +#### For macOS |
| 24 | +Use `xcode-select` to install xcode compilation tools from a Terminal |
| 25 | +``` |
| 26 | +xcode-select --install |
| 27 | +``` |
| 28 | + |
| 29 | +#### For Windows |
| 30 | +Get `MSYS2` from https://www.msys2.org/ and install it. From the MSYS command window that appears after installation, run this command to install the compiler: |
| 31 | +``` |
| 32 | +pacman -S mingw-w64-ucrt-x86_64-gcc |
| 33 | +``` |
| 34 | + |
| 35 | +Edit the Windows System Environment Variables (search the web for instructions) and add these to the System variables `Path` variable |
| 36 | +``` |
| 37 | +C:\msys64\mingw32\bin |
| 38 | +C:\msys64\ucrt64\bin |
| 39 | +C:\msys64\usr\bin |
| 40 | +``` |
| 41 | + |
| 42 | + |
| 43 | + --- |
| 44 | + |
| 45 | +### Install SDL2 |
| 46 | + |
| 47 | +Install `SDL2` per these instructions |
| 48 | +https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html#install-sdl-2 |
| 49 | + |
| 50 | + |
| 51 | +#### For Linux |
| 52 | + |
| 53 | +Install libsdl2 using apt-get |
| 54 | + |
| 55 | +``` |
| 56 | +sudo apt-get install libsdl2 libsdl2-dev |
| 57 | +``` |
| 58 | + |
| 59 | +#### For MacOS OSX |
| 60 | + |
| 61 | +Install sdl2 using Homebrew |
| 62 | +``` |
| 63 | + brew install sdl2 |
| 64 | +``` |
| 65 | + |
| 66 | +#### For Windows |
| 67 | + |
| 68 | +`platform = native` In the steps above, msys2 was installed, so get the SDL2-devel-x.xx.x-mingw release package from the SDL2 Github repository at |
| 69 | +https://github.com/libsdl-org/SDL/releases |
| 70 | + |
| 71 | +The filename at the time these instructions were written was `SDL2-devel-2.30.0-mingw.zip`. |
| 72 | +Unzip it, open the folder inside `x86_64-w64-mingw32`, and confirm that the following four folders appear inside. |
| 73 | + - share |
| 74 | + - bin |
| 75 | + - include |
| 76 | + - lib |
| 77 | + |
| 78 | +Open `C:\msys64\mingw32\` and confirm that it also contains those four folders, then add the contents of the fourfSDL2 folders to those inside `C:\msys64\mingw32\`. Typically, those four mingw32 folders are initially empty, so you can simply overwrite the mingw32 folders with the SDL2 ones. |
| 79 | + |
| 80 | + --- |
| 81 | + |
| 82 | +### Compiling and Running the example program |
| 83 | + |
| 84 | +#### Build the program |
| 85 | + |
| 86 | +In VsCode, open this folder, i.e. <LovyanGFX>/examples_for_PC/PlatformIO_SDL/. The first time that you do so, PlatformIO will install a lot of packages. |
| 87 | + |
| 88 | +Build the program by clicking on the checkmark icon at the bottom of the VsCode window; its tooltip is PlatformIO:Build. |
| 89 | + |
| 90 | +#### Run the program |
| 91 | + |
| 92 | +Run the program by starting a terminal - click on the icon at the bottom of the VsCode window whose tooltip is "PlatformIO:New Terminal" . Inside the terminal window that appears, type this command |
| 93 | + |
| 94 | +``` |
| 95 | +.pio/build/native/program |
| 96 | +``` |
0 commit comments