LVGL on a TFT LCD Display with the nRF9160 DK

This blog post demonstrates how to get a LVGL sample up and running on the nRF9160 DK using Adafruit 1.3" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789. Follow the wiring guide and the steps in the blog post and get your display going! In an ideal world, we would be able to use the st7789v shield for waveshare 240x240, but since the nRF9160 DK does not have a device tree node label for arduino_spi, we need to implement a workaround. For the details on how the project configuration and overlay files were derived, check out my other blog post.

guide_result

Hardware

Components

Wiring

Important: The display operates with 3.3V logic, so on the nRF9160 DK, you must ensure that a tiny switch, SW9 (which sets VDD IO) is set at 3V!

Following the generic ST7789V shield pin assignment, we wire the connection as such:

nRF9160 DK pin Display pin
P0.08 RST
P0.09 D/C
P0.10 TCS
P0.11 SI
P0.12 SO
P0.13 SCK
GND GND
5V Vin


Software

After having wired up your DK, we need to perform some steps on the software side!

Prerequisites

nRF Connect SDK installation (I used v1.6.0).

This SDK uses LVGL v7.6.1 so this project might not be compatible with builds that were released after Feb 24th (which is when LVGL was updated in Zephyr)

Steps

  1. Download the attached project
  2. Extract it into a valid west workspace (that is, a folder from which you can call the command west build from command line)
  3. Connect your nRF9160 DK (with the screen already wired up) to your computer
  4. Build and flash the project to the DK

Incorporating this into other projects

If you want this display to work with your project (let's call it YourProject), you need to:

  1. Ensure that the LVGL and display-specific settings from the provided ZIP's config file (prj.conf) is in YourProject's config file
  2. Ensure that the overlay from the provided ZIP is also included (that is, boards/nrf9160dk_nrf9160ns.overlay)
    1. If YourProject already has an overlay file (nrf9160dk_nrf9160ns.overlay), you could copy-paste the contents of the provided overlay file to YourProject's nrf9160dk_nrf9160ns.overlay
    2. If YourProject does not have an overlay file, then you could copy the whole file into YourProject folder. This will automatically be detected by CMake when you hit build!
  3. Be sure to include device.h, drivers/display.h and lvgl.h in the C-file in which you want to program using LVGL.

Note on the source code structure

The source code might not look like ordinary LVGL code (which uses lv_init, lv_disp_draw_buf_init etc) because this part of LVGL is abstracted away by Zephyr, as seen in lvgl.c in Zephyr. The source code is also based on the LVGL sample provided by Zephyr, with changes made so that it works with the nRF9160 DK when following this tutorial.

Attached files

lvgl_with_logo_sample.zip
  • I'm not offended. Your earlier comment was taken down by a moderator for unprofessional behaviour. LVGL was initially named LittlevGL but was later renamed to Light and Versatile Graphics Library. Check out the Zephyr LVGL codebase readme if you haven't already. 

  • Hi! First of all, sorry for taking long to respond. I work one day a week at Nordic. I have no experience working with custom display drivers on Zephyr, but I would probably solve this by implementing my own display driver such as the ones implemented here. Then, I would enable the display in the prj.conf-file using CONFIG_YOUR_DISPLAY_DRIVER=y. As explained under "Note on the source code structure", some LVGL is abstracted away in Zephyr so it's bound to look a bit different than a "normal" LVGL project.

    I'm unavailable for a couple of months after today, so if you need help with this I would recommend seeking help elsewhere (either ask for help in the forums here, or for more zephyr-specific stuff you could perhaps post an issue in the repo) as I won't be around to follow this up.

  • In general, if I offended the author, I apologize. I have a task to work with a large display. This display is not in zephire. I wrote the driver for it myself. I know the LVGL library. But I don't understand at all how to work with her here. At a minimum, you need a callback for rendering. But he's not here. 

  • If I correctly understand there are two different libraries LVGL (https://lvgl.io) and LittlevGL  ( included zephyre) The author for some reason calls  LittlevGL as LVGL. Because of this, there is a confusion. The author, instead of trying to figure it out, is offended.

  • Thank you! I think it would be possible to make this display sit on the board connectors. If you change lines 19 and 20 in the overlay file to:

    cmd-data-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
    reset-gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;


    I think the only thing that would have to be done after that is to figure out a way to supply power (VDD, 3V3) out to P0.30.

    The display would then line up so that the DC pin connects to P0.08, and GND connects to GND. Doing this is a cool idea! I might look into it if I get the time (however, I only work one day a week now so my progress is slooooow).

    If you would like to get it working but can't figure it out, feel free to ask in the forums with a link to this blog post Smiley