Makerfabs 4.3" touch help

Trying to get touch to work with Makerfabs 4.3" ESP32-S3 module / Squareline v. 1.3.1 / Windows 10.

I’m so beyond lost here. And fair warning – I have dumb questions!

I’ve learned to put the Squareline ui export files into a “Ui” folder in the Arduino libraries folder. Doing that, I’ve created and downloaded into the module some ui’s (with inactive buttons, bars, switches, etc.) which display fine. I can build a ui which in Squareline’s “play mode” will switch between screens when a button is pressed. But when complied and loaded, they don’t respond to touch.

I’ve tried to install a Makerfabs / Squareline example like this one but it crashes almost at the end of compiling. :confounded:

I’m not even clear on what commands I need to include in the .ino file. I mean, I’m including the TAMC_GT911.h (library is installed), and I’ve even tried stuffing the “Touch.h” file from some examples in the Library “Ui” folder and other places. No luck. Do I need to specifically call out x,y coordinates where a given button is located, as if I were building a ui without Squareline? I sort of assumed all that would be handled by the Squareline ui structure itself…?

Words of wisdom please? Encouragement? At least curse my stupidity? :laughing:

Hey Drone601,

I was looking at that same board and sample code yesterday as a path forward to getting a functioning touch screen with SLS. Good to know it’s not as simple as Makerfab promotes.
I’m getting lost in the weeds too so I’m taking a step back and getting a simple touchscreen with a display driver and touch driver that is known to work in the SLS environment (mainly TFT_eSPI). It’s the 2.8" resistive touch with ILI9341 display and XPT2046 touch drivers that you can get through Amazon for under $20 that I’ll control with ESP32. If I get this working with touch feedback I’ll post the results in my thread, “Lessons learned with Arduino”.
In the meantime I hope you get some feedback from the SLS community and get that touch figured out. That Makerfab board looks like a good final solution to my company project.

Bryan

Hey, @bcuervo thanks for the reply. For my application this specific module is fairly uniquely ideal so I’m kind of “stuck” with it. Which is fine as it looks and works pretty darn good, plus cost is very reasonable. And I’m totally loving SLS for the seeming ease and simplicity of laying out a professional-looking GUI.

But holy heck – trying to get SLS and this module to work together has been frustrating. Also not helped by the all-around broken examples, conflicting info, and thin documentation (and “undocumentation”) out there. But admittedly my inexperience is probably a major factor. Still…it just can’t (or shouldn’t) be this hard. What I’d give for one good, simple (like “just 1 button”), actually working project example.

If while agonizingly banging my head on the keyboard I randomly arrive at a string of characters that achieves something even roughly approximating “working”, I’ll happily post it here.

1 Like

I have a similar model ESP32-S3 Parallel TFT with Touch 3.5’’ ILI9488 | Makerfabs.

I could run LVGL demo on their Github repo with no problem. Maybe you can refer to info of this model as well.

However, I am doing all of these in ESP-IDF instead of Arduino.

I do agree that the documentation lacks some working examples for beginners.

To help with that, I suggest you buy products with BSP (board support package) either officially built in in SLS or someone made it in some GitHub repo.

With a working BSP, you can export the code, and flash them onto your device easily. This can help you get around the starting stage of being overwhelmed by a lot of errors.

A word of wisdom:

Squareline generates the graphical UI only. Touch handling will need to be implemented by you using LVGL functionality. I have no idea how your specific board works, but normally you will need to implement that indev.drv.read.cb callback function yourself.
https://docs.lvgl.io/8.3/porting/indev.html

However, it appears that this code already exists in some capacity. “ui.ino” already has the function my_touchpad_read(), and it is even being assigned to the callback as described in the documentation above.

My suggestion is the following:

  • Generate a UI with SLS, find out where in your code the display flushing function my_disp_flush() is implemented.
  • Inside this same .c or .ino file, implement the touch driver like explained above.

Hope this helps! The provided ui.ino file should contain the proper implementation of the touch driver already, so just copy that.

EDIT: this LVGL forum post contains source code Display glitching while connecting to WiFi: ESP32S3+8048S043 - #2 by ASMD - General discussion - LVGL Forum that might be of use to you, it seems to use the same or almost equal system.

