mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
Allow changing LVGL refresh and animation period
This commit is contained in:
parent
de0aeab435
commit
2738bff96a
@ -90,6 +90,7 @@ const char FP_GUI_BACKLIGHTINVERT[] PROGMEM = "bcklinv";
|
||||
const char FP_GUI_POINTER[] PROGMEM = "cursor";
|
||||
const char FP_GUI_LONG_TIME[] PROGMEM = "long";
|
||||
const char FP_GUI_REPEAT_TIME[] PROGMEM = "repeat";
|
||||
const char FP_GUI_FPS[] PROGMEM = "fps";
|
||||
const char FP_DEBUG_TELEPERIOD[] PROGMEM = "tele";
|
||||
const char FP_DEBUG_ANSI[] PROGMEM = "ansi";
|
||||
const char FP_GPIO_CONFIG[] PROGMEM = "config";
|
||||
|
@ -57,6 +57,8 @@ uint32_t screenshotEtag = 0;
|
||||
void (*drv_display_flush_cb)(struct _disp_drv_t* disp_drv, const lv_area_t* area, lv_color_t* color_p);
|
||||
|
||||
static lv_disp_buf_t disp_buf;
|
||||
static bool gui_initialized = false;
|
||||
static uint32_t anim_fps_deferred = 0;
|
||||
|
||||
static inline void gui_init_lvgl()
|
||||
{
|
||||
@ -100,6 +102,27 @@ void gui_hide_pointer(bool hidden)
|
||||
if(cursor) lv_obj_set_hidden(cursor, hidden || !gui_settings.show_pointer);
|
||||
}
|
||||
|
||||
bool gui_set_fps(uint32_t fps)
|
||||
{
|
||||
if(!gui_initialized) {
|
||||
LOG_ERROR(TAG_GUI, F("GUI not initialized, deferring FPS setting"));
|
||||
anim_fps_deferred = fps;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
uint32_t period = 1000 / fps;
|
||||
// find animation task by its period
|
||||
lv_task_t* task = NULL;
|
||||
while(task = lv_task_get_next(task)) {
|
||||
if(!(task->period == LV_DISP_DEF_REFR_PERIOD)) continue;
|
||||
changed |= (task->period != period);
|
||||
LOG_INFO(TAG_GUI, F("Changing animation period: %u -> %u (%u FPS)"), task->period, period, fps);
|
||||
task->period = period;
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
IRAM_ATTR void gui_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p)
|
||||
{
|
||||
haspTft.flush_pixels(disp, area, color_p);
|
||||
@ -373,6 +396,13 @@ void guiSetup()
|
||||
}
|
||||
#endif // ESP32 && HASP_USE_ESP_MQTT
|
||||
|
||||
// apply deferred FPS setting
|
||||
gui_initialized = true;
|
||||
if(anim_fps_deferred != 0) {
|
||||
gui_set_fps(anim_fps_deferred);
|
||||
anim_fps_deferred = 0;
|
||||
}
|
||||
|
||||
LOG_INFO(TAG_LVGL, F(D_SERVICE_STARTED));
|
||||
}
|
||||
|
||||
@ -612,6 +642,11 @@ bool guiSetConfig(const JsonObject& settings)
|
||||
changed |= status;
|
||||
}
|
||||
|
||||
if(!settings[FPSTR(FP_GUI_FPS)].isNull()) {
|
||||
uint32_t fps = settings[FPSTR(FP_GUI_FPS)].as<uint32_t>();
|
||||
changed |= gui_set_fps(fps);
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
#endif // HASP_USE_CONFIG
|
||||
|
@ -48,6 +48,7 @@ void guiEverySecond(void);
|
||||
void guiStart(void);
|
||||
void guiStop(void);
|
||||
void gui_hide_pointer(bool hidden);
|
||||
bool gui_set_fps(uint32_t fps);
|
||||
|
||||
/* ===== Special Event Processors ===== */
|
||||
void guiCalibrate(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user