eink_290inch  2.0.0.0
eink_290inch.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 EINK290INCH_H
36 #define EINK290INCH_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define EINK290INCH_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
54  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
55  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
56  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
58  cfg.dc = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
59  cfg.bsy = MIKROBUS( mikrobus, MIKROBUS_INT )
60 
66 #define EINK290INCH_RETVAL uint8_t
67 
68 #define EINK290INCH_OK 0x00
69 #define EINK290INCH_INIT_ERROR 0xFF
70 
76 #define EINK290_DISPLAY_WIDTH 128
77 #define EINK290_DISPLAY_HEIGHT 296
78 #define EINK290_DISPLAY_RESOLUTIONS 4736
79 
85 #define EINK290_SCREEN_COLOR_WHITE 0xFF
86 #define EINK290_SCREEN_COLOR_BLACK 0x00
87 #define EINK290_SCREEN_COLOR_LIGHT_GREY 0xAA
88 #define EINK290_SCREEN_COLOR_DARK_GREY 0x55
89 
90 #define EINK290_FO_HORIZONTAL 0x00
91 #define EINK290_FO_VERTICAL 0x01
92 #define EINK290_FO_VERTICAL_COLUMN 0x02
93 
99 #define EINK290_CMD_DRIVER_OUTPUT_CONTROL 0x01
100 #define EINK290_CMD_BOOSTER_SOFT_START_CONTROL 0x0C
101 #define EINK290_CMD_GATE_SCAN_START_POSITION 0x0F
102 #define EINK290_CMD_DEEP_SLEEP_MODE 0x10
103 #define EINK290_CMD_DATA_ENTRY_MODE_SETTING 0x11
104 #define EINK290_CMD_SW_RESET 0x12
105 #define EINK290_CMD_TEMPERATURE_SENSOR_CONTROL 0x1A
106 #define EINK290_CMD_MASTER_ACTIVATION 0x20
107 #define EINK290_CMD_DISPLAY_UPDATE_CONTROL_1 0x21
108 #define EINK290_CMD_DISPLAY_UPDATE_CONTROL_2 0x22
109 #define EINK290_CMD_WRITE_RAM 0x24
110 #define EINK290_CMD_WRITE_VCOM_REGISTER 0x2C
111 #define EINK290_CMD_WRITE_LUT_REGISTER 0x32
112 #define EINK290_CMD_SET_DUMMY_LINE_PERIOD 0x3A
113 #define EINK290_CMD_SET_GATE_TIME 0x3B
114 #define EINK290_CMD_BORDER_WAVEFORM_CONTROL 0x3C
115 #define EINK290_CMD_SET_RAM_X_ADDRESS_START_END_POSITION 0x44
116 #define EINK290_CMD_SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
117 #define EINK290_CMD_SET_RAM_X_ADDRESS_COUNTER 0x4E
118 #define EINK290_CMD_SET_RAM_Y_ADDRESS_COUNTER 0x4F
119 #define EINK290_CMD_TERMINATE_FRAME_READ_WRITE 0xFF
120  // End group macro
123 // --------------------------------------------------------------- PUBLIC TYPES
129 typedef struct
130 {
131  const uint8_t *p_font;
132  uint16_t color;
133  uint8_t orientation;
134  uint16_t first_char;
135  uint16_t last_char;
136  uint16_t height;
137 
139 
140 typedef struct
141 {
142  uint16_t x;
143  uint16_t y;
144 
146 
147 typedef struct
148 {
149  uint16_t x_start;
150  uint16_t y_start;
151  uint16_t x_end;
152  uint16_t y_end;
153 
155 
156 typedef struct
157 {
158  uint8_t n_char;
159  uint16_t text_x;
160  uint16_t text_y;
161 
163 
167 typedef struct
168 {
169  // Output pins
170 
171  digital_out_t cs;
172  digital_out_t rst;
173  digital_out_t dc;
174 
175  // Input pins
176 
177  digital_in_t bsy;
178 
179  // Modules
180 
181  spi_master_t spi;
182  pin_name_t chip_select;
183 
184 #ifndef IMAGE_MODE_ONLY
185  uint8_t frame[ 4736 ];
186 #endif
187 
190 
192 
196 typedef struct
197 {
198  // Communication gpio pins
199 
200  pin_name_t miso;
201  pin_name_t mosi;
202  pin_name_t sck;
203  pin_name_t cs;
204 
205  // Additional gpio pins
206 
207  pin_name_t rst;
208  pin_name_t dc;
209  pin_name_t bsy;
210 
211  // static variable
212 
213  uint32_t spi_speed;
214  spi_master_mode_t spi_mode;
215  spi_master_chip_select_polarity_t cs_polarity;
216 
218  // End types group
220 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
221 
226 #ifdef __cplusplus
227 extern "C"{
228 #endif
229 
239 
249 
261 void eink_290inch_generic_transfer ( eink_290inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
262 
269 void eink_290_send_command ( eink_290inch_t *ctx, uint8_t command );
270 
277 void eink_290_send_data ( eink_290inch_t *ctx, uint8_t c_data );
278 
285 
292 
302 void eink_290_set_lut ( eink_290inch_t *ctx, const uint8_t *lut, uint8_t lut_cnt );
303 
310 
318 void eink_290_set_memory_pointer ( eink_290inch_t *ctx, uint16_t x, uint16_t y );
319 
327 
334 
347 void eink_290_fill_screen ( eink_290inch_t *ctx, uint8_t color );
348 
358 void eink_290_display_image ( eink_290inch_t *ctx, const uint8_t* image_buffer );
359 
368 void eink_290_text ( eink_290inch_t *ctx, char *text, eink_290inch_set_text_t *text_set );
369 
377 
378 #ifdef __cplusplus
379 }
380 #endif
381 #endif // _EINK290INCH_H_
382  // End public_function group
385 
386 // ------------------------------------------------------------------------- END
eink_290inch_cfg_t::bsy
pin_name_t bsy
Definition: eink_290inch.h:209
eink_290inch_cfg_t::cs
pin_name_t cs
Definition: eink_290inch.h:203
eink_290inch_font_t::first_char
uint16_t first_char
Definition: eink_290inch.h:134
eink_290inch_font_t
Definition: eink_290inch.h:130
eink_290inch_font_t::height
uint16_t height
Definition: eink_290inch.h:136
eink_290_fill_screen
void eink_290_fill_screen(eink_290inch_t *ctx, uint8_t color)
Function that fills the screen.
eink_290_display_image
void eink_290_display_image(eink_290inch_t *ctx, const uint8_t *image_buffer)
Display image function.
eink_290inch_cord_t
Definition: eink_290inch.h:141
eink_290inch_cfg_t::miso
pin_name_t miso
Definition: eink_290inch.h:200
eink_290inch_set_text_t::n_char
uint8_t n_char
Definition: eink_290inch.h:158
eink_290inch_cord_t::y
uint16_t y
Definition: eink_290inch.h:143
eink_290_send_command
void eink_290_send_command(eink_290inch_t *ctx, uint8_t command)
Function for sending a command.
eink_290inch_t::rst
digital_out_t rst
Definition: eink_290inch.h:172
eink_290inch_t::chip_select
pin_name_t chip_select
Definition: eink_290inch.h:182
eink_290inch_t::dc
digital_out_t dc
Definition: eink_290inch.h:173
eink_290inch_font_t::last_char
uint16_t last_char
Definition: eink_290inch.h:135
eink_290inch_set_text_t
Definition: eink_290inch.h:157
eink_290_set_font
void eink_290_set_font(eink_290inch_t *ctx, eink_290inch_font_t *cfg_font)
Set font function.
eink_290inch_set_text_t::text_x
uint16_t text_x
Definition: eink_290inch.h:159
eink_290_set_lut
void eink_290_set_lut(eink_290inch_t *ctx, const uint8_t *lut, uint8_t lut_cnt)
Set LUT table.
eink_290inch_t::cs
digital_out_t cs
Definition: eink_290inch.h:171
eink_290inch_cfg_t::dc
pin_name_t dc
Definition: eink_290inch.h:208
eink_290inch_t::dev_font
eink_290inch_font_t dev_font
Definition: eink_290inch.h:188
eink_290_reset
void eink_290_reset(eink_290inch_t *ctx)
Function for reset chip.
eink_290inch_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: eink_290inch.h:215
eink_290inch_init
EINK290INCH_RETVAL eink_290inch_init(eink_290inch_t *ctx, eink_290inch_cfg_t *cfg)
Initialization function.
eink_290_start_config
void eink_290_start_config(eink_290inch_t *ctx)
Start configuration display.
eink_290inch_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: eink_290inch.h:214
eink_290inch_cfg_setup
void eink_290inch_cfg_setup(eink_290inch_cfg_t *cfg)
Config Object Initialization function.
eink_290inch_t
Click ctx object definition.
Definition: eink_290inch.h:168
eink_290inch_font_t::color
uint16_t color
Definition: eink_290inch.h:132
eink_290_set_memory_area
void eink_290_set_memory_area(eink_290inch_t *ctx, eink_290inch_xy_t *xy)
Function for setting area in memory.
eink_290inch_set_text_t::text_y
uint16_t text_y
Definition: eink_290inch.h:160
eink_290inch_cfg_t::rst
pin_name_t rst
Definition: eink_290inch.h:207
eink_290inch_cfg_t::mosi
pin_name_t mosi
Definition: eink_290inch.h:201
eink_290inch_generic_transfer
void eink_290inch_generic_transfer(eink_290inch_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
eink_290inch_xy_t::y_end
uint16_t y_end
Definition: eink_290inch.h:152
eink_290_sleep_mode
void eink_290_sleep_mode(eink_290inch_t *ctx)
Function for go to sleep mode.
eink_290inch_t::spi
spi_master_t spi
Definition: eink_290inch.h:181
eink_290inch_cfg_t::sck
pin_name_t sck
Definition: eink_290inch.h:202
eink_290inch_cfg_t
Click configuration structure definition.
Definition: eink_290inch.h:197
eink_290_text
void eink_290_text(eink_290inch_t *ctx, char *text, eink_290inch_set_text_t *text_set)
Function for draw text on the screen.
eink_290inch_cord_t::x
uint16_t x
Definition: eink_290inch.h:142
eink_290inch_t::dev_cord
eink_290inch_cord_t dev_cord
Definition: eink_290inch.h:189
eink_290inch_xy_t::x_end
uint16_t x_end
Definition: eink_290inch.h:151
eink_290inch_font_t::p_font
const uint8_t * p_font
Definition: eink_290inch.h:131
eink_290_send_data
void eink_290_send_data(eink_290inch_t *ctx, uint8_t c_data)
Function for sending data.
eink_290inch_cfg_t::spi_speed
uint32_t spi_speed
Definition: eink_290inch.h:213
EINK290INCH_RETVAL
#define EINK290INCH_RETVAL
Definition: eink_290inch.h:66
eink_290inch_font_t::orientation
uint8_t orientation
Definition: eink_290inch.h:133
eink_290inch_xy_t::x_start
uint16_t x_start
Definition: eink_290inch.h:149
eink_290inch_xy_t
Definition: eink_290inch.h:148
eink_290inch_xy_t::y_start
uint16_t y_start
Definition: eink_290inch.h:150
eink_290_set_memory_pointer
void eink_290_set_memory_pointer(eink_290inch_t *ctx, uint16_t x, uint16_t y)
Function for setting pointers in memory.
eink_290_update_display
void eink_290_update_display(eink_290inch_t *ctx)
Functions for update dispaly.
eink_290inch_t::bsy
digital_in_t bsy
Definition: eink_290inch.h:177