lcdmono  2.0.0.0
lcdmono.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef LCDMONO_H
36 #define LCDMONO_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
54 #define LCDMONO_MAP_MIKROBUS( cfg, mikrobus ) \
55  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
56  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
57  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
58  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
59  cfg.com = MIKROBUS( mikrobus, MIKROBUS_PWM )
60 
66 #define LCDMONO_RETVAL uint8_t
67 
68 #define LCDMONO_OK 0x00
69 #define LCDMONO_INIT_ERROR 0xFF
70 
76 #define LCDMONO_DISPLAY_WIDTH 128
77 #define LCDMONO_DISPLAY_HEIGHT 128
78 #define LCDMONO_DISPLAY_RESOLUTIONS 2307
79 
85 #define LCDMONO_COLOR_WHITE 0x00
86 #define LCDMONO_COLOR_BLACK 0x01
87 
93 #define LCDMONO_REFRESH_DISPLAY_END 0x01
94 #define LCDMONO_CHECK_NEW_TEXT 0x00
95 #define LCDMONO_REFRESH_TEXT_BUFFER 0x10
96 
102 #define LCDMONO_CMD_DISPLAY_FLAG 0x80
103 #define LCDMONO_CMD_CLEAR_FLAG 0x20
104 #define LCDMONO_DUMMY_BYTE 0x00
105 
111 #define LCDMONO_POWER_ON 1
112 #define LCDMONO_POWER_OFF 0
113  // End group macro
116 // --------------------------------------------------------------- PUBLIC TYPES
122 typedef struct
123 {
124  uint8_t *this_font;
125  uint16_t first_char;
126  uint16_t last_char;
127  uint16_t height;
128 
130 
131 typedef struct
132 {
133  uint16_t x;
134  uint16_t y;
135 
137 
138 typedef struct
139 {
140  // Draw Text
141  uint8_t len; // Number of characters in the text
142  uint16_t start_cord_x; // X position of the text
143  uint16_t start_cord_y; // Y position of the text
144  uint8_t text_color; // Text font color
145  uint8_t bg_color; // Background color
146 
148 
152 typedef struct
153 {
154  // Output pins
155 
156  digital_out_t com;
157 
158  // Modules
159 
160  spi_master_t spi;
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  hal_spi_speed_t spi_speed;
190  hal_spi_mode_t spi_mode;
191 
193 
194 } lcdmono_cfg_t;
195  // End types group
197 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
198 
203 #ifdef __cplusplus
204 extern "C"{
205 #endif
206 
215 void lcdmono_cfg_setup ( lcdmono_cfg_t *cfg );
216 
225 
234 void lcdmono_generic_transfer ( lcdmono_t *ctx, spi_master_transfer_data_t *block );
235 
245 void lcdmono_send_line_package ( lcdmono_t *ctx, uint8_t addr, uint8_t *tx_data );
246 
252 void lcdmono_clear ( lcdmono_t *ctx );
253 
264 void lcdmono_draw_frame ( lcdmono_t *ctx, uint8_t *frame_data );
265 
276 void lcdmono_draw_const_frame ( lcdmono_t *ctx, const uint8_t *frame_data );
277 
291 void lcdmono_draw_text ( lcdmono_t *ctx, char *text_buf, lcdmono_text_settings_t *tx_set , uint8_t end_mode);
292 
299 void lcdmono_set_font ( lcdmono_t *ctx, lcdmono_font_t *dev_lcd_font );
300 
307 void lcdmono_display_power ( lcdmono_t *ctx, uint8_t ctrl );
308 
314 void lcdmono_display_reset ( lcdmono_t *ctx );
315 
316 #ifdef __cplusplus
317 }
318 #endif
319 #endif // _LCDMONO_H_
320  // End public_function group
323 
324 // ------------------------------------------------------------------------- END
lcdmono_coordinate_t
Definition: lcdmono.h:131
lcdmono_font_t::first_char
uint16_t first_char
Definition: lcdmono.h:125
lcdmono_cfg_t::miso
pin_name_t miso
Definition: lcdmono.h:178
lcdmono_text_settings_t::len
uint8_t len
Definition: lcdmono.h:141
lcdmono_text_settings_t
Definition: lcdmono.h:138
lcdmono_cfg_t::sck
pin_name_t sck
Definition: lcdmono.h:180
lcdmono_t
Click ctx object definition.
Definition: lcdmono.h:152
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:142
lcdmono_cfg_t::spi_mode
hal_spi_mode_t spi_mode
Definition: lcdmono.h:190
lcdmono_text_settings_t::bg_color
uint8_t bg_color
Definition: lcdmono.h:145
lcdmono_send_line_package
void lcdmono_send_line_package(lcdmono_t *ctx, uint8_t addr, uint8_t *tx_data)
Send line data package.
lcdmono_cfg_t::dev_lcd_frame_color
uint8_t dev_lcd_frame_color
Definition: lcdmono.h:192
LCDMONO_RETVAL
#define LCDMONO_RETVAL
Definition: lcdmono.h:66
lcdmono_font_t::this_font
uint8_t * this_font
Definition: lcdmono.h:124
lcdmono_cfg_t::spi_speed
hal_spi_speed_t spi_speed
Definition: lcdmono.h:189
lcdmono_draw_frame
void lcdmono_draw_frame(lcdmono_t *ctx, uint8_t *frame_data)
Displays draw frame.
lcdmono_t::tx_set
lcdmono_text_settings_t tx_set
Definition: lcdmono.h:167
lcdmono_draw_text
void lcdmono_draw_text(lcdmono_t *ctx, char *text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode)
Draw text on the screen.
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:144
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:160
lcdmono_coordinate_t::x
uint16_t x
Definition: lcdmono.h:133
lcdmono_font_t::height
uint16_t height
Definition: lcdmono.h:127
lcdmono_generic_transfer
void lcdmono_generic_transfer(lcdmono_t *ctx, spi_master_transfer_data_t *block)
Generic transfer function.
lcdmono_display_reset
void lcdmono_display_reset(lcdmono_t *ctx)
Reset procedure.
lcdmono_font_t
Definition: lcdmono.h:122
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:126
lcdmono_t::lcd_font
lcdmono_font_t lcd_font
Definition: lcdmono.h:165
lcdmono_t::com
digital_out_t com
Definition: lcdmono.h:156
lcdmono_coordinate_t::y
uint16_t y
Definition: lcdmono.h:134
lcdmono_init
LCDMONO_RETVAL lcdmono_init(lcdmono_t *ctx, lcdmono_cfg_t *cfg)
Initialization function.
lcdmono_cfg_t::mosi
pin_name_t mosi
Definition: lcdmono.h:179
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:143
lcdmono_clear
void lcdmono_clear(lcdmono_t *ctx)
Clear display.
lcdmono_draw_const_frame
void lcdmono_draw_const_frame(lcdmono_t *ctx, const uint8_t *frame_data)
Displays draw const frame.