Arduino include issue with integration into existing application

A little bit of preamble here, sorry…

I have an existing application (Ham radio firmware) that historically used the Arduino IDE and Nextion (or dumb 2x16 lcd). My goal is to replace the Nextion screens with “standard” tft screen - initially 240x320, later probably higher resolution. Since even less sophisticated users than myself occasionally re-compile the firmware, I would prefer to keep using the Arduino IDE instead what would be a better solution e.g. PlatformIO.

I created a basic UI (push button where the label changes when pushed) using Squareline 1.3.2. TFT_eSPI is installed and the basic UI runs on a Pico with the tft.

So trying to move this code to the existing project. The project is made up of 10+ *.ino files.

The code generated by SL, creates this hierarchy:
→ ui

ui/src contains the expected .c and .h generated code

I took the code generated ui/ui.ino and put it in the format for the UI loop used by my program. The file (call it foo.ino :wink: ) uses the following includes:

#include <lvgl.h>
#include <TFT_eSPI.h>
#include “libraries/ui/ui.h”

The issue is that I am not including the header files (looks like they are in the core?) for various type defs like lv_disp_drv_t, lv_area_t, etc, basically the function signature for my_disp_flush.

errors are generated like:
error: ‘lv_disp_drv_t’ was not declared in this scope

When I try changing the sketchbook location as it worked in the example, I get other libraries undefined (eg. some of the Sparkfun libraries).

Any suggestions? Be happy to clarify any data needed!



OK, figured out a path here…

  1. Keep the sketchbook folder where it should be /Arduino (where all your other sketches are.)
  2. In Squareline, under project settings keep the root as /Arduino/
    But change UI file export to: /Arduino//ui/src
  3. Put the lvgl and TFT_eSPI in the /Arduino/libraries. Make sure you put the generated lv_conf.h in the lvgl directory.
  4. In the ui.c file, change #include “ui.h” to #include “src/ui.h”

Then everything builds and you can modify ui.c so that it fits within the existing app framework.

A lot of things to hate about this hack:

  1. To support multiple size/resolution/drivers I need to hack the master TFT_eSPI configuration. If you are building multiple sketches that use this library and target different devices, oops…
  2. the lv_conf.h is really part of the generated code. If you go in and change a font size, then you need to edit this file to include that other font (and perhaps not use the original one). Seems a little strange that when you export the ui files, you don’t get a new lv_conf.h… Probably missing something here being a newbie.

After a good nights sleep, probably will put the TFT_eSPI back into the project directory and add some defines to choose the right configuration.

If anybody has been here before and has a better solution, very interested in hearing about it. Probably the real solution is PlatformIO, but I got legacy users…



Spent a day on this, and finally got a “push button” example working within the existing app. Here is what I did:

  1. Left the Sketchbook location alone (Documents/Arduino)
  2. Checked the SquareLine Studio option to create a flat structure for the generated UI. (this might or might not have been required).
  3. Set the output for the UI files to be -pathtosketch-/src
  4. In my primary “.ino” file, I added the following #includes:
    #include <lvgl.h>
    #include <TFT_eSPI.h>
    #include “src/ui.h”

This is a very important thing to do as otherwise downstream .ino’s will not have access to lvgl type defs, and routines.

  1. Then of course created my own initiation routine and kicked off the event loop. (The main program does a round robin running of all the items that need cycles and the lv-timer_handler is just one of them. (obviously can do more here in terms of how often loops are run and there is a danger that the UI can hang while some other processing happens. But that is a future issue to address.)

I still don’t like that TFT_eSPI and lvgl libraries have custom mods to them that is not getting captured in my git repository. Another thing to worry about in the future.

Hope this helps others here.