58 lines
1.4 KiB
C
58 lines
1.4 KiB
C
#ifndef ST7789_LCD_H
|
|
#define ST7789_LCD_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
ST7789_SUCCESS,
|
|
ST7789_FAIL,
|
|
} st7789_lcd_ret_t;
|
|
|
|
typedef enum {
|
|
ST7789_LCD_DIR_0,
|
|
ST7789_LCD_DIR_90,
|
|
ST7789_LCD_DIR_180,
|
|
ST7789_LCD_DIR_270,
|
|
} st7789_lcd_dir_t;
|
|
|
|
typedef enum {
|
|
ST7789_LCD_PIXFMT_RGB444 = 3U,
|
|
ST7789_LCD_PIXFMT_RGB565 = 5U,
|
|
ST7789_LCD_PIXFMT_RGB666 = 6U,
|
|
ST7789_LCD_PIXFMT_RGB888 = 7U,
|
|
} st7789_lcd_pixfmt_t;
|
|
|
|
typedef struct {
|
|
st7789_lcd_ret_t (*write_command_cb)(void *handle, uint8_t *command, uint32_t len);
|
|
st7789_lcd_ret_t (*write_data_cb)(void *handle, uint8_t *data, uint32_t len);
|
|
st7789_lcd_ret_t (*reset_cb)(void *handle);
|
|
st7789_lcd_ret_t (*poll_busy_cb)(void *handle);
|
|
st7789_lcd_ret_t (*delay_cb)(void *handle, uint32_t msec);
|
|
} st7789_lcd_cb_t;
|
|
|
|
typedef struct {
|
|
uint32_t x_start;
|
|
uint32_t x_end;
|
|
uint32_t y_start;
|
|
uint32_t y_end;
|
|
} st7789_lcd_coord_t;
|
|
|
|
typedef struct {
|
|
st7789_lcd_dir_t dir;
|
|
st7789_lcd_pixfmt_t pix_fmt;
|
|
bool inverted;
|
|
bool bgr_mode;
|
|
} st7789_lcd_config_t;
|
|
|
|
typedef struct {
|
|
st7789_lcd_cb_t cb;
|
|
st7789_lcd_config_t config;
|
|
void *user_data;
|
|
} st7789_lcd_t;
|
|
|
|
st7789_lcd_ret_t st7789_lcd_init(st7789_lcd_t *lcd);
|
|
st7789_lcd_ret_t st7789_lcd_power(st7789_lcd_t *lcd, bool on);
|
|
st7789_lcd_ret_t st7789_lcd_upload(st7789_lcd_t *lcd, st7789_lcd_coord_t *coord, uint8_t *data);
|
|
|
|
#endif |