Hey, thanks SO much to all above, but especially @Student01HF. I’ve been looking for examples and slowly (mostly this morning) gathered that touch isn’t handled by SLS. You’ve thankfully confirmed this. I know it’s embarrassingly dumb, but given how SLS sets up buttons with events (and works in “play” mode) along with some inappropriate examples I’d looked at, I’d been under the stubborn misconception SLS could – if configured rightly – automagically handle touch.

I’m seeing some of the things you’ve mentioned. I still don’t grasp the usage or syntax yet and the documentation still seems scattered and thin, but I’ll keep clonking away at it with my programming mallet and see what happens.

Thanks again to all. For a novice like me this project is like trying to build a jet engine in the dark with parts from old cars using only salad tongs for tools while going by instructions torn from random washing machine service manuals and I’m an accountant.

The sample code that SLS generates for Arduino IDE includes a touch function which contains “tft.getTouch” but this is from bodmer’s TFT.eSPI library, not LVGL so it looks like SLS is prioritizing TFT.eSPI for touch control?

I can’t even get the “my_touchpad_read ()” to compile and run and I’ve resorted back to a display/touchpad combo that I know works with bodmer’s library. This display runs the bodmer touch samples just fine but no luck getting it to work with SLS.

I’m getting closer. Maybe? Its too foggy to tell.

I’m sort of baffled by this bit of code I found:

static void btn_event_handler(lv_event_t *e) {
lv_event_code_t code = lv_event_get_code(e);
lv_obj_t *btn = (lv_obj_t *)lv_event_get_target(e);
if (code == LV_EVENT_CLICKED) {
THIS IS PRESUMABLY WHERE I NEED TO PUT SOME COMMAND TO EXECUTE THE EVENT1 WHICH I ASSIGNED TO Button4 IN SLS;
}
}

void action_init() {
lv_obj_add_event_cb(ui_Button4, btn_event_handler, LV_EVENT_CLICKED, NULL);

}

Touch aside (maybe), as far as getting it to “actually do something”, is that in the neighborhood of the ballpark? If so, what do I put in that one line to tell it to execute what I’m calling “Event1”?

I hate bugging y’all with these probably obvious or just completely mental questions.

OK, using various examples I’ve boiled down to something I think should work, but doesn’t. As for the SLS side, all I have are 2 screens with a single button on each (on opposite edges of the screen). Per SLS, clicking on a button returns you to the opposite screen. But nope. Any clue what might be wrong? A shoelace untied? Insufficient postage?

#include <lvgl.h>
#include <Arduino_GFX_Library.h>
#include <ArduinoJson.h>
#include "ui.h"

static const uint16_t screenWidth = 800;
static const uint16_t screenHeight = 480;

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[screenWidth * screenHeight / 10];

#define GFX_BL 2
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
    40 /* DE */, 41 /* VSYNC */, 39 /* HSYNC */, 42 /* PCLK */,
    45 /* R0 */, 48 /* R1 */, 47 /* R2 */, 21 /* R3 */, 14 /* R4 */,
    5 /* G0 */, 6 /* G1 */, 7 /* G2 */, 15 /* G3 */, 16 /* G4 */, 4 /* G5 */,
    8 /* B0 */, 3 /* B1 */, 46 /* B2 */, 9 /* B3 */, 1 /* B4 */,
    0 /* hsync_polarity */, 40 /* hsync_front_porch */, 48 /* hsync_pulse_width */, 88 /* hsync_back_porch */,
    0 /* vsync_polarity */, 13 /* vsync_front_porch */, 3 /* vsync_pulse_width */, 32 /* vsync_back_porch */,
    1 /* pclk_active_neg */, 16000000 /* prefer_speed */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
    800 /* width */, 480 /* height */, rgbpanel);

Arduino_DataBus *bus = create_default_Arduino_DataBus();

#include "touch.h"

#if LV_USE_LOG != 0

void my_print(const char *buf)
{
    Serial.printf(buf);
    Serial.flush();
}
#endif

/* Display flushing */
void my_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
    uint32_t w = (area->x2 - area->x1 + 1);
    uint32_t h = (area->y2 - area->y1 + 1);

