From 255a1a768017ee25c16d241a5b970c6462145ca8 Mon Sep 17 00:00:00 2001 From: martinberlin Date: Sun, 13 Jun 2021 09:42:19 +0200 Subject: [PATCH] Update callbacks to support also fast update MODE_DU configurable with updateMode enum --- lvgl_tft/epdiy_epaper.cpp | 7 +++++-- lvgl_tft/epdiy_epaper_v1.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lvgl_tft/epdiy_epaper.cpp b/lvgl_tft/epdiy_epaper.cpp index 0546caf..569781c 100644 --- a/lvgl_tft/epdiy_epaper.cpp +++ b/lvgl_tft/epdiy_epaper.cpp @@ -10,6 +10,9 @@ uint16_t flushcalls = 0; uint8_t * framebuffer; uint8_t temperature = 25; bool init = true; +// MODE_DU: Fast monochrome | MODE_GC16 slow with 16 grayscales +enum EpdDrawMode updateMode = MODE_DU; + #define BUF_MAX 111600 /* Display initialization routine */ @@ -78,7 +81,7 @@ void epdiy_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_ma // Does not work for full screen update yet (Should check large of buf) buf_copy_to_framebuffer(update_area, buf); - epd_hl_update_area(&hl, MODE_GC16, temperature, update_area); //update_area + epd_hl_update_area(&hl, updateMode, temperature, update_area); //update_area printf("epdiy_flush %d x:%d y:%d w:%d h:%d\n", flushcalls,(uint16_t)area->x1,(uint16_t)area->y1,w,h); /* Inform the graphics library that you are ready with the flushing */ @@ -105,7 +108,7 @@ void epdiy_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf, // Test using RGB232 int16_t epd_color = 255; if ((int16_t)color.full<250) { - epd_color = (int16_t)color.full/3; + epd_color = (updateMode==MODE_DU) ? 0 : (int16_t)color.full/3; } //Instead of using epd_draw_pixel: Set pixel directly in *buf that comes afterwards in flush as *color_map diff --git a/lvgl_tft/epdiy_epaper_v1.cpp b/lvgl_tft/epdiy_epaper_v1.cpp index 7b99d63..38cd948 100644 --- a/lvgl_tft/epdiy_epaper_v1.cpp +++ b/lvgl_tft/epdiy_epaper_v1.cpp @@ -7,9 +7,12 @@ #include "epd_driver.h" #include "epd_highlevel.h" -/********************* - * DEFINES - *********************/ +/************************************************************************************************** + * NOTE: This file iis the first version that writes directly on the set_px callback + * each pixel into the epaper display buffer. The second version is not epdiy_epaper.cpp + * It writes *buf and then it comes as *color_map on the flush callback. + * Feel free to experiment with this 2. epdiy_epaper.cpp works better to make a small UX + **************************************************************************************************/ #define TAG "EPDIY" EpdiyHighlevelState hl; uint16_t flushcalls = 0;