Leave buf_copy_to_framebuffer as the default method and Gabor method as secondary

This commit is contained in:
martinberlin 2021-06-13 15:18:48 +02:00
parent 9a16924501
commit 588b14f029

View file

@ -12,8 +12,8 @@ uint8_t temperature = 25;
bool init = true; bool init = true;
// MODE_DU: Fast monochrome | MODE_GC16 slow with 16 grayscales // MODE_DU: Fast monochrome | MODE_GC16 slow with 16 grayscales
enum EpdDrawMode updateMode = MODE_DU; enum EpdDrawMode updateMode = MODE_DU;
// Ideally this BUF should be width/2*height = 259200. Now set to 111600
#define BUF_MAX 111600 #define BUF_MAX 110400
/* Display initialization routine */ /* Display initialization routine */
void epdiy_init(void) void epdiy_init(void)
@ -26,6 +26,18 @@ void epdiy_init(void)
epd_fullclear(&hl, temperature); epd_fullclear(&hl, temperature);
} }
/* Suggested by @kisvegabor https://forum.lvgl.io/t/lvgl-port-to-be-used-with-epaper-displays/5630/26 */
void buf_area_to_framebuffer(const lv_area_t *area, const uint8_t *image_data) {
assert(framebuffer != NULL);
uint8_t *fb_ptr = &framebuffer[area->y1 * EPD_WIDTH / 2 + area->x1 / 2];
lv_coord_t img_w = lv_area_get_width(area);
for(uint32_t y = area->y1; y < area->y2; y++) {
memcpy(fb_ptr, image_data, img_w / 2);
fb_ptr += EPD_WIDTH / 2;
image_data += img_w / 2;
}
}
/* A copy from epd_copy_to_framebuffer with temporary lenght prediction */ /* A copy from epd_copy_to_framebuffer with temporary lenght prediction */
void buf_copy_to_framebuffer(EpdRect image_area, const uint8_t *image_data) { void buf_copy_to_framebuffer(EpdRect image_area, const uint8_t *image_data) {
assert(framebuffer != NULL); assert(framebuffer != NULL);
@ -34,10 +46,10 @@ void buf_copy_to_framebuffer(EpdRect image_area, const uint8_t *image_data) {
// Get out if we get the end of the buffer. Question: How to detect the end without a lenght? // Get out if we get the end of the buffer. Question: How to detect the end without a lenght?
// Zero terminator check gets out before: (image_data[value_index / 2]== '\0') // Zero terminator check gets out before: (image_data[value_index / 2]== '\0')
// 111684 seems to be the last element in image_data // 111684 seems to be the last element in image_data
if (i / 2 > BUF_MAX) { /* if (i / 2 > BUF_MAX) {
printf("FOUND END incr:%d Aw:%d Ah:%d\n", i, image_area.width, image_area.height); printf("FOUND END incr:%d Aw:%d Ah:%d\n", i, image_area.width, image_area.height);
break; break;
} } */
uint8_t val = (i % 2) ? (image_data[i / 2] & 0xF0) >> 4 uint8_t val = (i % 2) ? (image_data[i / 2] & 0xF0) >> 4
: image_data[i / 2] & 0x0F; : image_data[i / 2] & 0x0F;
int xx = image_area.x + i % image_area.width; int xx = image_area.x + i % image_area.width;
@ -81,6 +93,9 @@ 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) // Does not work for full screen update yet (Should check large of buf)
buf_copy_to_framebuffer(update_area, buf); buf_copy_to_framebuffer(update_area, buf);
//Faster mode suggested in LVGL forum (Leaves ghosting)
//buf_area_to_framebuffer(area, buf);
epd_hl_update_area(&hl, updateMode, 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); printf("epdiy_flush %d x:%d y:%d w:%d h:%d\n", flushcalls,(uint16_t)area->x1,(uint16_t)area->y1,w,h);
@ -89,8 +104,7 @@ void epdiy_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_ma
} }
/* /*
* Called for each pixel. Designed with the idea to fill the buffer directly, not to set each pixel, see: * Called for each pixel. Designed with the idea to fill the buffer directly, not to set each pixel, see LVGL Forum (buf_area_to_framebuffer)
* https://forum.lvgl.io/t/lvgl-port-to-be-used-with-epaper-displays/5630/3
*/ */
void epdiy_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf, void epdiy_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf,
lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y,