acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

pc-simulator.md (6195B)

      1 ```eval_rst
      2 .. include:: /header.rst
      3 :github_url: |github_link_base|/get-started/platoforms/simulator.md
      4 ```
      5 # Simulator on PC
      6 
      7 
      8 You can try out LVGL **using only your PC** (i.e. without any development boards). LVGL will run on a simulator environment on the PC where anyone can write and experiment with real LVGL applications.
      9 
     10 Using the simulator on a PC has the following advantages:
     11 - Hardware independent - Write code, run it on the PC and see the result on a monitor.
     12 - Cross-platform - Any Windows, Linux or macOS system can run the PC simulator.
     13 - Portability - The written code is portable, which means you can simply copy it when migrating to embedded hardware.
     14 - Easy Validation - The simulator is also very useful to report bugs because it provides a common platform for every user. So it's a good idea to reproduce a bug in the simulator and use that code snippet in the [Forum](https://forum.lvgl.io).
     15 
     16 ## Select an IDE
     17 
     18 The simulator is ported to various IDEs (Integrated Development Environments). Choose your favorite IDE, read its README on GitHub, download the project, and load it to the IDE.
     19 
     20 - [Eclipse with SDL driver](https://github.com/lvgl/lv_sim_eclipse_sdl): Recommended on Linux and Mac
     21 - [CodeBlocks](https://github.com/lvgl/lv_sim_codeblocks_win): Recommended on Windows
     22 - [VisualStudio with SDL driver](https://github.com/lvgl/lv_sim_visual_studio_sdl): For Windows
     23 - [VSCode with SDL driver](https://github.com/lvgl/lv_sim_vscode_sdl): Recommended on Linux and Mac
     24 - [PlatformIO with SDL driver](https://github.com/lvgl/lv_platformio): Recommended on Linux and Mac
     25 
     26 You can use any IDE for development but, for simplicity, the configuration for Eclipse CDT is what we'll focus on in this tutorial.
     27 The following section describes the set-up guide of Eclipse CDT in more detail.
     28 
     29 **Note: If you are on Windows, it's usually better to use the Visual Studio or CodeBlocks projects instead. They work out of the box without requiring extra steps.**
     30 
     31 ## Set-up Eclipse CDT
     32 
     33 ### Install Eclipse CDT
     34 
     35 [Eclipse CDT](https://eclipse.org/cdt/) is a C/C++ IDE.
     36 
     37 Eclipse is a Java-based tool so be sure **Java Runtime Environment** is installed on your system.
     38 
     39 On Debian-based distros (e.g. Ubuntu): `sudo apt-get install default-jre`
     40 
     41 Note: If you are using other distros, then please install a 'Java Runtime Environment' suitable to your distro.
     42 Note: If you are using macOS and get a "Failed to create the Java Virtual Machine" error, uninstall any other Java JDK installs and install Java JDK 8u. This should fix the problem.
     43 
     44 You can download Eclipse's CDT from: [https://www.eclipse.org/cdt/downloads.php](https://www.eclipse.org/cdt/downloads.php). Start the installer and choose *Eclipse CDT* from the list.
     45 
     46 ### Install SDL 2
     47 
     48 The PC simulator uses the [SDL 2](https://www.libsdl.org/download-2.0.php) cross-platform library to simulate a TFT display and a touchpad.
     49 
     50 #### Linux
     51 On **Linux** you can easily install SDL2 using a terminal:
     52 
     53 1. Find the current version of SDL2: `apt-cache search libsdl2 (e.g. libsdl2-2.0-0)`
     54 2. Install SDL2: `sudo apt-get install libsdl2-2.0-0` (replace with the found version)
     55 3. Install SDL2 development package: `sudo apt-get install libsdl2-dev`
     56 4. If build essentials are not installed yet: `sudo apt-get install build-essential`
     57 
     58 #### Windows
     59 If you are using **Windows** firstly you need to install MinGW ([64 bit version](http://mingw-w64.org/doku.php/download)). After installing MinGW, do the following steps to add SDL2:
     60 
     61 1. Download the development libraries of SDL.
     62 Go to [https://www.libsdl.org/download-2.0.php](https://www.libsdl.org/download-2.0.php) and download _Development Libraries: SDL2-devel-2.0.5-mingw.tar.gz_
     63 2. Decompress the file and go to _x86_64-w64-mingw32_ directory (for 64 bit MinGW) or to _i686-w64-mingw32_ (for 32 bit MinGW)
     64 3. Copy _..._mingw32/include/SDL2_ folder to _C:/MinGW/.../x86_64-w64-mingw32/include_
     65 4. Copy _..._mingw32/lib/_ content to _C:/MinGW/.../x86_64-w64-mingw32/lib_
     66 5. Copy _..._mingw32/bin/SDL2.dll_ to _{eclipse_workspace}/pc_simulator/Debug/_.  Do it later when Eclipse is installed.
     67 
     68 Note: If you are using **Microsoft Visual Studio** instead of Eclipse then you don't have to install MinGW.
     69 
     70 #### OSX
     71 On **OSX** you can easily install SDL2 with brew: `brew install sdl2`
     72 
     73 If something is not working, then please refer [this tutorial](http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php) to get started with SDL.
     74 
     75 ### Pre-configured project
     76 
     77 A pre-configured graphics library project (based on the latest release) is always available to get started easily.
     78 You can find the latest one on [GitHub](https://github.com/lvgl/lv_sim_eclipse_sdl).
     79 (Please note that, the project is configured for Eclipse CDT).
     80 
     81 ### Add the pre-configured project to Eclipse CDT
     82 
     83 Run Eclipse CDT. It will show a dialogue about the **workspace path**. Before accepting the path, check that path and copy (and unzip) the downloaded pre-configured project there. After that, you can accept the workspace path. Of course you can modify this path but in that case copy the project to the corresponding location.
     84 
     85 Close the start-up window and go to **File->Import** and choose **General->Existing project into Workspace**. **Browse the root directory** of the project and click **Finish**
     86 
     87 On **Windows** you have to do two additional things:
     88 
     89 - Copy the **SDL2.dll** into the project's Debug folder
     90 - Right-click on the project -> Project properties -> C/C++ Build -> Settings -> Libraries -> Add ... and add _mingw32_ above SDLmain and SDL. (The order is important: mingw32, SDLmain, SDL)
     91 
     92 ### Compile and Run
     93 
     94 Now you are ready to run LVGL on your PC. Click on the Hammer Icon on the top menu bar to Build the project. If you have done everything right, then you will not get any errors. Note that on some systems additional steps might be required to "see" SDL 2 from Eclipse but in most cases the configuration in the downloaded project is enough.
     95 
     96 After a successful build, click on the Play button on the top menu bar to run the project. Now a window should appear in the middle of your screen.
     97 
     98 Now you are ready to use LVGL and begin development on your PC.