#if (LV_COLOR_16_SWAP != 0)
    gfx->draw16bitBeRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#else
    gfx->draw16bitRGBBitmap(area->x1, area->y1, (uint16_t *)&color_p->full, w, h);
#endif

    lv_disp_flush_ready(disp);
}

void my_touchpad_read(lv_indev_drv_t *indev_driver, lv_indev_data_t *data)
{
    if (touch_has_signal())
    {
        if (touch_touched())
        {
            data->state = LV_INDEV_STATE_PR;

            /*Set the coordinates*/
            data->point.x = touch_last_x;
            data->point.y = touch_last_y;
        }
        else if (touch_released())
        {
            data->state = LV_INDEV_STATE_REL;
        }
    }
    else
    {
        data->state = LV_INDEV_STATE_REL;
    }
}


void setup()
{
   Serial.begin(115200); /* prepare for possible serial debug */

   String LVGL_Arduino = "Hello Arduino! ";
   LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();

   Serial.println(LVGL_Arduino);
   Serial.println("I am LVGL_Arduino");
    
   touch_init();

   gfx->begin();
   gfx->fillScreen(BLACK);

  #ifdef GFX_BL
  pinMode(GFX_BL, OUTPUT);
  digitalWrite(GFX_BL, HIGH);
  #endif

   lv_init();

#if LV_USE_LOG != 0
    lv_log_register_print_cb(my_print); /* register print function for debugging */
#endif

    lv_disp_draw_buf_init(&draw_buf, buf, NULL, screenWidth * screenHeight / 10);

    static lv_disp_drv_t disp_drv;
    lv_disp_drv_init(&disp_drv);
    
    disp_drv.hor_res = screenWidth;
    disp_drv.ver_res = screenHeight;
    disp_drv.flush_cb = my_disp_flush;
    disp_drv.draw_buf = &draw_buf;
    lv_disp_drv_register(&disp_drv);

    /*Initialize the (dummy) input device driver*/
    static lv_indev_drv_t indev_drv;
    lv_indev_drv_init(&indev_drv);
    indev_drv.type = LV_INDEV_TYPE_POINTER;
    indev_drv.read_cb = my_touchpad_read;
    lv_indev_drv_register(&indev_drv);

    ui_init();
   
    Serial.println("Setup done");

   xTaskCreatePinnedToCore(Task_TFT, "Task_TFT", 20480, NULL, 3, NULL, 0);

}

void Task_TFT(void *pvParameters)
{
    while (1)
    {
        lv_timer_handler();
        vTaskDelay(10);
    }
}

long task_runtime_1 = 0;

void loop()
{
}

I have made a SLS BSP for ESP32-S3 Parallel TFT with Touch 3.5’’ ILI9488 | Makerfabs.

Let’s see if this will help for other members in the forum. I have tried to solve most of the build errors, but I still encounter some <cstblib> include error.

hayschan/board_makerfabs_esp32_s3_parallel_tft_with_touch (github.com)

Hello again. Just to be sure it works: does this button react in any way? Standard behavior should at least make the button animate slightly, the color should get a bit darker. If it does absolutely nothing then we can confirm touch doesn’t work.

P.S. I would advice moving this discussion over the LVGL forum, because this issue is more related to LVGL than SquareLine Studio at this point. I think the people over there might be better suited to get some minimal working example going (perhaps without SLS for the time being).

Yes, it does nothing at all when touched. I’ve since loaded another LVGL example from Makerfabs’ github and while thankfully does actually load without crashing it too does not respond to touch.

I have asked Makerfabs for help, but historically they have been slow to reply so it may be a few days before I can update on this. I will take the advice of going over to the LVGL forum to see if they have any suggestions.

Thanks all!

Touch is working with TAMC_GT911 library! I’m a rookie when it comes to working with Arduino. Posting it here in the hopes that it will help someone else. I’m using a Suntron 3.5 TFT Capacitive Touch screen

#include <lvgl.h>
#include <TFT_eSPI.h>
#include <ui.h>
#include <TAMC_GT911.h>

#define TOUCH_SDA 33
#define TOUCH_SCL 32
#define TOUCH_INT 21
#define TOUCH_RST 25
#define TOUCH_WIDTH 320
#define TOUCH_HEIGHT 480
/Don’t forget to set Sketchbook location in File/Preferencesto the path of your UI project (the parent foder of this INO file)/

