Add generic CalEPD SPI epaper driver

This commit is contained in:
Martin Fasani 2021-06-03 13:38:23 +02:00
parent 42ae32f373
commit 160035caca
7 changed files with 63 additions and 24 deletions

View file

@ -12,6 +12,8 @@ if(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341)
list(APPEND SOURCES "lvgl_tft/ili9341.c") list(APPEND SOURCES "lvgl_tft/ili9341.c")
elseif(CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER) elseif(CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER)
list(APPEND SOURCES "lvgl_tft/epdiy_epaper.cpp") list(APPEND SOURCES "lvgl_tft/epdiy_epaper.cpp")
elseif(CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER)
list(APPEND SOURCES "lvgl_tft/calepd_epaper.cpp")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481) elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481)
list(APPEND SOURCES "lvgl_tft/ili9481.c") list(APPEND SOURCES "lvgl_tft/ili9481.c")
elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486) elseif(CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9486)

View file

@ -45,6 +45,9 @@ extern "C" {
// Here is the issue that it does not draw full epaper. Insufficient buffer: // Here is the issue that it does not draw full epaper. Insufficient buffer:
#elif defined (CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER) #elif defined (CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 90) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 90)
#elif defined (CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER)
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 90)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_HX8357
#define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40) #define DISP_BUF_SIZE (LV_HOR_RES_MAX * 40)
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107

View file

@ -89,7 +89,10 @@ menu "LVGL TFT/Epaper Display controller"
bool bool
help help
EPDIY parallel epaper controller. EPDIY parallel epaper controller.
config LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
bool
help
CalEPD SPI epaper controller.
config LV_TFT_DISPLAY_CONTROLLER_ILI9341 config LV_TFT_DISPLAY_CONTROLLER_ILI9341
bool bool
help help
@ -271,8 +274,12 @@ menu "LVGL TFT/Epaper Display controller"
bool "EPDIY_GENERIC" bool "EPDIY_GENERIC"
select LV_EPAPER_EPDIY_DISPLAY_CONTROLLER select LV_EPAPER_EPDIY_DISPLAY_CONTROLLER
select LV_EPAPER_DISPLAY_PROTOCOL_PARALLEL select LV_EPAPER_DISPLAY_PROTOCOL_PARALLEL
#select LV_TFT_DISPLAY_PROTOCOL_SPI
config LV_EPAPER_DISPLAY_USER_CONTROLLER_CALEPD
bool "CALEPD_GENERIC"
# Use also Parallel to avoid LGVL SPI instantiation
select LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
select LV_EPAPER_DISPLAY_PROTOCOL_PARALLEL
config LV_TFT_DISPLAY_USER_CONTROLLER_ILI9341 config LV_TFT_DISPLAY_USER_CONTROLLER_ILI9341
bool "ILI9341" bool "ILI9341"
select LV_TFT_DISPLAY_CONTROLLER_ILI9341 select LV_TFT_DISPLAY_CONTROLLER_ILI9341

View file

