epd_bw_spi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Silke Hofstra
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
32 #ifndef EPD_BW_SPI_H
33 #define EPD_BW_SPI_H
34 
35 #include "periph/spi.h"
36 #include "periph/gpio.h"
37 
38 #ifdef MODULE_DISP_DEV
39 #include "disp_dev.h"
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #define EPD_BW_SPI_COLOR_WHITE (0xFF)
47 #define EPD_BW_SPI_COLOR_BLACK (0x00)
54 typedef enum {
60 
64 enum {
65  EPD_BW_SPI_DC_FAIL = -5,
66  EPD_BW_SPI_RST_FAIL = -6,
67  EPD_BW_SPI_BUSY_FAIL = -7,
68 };
69 
73 typedef struct {
74  uint8_t vcom;
75  const uint16_t size_x;
76  const uint16_t size_y;
77  const uint8_t lut_size;
78  const uint8_t *lut_full;
79  const uint8_t *lut_part;
81 
85 typedef struct {
86  spi_t spi;
88  gpio_t cs_pin;
89  gpio_t dc_pin;
90  gpio_t rst_pin;
91  gpio_t busy_pin;
92  bool busy_value;
94  bool dummy;
97  uint16_t size_x;
98  uint16_t size_y;
102 
106 typedef struct {
107  #ifdef MODULE_DISP_DEV
108  disp_dev_t *dev;
109  #endif
113 } epd_bw_spi_t;
114 
122 
129 
136 
143 
150 
157 
164 
171 
178 
185 
196 void epd_bw_spi_fill(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1,
197  uint16_t y2,
198  uint8_t color);
199 
213 void epd_bw_spi_fill_pixels(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2,
214  uint16_t y1, uint16_t y2,
215  uint8_t *px);
216 
226 void epd_bw_spi_set_area(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1,
227  uint16_t y2);
228 
239 void epd_bw_spi_write_buffer(epd_bw_spi_t *dev, const uint8_t *buf, size_t len);
240 
250 
259 
269 
270 #ifdef __cplusplus
271 }
272 #endif
273 #endif /* EPD_BW_SPI_H */
spi_clk_t
Definition: periph_cpu.h:352
Low-level GPIO peripheral driver interface definitions.
void epd_bw_spi_update_auto(epd_bw_spi_t *dev)
Update the display with an automatic partial/full refresh.
void epd_bw_spi_swreset(epd_bw_spi_t *dev)
Perform a soft reset of the device.
void epd_bw_spi_update_full(epd_bw_spi_t *dev)
Update the display with a full refresh.
void epd_bw_spi_init_part(epd_bw_spi_t *dev)
Initialise the display for a partial refresh.
void epd_bw_spi_update_part(epd_bw_spi_t *dev)
Update the display with a partial refresh.
void epd_bw_spi_wake(epd_bw_spi_t *dev)
Wake the device.
void epd_bw_spi_fill_pixels(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1, uint16_t y2, uint8_t *px)
Fill an area with an array of pixels.
void epd_bw_spi_deactivate(epd_bw_spi_t *dev)
Deactivate the display.
int epd_bw_spi_init(epd_bw_spi_t *dev, const epd_bw_spi_params_t *params)
Initialise the display.
void epd_bw_spi_sleep(epd_bw_spi_t *dev)
Set the display to deep sleep mode.
void epd_bw_spi_init_full(epd_bw_spi_t *dev)
Initialise the display for a full refresh.
void epd_bw_spi_fill(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1, uint16_t y2, uint8_t color)
Fill an area with a single color.
void epd_bw_spi_init_auto(epd_bw_spi_t *dev)
Initialise the display for an automatic partial/full refresh.
void epd_bw_spi_clear(epd_bw_spi_t *dev)
Clear the entire display.
void epd_bw_spi_set_area(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1, uint16_t y2)
Set the area in which can be drawn.
epd_bw_spi_entry_mode_t
Data entry mode settings.
Definition: epd_bw_spi.h:54
void epd_bw_spi_activate(epd_bw_spi_t *dev)
Activate the display.
void epd_bw_spi_write_buffer(epd_bw_spi_t *dev, const uint8_t *buf, size_t len)
Write to the RAM of the epd_bw_spi controller.
@ EPD_BW_SPI_Y_DEC_X_DEC
Y decrement, X decrement.
Definition: epd_bw_spi.h:55
@ EPD_BW_SPI_Y_INC_X_INC
Y increment, X increment.
Definition: epd_bw_spi.h:58
@ EPD_BW_SPI_Y_DEC_X_INC
Y decrement, X increment.
Definition: epd_bw_spi.h:56
@ EPD_BW_SPI_Y_INC_X_DEC
Y increment, X decrement.
Definition: epd_bw_spi.h:57
Low-level SPI peripheral driver interface definition.
Generic type for a display device.
Definition: disp_dev.h:107
Display controller parameters.
Definition: epd_bw_spi.h:73
const uint8_t lut_size
size of the waveform lookup table
Definition: epd_bw_spi.h:77
const uint16_t size_x
supported number of horizontal pixels
Definition: epd_bw_spi.h:75
const uint8_t * lut_part
lookup table for a partial display refresh
Definition: epd_bw_spi.h:79
const uint8_t * lut_full
lookup table for a full display refresh
Definition: epd_bw_spi.h:78
uint8_t vcom
VCOM voltage level.
Definition: epd_bw_spi.h:74
const uint16_t size_y
supported number of vertical pixels
Definition: epd_bw_spi.h:76
SPI display device initialisation parameters.
Definition: epd_bw_spi.h:85
gpio_t busy_pin
pin connected to the busy line (optional)
Definition: epd_bw_spi.h:91
epd_bw_spi_entry_mode_t entry_mode
data entry mode
Definition: epd_bw_spi.h:96
bool dummy
if device requires a dummy cycle before read
Definition: epd_bw_spi.h:94
gpio_t dc_pin
pin connected to the DC line
Definition: epd_bw_spi.h:89
uint16_t partial_refresh_max
maximum number of partial refreshes to perform before triggering a full refresh
Definition: epd_bw_spi.h:99
spi_t spi
SPI device that the display is connected to.
Definition: epd_bw_spi.h:86
uint16_t size_x
number of horizontal pixels in the display
Definition: epd_bw_spi.h:97
bool busy_value
expected value for the busy pin when the display is busy
Definition: epd_bw_spi.h:92
epd_bw_spi_controller_t controller
display controller of the e-Paper display
Definition: epd_bw_spi.h:95
gpio_t rst_pin
pin connected to the reset line (optional)
Definition: epd_bw_spi.h:90
spi_clk_t spi_clk
SPI clock speed to use.
Definition: epd_bw_spi.h:87
gpio_t cs_pin
pin connected to the CHIP SELECT line
Definition: epd_bw_spi.h:88
uint16_t size_y
number of vertical pixels in the display
Definition: epd_bw_spi.h:98
Device initialisation parameters.
Definition: epd_bw_spi.h:106
uint16_t partial_refresh_count
number of partial refreshes since the last full refresh
Definition: epd_bw_spi.h:111
epd_bw_spi_params_t params
SPI display parameters.
Definition: epd_bw_spi.h:110