LVGL screenshot disk full protection

This commit is contained in:
Stephan Hadinger 2022-01-15 10:42:25 +01:00
parent e4d295d631
commit 3954831a27

View File

@ -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; uint16_t * pix = (uint16_t*) color_p;
for (uint32_t i = 0; i < btw / 2; i++) (pix[i] = pix[i] << 8 | pix[i] >> 8); for (uint32_t i = 0; i < btw / 2; i++) (pix[i] = pix[i] << 8 | pix[i] >> 8);
#endif #endif
int32_t ret = glue->getScreenshotFile()->write((const uint8_t*) color_p, btw); if (btw > 0) { // if we had a previous error (ex disk full) don't try to write anymore
if (ret >= 0) { int32_t ret = glue->getScreenshotFile()->write((const uint8_t*) color_p, btw);
btw -= ret; if (ret >= 0) {
} else { btw -= ret;
btw = 0; // abort } else {
btw = 0; // abort
}
} }
} }
lv_disp_flush_ready(disp); lv_disp_flush_ready(disp);