mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-26 04:36:38 +00:00
Prevent screen updates during antiburn #389
This commit is contained in:
parent
80bda2c78e
commit
180326f843
@ -186,10 +186,15 @@ static lv_task_t* antiburn_task;
|
|||||||
|
|
||||||
bool hasp_stop_antiburn()
|
bool hasp_stop_antiburn()
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
lv_obj_t* layer = lv_disp_get_layer_sys(NULL);
|
|
||||||
|
|
||||||
|
/* Refresh screen to flush callback */
|
||||||
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
|
disp->driver.flush_cb = gui_flush_cb;
|
||||||
|
|
||||||
|
// lv_obj_t* layer = lv_disp_get_layer_sys(NULL);
|
||||||
// if(layer) lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
// if(layer) lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
|
||||||
|
|
||||||
if(antiburn_task) {
|
if(antiburn_task) {
|
||||||
lv_task_del(antiburn_task);
|
lv_task_del(antiburn_task);
|
||||||
lv_obj_invalidate(lv_scr_act());
|
lv_obj_invalidate(lv_scr_act());
|
||||||
@ -197,8 +202,8 @@ bool hasp_stop_antiburn()
|
|||||||
}
|
}
|
||||||
antiburn_task = NULL;
|
antiburn_task = NULL;
|
||||||
hasp_set_wakeup_touch(haspDevice.get_backlight_power() == false); // enabled if backlight is OFF
|
hasp_set_wakeup_touch(haspDevice.get_backlight_power() == false); // enabled if backlight is OFF
|
||||||
gui_hide_pointer(false);
|
|
||||||
|
|
||||||
|
// gui_hide_pointer(false);
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +213,6 @@ void hasp_antiburn_cb(lv_task_t* task)
|
|||||||
if(layer) {
|
if(layer) {
|
||||||
// lv_color_t color[5] = {LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_RED, LV_COLOR_LIME, LV_COLOR_BLUE};
|
// lv_color_t color[5] = {LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_RED, LV_COLOR_LIME, LV_COLOR_BLUE};
|
||||||
// lv_obj_set_style_local_bg_color(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color[task->repeat_count % 5]);
|
// lv_obj_set_style_local_bg_color(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, color[task->repeat_count % 5]);
|
||||||
// lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
|
||||||
lv_disp_t* disp = lv_disp_get_default();
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
lv_disp_drv_t* disp_drv = &disp->driver;
|
lv_disp_drv_t* disp_drv = &disp->driver;
|
||||||
lv_area_t area;
|
lv_area_t area;
|
||||||
@ -231,6 +235,9 @@ void hasp_antiburn_cb(lv_task_t* task)
|
|||||||
if(task->repeat_count != 1) return; // don't stop yet
|
if(task->repeat_count != 1) return; // don't stop yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// lv_obj_invalidate(lv_scr_act());
|
||||||
|
if(task->repeat_count != 1) return; // don't stop yet
|
||||||
|
|
||||||
// task is about to get deleted
|
// task is about to get deleted
|
||||||
hasp_stop_antiburn();
|
hasp_stop_antiburn();
|
||||||
dispatch_state_antiburn(HASP_EVENT_OFF);
|
dispatch_state_antiburn(HASP_EVENT_OFF);
|
||||||
@ -245,13 +252,21 @@ void hasp_set_antiburn(int32_t repeat_count, uint32_t period)
|
|||||||
lv_obj_t* layer = lv_disp_get_layer_sys(NULL);
|
lv_obj_t* layer = lv_disp_get_layer_sys(NULL);
|
||||||
if(!layer) return;
|
if(!layer) return;
|
||||||
|
|
||||||
if(!antiburn_task) antiburn_task = lv_task_create(hasp_antiburn_cb, period, LV_TASK_PRIO_LOWEST, NULL);
|
if(!antiburn_task) antiburn_task = lv_task_create(hasp_antiburn_cb, period, LV_TASK_PRIO_LOW, NULL);
|
||||||
if(antiburn_task) {
|
if(antiburn_task) {
|
||||||
|
// lv_obj_set_style_local_bg_color(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||||
|
// lv_obj_set_style_local_bg_opa(layer, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_COVER);
|
||||||
lv_obj_set_event_cb(layer, first_touch_event_handler);
|
lv_obj_set_event_cb(layer, first_touch_event_handler);
|
||||||
lv_obj_set_click(layer, true);
|
lv_obj_set_click(layer, true);
|
||||||
lv_task_set_repeat_count(antiburn_task, repeat_count);
|
lv_task_set_repeat_count(antiburn_task, repeat_count);
|
||||||
lv_task_set_period(antiburn_task, period);
|
lv_task_set_period(antiburn_task, period);
|
||||||
gui_hide_pointer(true);
|
// gui_hide_pointer(true);
|
||||||
|
|
||||||
|
/* Refresh screen to antiburn callback */
|
||||||
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
|
disp->driver.flush_cb = gui_antiburn_cb;
|
||||||
|
lv_obj_invalidate(lv_scr_act());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO(TAG_HASP, F("Antiburn %s"), D_INFO_FAILED);
|
LOG_INFO(TAG_HASP, F("Antiburn %s"), D_INFO_FAILED);
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,10 @@ uint16_t tft_height = TFT_HEIGHT;
|
|||||||
|
|
||||||
bool screenshotIsDirty = true;
|
bool screenshotIsDirty = true;
|
||||||
uint32_t screenshotEtag = 0;
|
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 lv_disp_buf_t disp_buf;
|
||||||
|
|
||||||
|
|
||||||
static inline void gui_init_lvgl()
|
static inline void gui_init_lvgl()
|
||||||
{
|
{
|
||||||
LOG_VERBOSE(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
LOG_VERBOSE(TAG_LVGL, F("Version : %u.%u.%u %s"), LVGL_VERSION_MAJOR, LVGL_VERSION_MINOR, LVGL_VERSION_PATCH,
|
||||||
@ -141,6 +141,27 @@ IRAM_ATTR void gui_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color
|
|||||||
screenshotIsDirty = true;
|
screenshotIsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gui_antiburn_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p)
|
||||||
|
{
|
||||||
|
/* uint32_t w = (area->x2 - area->x1 + 1);
|
||||||
|
uint32_t h = (area->y2 - area->y1 + 1);
|
||||||
|
uint32_t len = w * h;
|
||||||
|
|
||||||
|
lv_color_t dots[w];
|
||||||
|
lv_area_t line = *area;
|
||||||
|
|
||||||
|
for(lv_coord_t y = 0; y < h; y++) {
|
||||||
|
for(lv_coord_t x = 0; x < w; x++) {
|
||||||
|
dots[x].full = HASP_RANDOM(UINT16_MAX);
|
||||||
|
}
|
||||||
|
line.y1 = area->y1 + y;
|
||||||
|
line.y2 = line.y1;
|
||||||
|
haspTft.flush_pixels(disp, &line, dots);
|
||||||
|
} */
|
||||||
|
/* Tell lvgl that flushing is done */
|
||||||
|
lv_disp_flush_ready(disp);
|
||||||
|
}
|
||||||
|
|
||||||
IRAM_ATTR void gui_monitor_cb(lv_disp_drv_t* disp_drv, uint32_t time, uint32_t px)
|
IRAM_ATTR void gui_monitor_cb(lv_disp_drv_t* disp_drv, uint32_t time, uint32_t px)
|
||||||
{
|
{
|
||||||
// if(screenshotIsDirty) return;
|
// if(screenshotIsDirty) return;
|
||||||
@ -602,8 +623,7 @@ static void gui_screenshot_to_file(lv_disp_drv_t* disp, const lv_area_t* area, l
|
|||||||
if(res != len) gui_flush_not_complete();
|
if(res != len) gui_flush_not_complete();
|
||||||
|
|
||||||
// indirect callback to flush screenshot data to the screen
|
// indirect callback to flush screenshot data to the screen
|
||||||
// drv_display_flush_cb(disp, area, color_p);
|
drv_display_flush_cb(disp, area, color_p);
|
||||||
haspTft.flush_pixels(disp, area, color_p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Take Screenshot.
|
/** Take Screenshot.
|
||||||
@ -628,14 +648,13 @@ void guiTakeScreenshot(const char* pFileName)
|
|||||||
LOG_VERBOSE(TAG_GUI, F("Bitmap header written"));
|
LOG_VERBOSE(TAG_GUI, F("Bitmap header written"));
|
||||||
|
|
||||||
/* Refresh screen to screenshot callback */
|
/* Refresh screen to screenshot callback */
|
||||||
lv_disp_t* disp = lv_disp_get_default();
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t* area, lv_color_t* color_p);
|
drv_display_flush_cb = disp->driver.flush_cb; /* store callback */
|
||||||
flush_cb = disp->driver.flush_cb; /* store callback */
|
|
||||||
disp->driver.flush_cb = gui_screenshot_to_file;
|
disp->driver.flush_cb = gui_screenshot_to_file;
|
||||||
|
|
||||||
lv_obj_invalidate(lv_scr_act());
|
lv_obj_invalidate(lv_scr_act());
|
||||||
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
||||||
disp->driver.flush_cb = flush_cb; /* restore callback */
|
disp->driver.flush_cb = drv_display_flush_cb; /* restore callback */
|
||||||
|
|
||||||
LOG_VERBOSE(TAG_GUI, F("Bitmap data flushed to %s"), pFileName);
|
LOG_VERBOSE(TAG_GUI, F("Bitmap data flushed to %s"), pFileName);
|
||||||
|
|
||||||
@ -660,8 +679,7 @@ static void gui_screenshot_to_http(lv_disp_drv_t* disp, const lv_area_t* area, l
|
|||||||
if(res != len) gui_flush_not_complete();
|
if(res != len) gui_flush_not_complete();
|
||||||
|
|
||||||
// indirect callback to flush screenshot data to the screen
|
// indirect callback to flush screenshot data to the screen
|
||||||
// drv_display_flush_cb(disp, area, color_p);
|
drv_display_flush_cb(disp, area, color_p);
|
||||||
haspTft.flush_pixels(disp, area, color_p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Take Screenshot.
|
/** Take Screenshot.
|
||||||
@ -680,13 +698,12 @@ void guiTakeScreenshot()
|
|||||||
LOG_VERBOSE(TAG_GUI, F("Bitmap header sent"));
|
LOG_VERBOSE(TAG_GUI, F("Bitmap header sent"));
|
||||||
|
|
||||||
/* Refresh screen to screenshot callback */
|
/* Refresh screen to screenshot callback */
|
||||||
lv_disp_t* disp = lv_disp_get_default();
|
lv_disp_t* disp = lv_disp_get_default();
|
||||||
void (*flush_cb)(struct _disp_drv_t * disp_drv, const lv_area_t* area, lv_color_t* color_p);
|
drv_display_flush_cb = disp->driver.flush_cb; /* store callback */
|
||||||
flush_cb = disp->driver.flush_cb; /* store callback */
|
|
||||||
disp->driver.flush_cb = gui_screenshot_to_http;
|
disp->driver.flush_cb = gui_screenshot_to_http;
|
||||||
lv_obj_invalidate(lv_scr_act());
|
lv_obj_invalidate(lv_scr_act());
|
||||||
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
lv_refr_now(NULL); /* Will call our disp_drv.disp_flush function */
|
||||||
disp->driver.flush_cb = flush_cb; /* restore callback */
|
disp->driver.flush_cb = drv_display_flush_cb; /* restore callback */
|
||||||
screenshotIsDirty = false;
|
screenshotIsDirty = false;
|
||||||
|
|
||||||
LOG_VERBOSE(TAG_GUI, F("Bitmap data flushed to webclient"));
|
LOG_VERBOSE(TAG_GUI, F("Bitmap data flushed to webclient"));
|
||||||
|
@ -56,6 +56,10 @@ void guiTakeScreenshot(void); // webclient
|
|||||||
bool guiScreenshotIsDirty();
|
bool guiScreenshotIsDirty();
|
||||||
uint32_t guiScreenshotEtag();
|
uint32_t guiScreenshotEtag();
|
||||||
|
|
||||||
|
/* ===== Callbacks ===== */
|
||||||
|
void gui_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
|
||||||
|
void gui_antiburn_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
|
||||||
|
|
||||||
/* ===== Read/Write Configuration ===== */
|
/* ===== Read/Write Configuration ===== */
|
||||||
#if HASP_USE_CONFIG > 0
|
#if HASP_USE_CONFIG > 0
|
||||||
bool guiGetConfig(const JsonObject& settings);
|
bool guiGetConfig(const JsonObject& settings);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user