98 lines
3.5 KiB
C
98 lines
3.5 KiB
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#include "driver/spi_master.h"
|
|
#include "esp_err.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct st7789p3_panel_t *st7789p3_handle_t;
|
|
|
|
#define ST7789P3_MADCTL_MY 0x80
|
|
#define ST7789P3_MADCTL_MX 0x40
|
|
#define ST7789P3_MADCTL_MV 0x20
|
|
#define ST7789P3_MADCTL_ML 0x10
|
|
#define ST7789P3_MADCTL_BGR 0x08
|
|
#define ST7789P3_MADCTL_MH 0x04
|
|
|
|
typedef struct {
|
|
spi_host_device_t spi_host;
|
|
int pin_mosi;
|
|
int pin_miso;
|
|
int pin_sclk;
|
|
int pin_cs;
|
|
int pin_dc;
|
|
int pin_rst;
|
|
int pin_bckl;
|
|
uint32_t pclk_hz;
|
|
uint8_t spi_mode;
|
|
int queue_size;
|
|
size_t max_transfer_sz;
|
|
uint16_t h_res;
|
|
uint16_t v_res;
|
|
uint16_t x_gap;
|
|
uint16_t y_gap;
|
|
uint8_t madctl_val;
|
|
bool invert_color;
|
|
bool swap_color_bytes;
|
|
int backlight_on_level;
|
|
bool init_spi_bus;
|
|
} st7789p3_config_t;
|
|
|
|
#define ST7789P3_CONFIG_DEFAULT() \
|
|
{ \
|
|
.spi_host = SPI2_HOST, \
|
|
.pin_mosi = -1, \
|
|
.pin_miso = -1, \
|
|
.pin_sclk = -1, \
|
|
.pin_cs = -1, \
|
|
.pin_dc = -1, \
|
|
.pin_rst = -1, \
|
|
.pin_bckl = -1, \
|
|
.pclk_hz = 10 * 1000 * 1000, \
|
|
.spi_mode = 0, \
|
|
.queue_size = 7, \
|
|
.max_transfer_sz = 0, \
|
|
.h_res = 320, \
|
|
.v_res = 240, \
|
|
.x_gap = 0, \
|
|
.y_gap = 0, \
|
|
.madctl_val = ST7789P3_MADCTL_MX | ST7789P3_MADCTL_MV, \
|
|
.invert_color = false, \
|
|
.swap_color_bytes = false, \
|
|
.backlight_on_level = 1, \
|
|
.init_spi_bus = true, \
|
|
}
|
|
|
|
esp_err_t st7789p3_new_panel(const st7789p3_config_t *config, st7789p3_handle_t *ret_panel);
|
|
esp_err_t st7789p3_del(st7789p3_handle_t panel);
|
|
|
|
esp_err_t st7789p3_reset(st7789p3_handle_t panel);
|
|
esp_err_t st7789p3_init(st7789p3_handle_t panel);
|
|
|
|
esp_err_t st7789p3_set_backlight(st7789p3_handle_t panel, bool on);
|
|
esp_err_t st7789p3_set_madctl(st7789p3_handle_t panel, uint8_t madctl_val);
|
|
esp_err_t st7789p3_set_invert(st7789p3_handle_t panel, bool invert_color);
|
|
esp_err_t st7789p3_set_swap_color_bytes(st7789p3_handle_t panel, bool swap_color_bytes);
|
|
esp_err_t st7789p3_recover_spi_bus(st7789p3_handle_t panel);
|
|
|
|
esp_err_t st7789p3_set_window(
|
|
st7789p3_handle_t panel, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end);
|
|
esp_err_t st7789p3_draw_bitmap(st7789p3_handle_t panel,
|
|
uint16_t x_start,
|
|
uint16_t y_start,
|
|
uint16_t x_end,
|
|
uint16_t y_end,
|
|
const uint16_t *color_data);
|
|
|
|
esp_err_t st7789p3_fill_color(st7789p3_handle_t panel, uint16_t color);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|