eink154inch 2.0.0.0
eink154inch.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 EINK154INCH_H
36#define EINK154INCH_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 EINK154INCH_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 EINK154INCH_OK 0
82#define EINK154INCH_ERROR -1
89#define EINK154INCH_DISPLAY_WIDTH 200
90#define EINK154INCH_DISPLAY_HEIGHT 200
91#define EINK154INCH_DISPLAY_RESOLUTIONS 5000
98#define EINK154INCH_COMMUNICATION_SPI 0
99#define EINK154INCH_COMMUNICATION_I2C 1
106#define EINK154INCH_SCREEN_COLOR_WHITE 0xFF
107#define EINK154INCH_SCREEN_COLOR_BLACK 0x00
108#define EINK154INCH_SCREEN_COLOR_LIGHT_GREY 0xAA
109#define EINK154INCH_SCREEN_COLOR_DARK_GREY 0x55
110
111#define EINK154INCH_FO_HORIZONTAL 0x00
112#define EINK154INCH_FO_VERTICAL 0x01
113#define EINK154INCH_FO_VERTICAL_COLUMN 0x02
120#define EINK154INCH_CMD_DRIVER_OUTPUT_CONTROL 0x01
121#define EINK154INCH_CMD_BOOSTER_SOFT_START_CONTROL 0x0C
122#define EINK154INCH_CMD_GATE_SCAN_START_POSITION 0x0F
123#define EINK154INCH_CMD_DEEP_SLEEP_MODE 0x10
124#define EINK154INCH_CMD_DATA_ENTRY_MODE_SETTING 0x11
125#define EINK154INCH_CMD_SW_RESET 0x12
126#define EINK154INCH_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
127#define EINK154INCH_CMD_MASTER_ACTIVATION 0x20
128#define EINK154INCH_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
129#define EINK154INCH_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
130#define EINK154INCH_CMD_WRITE_RAM 0x24
131#define EINK154INCH_CMD_WRITE_VCOM_REGISTER 0x2C
132#define EINK154INCH_CMD_WRITE_LUT_REGISTER 0x32
133#define EINK154INCH_CMD_SET_DUMMY_LINE_PERIOD 0x3A
134#define EINK154INCH_CMD_SET_GATE_TIME 0x3B
135#define EINK154INCH_CMD_BORDER_WAVEFORM_CONTROL 0x3C
136#define EINK154INCH_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
137#define EINK154INCH_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
138#define EINK154INCH_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
139#define EINK154INCH_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
140#define EINK154INCH_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
147#define EINK154INCH_DEVICE_SLAVE_ADDRESS_000 0x28
148#define EINK154INCH_DEVICE_SLAVE_ADDRESS_001 0x29
149#define EINK154INCH_DEVICE_SLAVE_ADDRESS_010 0x2A
150#define EINK154INCH_DEVICE_SLAVE_ADDRESS_011 0x2B
151#define EINK154INCH_DEVICE_SLAVE_ADDRESS_100 0x2C
152#define EINK154INCH_DEVICE_SLAVE_ADDRESS_101 0x2D
153#define EINK154INCH_DEVICE_SLAVE_ADDRESS_110 0x2E
154#define EINK154INCH_DEVICE_SLAVE_ADDRESS_111 0x2F
157 // End group macro
158// --------------------------------------------------------------- PUBLIC TYPES
164typedef struct
165{
166 const uint8_t *p_font;
167 uint16_t color;
168 uint8_t orientation;
169 uint16_t first_char;
170 uint16_t last_char;
171 uint16_t height;
172
174
175typedef struct
176{
177 uint16_t x;
178 uint16_t y;
179
181
182typedef struct
183{
184 uint8_t x_start;
185 uint8_t y_start;
186 uint8_t x_end;
187 uint8_t y_end;
188
190
191typedef struct
192{
193 uint8_t text_x;
194 uint8_t text_y;
195 uint8_t n_char;
196
198
202typedef struct
203{
204 // Output pins
205 digital_out_t cs;
206 digital_out_t rst;
207 digital_out_t dc;
208
209 // Input pins
210 digital_in_t bsy;
211
212 // Modules
213 spi_master_t spi;
214 pin_name_t chip_select;
215
218#ifndef IMAGE_MODE_ONLY
219 uint8_t p_frame[5000];
220#endif
222
226typedef struct
227{
228 // Communication gpio pins
229 pin_name_t miso;
230 pin_name_t mosi;
231 pin_name_t sck;
232 pin_name_t cs;
233
234 // Additional gpio pins
235 pin_name_t rst;
236 pin_name_t dc;
237 pin_name_t bsy;
238
239 // static variable
240
241 uint32_t spi_speed;
242 spi_master_mode_t spi_mode;
243 spi_master_chip_select_polarity_t cs_polarity;
244
246
248
249 // End types group
250// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
251
256#ifdef __cplusplus
257extern "C"{
258#endif
259
269
279
286void eink154inch_send_cmd ( eink154inch_t *ctx, uint8_t command );
287
294void eink154inch_send_data ( eink154inch_t *ctx, uint8_t c_data );
295
302
309
316
326void eink154inch_set_lut ( eink154inch_t *ctx, const uint8_t *lut, uint8_t n_bytes );
327
335void eink154inch_set_mem_pointer ( eink154inch_t *ctx, uint8_t x, uint8_t y );
336
344
351
364void eink154inch_fill_screen ( eink154inch_t *ctx, uint8_t color );
365
374void eink154inch_image ( eink154inch_t *ctx, const uint8_t* image_buffer );
375
384void eink154inch_text ( eink154inch_t *ctx, char *text, eink154inch_text_set_t *text_set );
385
393
394#ifdef __cplusplus
395}
396#endif
397#endif // _EINK154INCH_H_
398
399 // End public_function group
401
402// ------------------------------------------------------------------------- END
err_t eink154inch_init(eink154inch_t *ctx, eink154inch_cfg_t *cfg)
Initialization function.
void eink154inch_text(eink154inch_t *ctx, char *text, eink154inch_text_set_t *text_set)
Draw text on the screen.
void eink154inch_sleep_mode(eink154inch_t *ctx)
Sleep mode.
void eink154inch_cfg_setup(eink154inch_cfg_t *cfg)
Config Object Initialization function.
void eink154inch_reset(eink154inch_t *ctx)
Reset chip.
void eink154inch_send_data(eink154inch_t *ctx, uint8_t c_data)
Sending data.
void eink154inch_set_font(eink154inch_t *ctx, eink154inch_font_t *cfg_font)
Set text font.
void eink154inch_set_lut(eink154inch_t *ctx, const uint8_t *lut, uint8_t n_bytes)
Set LUT table.
void eink154inch_fill_screen(eink154inch_t *ctx, uint8_t color)
Function that fills the screen.
void eink154inch_send_cmd(eink154inch_t *ctx, uint8_t command)
Sending a command.
void eink154inch_start_config(eink154inch_t *ctx)
Configuration display.
void eink154inch_update_display(eink154inch_t *ctx)
Update dispaly.
void eink154inch_set_mem_area(eink154inch_t *ctx, eink154inch_xy_t *xy)
Setting area in memory.
void eink154inch_image(eink154inch_t *ctx, const uint8_t *image_buffer)
Displays image.
void eink154inch_set_mem_pointer(eink154inch_t *ctx, uint8_t x, uint8_t y)
Setting pointers in memory.
Click configuration structure definition.
Definition eink154inch.h:227
pin_name_t bsy
Definition eink154inch.h:237
spi_master_chip_select_polarity_t cs_polarity
Definition eink154inch.h:243
pin_name_t sck
Definition eink154inch.h:231
spi_master_mode_t spi_mode
Definition eink154inch.h:242
pin_name_t dc
Definition eink154inch.h:236
pin_name_t mosi
Definition eink154inch.h:230
uint32_t spi_speed
Definition eink154inch.h:241
eink154inch_font_t font_cfg
Definition eink154inch.h:245
pin_name_t miso
Definition eink154inch.h:229
pin_name_t rst
Definition eink154inch.h:235
pin_name_t cs
Definition eink154inch.h:232
Definition eink154inch.h:176
uint16_t x
Definition eink154inch.h:177
uint16_t y
Definition eink154inch.h:178
Definition eink154inch.h:165
uint16_t first_char
Definition eink154inch.h:169
uint16_t color
Definition eink154inch.h:167
const uint8_t * p_font
Definition eink154inch.h:166
uint16_t height
Definition eink154inch.h:171
uint16_t last_char
Definition eink154inch.h:170
uint8_t orientation
Definition eink154inch.h:168
Click ctx object definition.
Definition eink154inch.h:203
digital_out_t cs
Definition eink154inch.h:205
spi_master_t spi
Definition eink154inch.h:213
digital_out_t dc
Definition eink154inch.h:207
eink154inch_font_t dev_font
Definition eink154inch.h:216
eink154inch_cordinate_t dev_cord
Definition eink154inch.h:217
digital_in_t bsy
Definition eink154inch.h:210
digital_out_t rst
Definition eink154inch.h:206
pin_name_t chip_select
Definition eink154inch.h:214
Definition eink154inch.h:192
uint8_t n_char
Definition eink154inch.h:195
uint8_t text_x
Definition eink154inch.h:193
uint8_t text_y
Definition eink154inch.h:194
Definition eink154inch.h:183
uint8_t y_start
Definition eink154inch.h:185
uint8_t y_end
Definition eink154inch.h:187
uint8_t x_end
Definition eink154inch.h:186
uint8_t x_start
Definition eink154inch.h:184