SetPixel removed, formatting

This commit is contained in:
k-brk
2019-05-04 15:37:10 +02:00
committed by Ron Evans
parent 4560c61c61
commit ba4de1efb8
5 changed files with 52 additions and 31 deletions
+19 -24
View File
@@ -2,7 +2,6 @@ package hd44780
import (
"errors"
"image/color"
"io"
"time"
)
@@ -12,24 +11,6 @@ type Buser interface {
SetCommandMode(set bool)
}
// NewGPIO4Bit returns 4bit data length HD44780 driver. Datapins are LCD DB pins starting from DB4 to DB7
func NewGPIO4Bit(dataPins []uint8, e, rs, rw uint8) (Device, error) {
const fourBitMode = 4
if len(dataPins) != fourBitMode {
return Device{}, errors.New("4 pins are required in data slice (D7-D4) when HD44780 is used in 4 bit mode")
}
return newGPIO(dataPins, e, rs, rw, DATA_LENGTH_4BIT), nil
}
// NewGPIO8Bit returns 8bit data length HD44780 driver. Datapins are LCD DB pins starting from DB0 to DB7
func NewGPIO8Bit(dataPins []uint8, e, rs, rw uint8) (Device, error) {
const eightBitMode = 8
if len(dataPins) != eightBitMode {
return Device{}, errors.New("8 pins are required in data slice (D7-D0) when HD44780 is used in 8 bit mode")
}
return newGPIO(dataPins, e, rs, rw, DATA_LENGTH_8BIT), nil
}
type Device struct {
bus Buser
width uint8
@@ -56,6 +37,24 @@ type Config struct {
Font uint8
}
// NewGPIO4Bit returns 4bit data length HD44780 driver. Datapins are LCD DB pins starting from DB4 to DB7
func NewGPIO4Bit(dataPins []uint8, e, rs, rw uint8) (Device, error) {
const fourBitMode = 4
if len(dataPins) != fourBitMode {
return Device{}, errors.New("4 pins are required in data slice (D4-D7) when HD44780 is used in 4 bit mode")
}
return newGPIO(dataPins, e, rs, rw, DATA_LENGTH_4BIT), nil
}
// NewGPIO8Bit returns 8bit data length HD44780 driver. Datapins are LCD DB pins starting from DB0 to DB7
func NewGPIO8Bit(dataPins []uint8, e, rs, rw uint8) (Device, error) {
const eightBitMode = 8
if len(dataPins) != eightBitMode {
return Device{}, errors.New("8 pins are required in data slice (D0-D7) when HD44780 is used in 8 bit mode")
}
return newGPIO(dataPins, e, rs, rw, DATA_LENGTH_8BIT), nil
}
// Configure initializes device
func (d *Device) Configure(cfg Config) error {
d.busyStatus = make([]byte, 1)
@@ -205,15 +204,11 @@ func (d *Device) CreateCharacter(cgramAddr uint8, data []byte) {
// Busy returns true when hd447890 is busy
func (d *Device) Busy() bool {
d.bus.SetCommandMode(true)
d.bus.Read(d.busyStatus)
return (d.busyStatus[0] & BUSY) > 0
}
// SetPixel is not supported on devices which uses HD44780 driver
func (d *Device) SetPixel(x, y int16, c color.RGBA) {
panic("HD44780 does not support setting individual pixels")
}
// Size returns the current size of the display.
func (d *Device) Size() (w, h int16) {
return int16(d.width), int16(d.height)