eink_213inch  2.0.0.0
eink_213inch.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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
53 #define EINK213INCH_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59  cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
60  cfg.bsy = MIKROBUS( mikrobus, MIKROBUS_INT )
61 
67 #define EINK213INCH_RETVAL uint8_t
68 
69 #define EINK213INCH_OK 0x00
70 #define EINK213INCH_INIT_ERROR 0xFF
71 
77 #define EINK213_DISPLAY_WIDTH 128
78 #define EINK213_DISPLAY_HEIGHT 250
79 #define EINK213_DISPLAY_RESOLUTIONS 4000
80 
86 #define EINK213_COMMUNICATION_SPI 0
87 #define EINK213_COMMUNICATION_I2C 1
88 
94 #define EINK213_SCREEN_COLOR_WHITE 0xFF
95 #define EINK213_SCREEN_COLOR_BLACK 0x00
96 #define EINK213_SCREEN_COLOR_LIGHT_GREY 0xAA
97 #define EINK213_SCREEN_COLOR_DARK_GREY 0x55
98 
99 #define EINK213_FO_HORIZONTAL 0x00
100 #define EINK213_FO_VERTICAL 0x01
101 #define EINK213_FO_VERTICAL_COLUMN 0x02
102 
108 #define EINK213_CMD_DRIVER_OUTPUT_CONTROL 0x01
109 #define EINK213_CMD_BOOSTER_SOFT_START_CONTROL 0x0C
110 #define EINK213_CMD_GATE_SCAN_START_POSITION 0x0F
111 #define EINK213_CMD_DEEP_SLEEP_MODE 0x10
112 #define EINK213_CMD_DATA_ENTRY_MODE_SETTING 0x11
113 #define EINK213_CMD_SW_RESET 0x12
114 #define EINK213_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
115 #define EINK213_CMD_MASTER_ACTIVATION 0x20
116 #define EINK213_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
117 #define EINK213_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
118 #define EINK213_CMD_WRITE_RAM 0x24
119 #define EINK213_CMD_WRITE_VCOM_REGISTER 0x2C
120 #define EINK213_CMD_WRITE_LUT_REGISTER 0x32
121 #define EINK213_CMD_SET_DUMMY_LINE_PERIOD 0x3A
122 #define EINK213_CMD_SET_GATE_TIME 0x3B
123 #define EINK213_CMD_BORDER_WAVEFORM_CONTROL 0x3C
124 #define EINK213_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
125 #define EINK213_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
126 #define EINK213_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
127 #define EINK213_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
128 #define EINK213_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
129  // End group macro
132 // --------------------------------------------------------------- PUBLIC TYPES
138 typedef struct
139 {
140  const uint8_t *p_font;
141  uint16_t color;
142  uint8_t orientation;
143  uint16_t first_char;
144  uint16_t last_char;
145  uint16_t height;
146 
148 
149 typedef struct
150 {
151  uint16_t x;
152  uint16_t y;
153 
155 
156 typedef struct
157 {
158  uint16_t x_start;
159  uint16_t y_start;
160  uint16_t x_end;
161  uint16_t y_end;
162 
164 
165 typedef struct
166 {
167  uint8_t n_char;
168  uint16_t text_x;
169  uint16_t text_y;
170 
172 
176 typedef struct
177 {
178  // Output pins
179 
180  digital_out_t cs;
181  digital_out_t rst;
182  digital_out_t dc;
183 
184  // Input pins
185 
186  digital_in_t bsy;
187 
188  // Modules
189 
190  spi_master_t spi;
191  pin_name_t chip_select;
192 
193 #ifndef IMAGE_MODE_ONLY
194  uint8_t frame[ 4000 ];
195 #endif
196 
199 
201 
205 typedef struct
206 {
207  // Communication gpio pins
208 
209  pin_name_t miso;
210  pin_name_t mosi;
211  pin_name_t sck;
212  pin_name_t cs;
213 
214  // Additional gpio pins
215 
216  pin_name_t rst;
217  pin_name_t dc;
218  pin_name_t bsy;
219 
220  // static variable
221 
222  uint32_t spi_speed;
223  spi_master_mode_t spi_mode;
224  spi_master_chip_select_polarity_t cs_polarity;
225 
227  // End types group
229 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
230 
235 #ifdef __cplusplus
236 extern "C"{
237 #endif
238 
248 
258 
270 void eink_213inch_generic_transfer ( eink_213inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
271 
278 void eink_213_send_command ( eink_213inch_t *ctx, uint8_t command );
279 
286 void eink_213_send_data ( eink_213inch_t *ctx, uint8_t c_data );
287 
293 void eink_213_reset ( eink_213inch_t *ctx );
294 
300 void eink_213_sleep_mode ( eink_213inch_t *ctx );
301 
311 void eink_213_set_lut ( eink_213inch_t *ctx, const uint8_t *lut, uint8_t n_bytes );
312 
319 
327 void eink_213_set_memory_pointer ( eink_213inch_t *ctx, uint16_t x, uint16_t y );
328 
336 
343 
356 void eink_213_fill_screen ( eink_213inch_t *ctx, uint8_t color );
357 
367 void eink_213_display_image ( eink_213inch_t *ctx, const uint8_t* image_buffer );
368 
377 void eink_213_text ( eink_213inch_t *ctx, char *text, eink_213inch_set_text_t *text_set );
378 
385 void eink_213_set_font ( eink_213inch_t *ctx, eink_213inch_font_t *cfg_font );
386 
387 #ifdef __cplusplus
388 }
389 #endif
390 #endif // _EINK213INCH_H_
391  // End public_function group
394 
395 // ------------------------------------------------------------------------- END
eink_213inch_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: eink_213inch.h:223
eink_213inch_set_text_t::n_char
uint8_t n_char
Definition: eink_213inch.h:167
eink_213inch_cfg_t::miso
pin_name_t miso
Definition: eink_213inch.h:209
eink_213inch_set_text_t::text_y
uint16_t text_y
Definition: eink_213inch.h:169
eink_213inch_t::dev_font
eink_213inch_font_t dev_font
Definition: eink_213inch.h:197
eink_213_send_command
void eink_213_send_command(eink_213inch_t *ctx, uint8_t command)
Function for sending a command.
eink_213inch_cfg_setup
void eink_213inch_cfg_setup(eink_213inch_cfg_t *cfg)
Config Object Initialization function.
eink_213inch_t::dev_cord
eink_213inch_cord_t dev_cord
Definition: eink_213inch.h:198
eink_213inch_xy_t::y_start
uint16_t y_start
Definition: eink_213inch.h:159
eink_213inch_font_t
Definition: eink_213inch.h:138
eink_213inch_cord_t::y
uint16_t y
Definition: eink_213inch.h:152
eink_213_display_image
void eink_213_display_image(eink_213inch_t *ctx, const uint8_t *image_buffer)
Display image function.
eink_213inch_font_t::first_char
uint16_t first_char
Definition: eink_213inch.h:143
eink_213inch_cfg_t::bsy
pin_name_t bsy
Definition: eink_213inch.h:218
eink_213inch_cord_t
Definition: eink_213inch.h:149
eink_213_text
void eink_213_text(eink_213inch_t *ctx, char *text, eink_213inch_set_text_t *text_set)
Function for draw text on the screen.
eink_213inch_xy_t
Definition: eink_213inch.h:156
eink_213inch_t::cs
digital_out_t cs
Definition: eink_213inch.h:180
eink_213inch_set_text_t
Definition: eink_213inch.h:165
eink_213inch_t
Click ctx object definition.
Definition: eink_213inch.h:176
eink_213inch_init
EINK213INCH_RETVAL eink_213inch_init(eink_213inch_t *ctx, eink_213inch_cfg_t *cfg)
Initialization function.
eink_213inch_cfg_t::rst
pin_name_t rst
Definition: eink_213inch.h:216
eink_213inch_font_t::height
uint16_t height
Definition: eink_213inch.h:145
eink_213inch_set_text_t::text_x
uint16_t text_x
Definition: eink_213inch.h:168
eink_213inch_cfg_t::sck
pin_name_t sck
Definition: eink_213inch.h:211
eink_213inch_t::bsy
digital_in_t bsy
Definition: eink_213inch.h:186
eink_213inch_xy_t::x_start
uint16_t x_start
Definition: eink_213inch.h:158
eink_213inch_xy_t::y_end
uint16_t y_end
Definition: eink_213inch.h:161
eink_213inch_cfg_t::cs
pin_name_t cs
Definition: eink_213inch.h:212
eink_213inch_cord_t::x
uint16_t x
Definition: eink_213inch.h:151
eink_213_sleep_mode
void eink_213_sleep_mode(eink_213inch_t *ctx)
Function for go to sleep mode.
eink_213_send_data
void eink_213_send_data(eink_213inch_t *ctx, uint8_t c_data)
Function for sending data.
eink_213inch_xy_t::x_end
uint16_t x_end
Definition: eink_213inch.h:160
eink_213inch_font_t::color
uint16_t color
Definition: eink_213inch.h:141
eink_213inch_cfg_t::dc
pin_name_t dc
Definition: eink_213inch.h:217
eink_213inch_t::rst
digital_out_t rst
Definition: eink_213inch.h:181
eink_213inch_font_t::orientation
uint8_t orientation
Definition: eink_213inch.h:142
eink_213inch_t::spi
spi_master_t spi
Definition: eink_213inch.h:190
eink_213inch_t::chip_select
pin_name_t chip_select
Definition: eink_213inch.h:191
eink_213_start_config
void eink_213_start_config(eink_213inch_t *ctx)
Start configuration display.
eink_213_update_display
void eink_213_update_display(eink_213inch_t *ctx)
Functions for update display.
eink_213inch_font_t::last_char
uint16_t last_char
Definition: eink_213inch.h:144
eink_213_reset
void eink_213_reset(eink_213inch_t *ctx)
Function for reset chip.
EINK213INCH_RETVAL
#define EINK213INCH_RETVAL
Definition: eink_213inch.h:67
eink_213_set_memory_pointer
void eink_213_set_memory_pointer(eink_213inch_t *ctx, uint16_t x, uint16_t y)
Function for setting pointers in memory.
eink_213inch_t::dc
digital_out_t dc
Definition: eink_213inch.h:182
eink_213inch_cfg_t
Click configuration structure definition.
Definition: eink_213inch.h:205
eink_213_fill_screen
void eink_213_fill_screen(eink_213inch_t *ctx, uint8_t color)
Function that fills the screen.
eink_213inch_font_t::p_font
const uint8_t * p_font
Definition: eink_213inch.h:140
eink_213inch_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: eink_213inch.h:224
eink_213inch_generic_transfer
void eink_213inch_generic_transfer(eink_213inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
eink_213inch_cfg_t::mosi
pin_name_t mosi
Definition: eink_213inch.h:210
eink_213_set_memory_area
void eink_213_set_memory_area(eink_213inch_t *ctx, eink_213inch_xy_t *xy)
Function for setting area in memory.
eink_213_set_font
void eink_213_set_font(eink_213inch_t *ctx, eink_213inch_font_t *cfg_font)
Set font function.
eink_213inch_cfg_t::spi_speed
uint32_t spi_speed
Definition: eink_213inch.h:222
eink_213_set_lut
void eink_213_set_lut(eink_213inch_t *ctx, const uint8_t *lut, uint8_t n_bytes)
Set LUT table.