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

arduino.md (3432B)

      1 ```eval_rst
      2 .. include:: /header.rst
      3 :github_url: |github_link_base|/get-started/platforms/arduino.md
      4 ```
      5 
      6 # Arduino
      7 
      8 The [LVGL library](https://github.com/lvgl/lvgl) is directly available as Arduino libraries.
      9 
     10 Note that you need to choose a board powerful enough to run LVGL and your GUI.  See the [requirements of LVGL](https://docs.lvgl.io/master/intro/index.html#requirements).
     11 
     12 For example ESP32 is a good candidate to create UI's with LVGL.
     13 
     14 ## Get the LVGL Arduino library
     15 
     16 LVGL can be installed via the Arduino IDE Library Manager or as a .ZIP library.
     17 
     18 You can [Download](https://github.com/lvgl/lvgl/archive/refs/heads/master.zip) the latest version of LVGL from GitHub and simply copy it to Arduino's library folder.
     19 
     20 ## Set up drivers
     21 
     22 To get started it's recommended to use [TFT_eSPI](https://github.com/Bodmer/TFT_eSPI) library as a TFT driver to simplify testing.
     23 To make it work, setup `TFT_eSPI` according to your TFT display type via editing either
     24 - `User_Setup.h`
     25 - or by selecting a configuration in the `User_Setup_Select.h`
     26 
     27 Both files are located in `TFT_eSPI` library's folder.
     28 
     29 ## Configure LVGL
     30 
     31 LVGL has its own configuration file called `lv_conf.h`. When LVGL is installed, follow these configuration steps:
     32 1. Go to the directory of the installed Arduino libraries
     33 2. Go to `lvgl` and copy `lv_conf_template.h` as `lv_conf.h` into the Arduino Libraries directory next to the `lvgl` library folder.
     34 3. Open `lv_conf.h` and change the first `#if 0` to `#if 1` to enable the content of the file
     35 4. Set the color depth of you display in `LV_COLOR_DEPTH`
     36 5. Set `LV_TICK_CUSTOM 1`
     37 
     38 Finally the layout with `lv_conf.h` should look like this:
     39 ```
     40 arduino
     41  |-libraries
     42    |-lvgl
     43    |-other_lib_1
     44    |-other_lib_2
     45    |-lv_conf.h
     46 ```
     47 
     48 ## Initialize and run LVGL
     49 
     50 Take a look at [LVGL_Arduino.ino](https://github.com/lvgl/lvgl/blob/master/examples/arduino/LVGL_Arduino/LVGL_Arduino.ino) to see how to initialize LVGL.
     51 `TFT_eSPI` is used as the display driver.
     52 
     53 In the INO file you can see how to register a display and a touchpad for LVGL and call an example.
     54 
     55 ## Use the examples and demos
     56 
     57 Note that, there is no dedicated INO file for every example. Instead, you can load an example by calling an `lv_example_...` function. For example `lv_example_btn_1()`.
     58 
     59 **IMPORTANT**
     60 Due to some the limitations of Arduino's build system you need to copy `lvgl/examples` to `lvgl/src/examples`. Similarly for the demos `lvgl/demos` to `lvgl/src/demos`.
     61 
     62 ## Debugging and logging
     63 
     64 LVGL can display debug information in case of trouble.
     65 In the `LVGL_Arduino.ino` example there is a `my_print` method, which sends this debug information to the serial interface.
     66 To enable this feature you have to edit the `lv_conf.h` file and enable logging in the section `log settings`:
     67 
     68 ```c
     69 /*Log settings*/
     70 #define USE_LV_LOG      1   /*Enable/disable the log module*/
     71 #if LV_USE_LOG
     72 /* How important log should be added:
     73  * LV_LOG_LEVEL_TRACE       A lot of logs to give detailed information
     74  * LV_LOG_LEVEL_INFO        Log important events
     75  * LV_LOG_LEVEL_WARN        Log if something unwanted happened but didn't cause a problem
     76  * LV_LOG_LEVEL_ERROR       Only critical issue, when the system may fail
     77  * LV_LOG_LEVEL_NONE        Do not log anything
     78  */
     79 #  define LV_LOG_LEVEL    LV_LOG_LEVEL_WARN
     80 ```
     81 
     82 After enabling the log module and setting LV_LOG_LEVEL accordingly, the output log is sent to the `Serial` port @ 115200 bps.
     83