From f3f6ba6470860b8cc05f182d0f4d02a8357a5f4a Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Thu, 18 Nov 2021 08:58:04 +0100 Subject: [PATCH] Added PCD8544 to readme, addressed PR comments --- README.md | 1 + lvgl_tft/pcd8544.c | 8 +++++--- lvgl_tft/pcd8544.h | 42 +++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a664636..522c0e1 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ swap of RGB565 color on the LVGL configuration menuconfig (it's not handled auto | RA8875 | TFT | SPI | 16: RGB565 | Yes | | SH1107 | Monochrome | SPI | 1: 1byte per pixel | No | | SSD1306 | Monochrome | I2C | 1: 1byte per pixel | No | +| PCD8544 | Monochrome | SPI | 1: 1byte per pixel | No | | IL3820 | e-Paper | SPI | 1: 1byte per pixel | No | | UC8151D/ GoodDisplay GDEW0154M10 DES | e-Paper | SPI | 1: 1byte per pixel | No | | FitiPower JD79653A/ GoodDisplay GDEW0154M09 | e-Paper | SPI | 1: 1byte per pixel | No | diff --git a/lvgl_tft/pcd8544.c b/lvgl_tft/pcd8544.c index b2a7bed..49d067e 100644 --- a/lvgl_tft/pcd8544.c +++ b/lvgl_tft/pcd8544.c @@ -116,9 +116,12 @@ void pcd8544_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t uint8_t * buf = (uint8_t *) color_map; + // Check if the whole frame buffer can be sent in a single SPI transaction + if ((area->x1 == 0) && (area->y1 == 0) && (area->x2 == (disp_drv->hor_res - 1)) && (area->y2 == (disp_drv->ver_res - 1))){ - // optimize flush of complete frame buffer in a single SPI transaction + // send complete frame buffer at once. + // NOTE: disp_spi_send_colors triggers lv_disp_flush_ready pcd8544_send_cmd(0x40); /* set Y address */ pcd8544_send_cmd(0x80); /* set X address */ @@ -134,13 +137,12 @@ void pcd8544_flush(lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t uint16_t bank; uint16_t cols_to_update = area->x2 - area->x1 + 1; for (bank = bank_start ; bank <= bank_end ; bank++ ){ - pcd8544_send_cmd(0x40 | bank ); /* set Y address */ + pcd8544_send_cmd(0x40 | bank ); /* set Y address */ pcd8544_send_cmd(0x80 | area->x1 ); /* set X address */ uint16_t offset = bank * disp_drv->hor_res + area->x1; pcd8544_send_data(&buf[offset], cols_to_update); } lv_disp_flush_ready(disp_drv); - } } diff --git a/lvgl_tft/pcd8544.h b/lvgl_tft/pcd8544.h index b9357fe..24fcc71 100644 --- a/lvgl_tft/pcd8544.h +++ b/lvgl_tft/pcd8544.h @@ -11,9 +11,9 @@ extern "C" { #endif - /********************* - * INCLUDES - *********************/ +/********************* + * INCLUDES + *********************/ #include #ifdef LV_LVGL_H_INCLUDE_SIMPLE @@ -22,32 +22,32 @@ extern "C" { #include "lvgl/lvgl.h" #endif - /********************* - * DEFINES - *********************/ +/********************* + * DEFINES + *********************/ #define PCD8544_DC CONFIG_LV_DISP_PIN_DC #define PCD8544_RST CONFIG_LV_DISP_PIN_RST #define PCD8544_BCKL CONFIG_LV_DISP_PIN_BCKL - /********************** - * TYPEDEFS - **********************/ +/********************** + * TYPEDEFS + **********************/ - /********************** - * GLOBAL PROTOTYPES - **********************/ +/********************** + * GLOBAL PROTOTYPES + **********************/ - void pcd8544_init(void); - void pcd8544_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); - void pcd8544_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area); - void pcd8544_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 pcd8544_set_contrast(uint8_t contrast); +void pcd8544_init(void); +void pcd8544_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map); +void pcd8544_rounder(lv_disp_drv_t * disp_drv, lv_area_t *area); +void pcd8544_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 pcd8544_set_contrast(uint8_t contrast); - /********************** - * MACROS - **********************/ +/********************** + * MACROS + **********************/ #ifdef __cplusplus