From 3954831a270606b83ccd0a23058cce32c0dfec3d Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 15 Jan 2022 10:42:25 +0100 Subject: [PATCH] LVGL screenshot disk full protection --- tasmota/xdrv_54_lvgl.ino | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tasmota/xdrv_54_lvgl.ino b/tasmota/xdrv_54_lvgl.ino index dd4089b0c..d911bb48d 100644 --- a/tasmota/xdrv_54_lvgl.ino +++ b/tasmota/xdrv_54_lvgl.ino @@ -71,11 +71,13 @@ void lv_flush_callback(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *c uint16_t * pix = (uint16_t*) color_p; for (uint32_t i = 0; i < btw / 2; i++) (pix[i] = pix[i] << 8 | pix[i] >> 8); #endif - int32_t ret = glue->getScreenshotFile()->write((const uint8_t*) color_p, btw); - if (ret >= 0) { - btw -= ret; - } else { - btw = 0; // abort + if (btw > 0) { // if we had a previous error (ex disk full) don't try to write anymore + int32_t ret = glue->getScreenshotFile()->write((const uint8_t*) color_p, btw); + if (ret >= 0) { + btw -= ret; + } else { + btw = 0; // abort + } } } lv_disp_flush_ready(disp);