Hi,
I am running a code on ESP IDE for WT32-SC01 Plus Touch LCD which has a ESP32 S3 MCU.
I am displaying 60 float numbers on a page that is under menu section of my UI. The way I hav implemented it works but it seems super inefficient and I can see my LCD is struggling to update the numbers (CPU usage goes to 98%). How ever, I can not find any other way to do it. Can anyone suggest a better way?
Here is the simplified code:
The code block(s) should be formatted like:
void Rate_0(void *pvParameter)
{
TickType_t xLastWakeTime0;
const TickType_t xFrequency = 1 / portTICK_PERIOD_MS; // 1000 Hz
xLastWakeTime0 = xTaskGetTickCount();
char str[25];
while (1) {
lv_timer_handler();
sprintf(str, "Status: %.2f", *(IncomingData485 +0));
lv_label_set_text(ui_Status, str);
sprintf(str, "ArmPos1: %.2f", *(IncomingData485 +1));
lv_label_set_text(ui_ArmPos1, str);
sprintf(str, "ArmPos2: %.2f", *(IncomingData485 +2));
lv_label_set_text(ui_ArmPos2, str);
.
.
.
sprintf(str, "ArmPos58: %.2f", *(IncomingData485 +58));
lv_label_set_text(ui_ArmPos58, str);
sprintf(str, "ArmPos59: %.2f", *(IncomingData485 +59));
lv_label_set_text(ui_ArmPos59, str);
vTaskDelayUntil(&xLastWakeTime0, xFrequency);
}
}
extern "C" void app_main(void)
{
/* Initialize model */
init_lvgl_lgfx();
ui_init();
xTaskCreate(Rate_0, "Rate_0", 10240 , NULL, configMAX_PRIORITIES-1,NULL);
}
As you can, these numbers are getting updated 1000 times per second in my loop. However, I do not need them to be updated all the time. I only want them updated when I go to that specific page in my menu UI. when I actually try to see them.
- How can I make them run only when that page is showing?
- Is it even an efficient way to put the number in a string then use “lv_label_set_text” to update it on screen? is there any other way?
PS. The code freaks out if I take the “lv_label_set_text” functions out of “lv_timer_handler” task and put it in another task with a different rate or even if I put them all in an “if” condition that makes it run less frequent. Not sure why that happens. By freaking out I mean it interrupts other features in my code and they wont work properly.