-
Notifications
You must be signed in to change notification settings - Fork 6
/
HD44780.h
142 lines (99 loc) · 3.5 KB
/
HD44780.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* ************************************************************************
*
* HD44780 compatible character display
*
* (c) 2012-2021 by Markus Reschke
* based on code from Markus Frejek and Karl-Heinz Kübbeler
*
* ************************************************************************ */
/* ************************************************************************
* addresses
* ************************************************************************ */
/*
* CGROM
* - 1240 bytes
* - 208 characters 5x8 and 32 characters 5x10
*/
/*
* CGRAM
* - 64 bytes
* - user-defined characters
* - 8 characters 5x8 or 4 characters 5x10
*/
/*
* DDRAM
* - 80 bytes
*/
/* start addresses of text lines */
#define ADDR_LINE_1 0x00 /* line #1 */
#define ADDR_LINE_2 0x40 /* line #2 */
#define ADDR_LINE_3 0x14 /* line #3 */
#define ADDR_LINE_4 0x54 /* line #4 */
/* ************************************************************************
* LCD commands
* ************************************************************************ */
/*
* clear display
* - 1 byte cmd
*/
#define CMD_CLEAR_DISPLAY 0x01 /* clear display */
/*
* return home
* - 1 byte cmd
* - exec time: 1.52ms
*/
#define CMD_RETURN_HOME 0x02 /* return home */
/*
* entry mode set
* - 1 byte cmd
* - exec time: 37µs
*/
#define CMD_ENTRY_MODE_SET 0x04 /* entry mode set */
#define FLAG_CURSOR_DECREASE 0b00000000 /* auto-decrease cursor position */
#define FLAG_CURSOR_INCREASE 0b00000010 /* auto-increase cursor position */
#define FLAG_DISPLAY_NOSHIFT 0b00000000 /* enable display auto-shift */
#define FLAG_DISPLAY_SHIFT 0b00000001 /* disable display auto-shift */
/*
* display control
* - 1 byte cmd
*/
#define CMD_DISPLAY_CONTROL 0x08 /* display control */
#define FLAG_DISPLAY_OFF 0b00000000 /* display off */
#define FLAG_DISPLAY_ON 0b00000100 /* display on */
#define FLAG_CURSOR_OFF 0b00000000 /* cursor off */
#define FLAG_CURSOR_ON 0b00000010 /* cursor on */
#define FLAG_BLINK_OFF 0b00000000 /* blinking off */
#define FLAG_BLINK_ON 0b00000001 /* blinking on */
/*
* shift
* - 1 byte cmd
*/
#define CMD_SHIFT 0x10 /* shift */
#define FLAG_SHIFT_CURSOR 0b00000000 /* shift cursor */
#define FLAG_SHIFT_DISPLAY 0b00001000 /* shift display */
#define FLAG_SHIFT_LEFT 0b00000000 /* shift left */
#define FLAG_SHIFT_RIGHT 0b00000100 /* shift right */
/*
* function set
* - 1 byte cmd
*/
#define CMD_FUNCTION_SET 0x20 /* function set */
#define FLAG_INTERFACE_4BIT 0b00000000 /* enable 4 bit data interface */
#define FLAG_INTERFACE_8BIT 0b00010000 /* enable 8 bit data interface */
#define FLAG_LINES_1 0b00000000 /* display one line */
#define FLAG_LINES_2 0b00001000 /* display two lines */
#define FLAG_FONT_5X7 0b00000000 /* select 5x7 font */
#define FLAG_FONT_5X10 0b00000100 /* select 5x10 font */
/*
* set CG RAM address
* - 1 byte cmd
*/
#define CMD_SET_CG_RAM_ADDR 0x40 /* set CG RAM address (custom character) */
/*
* set DD RAM address
* - 1 byte cmd
*/
#define CMD_SET_DD_RAM_ADDR 0x80 /* set DD RAM address (cursor position) */
/* ************************************************************************
* EOF
* ************************************************************************ */