lcdmono  2.0.0.0
lcdmono.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 LCDMONO_H
36 #define LCDMONO_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_spi_master.h"
40 #include "generic_pointer.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
53 #define LCDMONO_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.com = MIKROBUS( mikrobus, MIKROBUS_PWM )
59 
65 #define LCDMONO_RETVAL uint8_t
66 
67 #define LCDMONO_OK 0x00
68 #define LCDMONO_INIT_ERROR 0xFF
69 
75 #define LCDMONO_DISPLAY_WIDTH 128
76 #define LCDMONO_DISPLAY_HEIGHT 128
77 #define LCDMONO_DISPLAY_RESOLUTIONS 2307
78 
84 #define LCDMONO_COLOR_WHITE 0x00
85 #define LCDMONO_COLOR_BLACK 0x01
86 
92 #define LCDMONO_REFRESH_DISPLAY_END 0x01
93 #define LCDMONO_CHECK_NEW_TEXT 0x00
94 #define LCDMONO_REFRESH_TEXT_BUFFER 0x10
95 
101 #define LCDMONO_CMD_DISPLAY_FLAG 0x80
102 #define LCDMONO_CMD_CLEAR_FLAG 0x20
103 #define LCDMONO_DUMMY_BYTE 0x00
104 
110 #define LCDMONO_POWER_ON 1
111 #define LCDMONO_POWER_OFF 0
112  // End group macro
115 // --------------------------------------------------------------- PUBLIC TYPES
121 typedef struct
122 {
123  uint8_t * __generic this_font;
124  uint16_t first_char;
125  uint16_t last_char;
126  uint16_t height;
127 
129 
130 typedef struct
131 {
132  uint16_t x;
133  uint16_t y;
134 
136 
137 typedef struct
138 {
139  // Draw Text
140  uint8_t len; // Number of characters in the text
141  uint16_t start_cord_x; // X position of the text
142  uint16_t start_cord_y; // Y position of the text
143  uint8_t text_color; // Text font color
144  uint8_t bg_color; // Background color
145 
147 
151 typedef struct
152 {
153  // Output pins
154 
155  digital_out_t com;
156 
157  // Modules
158 
159  spi_master_t spi;
160  pin_name_t chip_select;
161 
162  uint8_t lcd_frame[ 2307 ];
164 
168 
169 } lcdmono_t;
170 
174 typedef struct
175 {
176  // Communication gpio pins
177 
178  pin_name_t miso;
179  pin_name_t mosi;
180  pin_name_t sck;
181  pin_name_t cs;
182 
183  // Additional gpio pins
184 
185  pin_name_t com;
186 
187  // Static variable
188 
189  uint32_t spi_speed;
190  spi_master_mode_t spi_mode;
191  spi_master_chip_select_polarity_t cs_polarity;
192 
194 
195 } lcdmono_cfg_t;
196  // End types group
198 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
204 #ifdef __cplusplus
205 extern "C"{
206 #endif
207 
216 void lcdmono_cfg_setup ( lcdmono_cfg_t *cfg );
217 
226 
236  lcdmono_t *ctx,
237  uint8_t *wr_buf,
238  uint16_t wr_len,
239  uint8_t *rd_buf,
240  uint16_t rd_len
241 );
242 
252 void lcdmono_send_line_package ( lcdmono_t *ctx, uint8_t addr, uint8_t * __generic tx_data );
253 
259 void lcdmono_clear ( lcdmono_t *ctx );
260 
271 void lcdmono_draw_frame ( lcdmono_t *ctx, uint8_t * __generic frame_data );
272 
286 void lcdmono_draw_text ( lcdmono_t *ctx, char * __generic text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode );
287 
294 void lcdmono_set_font ( lcdmono_t *ctx, lcdmono_font_t *dev_lcd_font );
295 
302 void lcdmono_display_power ( lcdmono_t *ctx, uint8_t ctrl );
303 
309 void lcdmono_display_reset ( lcdmono_t *ctx );
310 
311 #ifdef __cplusplus
312 }
313 #endif
314 #endif // LCDMONO_H
315  // End public_function group
318 
319 // ------------------------------------------------------------------------ END
lcdmono_coordinate_t
Definition: lcdmono.h:130
lcdmono_font_t::first_char
uint16_t first_char
Definition: lcdmono.h:124
lcdmono_cfg_t::miso
pin_name_t miso
Definition: lcdmono.h:178
lcdmono_text_settings_t::len
uint8_t len
Definition: lcdmono.h:140
lcdmono_text_settings_t
Definition: lcdmono.h:137
lcdmono_cfg_t::sck
pin_name_t sck
Definition: lcdmono.h:180
lcdmono_t
Click ctx object definition.
Definition: lcdmono.h:151
lcdmono_cfg_t::com
pin_name_t com
Definition: lcdmono.h:185
lcdmono_text_settings_t::start_cord_x
uint16_t start_cord_x
Definition: lcdmono.h:141
lcdmono_text_settings_t::bg_color
uint8_t bg_color
Definition: lcdmono.h:144
lcdmono_cfg_t::dev_lcd_frame_color
uint8_t dev_lcd_frame_color
Definition: lcdmono.h:193
LCDMONO_RETVAL
#define LCDMONO_RETVAL
Definition: lcdmono.h:65
lcdmono_draw_text
void lcdmono_draw_text(lcdmono_t *ctx, char *__generic text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode)
Draw text on the screen.
lcdmono_t::tx_set
lcdmono_text_settings_t tx_set
Definition: lcdmono.h:167
lcdmono_cfg_t::cs
pin_name_t cs
Definition: lcdmono.h:181
lcdmono_text_settings_t::text_color
uint8_t text_color
Definition: lcdmono.h:143
lcdmono_cfg_setup
void lcdmono_cfg_setup(lcdmono_cfg_t *cfg)
Config Object Initialization function.
lcdmono_cfg_t
Click configuration structure definition.
Definition: lcdmono.h:174
lcdmono_display_power
void lcdmono_display_power(lcdmono_t *ctx, uint8_t ctrl)
Display Power State.
lcdmono_t::spi
spi_master_t spi
Definition: lcdmono.h:159
lcdmono_coordinate_t::x
uint16_t x
Definition: lcdmono.h:132
lcdmono_font_t::height
uint16_t height
Definition: lcdmono.h:126
lcdmono_display_reset
void lcdmono_display_reset(lcdmono_t *ctx)
Reset procedure.
lcdmono_font_t::this_font
uint8_t *__generic this_font
Definition: lcdmono.h:123
lcdmono_font_t
Definition: lcdmono.h:121
lcdmono_set_font
void lcdmono_set_font(lcdmono_t *ctx, lcdmono_font_t *dev_lcd_font)
Set font.
lcdmono_font_t::last_char
uint16_t last_char
Definition: lcdmono.h:125
lcdmono_t::lcd_font
lcdmono_font_t lcd_font
Definition: lcdmono.h:165
lcdmono_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: lcdmono.h:190
lcdmono_t::com
digital_out_t com
Definition: lcdmono.h:155
lcdmono_t::chip_select
pin_name_t chip_select
Definition: lcdmono.h:160
lcdmono_cfg_t::spi_speed
uint32_t spi_speed
Definition: lcdmono.h:189
lcdmono_coordinate_t::y
uint16_t y
Definition: lcdmono.h:133
lcdmono_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: lcdmono.h:191
lcdmono_init
LCDMONO_RETVAL lcdmono_init(lcdmono_t *ctx, lcdmono_cfg_t *cfg)
Initialization function.
lcdmono_send_line_package
void lcdmono_send_line_package(lcdmono_t *ctx, uint8_t addr, uint8_t *__generic tx_data)
Send line data package.
lcdmono_cfg_t::mosi
pin_name_t mosi
Definition: lcdmono.h:179
lcdmono_generic_transfer
void lcdmono_generic_transfer(lcdmono_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
lcdmono_t::lcd_cord
lcdmono_coordinate_t lcd_cord
Definition: lcdmono.h:166
lcdmono_t::lcd_frame_color
uint8_t lcd_frame_color
Definition: lcdmono.h:163
lcdmono_text_settings_t::start_cord_y
uint16_t start_cord_y
Definition: lcdmono.h:142
lcdmono_draw_frame
void lcdmono_draw_frame(lcdmono_t *ctx, uint8_t *__generic frame_data)
Displays draw frame.
lcdmono_clear
void lcdmono_clear(lcdmono_t *ctx)
Clear display.