/Change to your screen resolution/
static const uint16_t screenWidth = 320;
static const uint16_t screenHeight = 480;

static lv_disp_draw_buf_t draw_buf;
static lv_color_t buf[ screenWidth * screenHeight / 10 ];

TFT_eSPI tft = TFT_eSPI(); /* TFT instance */
TAMC_GT911 tp = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);

#if LV_USE_LOG != 0
/* Serial debugging */
void my_print(const char * buf)
{
Serial.printf(buf);
Serial.flush();
}
#endif

/* Display flushing */
void my_disp_flush( lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p )
{
uint32_t w = ( area->x2 - area->x1 + 1 );
uint32_t h = ( area->y2 - area->y1 + 1 );

tft.startWrite();
tft.setAddrWindow( area->x1, area->y1, w, h );
tft.pushColors( ( uint16_t * )&color_p->full, w * h, true );
tft.endWrite();

lv_disp_flush_ready( disp );

}

/Read the touchpad/
void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
{
uint16_t touchX = 0, touchY = 0;
tp.read();
bool touched = false;

if(tp.isTouched){
  touched = true;
  for (int i=0; i<tp.touches; i++){
    touchX = tp.points[i].x;
    touchY = tp.points[i].y;
}

}

if( !touched )
{
    data->state = LV_INDEV_STATE_REL;
}
else
{
    data->state = LV_INDEV_STATE_PR;

    /*Set the coordinates*/
    data->point.x = touchX;
    data->point.y = touchY;

    Serial.print( "Data x " );
    Serial.println( touchX );

    Serial.print( "Data y " );
    Serial.println( touchY );
}

}

void setup()
{
Serial.begin( 115200 ); /* prepare for possible serial debug */

String LVGL_Arduino = "Hello Arduino! ";
LVGL_Arduino += String('V') + lv_version_major() + "." + lv_version_minor() + "." + lv_version_patch();

Serial.println( LVGL_Arduino );
Serial.println( "I am LVGL_Arduino" );

lv_init();

#if LV_USE_LOG != 0
lv_log_register_print_cb( my_print ); /* register print function for debugging */
#endif

tft.begin();          /* TFT init */
tft.setRotation( 0 ); /* Landscape orientation, flipped */
tp.begin();
tp.setRotation(ROTATION_INVERTED);

lv_disp_draw_buf_init( &draw_buf, buf, NULL, screenWidth * screenHeight / 10 );

/*Initialize the display*/
static lv_disp_drv_t disp_drv;
lv_disp_drv_init( &disp_drv );
/*Change the following line to your display resolution*/
disp_drv.hor_res = screenWidth;
disp_drv.ver_res = screenHeight;
disp_drv.flush_cb = my_disp_flush;
disp_drv.draw_buf = &draw_buf;
lv_disp_drv_register( &disp_drv );

/*Initialize the (dummy) input device driver*/
static lv_indev_drv_t indev_drv;
lv_indev_drv_init( &indev_drv );
indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_touchpad_read;
lv_indev_drv_register( &indev_drv );


ui_init();

Serial.println( "Setup done" );

}

void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
}

Hi all! First, let me thank everyone who helped out with this. With your kind assistance, everything works now!

In fact the code I posted above (August 7) basically works fine. In that particular case the problem was that even though the Makerfabs module displayed my UI on the screen, the code (or at least the touch part) doesn’t really start running until you press the hardware RST button on the back of the module. Really thought I had tried that, but must not have or else I was pressing the FLASH button which is next to it. :thinking: :upside_down_face:

1 Like

That great!
I just looked over your code and realized you aren’t even using the TFT_eSPI library. I had thought that we were stuck with using this but good to know otherwise.

I had the same problem, I solved it with this link

The link didn’t solve all my problems but put me on the right path

I created a Board Support Package (BSP) for the Makerfabs 3.5" touch model.

I posted on the details on the forum as well Introducing the Makerfabs 3.5" Touch TFT Display BSP for Squareline Studio! :rocket: - My projects - Forum - SquareLine Studio.

Not sure if this helps or not. I hope there is some similarity between them as they all come from Makerfabs.