@ -2,15 +2,29 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/task.h" #include "freertos/task.h"
#include "epdiy_epaper.h" #include "calepd_epaper.h"
// NOTE: This needs Epdiy component https://github.com/vroland/epdiy // NOTE: This needs Epdiy component https://github.com/vroland/epdiy
// Run idf.py menuconfig-> Component Config -> E-Paper driver and select: // Run idf.py menuconfig-> Component Config -> E-Paper driver and select:
// Display type: LILIGO 4.7 ED047TC1 // Display type: LILIGO 4.7 ED047TC1
// Board: LILIGO T5-4.7 Epaper // Board: LILIGO T5-4.7 Epaper
// In the same section Component Config -> ESP32 Specifics -> Enable PSRAM // In the same section Component Config -> ESP32 Specifics -> Enable PSRAM
#include "parallel/ED047TC1.h" //#include "parallel/ED047TC1.h"
Ed047TC1 display; //Ed047TC1 display;
// SPI Generic epapers (Goodisplay/ Waveshare)
// Select the right class for your SPI epaper: https://github.com/martinberlin/cale-idf/wiki
//#include <gdew0583t7.h>
#include <gdew027w3.h>
Gdew027w3 display(io);
EpdSpi io;
//Gdew0583T7 display(io);
/** test Display dimensions
* Do not forget to set: menuconfig -> Components -> LVGL configuration
* Max. Horizontal resolution 264 -> WIDTH of your epaper
* Max. Vertical resolution 176 -> HEIGHT
*/
/********************* /*********************
* DEFINES * DEFINES
@ -20,26 +34,29 @@ Ed047TC1 display;
uint16_t flushcalls = 0; uint16_t flushcalls = 0;
/* Display initialization routine */ /* Display initialization routine */
void epdiy_init(void) void calepd_init(void)
{ {
printf("epdiy_init\n"); printf("calepd_init\n");
display.init(); display.init();
display.setRotation(0); display.setRotation(0);
display.clearScreen(); // Clear screen
//display.update();
} }
/* Required by LVGL */ /* Required by LVGL */
void epdiy_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map) void calepd_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{ {
++flushcalls; ++flushcalls;
printf("epdiy_flush %d x:%d y:%d w:%d h:%d\n", flushcalls,area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area)); printf("flush %d x:%d y:%d w:%d h:%d\n", flushcalls,area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area));
// Full update // Full update
if (lv_area_get_width(area)==display.width() && lv_area_get_height(area)==display.height()) { if (lv_area_get_width(area)==display.width() && lv_area_get_height(area)==display.height()) {
display.update(); display.update();
} else { } else {
// Partial update: Looks nice but should find a way to clear that area first. Mode: MODE_EPDIY_WHITE_TO_GL16 // Partial update:
display.updateWindow(area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area),MODE_GC16); display.update(); // Uncomment to disable partial update
//display.updateWindow(area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area), true);
//display.updateWindow(area->x1,area->y1,lv_area_get_width(area),lv_area_get_height(area));
} }
/* IMPORTANT!!! /* IMPORTANT!!!
@ -48,19 +65,20 @@ void epdiy_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_ma
} }
/* Called for each pixel */ /* Called for each pixel */
void epdiy_set_px_cb(lv_disp_drv_t * disp_drv, uint8_t* buf, void calepd_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_coord_t buf_w, lv_coord_t x, lv_coord_t y,
lv_color_t color, lv_opa_t opa) lv_color_t color, lv_opa_t opa)
{ {
// Is printing Y axis only till 40 px: And flushing too many times //If not drawing anything: Debug to see if this function is called:
//printf("%d ", (int16_t)y); // Works and prints "Hello world" //printf("set_px %d %d\n",(int16_t)x,(int16_t)y);
//printf("%d ",(int16_t)color.full); // Debug colors
// Test using RGB232 // Test using RGB232
int16_t epd_color = EPD_WHITE; int16_t epd_color = EPD_WHITE;
// Color setting use: RGB232 // Color setting use: RGB232
if ((int16_t)color.full<250) { // Only monochrome:All what is not white, turn black
epd_color = (int16_t)color.full/3; if ((int16_t)color.full<254) {
epd_color = EPD_BLACK;
} }
display.drawPixel((int16_t)x, (int16_t)y, epd_color); display.drawPixel((int16_t)x, (int16_t)y, epd_color);
} }

View file

@ -19,14 +19,14 @@ extern "C" {
#include "sdkconfig.h" #include "sdkconfig.h"
/* Configure your display */ /* Configure your display */
void epdiy_init(void); void calepd_init(void);
/* LVGL callbacks */ /* LVGL callbacks */
void epdiy_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map); void calepd_flush(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map);
/* Only for monochrome displays. But we use epdiy_set_px also for epapers */ /* Only for monochrome displays. But we use epdiy_set_px also for epapers */
//void epdiy_rounder(lv_disp_drv_t *disp_drv, lv_area_t *area); //void epdiy_rounder(lv_disp_drv_t *disp_drv, lv_area_t *area);
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); void calepd_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);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View file

@ -4,8 +4,7 @@
#include "disp_driver.h" #include "disp_driver.h"
#include "disp_spi.h" #include "disp_spi.h"
// This should be included with CMakeLists but is not
#include "lvgl_tft/epdiy_epaper.h"
void disp_driver_init(void) void disp_driver_init(void)
{ {
@ -13,6 +12,8 @@ void disp_driver_init(void)
ili9341_init(); ili9341_init();
#elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER #elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER
epdiy_init(); epdiy_init();
#elif defined CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
calepd_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
ili9481_init(); ili9481_init();
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488
@ -52,6 +53,8 @@ void disp_driver_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t *
ili9341_flush(drv, area, color_map); ili9341_flush(drv, area, color_map);
#elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER #elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER
epdiy_flush(drv, area, color_map); epdiy_flush(drv, area, color_map);
#elif defined CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
calepd_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
ili9481_flush(drv, area, color_map); ili9481_flush(drv, area, color_map);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488
@ -108,6 +111,8 @@ void disp_driver_set_px(lv_disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_
ssd1306_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa); ssd1306_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
#elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER #elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER
epdiy_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa); epdiy_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
#elif defined CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
calepd_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_SH1107
sh1107_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa); sh1107_set_px_cb(disp_drv, buf, buf_w, x, y, color, opa);
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_IL3820 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_IL3820

View file

@ -20,6 +20,10 @@ extern "C" {
#if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341 #if defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9341
#include "ili9341.h" #include "ili9341.h"
#elif defined CONFIG_LV_EPAPER_EPDIY_DISPLAY_CONTROLLER
#include "lvgl_tft/epdiy_epaper.h"
#elif defined CONFIG_LV_EPAPER_CALEPD_DISPLAY_CONTROLLER
#include "lvgl_tft/calepd_epaper.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9481
#include "ili9481.h" #include "ili9481.h"
#elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488 #elif defined CONFIG_LV_TFT_DISPLAY_CONTROLLER_ILI9488