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 
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_spi_master.h"
54 #include "generic_pointer.h"
55 
56 // -------------------------------------------------------------- PUBLIC MACROS
67 #define LCDMONO_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.com = MIKROBUS( mikrobus, MIKROBUS_PWM )
73 
79 #define LCDMONO_OK 0
80 #define LCDMONO_ERROR -1
81 
87 #define LCDMONO_DISPLAY_WIDTH 128
88 #define LCDMONO_DISPLAY_HEIGHT 128
89 #define LCDMONO_DISPLAY_RESOLUTIONS 2307
90 
96 #define LCDMONO_COLOR_WHITE 0x00
97 #define LCDMONO_COLOR_BLACK 0x01
98 
104 #define LCDMONO_REFRESH_DISPLAY_END 0x01
105 #define LCDMONO_CHECK_NEW_TEXT 0x00
106 #define LCDMONO_REFRESH_TEXT_BUFFER 0x10
107 
113 #define LCDMONO_CMD_DISPLAY_FLAG 0x80
114 #define LCDMONO_CMD_CLEAR_FLAG 0x20
115 #define LCDMONO_DUMMY_BYTE 0x00
116 
122 #define LCDMONO_POWER_ON 1
123 #define LCDMONO_POWER_OFF 0
124  // End group macro
127 // --------------------------------------------------------------- PUBLIC TYPES
133 typedef struct
134 {
135  uint8_t * __generic_ptr this_font;
136  uint16_t first_char;
137  uint16_t last_char;
138  uint16_t height;
139 
141 
142 typedef struct
143 {
144  uint16_t x;
145  uint16_t y;
146 
148 
149 typedef struct
150 {
151  // Draw Text
152  uint8_t len; // Number of characters in the text
153  uint16_t start_cord_x; // X position of the text
154  uint16_t start_cord_y; // Y position of the text
155  uint8_t bg_color; // Background color
156 
158 
162 typedef struct
163 {
164  // Output pins
165  digital_out_t com;
166 
167  // Modules
168  spi_master_t spi;
169  pin_name_t chip_select;
170 
171  uint8_t lcd_frame[ 2307 ];
173 
177 
178 } lcdmono_t;
179 
183 typedef struct
184 {
185  // Communication gpio pins
186  pin_name_t miso;
187  pin_name_t mosi;
188  pin_name_t sck;
189  pin_name_t cs;
190 
191  // Additional gpio pins
192  pin_name_t com;
193 
194  // Static variable
195  uint32_t spi_speed;
196  spi_master_mode_t spi_mode;
197  spi_master_chip_select_polarity_t cs_polarity;
198 
200 
201 } lcdmono_cfg_t;
202  // End types group
204 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
210 #ifdef __cplusplus
211 extern "C"{
212 #endif
213 
223 
231 err_t lcdmono_init ( lcdmono_t *ctx, lcdmono_cfg_t *cfg );
232 
242 void lcdmono_send_line_package ( lcdmono_t *ctx, uint8_t addr, uint8_t * __generic_ptr tx_data );
243 
249 void lcdmono_clear ( lcdmono_t *ctx );
250 
261 void lcdmono_draw_frame ( lcdmono_t *ctx, uint8_t * __generic_ptr frame_data );
262 
276 void lcdmono_draw_text ( lcdmono_t *ctx, uint8_t * __generic_ptr text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode );
277 
284 void lcdmono_set_font ( lcdmono_t *ctx, lcdmono_font_t *dev_lcd_font );
285 
292 void lcdmono_display_power ( lcdmono_t *ctx, uint8_t ctrl );
293 
300 
301 #ifdef __cplusplus
302 }
303 #endif
304 #endif // LCDMONO_H
305  // End public_function group
308 
309 // ------------------------------------------------------------------------ END
lcdmono_coordinate_t
Definition: lcdmono.h:143
lcdmono_font_t::first_char
uint16_t first_char
Definition: lcdmono.h:136
lcdmono_init
err_t lcdmono_init(lcdmono_t *ctx, lcdmono_cfg_t *cfg)
Initialization function.
lcdmono_cfg_t::miso
pin_name_t miso
Definition: lcdmono.h:186
lcdmono_text_settings_t::len
uint8_t len
Definition: lcdmono.h:152
lcdmono_text_settings_t
Definition: lcdmono.h:150
lcdmono_cfg_t::sck
pin_name_t sck
Definition: lcdmono.h:188
lcdmono_t
Click ctx object definition.
Definition: lcdmono.h:163
lcdmono_cfg_t::com
pin_name_t com
Definition: lcdmono.h:192
lcdmono_text_settings_t::start_cord_x
uint16_t start_cord_x
Definition: lcdmono.h:153
lcdmono_text_settings_t::bg_color
uint8_t bg_color
Definition: lcdmono.h:155
lcdmono_cfg_t::dev_lcd_frame_color
uint8_t dev_lcd_frame_color
Definition: lcdmono.h:199
lcdmono_t::tx_set
lcdmono_text_settings_t tx_set
Definition: lcdmono.h:176
lcdmono_cfg_t::cs
pin_name_t cs
Definition: lcdmono.h:189
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:184
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:168
lcdmono_coordinate_t::x
uint16_t x
Definition: lcdmono.h:144
lcdmono_font_t::height
uint16_t height
Definition: lcdmono.h:138
lcdmono_draw_text
void lcdmono_draw_text(lcdmono_t *ctx, uint8_t *__generic_ptr text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode)
Draw text on the screen.
lcdmono_display_reset
void lcdmono_display_reset(lcdmono_t *ctx)
Reset procedure.
lcdmono_send_line_package
void lcdmono_send_line_package(lcdmono_t *ctx, uint8_t addr, uint8_t *__generic_ptr tx_data)
Send line data package.
lcdmono_font_t
Definition: lcdmono.h:134
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:137
lcdmono_t::lcd_font
lcdmono_font_t lcd_font
Definition: lcdmono.h:174
lcdmono_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: lcdmono.h:196
lcdmono_t::com
digital_out_t com
Definition: lcdmono.h:165
lcdmono_font_t::this_font
uint8_t *__generic_ptr this_font
Definition: lcdmono.h:135
lcdmono_t::chip_select
pin_name_t chip_select
Definition: lcdmono.h:169
lcdmono_cfg_t::spi_speed
uint32_t spi_speed
Definition: lcdmono.h:195
lcdmono_coordinate_t::y
uint16_t y
Definition: lcdmono.h:145
lcdmono_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: lcdmono.h:197
lcdmono_draw_frame
void lcdmono_draw_frame(lcdmono_t *ctx, uint8_t *__generic_ptr frame_data)
Displays draw frame.
lcdmono_cfg_t::mosi
pin_name_t mosi
Definition: lcdmono.h:187
lcdmono_t::lcd_cord
lcdmono_coordinate_t lcd_cord
Definition: lcdmono.h:175
lcdmono_t::lcd_frame_color
uint8_t lcd_frame_color
Definition: lcdmono.h:172
lcdmono_text_settings_t::start_cord_y
uint16_t start_cord_y
Definition: lcdmono.h:154
lcdmono_clear
void lcdmono_clear(lcdmono_t *ctx)
Clear display.