fix(display_port): Rename display_hal_* to display_port_*

Also updates the display drivers that used it
This commit is contained in:
C47D 2021-09-11 14:21:08 -05:00
parent 359dcb92ba
commit 9d9fadf450
4 changed files with 67 additions and 46 deletions

View file

@ -1,19 +1,19 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "display_hal.h"
#include "display_port.h"
#include "sdkconfig.h"
#include "driver/gpio.h"
void display_hal_delay(lv_disp_drv_t *drv, uint32_t delay_ms)
void display_port_delay(lv_disp_drv_t *drv, uint32_t delay_ms)
{
(void) drv;
vTaskDelay(pdMS_TO_TICKS(delay_ms));
}
void display_hal_backlight(lv_disp_drv_t *drv, uint8_t state)
void display_port_backlight(lv_disp_drv_t *drv, uint8_t state)
{
(void) drv;
@ -22,7 +22,7 @@ void display_hal_backlight(lv_disp_drv_t *drv, uint8_t state)
#endif
}
void display_hal_gpio_dc(lv_disp_drv_t *drv, uint8_t state)
void display_port_gpio_dc(lv_disp_drv_t *drv, uint8_t state)
{
(void) drv;
@ -31,7 +31,7 @@ void display_hal_gpio_dc(lv_disp_drv_t *drv, uint8_t state)
#endif
}
void display_hal_gpio_rst(lv_disp_drv_t *drv, uint8_t state)
void display_port_gpio_rst(lv_disp_drv_t *drv, uint8_t state)
{
(void) drv;

View file

@ -1,30 +0,0 @@
#ifndef DISPLAY_HAL_H_
#define DISPLAY_HAL_H_
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/* NOTE We could remove this function from here, because it's used to
* initialize the GPIOS on the MCU */
void display_hal_init_io(void);
/* NOTE drv parameter is meant to be used in multi display projects, so the
* user could distinguish multiple displays on their hal implementation */
void display_hal_delay(lv_disp_drv_t *drv, uint32_t delay_ms);
void display_hal_backlight(lv_disp_drv_t *drv, uint8_t state);
void display_hal_gpio_dc(lv_disp_drv_t *drv, uint8_t state);
void display_hal_gpio_rst(lv_disp_drv_t *drv, uint8_t state);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

51
lvgl_tft/display_port.h Normal file
View file

@ -0,0 +1,51 @@
#ifndef DISPLAY_PORT_H_
#define DISPLAY_PORT_H_
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef LV_LVGL_H_INCLUDE_SIMPLE
#include "lvgl.h"
#else
#include "lvgl/lvgl.h"
#endif
/**
* Busy wait delay port
*
* @param drv Pointer to driver See @ref lv_disp_drv_t
* @param delay_ms Delay duration in milliseconds
*/
void display_port_delay(lv_disp_drv_t *drv, uint32_t delay_ms);
/**
* Backlight control port
*
* @param drv Pointer to driver See @ref lv_disp_drv_t
* @param state State of the backlight signal
*/
void display_port_backlight(lv_disp_drv_t *drv, uint8_t state);
/**
* DC signal control port
*
* @param drv Pointer to driver See @ref lv_disp_drv_t
* @param state State of the DC signal, 1 for logic high, 0 for logic low
*/
void display_port_gpio_dc(lv_disp_drv_t *drv, uint8_t state);
/**
* Hardware reset control port
*
* @param drv Pointer to driver See @ref lv_disp_drv_t
* @param state State of the reset signal, 1 for logic high, 0 for logic low
*/
void display_port_gpio_rst(lv_disp_drv_t *drv, uint8_t state);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View file

@ -7,7 +7,7 @@
#include "st7789.h"
#include "disp_spi.h"
#include "display_hal.h"
#include "display_port.h"
/*********************
* DEFINES
@ -91,7 +91,7 @@ void st7789_init(lv_disp_drv_t *drv)
st7789_send_cmd(drv, st7789_init_cmds[cmd].cmd);
st7789_send_data(drv, st7789_init_cmds[cmd].data, st7789_init_cmds[cmd].databytes&0x1F);
if (st7789_init_cmds[cmd].databytes & 0x80) {
display_hal_delay(drv, 100);
display_port_delay(drv, 100);
}
cmd++;
}
@ -113,7 +113,7 @@ void st7789_enable_backlight(lv_disp_drv_t *drv, bool backlight)
tmp = backlight ? 0 : 1;
#endif
display_hal_backlight(drv, tmp);
display_port_backlight(drv, tmp);
#endif
}
@ -173,21 +173,21 @@ void st7789_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * colo
static void st7789_send_cmd(lv_disp_drv_t *drv, uint8_t cmd)
{
disp_wait_for_pending_transactions();
display_hal_gpio_dc(drv, 0);
display_port_gpio_dc(drv, 0);
disp_spi_send_data(&cmd, 1);
}
static void st7789_send_data(lv_disp_drv_t *drv, void * data, uint16_t length)
{
disp_wait_for_pending_transactions();
display_hal_gpio_dc(drv, 1);
display_port_gpio_dc(drv, 1);
disp_spi_send_data(data, length);
}
static void st7789_send_color(lv_disp_drv_t *drv, void * data, uint16_t length)
{
disp_wait_for_pending_transactions();
display_hal_gpio_dc(drv, 1);
display_port_gpio_dc(drv, 1);
disp_spi_send_colors(data, length);
}
@ -195,13 +195,13 @@ static void st7789_send_color(lv_disp_drv_t *drv, void * data, uint16_t length)
static void st7789_reset(lv_disp_drv_t *drv)
{
#if !defined(ST7789_SOFT_RST)
display_hal_gpio_rst(drv, 0);
display_hal_delay(drv, 100);
display_hal_gpio_rst(drv, 1);
display_hal_delay(drv, 100);
display_port_gpio_rst(drv, 0);
display_port_delay(drv, 100);
display_port_gpio_rst(drv, 1);
display_port_delay(drv, 100);
#else
st7789_send_cmd(drv, ST7789_SWRESET);
display_hal_delay(drv, 5);
display_port_delay(drv, 5);
#endif
}