mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-14 20:03:40 +00:00
Update hd44780i2c.go
This commit is contained in:
@@ -101,7 +101,7 @@ func (d *Device) Configure(cfg Config) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearDisplay clears all texts on the display.
|
// ClearDisplay clears all texts on the display and sets the cursor back to position (0, 0).
|
||||||
func (d *Device) ClearDisplay() {
|
func (d *Device) ClearDisplay() {
|
||||||
d.sendCommand(DISPLAY_CLEAR)
|
d.sendCommand(DISPLAY_CLEAR)
|
||||||
d.cursor.x = 0
|
d.cursor.x = 0
|
||||||
@@ -119,7 +119,8 @@ func (d *Device) Home() {
|
|||||||
|
|
||||||
// SetCursor sets the cursor to a specific position (x, y).
|
// SetCursor sets the cursor to a specific position (x, y).
|
||||||
//
|
//
|
||||||
// if y (row) is set larger than actual rows, it would be set to 0.
|
// For example, on 16x2 LCDs the range of x (column) is 0~15 and y (row) is 0~1.
|
||||||
|
// if y is larger than actual rows, it would be set to 0 (restart from first row).
|
||||||
func (d *Device) SetCursor(x, y uint8) {
|
func (d *Device) SetCursor(x, y uint8) {
|
||||||
rowOffset := []uint8{0x0, 0x40, 0x14, 0x54}
|
rowOffset := []uint8{0x0, 0x40, 0x14, 0x54}
|
||||||
if y > (d.height - 1) {
|
if y > (d.height - 1) {
|
||||||
@@ -139,11 +140,11 @@ func (d *Device) Print(data []byte) {
|
|||||||
if chr == '\n' {
|
if chr == '\n' {
|
||||||
d.newLine()
|
d.newLine()
|
||||||
} else {
|
} else {
|
||||||
d.cursor.x++
|
|
||||||
if d.cursor.x >= d.width {
|
if d.cursor.x >= d.width {
|
||||||
d.newLine()
|
d.newLine()
|
||||||
}
|
}
|
||||||
d.sendData(uint8(rune(chr)))
|
d.sendData(uint8(rune(chr)))
|
||||||
|
d.cursor.x++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user