No Touch when using SquareLine Studio with Seeed XIAO ESP32S3 and Round-Display

I have followed the ‘HardwareTest’ example (Getting Started | Seeed Studio Wiki), so I know the hardware (specifically the touch screen ) is working.
But, I can’t get touch working using SquareLine Studio.
I have followed the steps from the tutorial, (Using LVGL and TFT for all XIAO Series | Seeed Studio Wiki). I’ve created a simple slider just for testing, compiled, and uploaded, but the Touch screen is not working.
I note the Readme file, says ‘project doesn’t contain touch pad driver. You can use an other Arudino library for your touchpad controller.’
How do I setup things up to get touch working?

Using library lvgl at version 8.2.0
Using library TFT_eSPI at version 2.5.22
Using library SPI at version 2.0.0
Using library Wire at version 2.0.0
Using library FS at version 2.0.0
Using library SPIFFS at version 2.0.0

Hi there,
Can you post the code?
So I have it working with Xiao the Nrf52840 here;

I know your using the Xiao ESP32S3 , I’ll try that next.
Take a LQQK at the compiler output anyway and the LIB versions for some insight, turned out certain versions are what make it go.
The slider was touchy, the SD button AOK.
HTH
GL :slight_smile: PJ

tbh, I’d be happy to pay you to sort out the bugs to get the Seeed Studio XIAO ESP32S3 and Seeed Studio Round Display working with Squareline with current or recent versions of everything.
Is that something you’d do?

what code you you want me to upload,

the ui.ino, here it is

#include <lvgl.h>

#include <TFT_eSPI.h>

#include “ui.h”

/*If you want to use the LVGL examples,

make sure to install the lv_examples Arduino library

and uncomment the following line.

#include <lv_examples.h>

*/

/Change to your screen resolution/

static const uint16_t screenWidth = 240;

static const uint16_t screenHeight = 240;

static lv_disp_draw_buf_t draw_buf;

static lv_color_t buf[ screenWidth * screenHeight / 10 ];

TFT_eSPI tft = TFT_eSPI(screenWidth, screenHeight); /* TFT instance */

#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;

bool touched = false;//tft.getTouch( &touchX, &touchY, 600 );

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( 3 ); /* Landscape orientation, flipped */

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);

}

The code for the touchscreen needs to be configured separately, I found the code snippet to turn it off in the code snippet you provided:

bool touched = false;//tft.getTouch( &touchX, &touchY, 600 );

i wish it were that easy, that piece of code doesn’t work with the hardware I have

Hi there,
Well you fail , step one…LOL
Post the code with the </> preformatted above , that just looks nasty…? :face_with_peeking_eye:
Can you post the compiler output so we can see what you have going on here?
The first 4.5 lines and the last 20 b4 the upload portion.
HTH
GL :slight_smile: PJ

Does this work?

// This sketch is to test the touch controller, nothing is displayed
// on the TFT.  The TFT_eSPI library must be configured to suit your
// pins used. Make sure both the touch chip select and the TFT chip
// select are correctly defined to avoid SPI bus contention.

// Make sure you have defined a pin for the touch controller chip
// select line in the user setup file or you will see "no member"
// compile errors for the touch functions!

// It is a support and diagnostic sketch for the TFT_eSPI library:
// https://github.com/Bodmer/TFT_eSPI

// The "raw" (unprocessed) touch sensor outputs are sent to the
// serial port. Touching the screen should show changes to the x, y
// and z values. x and y are raw ADC readings, not pixel coordinates.

#include <SPI.h>
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();

//====================================================================

void setup(void) {
  Serial.begin(115200);
  Serial.println("\n\nStarting...");

  tft.init();
}

//====================================================================

void loop() {

  uint16_t x, y;

  tft.getTouchRaw(&x, &y);
  
  Serial.printf("x: %i     ", x);

  Serial.printf("y: %i     ", y);

  Serial.printf("z: %i \n", tft.getTouchRawZ());

  delay(250);

}

//====================================================================

mind the info.

from man himself. https://github.com/Bodmer/TFT_eSPI/blob/master/examples/Test%20and%20diagnostics/Test_Touch_Controller/Test_Touch_Controller.ino

I used this tool from Bodmer to diagnose… You should try that. and report Back.

