eink_200inch  2.0.0.0
eink_200inch.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 EINK_200INCH_H
36 #define EINK_200INCH_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 EINK_200INCH_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 EINK_200INCH_RETVAL uint8_t
68 
69 #define EINK_200INCH_OK 0x00
70 #define EINK_200INCH_INIT_ERROR 0xFF
71 
77 #define EINK200_DISPLAY_WIDTH 72
78 #define EINK200_DISPLAY_HEIGHT 172
79 #define EINK200_DISPLAY_RESOLUTION 3096
80 
86 #define EINK200_COMMUNICATION_SPI 0
87 #define EINK200_COMMUNICATION_I2C 1
88 
94 #define EINK200_SCREEN_COLOR_WHITE 0xFF
95 #define EINK200_SCREEN_COLOR_BLACK 0x00
96 #define EINK200_SCREEN_COLOR_LIGHT_GREY 0xAA
97 #define EINK200_SCREEN_COLOR_DARK_GREY 0x55
98 
99 #define EINK200_FO_HORIZONTAL 0x00
100 #define EINK200_FO_VERTICAL 0x01
101 #define EINK200_FO_VERTICAL_COLUMN 0x02
102 
108 #define EINK200_CMD_DRIVER_OUTPUT_CONTROL 0x01
109 #define EINK200_CMD_GATE_VOLTAGE_CONTROL 0x03
110 #define EINK200_CMD_SOURCE_VOLTAGE_CONTROL 0x04
111 #define EINK200_CMD_DISPLAY_CONTROL 0x07
112 #define EINK200_CMD_NONOVERLAP_PERIOD 0x0B
113 #define EINK200_CMD_GATE_SCAN_START_POSITION 0x0F
114 #define EINK200_CMD_DEEP_SLEEP_MODE 0x10
115 #define EINK200_CMD_DATA_ENTRY_MODE_SETTING 0x11
116 #define EINK200_CMD_SW_RESET 0x12
117 #define EINK200_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
118 #define EINK200_CMD_TEMPERATURE_LOAD 0x1D
119 #define EINK200_CMD_MASTER_ACTIVATION 0x20
120 #define EINK200_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
121 #define EINK200_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
122 #define EINK200_CMD_WRITE_RAM 0x24
123 #define EINK200_CMD_VCOM_SENSE 0x28
124 #define EINK200_CMD_VCOM_SENSE_DURATION 0x29
125 #define EINK200_CMD_VCOM_PROG_OTP 0x2A
126 #define EINK200_CMD_WRITE_VCOM_REGISTER 0x2C
127 #define EINK200_CMD_OTP_WAVEFORM_SETTINGS 0x30
128 #define EINK200_CMD_WRITE_LUT_REGISTER 0x32
129 #define EINK200_CMD_OTP_PROGRAM 0x36
130 #define EINK200_CMD_OTP_SELECTION 0x37
131 #define EINK200_CMD_SET_DUMMY_LINE_PERIOD 0x3A
132 #define EINK200_CMD_SET_GATE_TIME 0x3B
133 #define EINK200_CMD_BORDER_WAVEFORM_CONTROL 0x3C
134 #define EINK200_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
135 #define EINK200_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
136 #define EINK200_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
137 #define EINK200_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
138 #define EINK200_CMD_BOOSTER_FEEDBACK_SELECTION 0xF0
139 #define EINK200_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
140 
146 #define EINK200_DEVICE_SLAVE_ADDRESS_000 0x28
147 #define EINK200_DEVICE_SLAVE_ADDRESS_001 0x29
148 #define EINK200_DEVICE_SLAVE_ADDRESS_010 0x2A
149 #define EINK200_DEVICE_SLAVE_ADDRESS_011 0x2B
150 #define EINK200_DEVICE_SLAVE_ADDRESS_100 0x2C
151 #define EINK200_DEVICE_SLAVE_ADDRESS_101 0x2D
152 #define EINK200_DEVICE_SLAVE_ADDRESS_110 0x2E
153 #define EINK200_DEVICE_SLAVE_ADDRESS_111 0x2F
154  // End group macro
157 // --------------------------------------------------------------- PUBLIC TYPES
163 typedef struct
164 {
165  const uint8_t *p_font;
166  uint16_t color;
167  uint8_t orientation;
168  uint16_t first_char;
169  uint16_t last_char;
170  uint16_t height;
171 
173 
174 typedef struct
175 {
176  uint16_t x;
177  uint16_t y;
178 
180 
181 typedef struct
182 {
183  uint8_t x_start;
184  uint8_t y_start;
185  uint8_t x_end;
186  uint8_t y_end;
187 
188 } eink_200_xy_t;
189 
190 typedef struct
191 {
192  uint8_t text_x;
193  uint8_t text_y;
194  uint8_t n_char;
195 
197 
201 typedef struct
202 {
203  // Output pins
204 
205  digital_out_t cs;
206  digital_out_t rst;
207  digital_out_t dc;
208 
209  // Input pins
210 
211  digital_in_t bsy;
212 
213  // Modules
214 
215  spi_master_t spi;
216  pin_name_t chip_select;
217 
220 #ifndef IMAGE_MODE_ONLY
221  uint8_t p_frame[EINK200_DISPLAY_RESOLUTION];
222 #endif
224 
228 typedef struct
229 {
230  // Communication gpio pins
231 
232  pin_name_t miso;
233  pin_name_t mosi;
234  pin_name_t sck;
235  pin_name_t cs;
236 
237  // Additional gpio pins
238 
239  //pin_name_t an;
240  pin_name_t rst;
241  pin_name_t dc;
242  pin_name_t bsy;
243 
244  // static variable
245 
246  uint32_t spi_speed;
247  spi_master_mode_t spi_mode;
248  spi_master_chip_select_polarity_t cs_polarity;
249 
251 
253  // End types group
255 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
256 
261 #ifdef __cplusplus
262 extern "C"{
263 #endif
264 
274 
284 
296 void eink_200inch_generic_transfer ( eink_200inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
297 
304 void eink200_send_command ( eink_200inch_t *ctx, uint8_t command );
305 
312 void eink200_send_data ( eink_200inch_t *ctx, uint8_t c_data );
313 
319 void eink200_reset( eink_200inch_t *ctx );
320 
326 void eink200_sleep_mode ( eink_200inch_t *ctx );
327 
334 
344 void eink200_set_lut ( eink_200inch_t *ctx, const uint8_t *lut, uint8_t n_bytes );
345 
353 void eink200_set_memory_pointer ( eink_200inch_t *ctx, uint8_t x, uint8_t y );
354 
362 
369 
382 void eink200_fill_screen ( eink_200inch_t *ctx, uint8_t color );
383 
392 void eink200_display_image ( eink_200inch_t *ctx, const uint8_t* image_buffer );
393 
402 void eink200_text ( eink_200inch_t *ctx, char *text, eink_200_text_set_t *text_set );
403 
410 void eink200_set_font ( eink_200inch_t *ctx, eink_200inch_font_t *cfg_font );
411 
412 #ifdef __cplusplus
413 }
414 #endif
415 #endif // _EINK_200INCH_H_
416  // End public_function group
419 
420 // ------------------------------------------------------------------------- END
eink_200_xy_t::y_start
uint8_t y_start
Definition: eink_200inch.h:184
eink_200inch_font_t::last_char
uint16_t last_char
Definition: eink_200inch.h:169
eink_200inch_font_t
Definition: eink_200inch.h:163
eink_200inch_cfg_t::rst
pin_name_t rst
Definition: eink_200inch.h:240
eink_200inch_cfg_t::bsy
pin_name_t bsy
Definition: eink_200inch.h:242
eink_200inch_t::cs
digital_out_t cs
Definition: eink_200inch.h:205
eink_200inch_t::rst
digital_out_t rst
Definition: eink_200inch.h:206
eink_200inch_font_t::first_char
uint16_t first_char
Definition: eink_200inch.h:168
eink_200inch_t::chip_select
pin_name_t chip_select
Definition: eink_200inch.h:216
eink_200inch_cfg_t
Click configuration structure definition.
Definition: eink_200inch.h:228
eink_200inch_t::bsy
digital_in_t bsy
Definition: eink_200inch.h:211
eink_200inch_cfg_t::mosi
pin_name_t mosi
Definition: eink_200inch.h:233
eink200_update_display
void eink200_update_display(eink_200inch_t *ctx)
Update dispaly.
eink_200inch_cfg_t::cs
pin_name_t cs
Definition: eink_200inch.h:235
eink_200_text_set_t
Definition: eink_200inch.h:190
eink_200inch_t::dc
digital_out_t dc
Definition: eink_200inch.h:207
eink_200inch_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: eink_200inch.h:247
eink_200inch_t::dev_cord
eink_200inch_cordinate_t dev_cord
Definition: eink_200inch.h:219
eink_200_xy_t::x_end
uint8_t x_end
Definition: eink_200inch.h:185
eink_200inch_cordinate_t::x
uint16_t x
Definition: eink_200inch.h:176
eink200_send_command
void eink200_send_command(eink_200inch_t *ctx, uint8_t command)
Sending a command.
eink_200inch_cfg_t::miso
pin_name_t miso
Definition: eink_200inch.h:232
eink_200inch_cordinate_t
Definition: eink_200inch.h:174
eink_200inch_t::spi
spi_master_t spi
Definition: eink_200inch.h:215
EINK200_DISPLAY_RESOLUTION
#define EINK200_DISPLAY_RESOLUTION
Definition: eink_200inch.h:79
eink200_set_font
void eink200_set_font(eink_200inch_t *ctx, eink_200inch_font_t *cfg_font)
Set text font.
eink_200inch_t
Click ctx object definition.
Definition: eink_200inch.h:201
eink_200inch_cfg_t::dc
pin_name_t dc
Definition: eink_200inch.h:241
eink200_display_image
void eink200_display_image(eink_200inch_t *ctx, const uint8_t *image_buffer)
Displays image.
eink_200inch_font_t::orientation
uint8_t orientation
Definition: eink_200inch.h:167
eink200_sleep_mode
void eink200_sleep_mode(eink_200inch_t *ctx)
Sleep mode.
eink200_reset
void eink200_reset(eink_200inch_t *ctx)
Reset chip.
eink_200inch_font_t::color
uint16_t color
Definition: eink_200inch.h:166
eink200_text
void eink200_text(eink_200inch_t *ctx, char *text, eink_200_text_set_t *text_set)
Draw text on the screen.
eink_200inch_cfg_t::font_cfg
eink_200inch_font_t font_cfg
Definition: eink_200inch.h:250
eink200_set_memory_area
void eink200_set_memory_area(eink_200inch_t *ctx, eink_200_xy_t *xy)
Setting area in memory.
eink_200inch_cordinate_t::y
uint16_t y
Definition: eink_200inch.h:177
eink200_set_lut
void eink200_set_lut(eink_200inch_t *ctx, const uint8_t *lut, uint8_t n_bytes)
Set LUT table.
eink_200_xy_t::y_end
uint8_t y_end
Definition: eink_200inch.h:186
eink_200_xy_t
Definition: eink_200inch.h:181
eink_200inch_cfg_t::spi_speed
uint32_t spi_speed
Definition: eink_200inch.h:246
eink200_fill_screen
void eink200_fill_screen(eink_200inch_t *ctx, uint8_t color)
Function that fills the screen.
eink_200_text_set_t::text_x
uint8_t text_x
Definition: eink_200inch.h:192
eink_200_xy_t::x_start
uint8_t x_start
Definition: eink_200inch.h:183
eink200_start_config
void eink200_start_config(eink_200inch_t *ctx)
Configuration display.
eink200_send_data
void eink200_send_data(eink_200inch_t *ctx, uint8_t c_data)
Sending data.
eink_200inch_cfg_t::sck
pin_name_t sck
Definition: eink_200inch.h:234
eink_200_text_set_t::text_y
uint8_t text_y
Definition: eink_200inch.h:193
eink_200inch_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: eink_200inch.h:248
eink200_set_memory_pointer
void eink200_set_memory_pointer(eink_200inch_t *ctx, uint8_t x, uint8_t y)
Setting pointers in memory.
eink_200inch_t::dev_font
eink_200inch_font_t dev_font
Definition: eink_200inch.h:218
eink_200inch_generic_transfer
void eink_200inch_generic_transfer(eink_200inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
eink_200inch_font_t::height
uint16_t height
Definition: eink_200inch.h:170
eink_200inch_init
EINK_200INCH_RETVAL eink_200inch_init(eink_200inch_t *ctx, eink_200inch_cfg_t *cfg)
Initialization function.
eink_200_text_set_t::n_char
uint8_t n_char
Definition: eink_200inch.h:194
eink_200inch_font_t::p_font
const uint8_t * p_font
Definition: eink_200inch.h:165
eink_200inch_cfg_setup
void eink_200inch_cfg_setup(eink_200inch_cfg_t *cfg)
Config Object Initialization function.
EINK_200INCH_RETVAL
#define EINK_200INCH_RETVAL
Definition: eink_200inch.h:67