m5stack / Core2-for-AWS-IoT-Kit

Accompanying code for use with AWS IoT Kit content. Works with PlatformIO and ESP-IDF v4.2.
https://m5stack.com/collections/m5-core/products/m5stack-core2-esp32-iot-development-kit-for-aws-iot-edukit
MIT License
127 stars 66 forks source link

The guiTask sometimes stops. #36

Closed arms22 closed 3 years ago

arms22 commented 3 years ago

The guiTask does not get out of the while loop of lv_refr_vdb_flush. https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/blob/d5b92eff833e6fc4cbefa23114646214dc055fb9/Smart-Thermostat/components/core2forAWS/tft/lvgl/lvgl/src/lv_core/lv_refr.c#L759

In disp_spi_transaction, I think it is because the call to spi_device_queue_trans returns ESP_ERR_NO_MEM and does not start SPI transfer. https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/blob/d5b92eff833e6fc4cbefa23114646214dc055fb9/Smart-Thermostat/components/core2forAWS/tft/disp_spi.c#L141

rashedtalukder commented 3 years ago

Thank you for reporting this. I'll take a look today.

rashedtalukder commented 3 years ago

Approximately how long do you leave it running before you see this error?

arms22 commented 3 years ago

Occurs frequently while using WiFi and Bluetooth. It seems to occur easily when transferring 40960bytes (DISP_BUF_SIZE * sizeof(lv_color_t)) data with spi_device_queue_trans.

rashedtalukder commented 3 years ago

Ok I see, so I'm assuming this is a modified project and not the standard Smart Thermostat project that we provide (since we don't use Bluetooth).

So what is happening is that you're passing in too much data to the display library to be shown. The 40960 byte limit is the buffer limit for the display and is calculating by:

Display width x 64 bytes (number of pixels) x 2 bytes (16 bit color depth): 320px 64 2 = 40960bytes

The flush callback copies the buffer's content to the display, but your buffer is already full, so it can't. Solution is to shrink down whatever it is you're trying to send to be 320px240px (or 320px320px and the bottom 80px will not show up) so that it fits. https://docs.lvgl.io/v7/en/html/porting/display.html#display-driver

Is that helpful?

arms22 commented 3 years ago

Yes, I'm modifying the Smart Thermostat project. I am sorry that I did not tell that to you.

I changed the DISP_BUF_SIZE to the following and the problem seems to be gone.

define DISP_BUF_SIZE (LV_HOR_RES_MAX * 32)

Thank you.

rashedtalukder commented 3 years ago

Well, that is one way...but you're just wasting memory and who knows what other consequences of trying to write to an area that doesn't exist. Can you reduce the size of whatever you're trying to display?