/*
  This sketch reads the user setup information from the processor via the Serial Port

  It is a support and diagnostic sketch for the TFT_eSPI library:
  https://github.com/Bodmer/TFT_eSPI

  The output is essentially a copy of the User_Setep configuration so can be used to
  verify the correct settings are being picked up by the compiler.

  If support is needed the output can be cut and pasted into an Arduino Forum post and
  already includes the formatting [code]...[/code] markups.

  Written by Bodmer 9/4/18
*/
//>>>>> Note: STM32 pin references above D15 may not reflect board markings <<<<<

#include <SPI.h>
#include <TFT_eSPI.h>      // Graphics library

TFT_eSPI tft = TFT_eSPI(); // Invoke library

#ifdef ARDUINO_ARCH_ESP8266
  ADC_MODE(ADC_VCC); // Read the supply voltage
#endif

setup_t user; // The library defines the type "setup_t" as a struct
              // Calling tft.getSetup(user) populates it with the settings
//------------------------------------------------------------------------------------------

void setup() {
  // Use serial port
  Serial.begin(9600);
 delay(2500);  //relax...Get Ready for serial port
  Serial.println();
  Serial.println();
  Serial.println("Power ON ");  // Let's BEGIN!!
  Serial.println("");
  // Init and get the time
 // configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  //printLocalTime();
  Serial.println("Program " __FILE__ " compiled on " __DATE__ " at " __TIME__ );
  Serial.println();
  // Initialise the TFT screen
  tft.init();
}

//------------------------------------------------------------------------------------------

