Add: beta working mt12232a display
This commit is contained in:
@ -18,8 +18,11 @@ const (
|
||||
type Device interface {
|
||||
Reset()
|
||||
WriteByte(b byte, cd rpio.State)
|
||||
WriteBytes(b []byte, cd rpio.State)
|
||||
ReadByte(cd rpio.State) byte
|
||||
|
||||
Pins() DevicePins
|
||||
|
||||
WaitReady() error
|
||||
}
|
||||
|
||||
@ -44,6 +47,7 @@ type DevicePins struct {
|
||||
type device struct {
|
||||
logger *log.Logger
|
||||
|
||||
isBusOutput bool
|
||||
DevicePins
|
||||
}
|
||||
|
||||
@ -54,6 +58,10 @@ func New(logger *log.Logger, pins DevicePins) Device {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *device) Pins() DevicePins {
|
||||
return d.DevicePins
|
||||
}
|
||||
|
||||
func (d *device) Reset() {
|
||||
d.PinA0.Output()
|
||||
d.PinRW.Output()
|
||||
@ -88,6 +96,31 @@ func (d *device) WriteByte(b byte, cd rpio.State) {
|
||||
time.Sleep(time.Millisecond - dataStrobeTimeout - adressWriteTimeout)
|
||||
}
|
||||
|
||||
func (d *device) WriteBytes(b []byte, cd rpio.State) {
|
||||
// d.logger.Println("Write byte", b, cd, l, r)
|
||||
d.busOutput()
|
||||
d.PinRW.Low() // We write
|
||||
d.PinA0.Write(cd)
|
||||
|
||||
// Write bus
|
||||
d.PinDB0.Write(rpio.State(b[0]))
|
||||
d.PinDB1.Write(rpio.State(b[1]))
|
||||
d.PinDB2.Write(rpio.State(b[2]))
|
||||
d.PinDB3.Write(rpio.State(b[3]))
|
||||
d.PinDB4.Write(rpio.State(b[4]))
|
||||
d.PinDB5.Write(rpio.State(b[5]))
|
||||
d.PinDB6.Write(rpio.State(b[6]))
|
||||
d.PinDB7.Write(rpio.State(b[7]))
|
||||
|
||||
// Strobe start
|
||||
d.PinE.High()
|
||||
time.Sleep(dataStrobeTimeout)
|
||||
|
||||
// Strobe end
|
||||
d.PinE.Low()
|
||||
time.Sleep(time.Millisecond - dataStrobeTimeout - adressWriteTimeout)
|
||||
}
|
||||
|
||||
func (d *device) ReadByte(cd rpio.State) byte {
|
||||
// Setup
|
||||
var b byte
|
||||
@ -148,6 +181,9 @@ func (d *device) WaitReady() error {
|
||||
|
||||
// Set bus pins to output
|
||||
func (d *device) busOutput() {
|
||||
// if d.isBusOutput {
|
||||
// return
|
||||
// }
|
||||
d.PinDB0.Output()
|
||||
d.PinDB1.Output()
|
||||
d.PinDB2.Output()
|
||||
@ -156,9 +192,13 @@ func (d *device) busOutput() {
|
||||
d.PinDB5.Output()
|
||||
d.PinDB6.Output()
|
||||
d.PinDB7.Output()
|
||||
d.isBusOutput = true
|
||||
}
|
||||
|
||||
func (d *device) busInput() {
|
||||
//if !d.isBusOutput {
|
||||
// return
|
||||
//}
|
||||
d.PinDB0.Input()
|
||||
d.PinDB1.Input()
|
||||
d.PinDB2.Input()
|
||||
@ -167,4 +207,5 @@ func (d *device) busInput() {
|
||||
d.PinDB5.Input()
|
||||
d.PinDB6.Input()
|
||||
d.PinDB7.Input()
|
||||
d.isBusOutput = false
|
||||
}
|
||||
|
Reference in New Issue
Block a user