mikroSDK Reference Manual
lcd.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
44#ifndef _LCD_H_
45#define _LCD_H_
46
47#ifdef __cplusplus
48extern "C"{
49#endif
50
51#include "lcd_controllers.h"
52
70#define LCD_CMD_FUNCTION_SET ((uint8_t)0x20)
71#define LCD_CMD_CLEAR ((uint8_t)0x1)
72#define LCD_CMD_RETURN_HOME ((uint8_t)0x2)
73#define LCD_CMD_CURSOR_OFF ((uint8_t)0xC)
74#define LCD_CMD_UNDERLINE_ON ((uint8_t)0xE)
75#define LCD_CMD_BLINK_CURSOR_ON ((uint8_t)0xF)
76#define LCD_CMD_MOVE_CURSOR_LEFT ((uint8_t)0x10)
77#define LCD_CMD_MOVE_CURSOR_RIGHT ((uint8_t)0x14)
78#define LCD_CMD_TURN_OFF ((uint8_t)0x8)
79#define LCD_CMD_TURN_ON ((uint8_t)0xC)
80#define LCD_CMD_SHIFT_LEFT ((uint8_t)0x18)
81#define LCD_CMD_SHIFT_RIGHT ((uint8_t)0x1C)
82#define LCD_CMD_MODE_4BIT ((uint8_t)0x08)
83 // lcdcommands
84
89#define LCD_MAP_PINS(lcd_cfg) LCD_MAP_PINS_4BIT(lcd_cfg)
90
94#define LCD_MAP_PINS_4BIT(lcd_cfg) \
95 lcd_cfg.pin_cs = TFT_CS; \
96 lcd_cfg.pin_rst = TFT_RST; \
97 lcd_cfg.pin_backlight = TFT_BPWM; \
98 lcd_cfg.pin_d4 = TFT_D4; \
99 lcd_cfg.pin_d5 = TFT_D5; \
100 lcd_cfg.pin_d6 = TFT_D6; \
101 lcd_cfg.pin_d7 = TFT_D7;
102
106#define LCD_MAP_PINS_8BIT(lcd_cfg) \
107 lcd_cfg.pin_cs = TFT_CS; \
108 lcd_cfg.pin_rst = TFT_RST; \
109 lcd_cfg.pin_backlight = TFT_BPWM; \
110 lcd_cfg.pin_d0 = TFT_D0; \
111 lcd_cfg.pin_d1 = TFT_D1; \
112 lcd_cfg.pin_d2 = TFT_D2; \
113 lcd_cfg.pin_d3 = TFT_D3; \
114 lcd_cfg.pin_d4 = TFT_D4; \
115 lcd_cfg.pin_d5 = TFT_D5; \
116 lcd_cfg.pin_d6 = TFT_D6; \
117 lcd_cfg.pin_d7 = TFT_D7;
118
122typedef enum
123{
125 LCD_ERROR = (-1)
127
136
145
149typedef enum
150{
151 LCD_ROW_1 = 0x80,
152 LCD_ROW_2 = 0xC0,
153 LCD_ROW_3 = 0x94,
154 LCD_ROW_4 = 0xD4
156
195
200typedef void (*init_sequence_ptr)(uint32_t);
201
227
267
296
325
360void lcd_write( lcd_handle_t lcd_handle, char lcd_cmd_data, lcd_select_t cmd_or_data );
361
393void lcd_write_text( lcd_handle_t lcd_handle, char *lcd_data, lcd_row_t row );
394
430
466
499
528
557
587
617
647
677
707
739
768
797
798 // middlewaregroup
799 // lcd
800
801#ifdef __cplusplus
802}
803#endif
804
805#endif // _LCD_H_
806
807// ------------------------------------------------------------------------ END
hal_pin_name_t pin_name_t
Definition drv_name.h:74
void lcd_turn_off(lcd_handle_t lcd_handle)
Turns LCD OFF.
void lcd_set_row(lcd_handle_t lcd_handle, lcd_row_t row)
Sets current active row on LCD.
void lcd_cursor_move_home(lcd_handle_t lcd_handle)
Moves cursor to first position.
void(* init_sequence_ptr)(uint32_t)
Init sequence prototype.
Definition lcd.h:200
void lcd_cursor_on(lcd_handle_t lcd_handle)
Shows cursor.
void lcd_cursor_move_left(lcd_handle_t lcd_handle)
Moves cursor position.
void lcd_backlight_on(lcd_handle_t lcd_handle)
Turns LCD backlight ON.
void lcd_cursor_move_right(lcd_handle_t lcd_handle)
Moves cursor position.
lcd_err_t
Definition lcd.h:123
lcd_row_t
Definition lcd.h:150
void lcd_cursor_off(lcd_handle_t lcd_handle)
Removes cursor.
void lcd_init(lcd_handle_t lcd_handle, init_sequence_ptr init_sequence)
Initializes LCD.
void lcd_clear(lcd_handle_t lcd_handle)
Clears LCD.
lcd_err_t lcd_configure(lcd_handle_t *lcd_handle, lcd_config_t *config)
Configures LCD handle with passed configuration structure.
void lcd_write(lcd_handle_t lcd_handle, char lcd_cmd_data, lcd_select_t cmd_or_data)
Writes data to LCD.
void lcd_shift_left(lcd_handle_t lcd_handle)
Shifts data currently on LCD.
struct lcd_handle lcd_handle_t
void lcd_shift_right(lcd_handle_t lcd_handle)
Shifts data currently on LCD.
void lcd_backlight_off(lcd_handle_t lcd_handle)
Turns LCD backlight OFF.
void lcd_write_text(lcd_handle_t lcd_handle, char *lcd_data, lcd_row_t row)
Writes text to LCD.
struct lcd_config lcd_config_t
lcd_mode_t
Definition lcd.h:141
lcd_select_t
Definition lcd.h:132
void lcd_turn_on(lcd_handle_t lcd_handle)
Turns LCD ON.
void lcd_configure_default(lcd_config_t *config)
Configure LCD configuration structure.
@ LCD_ERROR
Definition lcd.h:125
@ LCD_SUCCESS
Definition lcd.h:124
@ LCD_ROW_4
Definition lcd.h:154
@ LCD_ROW_1
Definition lcd.h:151
@ LCD_ROW_3
Definition lcd.h:153
@ LCD_ROW_2
Definition lcd.h:152
@ LCD_MODE_BIT_4
Definition lcd.h:142
@ LCD_MODE_BIT_8
Definition lcd.h:143
@ LCD_SELECT_CMD
Definition lcd.h:133
@ LCD_SELECT_DATA
Definition lcd.h:134
mikroSDK supported LCD controller list.
Digital output driver context structure, consisted of the following fields :
Definition drv_digital_out.h:73
Definition lcd.h:161
pin_name_t pin_d2
Definition lcd.h:174
pin_name_t pin_d6
Definition lcd.h:178
pin_name_t pin_d7
Definition lcd.h:179
lcd_mode_t mode
LCD mode.
Definition lcd.h:185
pin_name_t pin_d1
Definition lcd.h:173
pin_name_t pin_backlight
Definition lcd.h:167
pin_name_t pin_cs
LCD control pins.
Definition lcd.h:165
pin_name_t pin_rst
Definition lcd.h:166
uint16_t waitBetweenWrites
Time to wait before generating a pulse on CS line.
Definition lcd.h:193
pin_name_t pin_d4
Definition lcd.h:176
pin_name_t pin_d0
LCD data pins.
Definition lcd.h:172
pin_name_t pin_d3
Definition lcd.h:175
pin_name_t pin_d5
Definition lcd.h:177
Definition lcd.h:206
digital_out_t backlight_pin
Definition lcd.h:211
bool init_state
Init state.
Definition lcd.h:224
init_sequence_ptr init_sequence
Controller init sequence.
Definition lcd.h:218
digital_out_t data_pins[8]
Definition lcd.h:212
digital_out_t cs_pin
Definition lcd.h:209
lcd_config_t config
Definition lcd.h:207
digital_out_t rst_pin
Definition lcd.h:210