1 /*--------------------------------------------------------------------------*/
4 // This file is part of ruwai.
6 // If you use ruwai_parser in any program or publication, please inform and
7 // acknowledge its author Stefan Mertl (stefan@mertl-research.at).
9 // ruwai is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 /*--------------------------------------------------------------------------*/
26 #include "libgpio/gpio.h"
30 #define LCD_DELAY_ENABLE_PULSE 2
31 #define LCD_LONG_DELAY 1600
32 #define LCD_SHORT_DELAY 50
35 #define LCD_CMD_CLEAR_DISPLAY 0x01
36 #define LCD_CMD_RETURN_HOME 0x02
37 #define LCD_CMD_ENTRY_MODE_SET 0x04
38 #define LCD_CMD_DISPLAY 0x08
39 #define LCD_CMD_SHIFT 0x10
40 #define LCD_CMD_FUNCTION_SET 0x20
41 #define LCD_CMD_SET_CGRAM_ADDR 0x40
42 #define LCD_CMD_SET_DDRAM_ADDR 0x80
44 #define LCD_ENTRY_DISPLAY_SHIFT 0x01
45 #define LCD_ENTRY_CURSOR_INCREMENT 0x02
46 #define LCD_DISPLAY_CURSOR_BLINKS 0x01
47 #define LCD_DISPLAY_CURSOR_ON 0x02
48 #define LCD_DISPLAY_DISPLAY_ON 0X04
49 #define LCD_SHIFT_RIGHT 0x04
50 #define LCD_SHIFT_DISPLAY 0x08
51 #define LCD_FUNCTION_5X10_DOTS 0X04
52 #define LCD_FUNCTION_TWO_LINES 0X08
53 #define LCD_FUNCTION_8BIT_MODE 0X10
74 LCDDisplay(int rs_gpio
, int e_gpio
, int db0_gpio
, int db1_gpio
, int db2_gpio
, int db3_gpio
, int db4_gpio
, int db5_gpio
, int db6_gpio
, int db7_gpio
);
75 LCDDisplay(int rs_gpio
, int e_gpio
, int db4_gpio
, int db5_gpio
, int db6_gpio
, int db7_gpio
);
79 void write_data(std::uint8_t data
);
80 void print(std::string msg_line1
, std::string msg_line2
);
85 void write_4bit(std::uint8_t data
, bool command
);
86 void write_4bit_high_only(std::uint8_t data
, bool command
);
87 void write_8bit(std::uint8_t data
, bool command
);
88 void write_command(std::uint8_t data
);
93 #endif /* LCDDISPLAY_H */