Hello, I am new to the world of GUIs. I have been using ESP32’s for projects such as high altitude weather balloons, on-site condition monitoring (vibration analysis), etc. for many years.
So, I used Squareline Studio to create a simple GUI screen with two arcs and several labels. One arc is for temperature and the other for humidity. The data comes from a custom board with an SPL06 and an SHT21 from my weather balloon radiosondes. The screen displays perfectly and the routine to read the data works but the screen just does not update. This is the loop()
void loop()
{
lv_timer_handler(); /* let the GUI do its work */
delay(5);
collectMeasurements();
lv_arc_set_value(ui_Temp, airTemperature);
Serial.println(airTemperature);
lv_label_set_text_fmt(ui_TempTxt, "%d",airTemperature);
lv_arc_set_value(ui_Humid, humidity);
Serial.println(humidity);
lv_label_set_text_fmt(ui_HumTxt, "%d",humidity);
tick.attach_ms(LVGL_TICK_PERIOD, lv_tick_handler);
delay(2000);
}
Every two seconds I get the temperature and humidity sent to the monitor but the screen does not update. Apart from putting the device drivers into the setup() and the collectMeasurements() routine, I have not modifies any of the Squareline Studio generated code. If I insert the extra lines I put in loop() into setup(), it displays the correct values, not the default settings but doesn’t update the screen anymore once it gets into loop().
I am running this on a WT32-SC01 with an ESP32 Wrover chip with 8Mb PSRAM and 4Mb Flash and a and ST7796 TFT driver.
Thanks Tinus, no I have not. Where do I implement it? I have read the documentation and it says it should be called in a higher priority routine than lv_task_handler() (e.g. in an interrupt)
I could set up an interrupt timer and call it, would that work?
Most straightforward option is to implement it in a timer interrupt. Say… once every 2 milliseconds, you then call that lv_tick_inc(2) function in the interrupt.
SO I have sorted out the interrupt timer to fire every 200uS to call lv_tick_inc(2); but I have
error: tick, LVGL_TICK_PERIOD and lv_tick_handler not declared in this scope.
Is there an include or declarations I should be making at the top of the scketch?
That is odd. As long as you have included “lvgl.h” at the top of your file it should recognize those. Does your interrupt just consist of the following?
/* Assuming this is on 2ms timer*/
void interrupt()
{
lv_tick_inc(2);
}