diff --git a/src/displays.c b/src/displays.c index b5d1f2bd..54809716 100644 --- a/src/displays.c +++ b/src/displays.c @@ -7,6 +7,7 @@ const EpdDisplay_t ED060SCT = { .bus_speed = 20, .default_waveform = &epdiy_ED060SCT, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED060XC3 = { @@ -16,6 +17,7 @@ const EpdDisplay_t ED060XC3 = { .bus_speed = 20, .default_waveform = &epdiy_ED060XC3, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED097OC4 = { @@ -25,6 +27,7 @@ const EpdDisplay_t ED097OC4 = { .bus_speed = 15, .default_waveform = &epdiy_ED097OC4, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED097TC2 = { @@ -34,6 +37,7 @@ const EpdDisplay_t ED097TC2 = { .bus_speed = 18, // 22 works .default_waveform = &epdiy_ED097TC2, .display_type = DISPLAY_TYPE_ED097TC2, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED133UT2 = { @@ -43,6 +47,7 @@ const EpdDisplay_t ED133UT2 = { .bus_speed = 16, .default_waveform = &epdiy_ED133UT2, .display_type = DISPLAY_TYPE_ED097TC2, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED047TC1 = { @@ -52,6 +57,7 @@ const EpdDisplay_t ED047TC1 = { .bus_speed = 20, .default_waveform = &epdiy_ED047TC1, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED047TC2 = { @@ -61,6 +67,7 @@ const EpdDisplay_t ED047TC2 = { .bus_speed = 20, .default_waveform = &epdiy_ED047TC2, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t ED078KC1 = { @@ -70,6 +77,7 @@ const EpdDisplay_t ED078KC1 = { .bus_speed = 11, .default_waveform = &epdiy_ED047TC2, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_NONE }; const EpdDisplay_t WAVE103 = { @@ -79,6 +87,7 @@ const EpdDisplay_t WAVE103 = { .bus_speed = 10, // Could be higher, just try .default_waveform = &epdiy_ED097TC2, .display_type = DISPLAY_TYPE_ED097TC2, + .display_color_filter = DISPLAY_CFA_NONE }; // This display is produced by https://en.wf-tech.com and sold by Good-Display @@ -89,6 +98,7 @@ const EpdDisplay_t GDEW101C01 = { .bus_speed = 10, .default_waveform = &epdiy_GDEW101C01, .display_type = DISPLAY_TYPE_GENERIC, + .display_color_filter = DISPLAY_CFA_DES }; // EINK Kaleido display // epdiy_ED047TC2 is the one that gets more grays, but is not right @@ -99,4 +109,5 @@ const EpdDisplay_t EC060KH3 = { .bus_speed = 20, .default_waveform = &epdiy_ED047TC2, .display_type = DISPLAY_TYPE_GENERIC, -}; \ No newline at end of file + .display_color_filter = DISPLAY_CFA_KALEIDO +}; diff --git a/src/epd_display.h b/src/epd_display.h index 76c311b3..28e8300f 100644 --- a/src/epd_display.h +++ b/src/epd_display.h @@ -14,6 +14,19 @@ enum EpdDisplayType { DISPLAY_TYPE_ED097TC2, }; +/** + * Display Color filter type + * This applies only to those epapers with CFA on top + */ +enum EpdColorFilterType { + /// No color filter, the default for all grayscale epapers + DISPLAY_CFA_NONE, + /// Eink.com Kaleido + DISPLAY_CFA_KALEIDO, + /// https://en.wf-tech.com called DES color and sold by Good-Display + DISPLAY_CFA_DES, +}; + typedef struct { /// Width of the display in pixels. int width; @@ -30,6 +43,8 @@ typedef struct { const EpdWaveform* default_waveform; /// Display type enum EpdDisplayType display_type; + /// Display Color filter type (CFA) + enum EpdColorFilterType display_color_filter; } EpdDisplay_t; extern const EpdDisplay_t ED060SCT; diff --git a/src/epdiy.c b/src/epdiy.c index 9e3f78e3..b7db5d84 100644 --- a/src/epdiy.c +++ b/src/epdiy.c @@ -117,6 +117,7 @@ uint8_t epd_get_panel_color(int x, int y, uint8_t r, uint8_t g, uint8_t b) { } } +// Kaleido test, getting right color on top of the pixel. Thanks to https://github.com/koreader/koreader/issues/6479 uint8_t epd_get_kpanel_color(int x, int y, uint8_t r, uint8_t g, uint8_t b) { uint8_t c = (x + y) % 3; switch (c) @@ -145,8 +146,13 @@ void epd_draw_cpixel(int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t *fra if (y < 0 || y >= epd_height()) { return; } + uint8_t color = 255; // Need to discriminate here display CFA type or in only one get_color function - uint8_t color = epd_get_panel_color(x, y, r, g, b); + if (epd_get_display()->display_color_filter == DISPLAY_CFA_DES) { + color = epd_get_panel_color(x, y, r, g, b); + } else if (epd_get_display()->display_color_filter == DISPLAY_CFA_KALEIDO) { + color = epd_get_kpanel_color(x, y, r, g, b); + } uint8_t *buf_ptr = &framebuffer[y * epd_width() / 2 + x / 2]; if (x % 2) {