From 6fdfdf68e3955d787c704961aa924ee85fd0982f Mon Sep 17 00:00:00 2001 From: martinberlin Date: Sat, 9 Dec 2023 00:20:34 +0100 Subject: [PATCH] #266 Preparation to get Kaleido color lookup --- examples/color/main/main.c | 28 +++++++++++++++++----------- src/epdiy.c | 16 ++++++++++++++++ src/epdiy.h | 6 ++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/examples/color/main/main.c b/examples/color/main/main.c index fd95164f..aeddf822 100644 --- a/examples/color/main/main.c +++ b/examples/color/main/main.c @@ -17,11 +17,11 @@ 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 @@ -29,19 +29,20 @@ int color_test() { * G R B row:2 * R B G row:3 */ - for (uint16_t y=1; 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(); @@ -61,7 +62,8 @@ 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); @@ -69,7 +71,11 @@ void app_main() { 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"); diff --git a/src/epdiy.c b/src/epdiy.c index c02717c9..9e3f78e3 100644 --- a/src/epdiy.c +++ b/src/epdiy.c @@ -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 @@ -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]; diff --git a/src/epdiy.h b/src/epdiy.h index a83f63e2..1d1ac35c 100644 --- a/src/epdiy.h +++ b/src/epdiy.h @@ -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) *