void loop(void) {

tft.getSetup(user); //

Serial.print("\n[code]\n");

Serial.print ("TFT_eSPI ver = "); Serial.println(user.version);
printProcessorName();
#if defined (ESP32) || defined (ARDUINO_ARCH_ESP8266)
  if (user.esp < 0x32F000 || user.esp > 0x32FFFF) { Serial.print("Frequency    = "); Serial.print(ESP.getCpuFreqMHz());Serial.println("MHz"); }
#endif
#ifdef ARDUINO_ARCH_ESP8266
  Serial.print("Voltage      = "); Serial.print(ESP.getVcc() / 918.0); Serial.println("V"); // 918 empirically determined
#endif
Serial.print("Transactions = "); Serial.println((user.trans  ==  1) ? "Yes" : "No");
Serial.print("Interface    = "); Serial.println((user.serial ==  1) ? "SPI" : "Parallel");
#ifdef ARDUINO_ARCH_ESP8266
if (user.serial ==  1){ Serial.print("SPI overlap  = "); Serial.println((user.overlap == 1) ? "Yes\n" : "No\n"); }
#endif
if (user.tft_driver != 0xE9D) // For ePaper displays the size is defined in the sketch
{
  Serial.print("Display driver = "); Serial.println(user.tft_driver, HEX); // Hexadecimal code
  Serial.print("Display width  = "); Serial.println(user.tft_width);  // Rotation 0 width and height
  Serial.print("Display height = "); Serial.println(user.tft_height);
  Serial.println();
}
else if (user.tft_driver == 0xE9D) Serial.println("Display driver = ePaper\n");

if (user.r0_x_offset  != 0)  { Serial.print("R0 x offset = "); Serial.println(user.r0_x_offset); } // Offsets, not all used yet
if (user.r0_y_offset  != 0)  { Serial.print("R0 y offset = "); Serial.println(user.r0_y_offset); }
if (user.r1_x_offset  != 0)  { Serial.print("R1 x offset = "); Serial.println(user.r1_x_offset); }
if (user.r1_y_offset  != 0)  { Serial.print("R1 y offset = "); Serial.println(user.r1_y_offset); }
if (user.r2_x_offset  != 0)  { Serial.print("R2 x offset = "); Serial.println(user.r2_x_offset); }
if (user.r2_y_offset  != 0)  { Serial.print("R2 y offset = "); Serial.println(user.r2_y_offset); }
if (user.r3_x_offset  != 0)  { Serial.print("R3 x offset = "); Serial.println(user.r3_x_offset); }
if (user.r3_y_offset  != 0)  { Serial.print("R3 y offset = "); Serial.println(user.r3_y_offset); }

if (user.pin_tft_mosi != -1) { Serial.print("MOSI    = "); Serial.print("GPIO "); Serial.println(getPinName(user.pin_tft_mosi)); }
if (user.pin_tft_miso != -1) { Serial.print("MISO    = "); Serial.print("GPIO "); Serial.println(getPinName(user.pin_tft_miso)); }
if (user.pin_tft_clk  != -1) { Serial.print("SCK     = "); Serial.print("GPIO "); Serial.println(getPinName(user.pin_tft_clk)); }

#ifdef ARDUINO_ARCH_ESP8266
if (user.overlap == true)
{
  Serial.println("Overlap selected, following pins MUST be used:");

                             Serial.println("MOSI     = SD1 (GPIO 8)");
                             Serial.println("MISO     = SD0 (GPIO 7)");
                             Serial.println("SCK      = CLK (GPIO 6)");
                             Serial.println("TFT_CS   = D3  (GPIO 0)\n");

  Serial.println("TFT_DC and TFT_RST pins can be user defined");
}
#endif
String pinNameRef = "GPIO ";
#ifdef ARDUINO_ARCH_ESP8266
  pinNameRef = "PIN_D";
#endif

if (user.esp == 0x32F) {
  Serial.println("\n>>>>> Note: STM32 pin references above D15 may not reflect board markings <<<<<");
  pinNameRef = "D";
}
if (user.pin_tft_cs != -1) { Serial.print("TFT_CS   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_cs)); }
if (user.pin_tft_dc != -1) { Serial.print("TFT_DC   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_dc)); }
if (user.pin_tft_rst!= -1) { Serial.print("TFT_RST  = " + pinNameRef); Serial.println(getPinName(user.pin_tft_rst)); }

if (user.pin_tch_cs != -1) { Serial.print("TOUCH_CS = " + pinNameRef); Serial.println(getPinName(user.pin_tch_cs)); }

if (user.pin_tft_wr != -1) { Serial.print("TFT_WR   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_wr)); }
if (user.pin_tft_rd != -1) { Serial.print("TFT_RD   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_rd)); }

if (user.pin_tft_d0 != -1) { Serial.print("\nTFT_D0   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d0)); }
if (user.pin_tft_d1 != -1) { Serial.print("TFT_D1   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d1)); }
if (user.pin_tft_d2 != -1) { Serial.print("TFT_D2   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d2)); }
if (user.pin_tft_d3 != -1) { Serial.print("TFT_D3   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d3)); }
if (user.pin_tft_d4 != -1) { Serial.print("TFT_D4   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d4)); }
if (user.pin_tft_d5 != -1) { Serial.print("TFT_D5   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d5)); }
if (user.pin_tft_d6 != -1) { Serial.print("TFT_D6   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d6)); }
if (user.pin_tft_d7 != -1) { Serial.print("TFT_D7   = " + pinNameRef); Serial.println(getPinName(user.pin_tft_d7)); }

#if defined (TFT_BL)
  Serial.print("\nTFT_BL           = " + pinNameRef); Serial.println(getPinName(user.pin_tft_led));
  #if defined (TFT_BACKLIGHT_ON)
    Serial.print("TFT_BACKLIGHT_ON = "); Serial.println(user.pin_tft_led_on == HIGH ? "HIGH" : "LOW");
  #endif
#endif

Serial.println();

uint16_t fonts = tft.fontsLoaded();
if (fonts & (1 << 1))        Serial.print("Font GLCD   loaded\n");
if (fonts & (1 << 2))        Serial.print("Font 2      loaded\n");
if (fonts & (1 << 4))        Serial.print("Font 4      loaded\n");
if (fonts & (1 << 6))        Serial.print("Font 6      loaded\n");
if (fonts & (1 << 7))        Serial.print("Font 7      loaded\n");
if (fonts & (1 << 9))        Serial.print("Font 8N     loaded\n");
else
if (fonts & (1 << 8))        Serial.print("Font 8      loaded\n");
if (fonts & (1 << 15))       Serial.print("Smooth font enabled\n");
Serial.print("\n");

if (user.serial==1)        { Serial.print("Display SPI frequency = "); Serial.println(user.tft_spi_freq/10.0); }
if (user.pin_tch_cs != -1) { Serial.print("Touch SPI frequency   = "); Serial.println(user.tch_spi_freq/10.0); }

Serial.println("[/code]");

delay(3000);
}

void printProcessorName(void)
{
  Serial.print("Processor    = ");
  if ( user.esp == 0x8266) Serial.println("ESP8266");
  if ( user.esp == 0x32)   Serial.println("ESP32");
  if ( user.esp == 0x32F)  Serial.println("STM32");
  if ( user.esp == 0x2040) Serial.println("RP2040");
  if ( user.esp == 0x0000) Serial.println("Generic");
}

// Get pin name
int8_t getPinName(int8_t pin)
{
  // For ESP32 and RP2040 pin labels on boards use the GPIO number
  if (user.esp == 0x32 || user.esp == 0x2040) return pin;

  if (user.esp == 0x8266) {
    // For ESP8266 the pin labels are not the same as the GPIO number
    // These are for the NodeMCU pin definitions:
    //        GPIO       Dxx
    if (pin == 16) return 0;
    if (pin ==  5) return 1;
    if (pin ==  4) return 2;
    if (pin ==  0) return 3;
    if (pin ==  2) return 4;
    if (pin == 14) return 5;
    if (pin == 12) return 6;
    if (pin == 13) return 7;
    if (pin == 15) return 8;
    if (pin ==  3) return 9;
    if (pin ==  1) return 10;
    if (pin ==  9) return 11;
    if (pin == 10) return 12;
  }

  if (user.esp == 0x32F) return pin;

  return pin; // Invalid pin
}

You get something like this Hopefully…

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4201586e
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710

Power ON 

Program C:\Users\Dude\AppData\Local\Temp\.arduinoIDE-unsaved2024119-12644-wgc9eb.01bx\Read_User_Setup\Read_User_Setup.ino compiled on Feb 20 2024 at 19:56:19

[code]
TFT_eSPI ver = 2.5.22
Processor    = ESP32
Frequency    = 160MHz
Transactions = Yes
Interface    = SPI
Display driver = 9A01
Display width  = 240
Display height = 240

MOSI    = GPIO 10
MISO    = GPIO 9
SCK     = GPIO 8
TFT_CS   = GPIO 3
TFT_DC   = GPIO 5

Font GLCD   loaded
Font 2      loaded
Font 4      loaded
Font 6      loaded
Font 7      loaded
Font 8      loaded
Smooth font enabled

Display SPI frequency = 27.00
[/code]
1 Like

i think that the problem is in the library not on the logic

because the same logic works with all hardware except our hardware Seeed XIAO ESP32S3 and Round-Display

1 Like

Hi there,
Yes it’s the LIB not the logic, It works if you have the edits made on them.
GL :slight_smile: PJ

btw if you just want to test if it works, I tried this and it works somewhat.

/*
   MIT License

  Copyright (c) 2021 Felix Biego

  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
*/

#include <CST816S.h>

CST816S touch(6, 7, -1, 20);	// sda, scl, rst, irq

void setup() {
  Serial.begin(115200);

  touch.begin();

  Serial.print(touch.data.version);
  Serial.print("\t");
  Serial.print(touch.data.versionInfo[0]);
  Serial.print("-");
  Serial.print(touch.data.versionInfo[1]);
  Serial.print("-");
  Serial.println(touch.data.versionInfo[2]);

}


void loop() {

  if (touch.available()) {
    Serial.print(touch.gesture());
    Serial.print("\t");
    Serial.print(touch.data.points);
    Serial.print("\t");
    Serial.print(touch.data.event);
    Serial.print("\t");
    Serial.print(touch.data.x);
    Serial.print("\t");
    Serial.println(touch.data.y);

  }


}

serial port output some data

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x15 (USB_UART_CHIP_RESET),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40053b60
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
E (84) gpio: gpio_set_level(226): GPIO output gpio_num error
E (134) gpio: gpio_set_level(226): GPIO output gpio_num error
E (139) gpio: gpio_set_level(226): GPIO output gpio_num error
0	0-0-0
NONE	0	3	2367	1056
UNKNOWN	32	0	0	0
UNKNOWN	25	0	0	2335
NONE	0	0	0	0
NONE	0	0	0	48

:wink: :v: