Skip to content

Commit 844b751

Browse files
committed
use lvgl timer to send refresh event to current screen
1 parent df323af commit 844b751

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/3rd_party_adapters/LVGL/GuiEngine.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ static void flushSSD1306Adafruit(lv_disp_drv_t *disp_drv, const lv_area_t *area,
3737
lv_disp_flush_ready(disp_drv);
3838
}
3939

40+
/**
41+
* lvgl timer function to be called from lv_timer_handler()
42+
* it shall refresh the data on a currently active screen
43+
* @param timer
44+
*/
45+
static void screenRefresh(lv_timer_t *timer)
46+
{
47+
if (CurrentScreen == nullptr)
48+
return;
49+
50+
CurrentScreen->refresh();
51+
}
52+
4053
static IKeypad *myKeypad = nullptr;
4154

4255
/**
@@ -95,6 +108,9 @@ GuiEngine::GuiEngine(const Configuration &configuration, TwoWire &i2c)
95108
lv_label_set_text(label, "LVGL is up");
96109
lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0);
97110

111+
// add screen refresh timer function to refresh screen data
112+
static lv_timer_t *timer = lv_timer_create(screenRefresh, 1000, nullptr);
113+
98114
// display lvgl screen
99115
lv_timer_handler();
100116
}
@@ -200,7 +216,6 @@ void GuiEngine::registerKeyPad(IKeypad *keypad)
200216
*/
201217
void GuiEngine::refresh()
202218
{
203-
CurrentScreen->refresh();
204219
lv_timer_handler();
205220
LV_LOG_TRACE("Adafruit display() start");
206221
this->display.display();

0 commit comments

Comments
 (0)