Square Line Studios /w ESP32-S3 Development Board, with 1.28inch Round Touch LCD

Hello, I am trynig to run this code in my arduino IDE

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

/*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  = 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);
}

every time I do, however, my console is flooded with this error.


Rebooting...
���ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x18 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42027156
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x420036bc  PS      : 0x00060830  A0      : 0x820017b1  A1      : 0x3fcebd40  
A2      : 0x3fc94f80  A3      : 0x00000010  A4      : 0x08000000  A5      : 0x00000001  
A6      : 0x00000000  A7      : 0x00ffffff  A8      : 0x60004000  A9      : 0x00000200  
A10     : 0x3fc95090  A11     : 0x00000001  A12     : 0xffffffff  A13     : 0x0000000b  
A14     : 0x000000ff  A15     : 0x00000000  SAR     : 0x00000012  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000010  LBEG    : 0x42006e08  LEND    : 0x42006e6b  LCOUNT  : 0x00000003  


Backtrace: 0x420036b9:0x3fcebd40 0x420017ae:0x3fcebd70 0x420076da:0x3fcebd90


I am not sure what I am doing wrong and would appreciate any help I can get.

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

Check the docs. Logging — LVGL documentation

The assumption you made about the argument(s) provided to my_print() is almost certainly the problem.

youre referencing these arguments? "const char * buf"

I moved your topic to an appropriate forum category @RylanB.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Sorry, I didn't realize I had to spell it out so completely.

Take a close look at the example in the docs I linked:

void my_log_cb(lv_log_level_t level, const char * buf)
{
  serial_send(buf, strlen(buf));
}
...
lv_log_register_print_cb(my_log_cb);

Now, compare your code, which fails disastrously:

void my_print(const char * buf)
{
...
    lv_log_register_print_cb( my_print ); /* register print function for debugging */

Note that in the example, there are TWO arguments to my_log_cb(), namely "lv_log_level_t level" and "const char * buf".

In contrast, in your code, there is only ONE argument to my_print(), namely "cont char * buf".

Let us imagine that interpreting "level" (a small integer) as a pointer to a text string could lead to a problem. Theoretically speaking, of course, and that probably isn't the only problem with the code, just the first one that jumped out at me.

why is bro so angry that I didn't recognize the problem :joy: :joy:

Not angry, but laziness and failure to pay attention doesn't make a good impression.

Lil bro cannot phantom someone not understanding something so he gets mad and calls it laziness :joy: You being condescending and not being able to explain something without being childish "doesn't make a good impression" :joy:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.