Skip to content

Commit

Permalink
#266 Preparation to get Kaleido color lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Dec 8, 2023
1 parent 9f06102 commit 6fdfdf6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
28 changes: 17 additions & 11 deletions examples/color/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@ int color_test() {
EpdRect epd_area = {
.x = 0,
.y = 0,
.width = epd_width()/2,
.width = epd_width(),
.height = epd_height()
};

uint8_t color_of = 0;
uint8_t color_of = 255;
/**
* @brief PATTERN
* pix1 2 3 X
* B G R row:1
* G R B row:2
* R B G row:3
*/
for (uint16_t y=1; y<epd_area.height; y++) {
for (uint16_t y=1; y<601; y++) {
for (uint16_t x=1; x<epd_area.width; x++) {
// x, y, r, g, b
if (y < 560) {
epd_draw_cpixel(x, y, x/10, color_of, color_of, hl.front_fb);
} else if (y >= 560 && y < 1120) {
epd_draw_cpixel(x, y, color_of, x/10, color_of, hl.front_fb);
if (y < 200) {
epd_draw_cpixel(x, y, x/6, color_of, color_of, hl.front_fb);
} else if (y >= 200 && y < 400) {
epd_draw_cpixel(x, y, color_of, x/6, color_of, hl.front_fb);
} else {
epd_draw_cpixel(x, y, color_of, color_of, x/10, hl.front_fb);
epd_draw_cpixel(x, y, color_of, color_of, x/6, hl.front_fb);
}
}
vTaskDelay(1);
//vTaskDelay(1);
}


enum EpdDrawError _err = epd_hl_update_screen(&hl, MODE_GC16, temperature);
epd_poweroff();
Expand All @@ -61,15 +62,20 @@ int getFreePsram(){
void app_main() {
printf("before epd_init() Free PSRAM: %d\n", getFreePsram());

epd_init(&epd_board_v7, &epdiy_GDEW101C01, EPD_LUT_64K);
epd_init(&epd_board_v7, &EC060KH3, EPD_LUT_64K);
//epd_set_rotation(EPD_ROT_PORTRAIT);
// Set VCOM for boards that allow to set this in software (in mV).
epd_set_vcom(1560);
hl = epd_hl_init(EPD_BUILTIN_WAVEFORM);
fb = epd_hl_get_framebuffer(&hl);
printf("after epd_hl_init() Free PSRAM: %d\n", getFreePsram());


epd_poweron();
epd_poweron();
epd_set_gamma_curve(0.4);
epd_fullclear(&hl, 25);


color_test();
printf("color example\n");

Expand Down
16 changes: 16 additions & 0 deletions src/epdiy.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ uint8_t epd_get_panel_color(int x, int y, uint8_t r, uint8_t g, uint8_t b) {
}
}

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)
{
case 0:
return gamme_curve[b];
break;
case 1:
return gamme_curve[g];
break;
default:
return gamme_curve[r];
}
}

// Pass the x, y and color. It will then let the background under color filter get the right grayscale (WHITE shows color)
void epd_draw_cpixel(int x, int y, uint8_t r, uint8_t g, uint8_t b, uint8_t *framebuffer) {
// Check rotation and move pixel around if necessary
Expand All @@ -130,6 +145,7 @@ 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;
}
// 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);

uint8_t *buf_ptr = &framebuffer[y * epd_width() / 2 + x / 2];
Expand Down
6 changes: 6 additions & 0 deletions src/epdiy.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ void epd_draw_pixel(int x, int y, uint8_t color, uint8_t *framebuffer);
*/
uint8_t epd_get_panel_color(int x, int y, uint8_t r, uint8_t g, uint8_t b);

/**
* @brief What color is on top of Kaleido x & y coordinates. Receives RGB and returns the grayscale for X:Y on that pixel
* @return uint8_t
*/
uint8_t epd_get_kpanel_color(int x, int y, uint8_t r, uint8_t g, uint8_t b);

/**
* @brief This draws a pixel begin aware of what color filter is on top (RGB for DES displays)
*
Expand Down

0 comments on commit 6fdfdf6

Please sign in to comment.