This is my set_px_cb callback now:
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_color_t color, lv_opa_t opa)
{
// Test using RGB232. Darker the color otherwise is too light for this epaper:
int16_t epd_color = 255;
if ((int16_t)color.full<250) {
epd_color = (int16_t)color.full/3;
}
int16_t x1 = (int16_t)x;
int16_t y1 = (int16_t)y;
// framebuffer is the epaper buffer that is sent via parallel 8 wire using EPDiy
//Instead of using epd_draw_pixel: Set pixel directly in buffer
//epd_draw_pixel(x1, y1, epd_color, framebuffer);
// 4 bit per pixel (16 grayscales)
uint8_t *buf_ptr = &framebuffer[y1 * buf_w / 2 + x1 / 2];
if (x % 2) {
*buf_ptr = (*buf_ptr & 0x0F) | (epd_color & 0xF0);
} else {
*buf_ptr = (*buf_ptr & 0xF0) | (epd_color >> 4);
}
}