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 
9 #pragma once
10 
34 #include "periph/spi.h"
35 #include "periph/gpio.h"
36 
37 #ifdef MODULE_DISP_DEV
38 #include "disp_dev.h"
39 #endif
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 #define EPD_BW_SPI_COLOR_WHITE (0xFF)
46 #define EPD_BW_SPI_COLOR_BLACK (0x00)
53 typedef enum {
59 
63 enum {
64  EPD_BW_SPI_DC_FAIL = -5,
65  EPD_BW_SPI_RST_FAIL = -6,
66  EPD_BW_SPI_BUSY_FAIL = -7,
67 };
68 
72 typedef struct {
73  uint8_t vcom;
74  const uint16_t size_x;
75  const uint16_t size_y;
76  const uint8_t lut_size;
77  const uint8_t *lut_full;
78  const uint8_t *lut_part;
80 
84 typedef struct {
85  spi_t spi;
87  gpio_t cs_pin;
88  gpio_t dc_pin;
89  gpio_t rst_pin;
90  gpio_t busy_pin;
91  bool busy_value;
93  bool dummy;
96  uint16_t size_x;
97  uint16_t size_y;
101 
105 typedef struct {
106  #ifdef MODULE_DISP_DEV
107  disp_dev_t *dev;
108  #endif
112 } epd_bw_spi_t;
113 
121 
128 
135 
142 
149 
156 
163 
170 
177 
184 
195 void epd_bw_spi_fill(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1,
196  uint16_t y2,
197  uint8_t color);
198 
212 void epd_bw_spi_fill_pixels(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2,
213  uint16_t y1, uint16_t y2,
214  uint8_t *px);
215 
225 void epd_bw_spi_set_area(epd_bw_spi_t *dev, uint8_t x1, uint8_t x2, uint16_t y1,
226  uint16_t y2);
227 
238 void epd_bw_spi_write_buffer(epd_bw_spi_t *dev, const uint8_t *buf, size_t len);
239 
249 
258 
268 
269 #ifdef __cplusplus
270 }
271 #endif
spi_clk_t
Definition: periph_cpu.h:351
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:53
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:54
@ EPD_BW_SPI_Y_INC_X_INC
Y increment, X increment.
Definition: epd_bw_spi.h:57
@ EPD_BW_SPI_Y_DEC_X_INC
Y decrement, X increment.
Definition: epd_bw_spi.h:55
@ EPD_BW_SPI_Y_INC_X_DEC
Y increment, X decrement.
Definition: epd_bw_spi.h:56
Low-level SPI peripheral driver interface definition.
Generic type for a display device.
Definition: disp_dev.h:106
Display controller parameters.
Definition: epd_bw_spi.h:72
const uint8_t lut_size
size of the waveform lookup table
Definition: epd_bw_spi.h:76
const uint16_t size_x
supported number of horizontal pixels
Definition: epd_bw_spi.h:74
const uint8_t * lut_part
lookup table for a partial display refresh
Definition: epd_bw_spi.h:78
const uint8_t * lut_full
lookup table for a full display refresh
Definition: epd_bw_spi.h:77
uint8_t vcom
VCOM voltage level.
Definition: epd_bw_spi.h:73
const uint16_t size_y
supported number of vertical pixels
Definition: epd_bw_spi.h:75
SPI display device initialisation parameters.
Definition: epd_bw_spi.h:84
gpio_t busy_pin
pin connected to the busy line (optional)
Definition: epd_bw_spi.h:90
epd_bw_spi_entry_mode_t entry_mode
data entry mode
Definition: epd_bw_spi.h:95
bool dummy
if device requires a dummy cycle before read
Definition: epd_bw_spi.h:93
gpio_t dc_pin
pin connected to the DC line
Definition: epd_bw_spi.h:88
uint16_t partial_refresh_max
maximum number of partial refreshes to perform before triggering a full refresh
Definition: epd_bw_spi.h:98
spi_t spi
SPI device that the display is connected to.
Definition: epd_bw_spi.h:85
uint16_t size_x
number of horizontal pixels in the display
Definition: epd_bw_spi.h:96
bool busy_value
expected value for the busy pin when the display is busy
Definition: epd_bw_spi.h:91
epd_bw_spi_controller_t controller
display controller of the e-Paper display
Definition: epd_bw_spi.h:94
gpio_t rst_pin
pin connected to the reset line (optional)
Definition: epd_bw_spi.h:89
spi_clk_t spi_clk
SPI clock speed to use.
Definition: epd_bw_spi.h:86
gpio_t cs_pin
pin connected to the CHIP SELECT line
Definition: epd_bw_spi.h:87
uint16_t size_y
number of vertical pixels in the display
Definition: epd_bw_spi.h:97
Device initialisation parameters.
Definition: epd_bw_spi.h:105
uint16_t partial_refresh_count
number of partial refreshes since the last full refresh
Definition: epd_bw_spi.h:110
epd_bw_spi_params_t params
SPI display parameters.
Definition: epd_bw_spi.h:109