From 642e75ad30b6577a9be3a60dc6804f5903168be7 Mon Sep 17 00:00:00 2001 From: Cruiser79 Date: Tue, 21 Feb 2017 08:07:53 +0100 Subject: [PATCH] Update hd44780.go Add method CreateChar. --- controller/hd44780/hd44780.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/controller/hd44780/hd44780.go b/controller/hd44780/hd44780.go index 88032d5..e046240 100644 --- a/controller/hd44780/hd44780.go +++ b/controller/hd44780/hd44780.go @@ -646,3 +646,14 @@ func (conn *I2CConnection) Close() error { glog.V(2).Info("hd44780: closing I2C bus") return conn.I2C.Close() } + +// Allows us to fill the first 8 CGRAM locations +// with custom characters, we can then print with writeChar(0-7) +func (hd *HD44780) CreateChar(location byte, charmap []byte) error { + location &= 0x7; + err := hd.WriteInstruction(lcdSetCGRamAddr | (location << 3)) + for i := 0; i < 8; i++ { + hd.WriteChar(charmap[i]); + } + return err +}