What am I doing wrong. I downloaded squareline studio. Installed it.
Created a new project for arduino, lvgl 8.3, round display, 240x240,16 bit. Rechecked in project settings.
Made a simple UI with an Arc, a label value, and an event. Play in Squareline: works. Export.
Then in ArduinoIDE, I replaced the lvgl files by those from seeed, samen for tft-espi. Set the correct folders and changed the code slightly.
First I got a crashing ESP on loop. This turned out to be the BSP. Downgraded to 2.0.8, and now it compiles, does not crash, and on the serial port it sais ‘setup done’.
However, there’s nothing on the screen.
The relevant code (chaged to use the round display driver from seeed):
#include "Arduino.h"
#define TOUCH_CS 21
#define USE_TFT_ESPI_LIBRARY
#include <lv_xiao_round_screen.h>
#include <ui.h>
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 ];
#if LV_USE_LOG != 0
void my_print(const char * buf)
{
Serial.printf(buf);
Serial.flush();
}
#endif
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 );
}
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 */
while (!Serial) {}
delay(1000);
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();
lv_xiao_disp_init();
lv_xiao_touch_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 );
[bunch of code cut out to shorten post]
ui_init();
Serial.println( "Setup done" );
}
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
}