Newbies Problem Solving ( TouchScreen not working, sketch too big, header include problems, uncalibrated screen...)


Hi everyone! It’s been long days wondering how to use SquareLine Studio and LVGL library. For newbies, it could be a rough and hard experience, but it’s worth the effort. In this post I want to give some tips and common errors to save you a ton of time.
Problem 1- .dram0.bss' will not fit in region dram0_0_seg’
This problem occurs when you try to compile and upload the sketch. The main mistake here is making a 32 bit project on SquareLineStudio. The solution is easy, you can set 16 bit color depth before creating the project or change the project settings before exporting it and set it to 16.

Problem 2- Try to not use uppercase or space in your projects name.
Giving your project a name like FIRST PROJECT, can cause some errors at including the headers when you export and compile the ui.ino file.

Problem 3- My touchscreen doesn’t work.
It’s a very common error. This is caused by the declaration of the function my_touchpad_read. The variable touched is assigned to false and it has a comment next to it. Make sure to uncomment and delete the FALSE assignation. Your code should appear like this

void my_touchpad_read( lv_indev_drv_t * indev_driver, lv_indev_data_t * data )
    uint16_t touchX = 0, touchY = 0;

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

    if( !touched )
        data->state = LV_INDEV_STATE_REL;
        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 );

A good way to make sure that the touchpad works is to open the serial monitor, set it at 115200baud and see if it prints any value.

Problem 4-I’m getting touchscreen values, but my buttons or events don’t get triggered.
Did you make an event that it gets triggered when releasing or touching a button? You tried it at SquareLine Studio, and it seems to work nicely. When you compile and upload it, it doesn’t work. You are looking at the serial monitor to check if the touchscreen works and its printing values. So, what’s wrong here?In my case, the problem was solved by switching the screenHeight and Width at the beginning of the code. You should also make sure you have the proper rotation at the tft. setrotation assignment.

TFT_eSPI tft = TFT_eSPI(screenHeight, screenWidth); 

I hope I helped someone with this post!