Squareline GUI + Sunton ESP32-8048S043 4.3" 800x480 capacitive touch display

Hello,

I am trying for days now to cobble together different code snippets for ESP32 display / GUI programming with low success rate. I got the LVGL widget demo running (GitHub - zingo/Sunton_ESP32-8048S043: Basic LVGL demo setup of Sunton ESP32-S3 4.3" 800*480 IPS with Touch).

But no success yet uploading / changing the code to integrate and start with custom UI generated by Squareline. Also compile errors trying to use newer GFX library versions.

Can anybody help me with a basic code package in VSCode/PlatformIO utilizing arduino and current libraries:

lib_deps = 
	moononournation/GFX Library for Arduino@^1.4.0
	lvgl/lvgl@^8.3.9
	tamctec/TAMC_GT911@^1.0.2
	SPI@^2.0.0
	Wire@^2.0.0

With a working UI (made in squareline, simple button transition from screen 1 > screen 2) so I can go from there?

My hardware is a Sunton ESP32-8048S043 4.3" 800x480 capacitive touch display.

I am actually going to be helping another person with a Sunton display accomplish the same exact thing you are trying to do. So I can kill 2 birds with one stone and get it going for you as well.

1 Like

In the meantime after a TON of trial and error I finally got it working! Showing a pretty basic test UI project from Squareline.

See my full project attached for VSCode on Github. Hope it works … it is my first upload.

Do not expect extensive support though … :laughing:

But for my last puzzle piece I need some further help.

I now have everything setup, display works with Squareline GUI and touch as well.

What I am trying to achieve is when a button on the Squareline GUI is pressed, a HEAD http request is send.

I have the connect to Wifi and Http request script and it works in the main.cpp:

// Wifi Setup
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "PUT-SSID-HERE";     // Replace with your network SSID (name)
const char* password = "PUT-PW-HERE";   // Replace with your network password

void setup() {
  Serial.begin(115200); // Begin serial communication at 9600 baud rate

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  Serial.print("Connecting to ");
  Serial.println(ssid);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void sendHEADRequest(String url) {
  HTTPClient http;
  // Your URL for the HEAD request
  http.begin(url);
  int httpCode = http.sendRequest("HEAD");
  //http.end();
}

void loop()
{
  // Head Request Test -> BLUE COLOR
  sendHEADRequest("http://192.168.178.59/win&A=128&FX=0&R=0&G=0&B=255"); // Replace with your URL
  Serial.println("Head request send!!!");
  delay(3000); // Debouncing delay
}

But putting the code in the main.cpp obviously does not work in combination with the button press. I identified the function call for my button is in “ui.c”:

///////////////////// FUNCTIONS ////////////////////
void ui_event_Button1( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
if ( event_code == LV_EVENT_RELEASED) {
      _ui_screen_change( &ui_Screen2, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_Screen2_screen_init);
      _ui_screen_delete( &ui_Screen1);
}

But if I just change it to:

void ui_event_Button1( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
if ( event_code == LV_EVENT_RELEASED) {
      _ui_screen_change( &ui_Screen2, LV_SCR_LOAD_ANIM_FADE_ON, 500, 0, &ui_Screen2_screen_init);
      _ui_screen_delete( &ui_Screen1);
      sendHEADRequest("http://192.168.178.59/win&A=128&FX=0&R=0&G=255&B=0"); // Replace with your URL
}

… it throws a couple of errors because of course the ui.c files is not aware of the libraries and function definitions.

I am quite new to C … could someone help me understand this and get it to work? What would be the easiest way to make “ui.c” aware of the function … or to put it there directly? But then I get a few errors because some libraries are missing / not correctly routed to that file…

If I have the setup:

main.cpp with the function:

void myFunction() {
  sendHEADRequest("http://192.168.178.59/win&A=128&FX=0&R=0&G=255&B=0");
}

main.h with the declaration:

// MAIN.h
#ifndef MAIN_H
#define MAIN_H

void myFunction();

#endif

ui.c with the call:

#include "main.h"
...
void ui_event_Button3( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
if ( event_code == LV_EVENT_RELEASED) {
      greenBtn( e );
      myFunction();
}

… why do I get an error: “undefined reference to `myFunction’”

IT WORKS NOW!

… as expected … C/C++ basic language understanding is my problem. But this solves my problem:

main.h

#ifndef MAIN_H
#define MAIN_H

#ifdef __cplusplus

extern "C"
{

#endif

//declare functions here
  void myFunction();

#ifdef __cplusplus

}

#endif

#endif

main.cpp

#include "main.h"
...
extern "C" void myFunction() {
  sendHEADRequest("http://192.168.178.59/win&A=128&FX=0&R=0&G=255&B=0");
}

ui.c

#include "main.h"
...
void ui_event_Button3( lv_event_t * e) {
    lv_event_code_t event_code = lv_event_get_code(e);lv_obj_t * target = lv_event_get_target(e);
if ( event_code == LV_EVENT_RELEASED) {
      greenBtn( e );
      myFunction();
}

Great! Now I have everything to build my remote controller. :grinning:

Yop but ui.c is not place for edit code… Learn use events in squareline
Yuo can choice ui_events.c or cpp

1 Like

Yes I moved my function calls there!

That is a working board for Squareline Studio