From 3c5a4061d94497689182c6509bf37c018ac7f510 Mon Sep 17 00:00:00 2001 From: C47D Date: Sat, 18 Sep 2021 20:14:35 -0500 Subject: [PATCH] feat(lv_port): Add abstraction for busy signal This signal can be used when driving eink displays --- lv_port/lv_port_display_espressif.c | 16 ++++++++++++++++ lvgl_tft/display_port.h | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lv_port/lv_port_display_espressif.c b/lv_port/lv_port_display_espressif.c index 9f6f4b1..79aaa40 100644 --- a/lv_port/lv_port_display_espressif.c +++ b/lv_port/lv_port_display_espressif.c @@ -39,3 +39,19 @@ void display_port_gpio_rst(lv_disp_drv_t *drv, uint8_t state) gpio_set_level(CONFIG_LV_DISP_PIN_RST, state); #endif } + +display_port_busy_t display_port_gpio_is_busy(lv_disp_drv_t *drv) +{ + (void) drv; + + display_port_busy_t device_busy = DISPLAY_PORT_DEVICE_NOT_BUSY; + +#ifdef CONFIG_LV_DISP_PIN_BUSY + /* FIXME Assuming the busy signal in logic 1 means the device is busy */ + if (gpio_get_level(CONFIG_LV_DISP_PIN_BUSY) == 1) { + device_busy = DISPLAY_PORT_DEVICE_IS_BUSY; + } +#endif + + return device_busy; +} diff --git a/lvgl_tft/display_port.h b/lvgl_tft/display_port.h index 2136ec6..bd58fe7 100644 --- a/lvgl_tft/display_port.h +++ b/lvgl_tft/display_port.h @@ -12,6 +12,14 @@ extern "C" #include "lvgl/lvgl.h" #endif +/** Display is busy port + * Useful for eink displays that need to poll their BUSY signal */ +typedef enum { + DISPLAY_PORT_DEVICE_NOT_BUSY, + DISPLAY_PORT_DEVICE_IS_BUSY, + /* NOTE Operation should not be interrupted when the device is busy */ +} display_port_busy_t; + /** * Busy wait delay port * @@ -44,6 +52,16 @@ void display_port_gpio_dc(lv_disp_drv_t *drv, uint8_t state); */ void display_port_gpio_rst(lv_disp_drv_t *drv, uint8_t state); +/** + * Display is busy port + * + * @param drv Pointer to driver See @ref lv_disp_drv_t + * + * @retval Returns DISPLAY_PORT_DEVICE_NOT_BUSY when display is not busy, + * DISPLAY_PORT_DEVICE_IS_BUSY otherwise. + */ +display_port_busy_t display_port_gpio_is_busy(lv_disp_drv_t *drv); + #ifdef __cplusplus } /* extern "C" */ #endif