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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_spi_master.h"
50 #include "generic_pointer.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
63 #define LCDMONO_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
65  cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
66  cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
67  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
68  cfg.com = MIKROBUS( mikrobus, MIKROBUS_PWM )
69 
75 #define LCDMONO_OK 0
76 #define LCDMONO_ERROR -1
77 
83 #define LCDMONO_DISPLAY_WIDTH 128
84 #define LCDMONO_DISPLAY_HEIGHT 128
85 #define LCDMONO_DISPLAY_RESOLUTIONS 2307
86 
92 #define LCDMONO_COLOR_WHITE 0x00
93 #define LCDMONO_COLOR_BLACK 0x01
94 
100 #define LCDMONO_REFRESH_DISPLAY_END 0x01
101 #define LCDMONO_CHECK_NEW_TEXT 0x00
102 #define LCDMONO_REFRESH_TEXT_BUFFER 0x10
103 
109 #define LCDMONO_CMD_DISPLAY_FLAG 0x80
110 #define LCDMONO_CMD_CLEAR_FLAG 0x20
111 #define LCDMONO_DUMMY_BYTE 0x00
112 
118 #define LCDMONO_POWER_ON 1
119 #define LCDMONO_POWER_OFF 0
120  // End group macro
123 // --------------------------------------------------------------- PUBLIC TYPES
129 typedef struct
130 {
131  uint8_t * __generic_ptr this_font;
132  uint16_t first_char;
133  uint16_t last_char;
134  uint16_t height;
135 
137 
138 typedef struct
139 {
140  uint16_t x;
141  uint16_t y;
142 
144 
145 typedef struct
146 {
147  // Draw Text
148  uint8_t len; // Number of characters in the text
149  uint16_t start_cord_x; // X position of the text
150  uint16_t start_cord_y; // Y position of the text
151  uint8_t bg_color; // Background color
152 
154 
158 typedef struct
159 {
160  // Output pins
161  digital_out_t com;
162 
163  // Modules
164  spi_master_t spi;
165  pin_name_t chip_select;
166 
167  uint8_t lcd_frame[ 2307 ];
169 
173 
174 } lcdmono_t;
175 
179 typedef struct
180 {
181  // Communication gpio pins
182  pin_name_t miso;
183  pin_name_t mosi;
184  pin_name_t sck;
185  pin_name_t cs;
186 
187  // Additional gpio pins
188  pin_name_t com;
189 
190  // Static variable
191  uint32_t spi_speed;
192  spi_master_mode_t spi_mode;
193  spi_master_chip_select_polarity_t cs_polarity;
194 
196 
197 } lcdmono_cfg_t;
198  // End types group
200 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
206 #ifdef __cplusplus
207 extern "C"{
208 #endif
209 
219 
227 err_t lcdmono_init ( lcdmono_t *ctx, lcdmono_cfg_t *cfg );
228 
238 void lcdmono_send_line_package ( lcdmono_t *ctx, uint8_t addr, uint8_t * __generic_ptr tx_data );
239 
245 void lcdmono_clear ( lcdmono_t *ctx );
246 
257 void lcdmono_draw_frame ( lcdmono_t *ctx, uint8_t * __generic_ptr frame_data );
258 
272 void lcdmono_draw_text ( lcdmono_t *ctx, uint8_t * __generic_ptr text_buf, lcdmono_text_settings_t *tx_set, uint8_t end_mode );
273 
280 void lcdmono_set_font ( lcdmono_t *ctx, lcdmono_font_t *dev_lcd_font );
281 
288 void lcdmono_display_power ( lcdmono_t *ctx, uint8_t ctrl );
289 
296 
297 #ifdef __cplusplus
298 }
299 #endif
300 #endif // LCDMONO_H
301  // End public_function group
304 
305 // ------------------------------------------------------------------------ END
lcdmono_coordinate_t
Definition: lcdmono.h:139
lcdmono_font_t::first_char
uint16_t first_char
Definition: lcdmono.h:132
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:182
lcdmono_text_settings_t::len
uint8_t len
Definition: lcdmono.h:148
lcdmono_text_settings_t
Definition: lcdmono.h:146
lcdmono_cfg_t::sck
pin_name_t sck
Definition: lcdmono.h:184
lcdmono_t
Click ctx object definition.
Definition: lcdmono.h:159
lcdmono_cfg_t::com
pin_name_t com
Definition: lcdmono.h:188
lcdmono_text_settings_t::start_cord_x
uint16_t start_cord_x
Definition: lcdmono.h:149
lcdmono_text_settings_t::bg_color
uint8_t bg_color
Definition: lcdmono.h:151
lcdmono_cfg_t::dev_lcd_frame_color
uint8_t dev_lcd_frame_color
Definition: lcdmono.h:195
lcdmono_t::tx_set
lcdmono_text_settings_t tx_set
Definition: lcdmono.h:172
lcdmono_cfg_t::cs
pin_name_t cs
Definition: lcdmono.h:185
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:180
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:164
lcdmono_coordinate_t::x
uint16_t x
Definition: lcdmono.h:140
lcdmono_font_t::height
uint16_t height
Definition: lcdmono.h:134
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:130
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:133
lcdmono_t::lcd_font
lcdmono_font_t lcd_font
Definition: lcdmono.h:170
lcdmono_cfg_t::spi_mode
spi_master_mode_t spi_mode
Definition: lcdmono.h:192
lcdmono_t::com
digital_out_t com
Definition: lcdmono.h:161
lcdmono_font_t::this_font
uint8_t *__generic_ptr this_font
Definition: lcdmono.h:131
lcdmono_t::chip_select
pin_name_t chip_select
Definition: lcdmono.h:165
lcdmono_cfg_t::spi_speed
uint32_t spi_speed
Definition: lcdmono.h:191
lcdmono_coordinate_t::y
uint16_t y
Definition: lcdmono.h:141
lcdmono_cfg_t::cs_polarity
spi_master_chip_select_polarity_t cs_polarity
Definition: lcdmono.h:193
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:183
lcdmono_t::lcd_cord
lcdmono_coordinate_t lcd_cord
Definition: lcdmono.h:171
lcdmono_t::lcd_frame_color
uint8_t lcd_frame_color
Definition: lcdmono.h:168
lcdmono_text_settings_t::start_cord_y
uint16_t start_cord_y
Definition: lcdmono.h:150
lcdmono_clear
void lcdmono_clear(lcdmono_t *ctx)
Clear display.