objc

drivers_st7789.h
Go to the documentation of this file.
1 
11 #pragma once
12 #include <runtime-hw/hw.h>
13 #include <stdbool.h>
14 #include <stdint.h>
15 
17 // TYPES
18 
23 typedef enum {
29 
34 typedef enum {
38 
43 typedef struct {
44  uint16_t x;
45  uint16_t y;
46  uint16_t width;
47  uint16_t height;
49 
59 typedef struct driver_st7789_t {
64  uint16_t width;
65  uint16_t height;
68  bool round;
71 
73 // LIFECYCLE
74 
99  uint8_t reset_pin, uint8_t backlight_pin,
100  uint16_t width, uint16_t height, bool round);
101 
115 
125 bool driver_st7789_valid(const driver_st7789_t *st7789);
126 
128 // CONFIGURATION
129 
143 
155 bool driver_st7789_set_backlight(driver_st7789_t *st7789, uint8_t brightness);
156 
158 // DISPLAY OPERATIONS
159 
169 
182  driver_st7789_rect_t rect);
183 
196 bool driver_st7789_write_pixels(driver_st7789_t *st7789, const uint8_t *data,
197  size_t size);
198 
209 bool driver_st7789_fill(driver_st7789_t *st7789, uint16_t color);
210 
225  driver_st7789_rect_t rect, const uint8_t *data,
226  size_t size);
bool driver_st7789_update_rect(driver_st7789_t *st7789, driver_st7789_rect_t rect, const uint8_t *data, size_t size)
Update a rectangular region of the ST7789 display.
bool driver_st7789_write_pixels(driver_st7789_t *st7789, const uint8_t *data, size_t size)
Send pixel data to the ST7789 display.
void driver_st7789_reset(driver_st7789_t *st7789)
Reset the ST7789 display.
driver_st7789_interface_t
ST7789 interface type.
ST7789 display driver structure.
hw_spi_t * spi
Pointer to the SPI interface (NULL for parallel)
hw_gpio_t dc
Data/Command pin.
driver_st7789_rotation_t rotation
Display rotation.
driver_st7789_interface_t interface
Interface type (SPI/Parallel)
uint16_t width
Width (pixels)
driver_st7789_rotation_t
ST7789 rotation modes.
hw_gpio_t backlight
Backlight pin (optional, can be invalid)
uint16_t width
Display width in pixels.
uint8_t backlight_brightness
Current backlight brightness (0-255)
Hardware interface abstraction layer.
bool driver_st7789_set_backlight(driver_st7789_t *st7789, uint8_t brightness)
Set the backlight brightness of the ST7789 display.
bool driver_st7789_valid(const driver_st7789_t *st7789)
Check if a ST7789 driver structure is valid.
bool driver_st7789_set_window(driver_st7789_t *st7789, driver_st7789_rect_t rect)
Set the display window for subsequent pixel data.
driver_st7789_t driver_st7789_init(hw_spi_t *spi, uint8_t dc_pin, uint8_t reset_pin, uint8_t backlight_pin, uint16_t width, uint16_t height, bool round)
Initialize a ST7789 display driver using the SPI interface.
uint16_t y
Y coordinate (pixels)
180-degree rotation
void driver_st7789_finalize(driver_st7789_t *st7789)
Finalize and release a ST7789 display driver.
hw_gpio_t reset
Reset pin (optional, can be invalid)
bool driver_st7789_fill(driver_st7789_t *st7789, uint16_t color)
Fill the entire display with a single color.
bool round
Round display flag.
270-degree rotation
SPI adapter.
Definition: spi.h:25
bool driver_st7789_set_rotation(driver_st7789_t *st7789, driver_st7789_rotation_t rotation)
Set the rotation of the ST7789 display.
uint16_t x
X coordinate (pixels)
GPIO logical pin structure.
Definition: gpio.h:60
90-degree rotation
ST7789 display rectangle for window operations.
uint16_t height
Height (pixels)
struct driver_st7789_t driver_st7789_t
ST7789 display driver structure.
uint16_t height
Display height in pixels.