eink_154inch  2.0.0.0
eink_154inch.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_154INCH_H
36 #define EINK_154INCH_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_154INCH_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_154INCH_RETVAL uint8_t
68 
69 #define EINK_154INCH_OK 0x00
70 #define EINK_154INCH_INIT_ERROR 0xFF
71 
77 #define EINK154_DISPLAY_WIDTH 200
78 #define EINK154_DISPLAY_HEIGHT 200
79 #define EINK154_DISPLAY_RESOLUTIONS 5000
80 
86 #define EINK154_COMMUNICATION_SPI 0
87 #define EINK154_COMMUNICATION_I2C 1
88 
94 #define EINK154_SCREEN_COLOR_WHITE 0xFF
95 #define EINK154_SCREEN_COLOR_BLACK 0x00
96 #define EINK154_SCREEN_COLOR_LIGHT_GREY 0xAA
97 #define EINK154_SCREEN_COLOR_DARK_GREY 0x55
98 
99 #define EINK154_FO_HORIZONTAL 0x00
100 #define EINK154_FO_VERTICAL 0x01
101 #define EINK154_FO_VERTICAL_COLUMN 0x02
102 
108 #define EINK154_CMD_DRIVER_OUTPUT_CONTROL 0x01
109 #define EINK154_CMD_BOOSTER_SOFT_START_CONTROL 0x0C
110 #define EINK154_CMD_GATE_SCAN_START_POSITION 0x0F
111 #define EINK154_CMD_DEEP_SLEEP_MODE 0x10
112 #define EINK154_CMD_DATA_ENTRY_MODE_SETTING 0x11
113 #define EINK154_CMD_SW_RESET 0x12
114 #define EINK154_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
115 #define EINK154_CMD_MASTER_ACTIVATION 0x20
116 #define EINK154_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
117 #define EINK154_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
118 #define EINK154_CMD_WRITE_RAM 0x24
119 #define EINK154_CMD_WRITE_VCOM_REGISTER 0x2C
120 #define EINK154_CMD_WRITE_LUT_REGISTER 0x32
121 #define EINK154_CMD_SET_DUMMY_LINE_PERIOD 0x3A
122 #define EINK154_CMD_SET_GATE_TIME 0x3B
123 #define EINK154_CMD_BORDER_WAVEFORM_CONTROL 0x3C
124 #define EINK154_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
125 #define EINK154_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
126 #define EINK154_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
127 #define EINK154_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
128 #define EINK154_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
129 
135 #define EINK154_DEVICE_SLAVE_ADDRESS_000 0x28
136 #define EINK154_DEVICE_SLAVE_ADDRESS_001 0x29
137 #define EINK154_DEVICE_SLAVE_ADDRESS_010 0x2A
138 #define EINK154_DEVICE_SLAVE_ADDRESS_011 0x2B
139 #define EINK154_DEVICE_SLAVE_ADDRESS_100 0x2C
140 #define EINK154_DEVICE_SLAVE_ADDRESS_101 0x2D
141 #define EINK154_DEVICE_SLAVE_ADDRESS_110 0x2E
142 #define EINK154_DEVICE_SLAVE_ADDRESS_111 0x2F
143  // End group macro
146 // --------------------------------------------------------------- PUBLIC TYPES
152 typedef struct
153 {
154  const uint8_t *p_font;
155  uint16_t color;
156  uint8_t orientation;
157  uint16_t first_char;
158  uint16_t last_char;
159  uint16_t height;
160 
162 
163 typedef struct
164 {
165  uint16_t x;
166  uint16_t y;
167 
169 
170 typedef struct
171 {
172  uint8_t x_start;
173  uint8_t y_start;
174  uint8_t x_end;
175  uint8_t y_end;
176 
177 } eink_154_xy_t;
178 
179 typedef struct
180 {
181  uint8_t text_x;
182  uint8_t text_y;
183  uint8_t n_char;
184 
186 
190 typedef struct
191 {
192  // Output pins
193 
194  digital_out_t cs;
195  digital_out_t rst;
196  digital_out_t dc;
197 
198  // Input pins
199 
200  digital_in_t bsy;
201 
202  // Modules
203 
204  spi_master_t spi;
205  pin_name_t chip_select;
206 
209 #ifndef IMAGE_MODE_ONLY
210  uint8_t p_frame[5000];
211 #endif
213 
217 typedef struct
218 {
219  // Communication gpio pins
220 
221  pin_name_t miso;
222  pin_name_t mosi;
223  pin_name_t sck;
224  pin_name_t cs;
225 
226  // Additional gpio pins
227 
228  //pin_name_t an;
229  pin_name_t rst;
230  pin_name_t dc;
231  pin_name_t bsy;
232 
233  // static variable
234 
235  uint32_t spi_speed;
236  spi_master_mode_t spi_mode;
237  spi_master_chip_select_polarity_t cs_polarity;
238 
240 
242  // End types group
244 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
245 
250 #ifdef __cplusplus
251 extern "C"{
252 #endif
253 
263 
273 
285 void eink_154inch_generic_transfer ( eink_154inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
286 
293 void eink154_send_command ( eink_154inch_t *ctx, uint8_t command );
294 
301 void eink154_send_data ( eink_154inch_t *ctx, uint8_t c_data );
302 
309 
316 
323 
333 void eink154_set_lut ( eink_154inch_t *ctx, const uint8_t *lut, uint8_t n_bytes );
334 
342 void eink154_set_memory_pointer ( eink_154inch_t *ctx, uint8_t x, uint8_t y );
343 
351 
358 
371 void eink154_fill_screen ( eink_154inch_t *ctx, uint8_t color );
372 
381 void eink154_display_image ( eink_154inch_t *ctx, const uint8_t* image_buffer );
382 
391 void eink154_text ( eink_154inch_t *ctx, char *text, eink_154_text_set_t *text_set );
392 
400 
401 #ifdef __cplusplus
402 }
403 #endif
404 #endif // _EINK_154INCH_H_
405  // End public_function group
408 
409 // ------------------------------------------------------------------------- END
eink_154inch_font_t::orientation
uint8_t orientation
Definition: eink_154inch.h:156
eink_154_text_set_t::text_x
uint8_t text_x
Definition: eink_154inch.h:181
eink_154inch_t
Click ctx object definition.
Definition: eink_154inch.h:191
eink_154inch_generic_transfer
void eink_154inch_generic_transfer(eink_154inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
eink_154inch_font_t::last_char
uint16_t last_char
Definition: eink_154inch.h:158
eink_154_xy_t::y_start
uint8_t y_start
Definition: eink_154inch.h:173
eink_154inch_t::dev_font
eink_154inch_font_t dev_font
Definition: eink_154inch.h:207
eink_154inch_cfg_t
Click configuration structure definition.
Definition: eink_154inch.h:218
eink_154_text_set_t::n_char
uint8_t n_char
Definition: eink_154inch.h:183
eink_154inch_font_t::color
uint16_t color
Definition: eink_154inch.h:155
eink_154inch_cordinate_t::y
uint16_t y
Definition: eink_154inch.h:166
eink_154inch_t::spi
spi_master_t spi
Definition: eink_154inch.h:204
eink_154_xy_t
Definition: eink_154inch.h:171
eink154_set_memory_area
void eink154_set_memory_area(eink_154inch_t *ctx, eink_154_xy_t *xy)
Setting area in memory.
eink_154inch_cfg_t::bsy
pin_name_t bsy
Definition: eink_154inch.h:231
eink_154inch_t::rst
digital_out_t rst
Definition: eink_154inch.h:195
eink154_display_image
void eink154_display_image(eink_154inch_t *ctx, const uint8_t *image_buffer)
Displays image.
eink_154inch_cfg_t::sck
pin_name_t sck
Definition: eink_154inch.h:223
eink_154inch_cfg_setup
void eink_154inch_cfg_setup(eink_154inch_cfg_t *cfg)
Config Object Initialization function.
eink_154inch_font_t::height
uint16_t height
Definition: eink_154inch.h:159
eink154_sleep_mode
void eink154_sleep_mode(eink_154inch_t *ctx)
Sleep mode.
eink_154inch_t::bsy
digital_in_t bsy
Definition: eink_154inch.h:200
eink_154inch_cfg_t::spi_speed
uint32_t spi_speed
Definition: eink_154inch.h:235
eink_154inch_init
EINK_154INCH_RETVAL eink_154inch_init(eink_154inch_t *ctx, eink_154inch_cfg_t *cfg)
Initialization function.
eink_154inch_t::dev_cord
eink_154inch_cordinate_t dev_cord
Definition: eink_154inch.h:208
eink154_set_memory_pointer
void eink154_set_memory_pointer(eink_154inch_t *ctx, uint8_t x, uint8_t y)
Setting pointers in memory.
eink_154inch_t::cs
digital_out_t cs
Definition: eink_154inch.h:194
eink_154inch_cfg_t::cs
pin_name_t cs
Definition: eink_154inch.h:224
eink_154inch_font_t::p_font
const uint8_t * p_font
Definition: eink_154inch.h:154
eink154_set_font
void eink154_set_font(eink_154inch_t *ctx, eink_154inch_font_t *cfg_font)
Set text font.
eink154_fill_screen
void eink154_fill_screen(eink_154inch_t *ctx, uint8_t color)
Function that fills the screen.
eink_154inch_t::dc
digital_out_t dc
Definition: eink_154inch.h:196
eink154_start_config
void eink154_start_config(eink_154inch_t *ctx)
Configuration display.
eink_154inch_cfg_t::rst
pin_name_t rst
Definition: eink_154inch.h:229
eink154_send_data
void eink154_send_data(eink_154inch_t *ctx, uint8_t c_data)
Sending data.
eink_154inch_cfg_t::miso
pin_name_t miso
Definition: eink_154inch.h:221
eink_154inch_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: eink_154inch.h:237
eink_154_xy_t::x_start
uint8_t x_start
Definition: eink_154inch.h:172
eink154_set_lut
void eink154_set_lut(eink_154inch_t *ctx, const uint8_t *lut, uint8_t n_bytes)
Set LUT table.
eink154_text
void eink154_text(eink_154inch_t *ctx, char *text, eink_154_text_set_t *text_set)
Draw text on the screen.
EINK_154INCH_RETVAL
#define EINK_154INCH_RETVAL
Definition: eink_154inch.h:67
eink_154_text_set_t
Definition: eink_154inch.h:180
eink_154inch_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: eink_154inch.h:236
eink_154inch_font_t
Definition: eink_154inch.h:153
eink_154inch_cordinate_t
Definition: eink_154inch.h:164
eink_154inch_font_t::first_char
uint16_t first_char
Definition: eink_154inch.h:157
eink_154inch_cfg_t::dc
pin_name_t dc
Definition: eink_154inch.h:230
eink154_reset
void eink154_reset(eink_154inch_t *ctx)
Reset chip.
eink_154_xy_t::x_end
uint8_t x_end
Definition: eink_154inch.h:174
eink_154inch_cfg_t::mosi
pin_name_t mosi
Definition: eink_154inch.h:222
eink_154inch_cordinate_t::x
uint16_t x
Definition: eink_154inch.h:165
eink_154_text_set_t::text_y
uint8_t text_y
Definition: eink_154inch.h:182
eink_154inch_cfg_t::font_cfg
eink_154inch_font_t font_cfg
Definition: eink_154inch.h:239
eink_154inch_t::chip_select
pin_name_t chip_select
Definition: eink_154inch.h:205
eink_154_xy_t::y_end
uint8_t y_end
Definition: eink_154inch.h:175
eink154_update_display
void eink154_update_display(eink_154inch_t *ctx)
Update dispaly.
eink154_send_command
void eink154_send_command(eink_154inch_t *ctx, uint8_t command)
Sending a command.