Skip to content

Commit

Permalink
#266 Idea to add Color Filter type, to support different CFA types
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Dec 9, 2023
1 parent 6fdfdf6 commit 780dbde
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/displays.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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
Expand All @@ -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
Expand All @@ -99,4 +109,5 @@ const EpdDisplay_t EC060KH3 = {
.bus_speed = 20,
.default_waveform = &epdiy_ED047TC2,
.display_type = DISPLAY_TYPE_GENERIC,
};
.display_color_filter = DISPLAY_CFA_KALEIDO
};
15 changes: 15 additions & 0 deletions src/epd_display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion src/epdiy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 780dbde

Please sign in to comment.