-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display.go
45 lines (39 loc) · 924 Bytes
/
display.go
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
package lcd
type displayMode struct {
On bool
Cursor bool
Blink bool
}
func (d displayMode) byte() byte {
var output byte
if d.On {
output |= 0b100
}
if d.Cursor {
output |= 0b10
}
if d.Blink {
output |= 0b1
}
return output
}
// On enables the LCD display
func (l *LCD) On() {
l.displayMode.On = true
l.execInstruction(insSetDisplayMode, l.displayMode.byte())
}
// Off disables the LCD display (content will be preserved)
func (l *LCD) Off() {
l.displayMode.On = false
l.execInstruction(insSetDisplayMode, l.displayMode.byte())
}
// SetBlink will enable/disable blinking of the cursor
func (l *LCD) SetBlink(enabled bool) {
l.displayMode.Blink = enabled
l.execInstruction(insSetDisplayMode, l.displayMode.byte())
}
// SetCursor will enable/disable the cursor
func (l *LCD) SetCursor(enabled bool) {
l.displayMode.Cursor = true
l.execInstruction(insSetDisplayMode, l.displayMode.byte())
}