eink213inch 2.0.0.0
eink213inch.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef EINK213INCH_H
36#define EINK213INCH_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
67#define EINK213INCH_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
74 cfg.bsy = MIKROBUS( mikrobus, MIKROBUS_INT )
81#define EINK213INCH_OK 0
82#define EINK213INCH_ERROR -1
89#define EINK213INCH_DISPLAY_WIDTH 128
90#define EINK213INCH_DISPLAY_HEIGHT 250
91#define EINK213INCH_DISPLAY_RESOLUTIONS 4000
98#define EINK213INCH_COMMUNICATION_SPI 0
99#define EINK213INCH_COMMUNICATION_I2C 1
106#define EINK213INCH_SCREEN_COLOR_WHITE 0xFF
107#define EINK213INCH_SCREEN_COLOR_BLACK 0x00
108#define EINK213INCH_SCREEN_COLOR_LIGHT_GREY 0xAA
109#define EINK213INCH_SCREEN_COLOR_DARK_GREY 0x55
110
111#define EINK213INCH_FO_HORIZONTAL 0x00
112#define EINK213INCH_FO_VERTICAL 0x01
113#define EINK213INCH_FO_VERTICAL_COLUMN 0x02
120#define EINK213INCH_CMD_DRIVER_OUTPUT_CONTROL 0x01
121#define EINK213INCH_CMD_BOOSTER_SOFT_START_CONTROL 0x0C
122#define EINK213INCH_CMD_GATE_SCAN_START_POSITION 0x0F
123#define EINK213INCH_CMD_DEEP_SLEEP_MODE 0x10
124#define EINK213INCH_CMD_DATA_ENTRY_MODE_SETTING 0x11
125#define EINK213INCH_CMD_SW_RESET 0x12
126#define EINK213INCH_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
127#define EINK213INCH_CMD_MASTER_ACTIVATION 0x20
128#define EINK213INCH_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
129#define EINK213INCH_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
130#define EINK213INCH_CMD_WRITE_RAM 0x24
131#define EINK213INCH_CMD_WRITE_VCOM_REGISTER 0x2C
132#define EINK213INCH_CMD_WRITE_LUT_REGISTER 0x32
133#define EINK213INCH_CMD_SET_DUMMY_LINE_PERIOD 0x3A
134#define EINK213INCH_CMD_SET_GATE_TIME 0x3B
135#define EINK213INCH_CMD_BORDER_WAVEFORM_CONTROL 0x3C
136#define EINK213INCH_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
137#define EINK213INCH_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
138#define EINK213INCH_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
139#define EINK213INCH_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
140#define EINK213INCH_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
143 // End group macro
144// --------------------------------------------------------------- PUBLIC TYPES
150typedef struct
151{
152 const uint8_t *p_font;
153 uint16_t color;
154 uint8_t orientation;
155 uint16_t first_char;
156 uint16_t last_char;
157 uint16_t height;
158
160
161typedef struct
162{
163 uint16_t x;
164 uint16_t y;
165
167
168typedef struct
169{
170 uint16_t x_start;
171 uint16_t y_start;
172 uint16_t x_end;
173 uint16_t y_end;
174
176
177typedef struct
178{
179 uint8_t n_char;
180 uint16_t text_x;
181 uint16_t text_y;
182
184
188typedef struct
189{
190 // Output pins
191 digital_out_t cs;
192 digital_out_t rst;
193 digital_out_t dc;
194
195 // Input pins
196 digital_in_t bsy;
197
198 // Modules
199 spi_master_t spi;
200 pin_name_t chip_select;
201
202#ifndef IMAGE_MODE_ONLY
203 uint8_t frame[ 4000 ];
204#endif
205
208
210
214typedef struct
215{
216 // Communication gpio pins
217 pin_name_t miso;
218 pin_name_t mosi;
219 pin_name_t sck;
220 pin_name_t cs;
221
222 // Additional gpio pins
223 pin_name_t rst;
224 pin_name_t dc;
225 pin_name_t bsy;
226
227 // static variable
228 uint32_t spi_speed;
229 spi_master_mode_t spi_mode;
230 spi_master_chip_select_polarity_t cs_polarity;
231
233
234 // End types group
235// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
236
241#ifdef __cplusplus
242extern "C"{
243#endif
244
254
264
271void eink213inch_send_cmd ( eink213inch_t *ctx, uint8_t command );
272
279void eink213inch_send_data ( eink213inch_t *ctx, uint8_t c_data );
280
287
294
304void eink213inch_set_lut ( eink213inch_t *ctx, const uint8_t *lut, uint8_t n_bytes );
305
312
320void eink213inch_set_mem_pointer ( eink213inch_t *ctx, uint16_t x, uint16_t y );
321
329
336
349void eink213inch_fill_screen ( eink213inch_t *ctx, uint8_t color );
350
360void eink213inch_display_image ( eink213inch_t *ctx, const uint8_t* image_buffer );
361
370void eink213inch_text ( eink213inch_t *ctx, uint8_t *text, eink213inch_set_text_t *text_set );
371
379
380#ifdef __cplusplus
381}
382#endif
383#endif // _EINK213INCH_H_
384
385 // End public_function group
387
388// ------------------------------------------------------------------------- END
void eink213inch_sleep_mode(eink213inch_t *ctx)
Function for go to sleep mode.
void eink213inch_fill_screen(eink213inch_t *ctx, uint8_t color)
Function that fills the screen.
void eink213inch_set_mem_area(eink213inch_t *ctx, eink213inch_xy_t *xy)
Function for setting area in memory.
void eink213inch_send_data(eink213inch_t *ctx, uint8_t c_data)
Function for sending data.
void eink213inch_start_config(eink213inch_t *ctx)
Start configuration display.
void eink213inch_text(eink213inch_t *ctx, uint8_t *text, eink213inch_set_text_t *text_set)
Function for draw text on the screen.
void eink213inch_display_image(eink213inch_t *ctx, const uint8_t *image_buffer)
Display image function.
void eink213inch_cfg_setup(eink213inch_cfg_t *cfg)
Config Object Initialization function.
void eink213inch_set_lut(eink213inch_t *ctx, const uint8_t *lut, uint8_t n_bytes)
Set LUT table.
void eink213inch_set_mem_pointer(eink213inch_t *ctx, uint16_t x, uint16_t y)
Function for setting pointers in memory.
void eink213inch_update_display(eink213inch_t *ctx)
Functions for update display.
err_t eink213inch_init(eink213inch_t *ctx, eink213inch_cfg_t *cfg)
Initialization function.
void eink213inch_reset(eink213inch_t *ctx)
Function for reset chip.
void eink213inch_set_font(eink213inch_t *ctx, eink213inch_font_t *cfg_font)
Set font function.
void eink213inch_send_cmd(eink213inch_t *ctx, uint8_t command)
Function for sending a command.
Click configuration structure definition.
Definition eink213inch.h:215
pin_name_t bsy
Definition eink213inch.h:225
spi_master_chip_select_polarity_t cs_polarity
Definition eink213inch.h:230
pin_name_t sck
Definition eink213inch.h:219
spi_master_mode_t spi_mode
Definition eink213inch.h:229
pin_name_t dc
Definition eink213inch.h:224
pin_name_t mosi
Definition eink213inch.h:218
uint32_t spi_speed
Definition eink213inch.h:228
pin_name_t miso
Definition eink213inch.h:217
pin_name_t rst
Definition eink213inch.h:223
pin_name_t cs
Definition eink213inch.h:220
Definition eink213inch.h:162
uint16_t x
Definition eink213inch.h:163
uint16_t y
Definition eink213inch.h:164
Definition eink213inch.h:151
uint16_t first_char
Definition eink213inch.h:155
uint16_t color
Definition eink213inch.h:153
const uint8_t * p_font
Definition eink213inch.h:152
uint16_t height
Definition eink213inch.h:157
uint16_t last_char
Definition eink213inch.h:156
uint8_t orientation
Definition eink213inch.h:154
Definition eink213inch.h:178
uint8_t n_char
Definition eink213inch.h:179
uint16_t text_y
Definition eink213inch.h:181
uint16_t text_x
Definition eink213inch.h:180
Click ctx object definition.
Definition eink213inch.h:189
eink213inch_cord_t dev_cord
Definition eink213inch.h:207
digital_out_t cs
Definition eink213inch.h:191
spi_master_t spi
Definition eink213inch.h:199
digital_out_t dc
Definition eink213inch.h:193
digital_in_t bsy
Definition eink213inch.h:196
digital_out_t rst
Definition eink213inch.h:192
eink213inch_font_t dev_font
Definition eink213inch.h:206
pin_name_t chip_select
Definition eink213inch.h:200
Definition eink213inch.h:169
uint16_t x_start
Definition eink213inch.h:170
uint16_t y_start
Definition eink213inch.h:171
uint16_t x_end
Definition eink213inch.h:172
uint16_t y_end
Definition eink213inch.h:173