Add: separated Parallel 8 bit lib
This commit is contained in:
@ -119,38 +119,37 @@ func (d *mt12864a) SetPixel(x, y byte, c bool) error {
|
||||
}
|
||||
|
||||
func (d *mt12864a) PowerOn() error {
|
||||
d.pinA0.Low()
|
||||
d.pinRW.Low()
|
||||
d.pinE.Low()
|
||||
d.pinDB0.Low()
|
||||
d.pinDB1.Low()
|
||||
d.pinDB2.Low()
|
||||
d.pinDB3.Low()
|
||||
d.pinDB4.Low()
|
||||
d.pinDB5.Low()
|
||||
d.pinDB6.Low()
|
||||
d.pinDB7.Low()
|
||||
d.pinE1.Low()
|
||||
d.pinE2.Low()
|
||||
d.pinRES.Low()
|
||||
d.logger.Println("All low ")
|
||||
d.PrintPins()
|
||||
d.logger.Println("Power on")
|
||||
d.logger.Println(d.ReadStatus(1, 0)) // Should be 0
|
||||
d.logger.Println("Reset")
|
||||
d.pinE.Low()
|
||||
d.pinRES.Low()
|
||||
time.Sleep(time.Microsecond)
|
||||
d.logger.Println(d.ReadStatus(1, 0)) // Should be 48 (power off and reset)
|
||||
d.pinRES.High()
|
||||
time.Sleep(10 * time.Microsecond)
|
||||
d.logger.Println(d.ReadStatus(1, 0)) // Should be 32 (power off)
|
||||
|
||||
// Module is reset and should be turned off
|
||||
if d.ReadStatus(1, 0) == 0 || d.ReadStatus(0, 1) == 0 {
|
||||
return fmt.Errorf("no response from display(or it is possible that it is turned on but...)")
|
||||
}
|
||||
|
||||
d.logger.Println("Power on")
|
||||
d.PrintPins()
|
||||
d.logger.Println("Top line to 0")
|
||||
d.WriteCodeL(0xC0) // Top line to 0
|
||||
d.WriteCodeR(0xC0) // Top line to 0
|
||||
d.PrintPins()
|
||||
d.logger.Println("Display on")
|
||||
d.WriteCodeL(0x3F) // Display on
|
||||
d.WriteCodeR(0x3F) // Display on
|
||||
d.PrintPins()
|
||||
|
||||
// Check that crystals are turned on
|
||||
if (d.ReadStatus(1, 0) & (1 << 5)) != 0 {
|
||||
return fmt.Errorf("Left cristal is still off")
|
||||
}
|
||||
if (d.ReadStatus(0, 1) & (1 << 5)) != 0 {
|
||||
return fmt.Errorf("Right cristal is still off")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -188,7 +187,7 @@ func (d *mt12864a) ReadDataR() (byte, error) {
|
||||
// Low level functions
|
||||
|
||||
func (d *mt12864a) writeByte(b byte, cd, l, r rpio.State) error {
|
||||
d.logger.Println("Write byte", b, cd, l, r)
|
||||
// d.logger.Println("Write byte", b, cd, l, r)
|
||||
if l == rpio.High && r == rpio.High {
|
||||
d.logger.Println("L and R are high!!!")
|
||||
return fmt.Errorf("cannot write left and right at the same times")
|
||||
@ -218,14 +217,6 @@ func (d *mt12864a) writeByte(b byte, cd, l, r rpio.State) error {
|
||||
|
||||
// Strobe end
|
||||
d.pinE.Low()
|
||||
d.pinDB0.Low()
|
||||
d.pinDB1.Low()
|
||||
d.pinDB2.Low()
|
||||
d.pinDB3.Low()
|
||||
d.pinDB4.Low()
|
||||
d.pinDB5.Low()
|
||||
d.pinDB6.Low()
|
||||
d.pinDB7.Low()
|
||||
time.Sleep(time.Millisecond - dataStrobeTimeout - adressWriteTimeout)
|
||||
return nil
|
||||
}
|
||||
@ -269,7 +260,7 @@ func (d *mt12864a) readByte(cd, l, r rpio.State) (byte, error) {
|
||||
|
||||
// Wait, checking status byte
|
||||
func (d *mt12864a) waitReady(l, r rpio.State) error {
|
||||
d.logger.Println("Wait ready", l, r)
|
||||
//d.logger.Println("Wait ready", l, r)
|
||||
d.busInput() // Set bus to input
|
||||
d.pinRW.High() // We read
|
||||
d.pinA0.Low() // Status
|
||||
@ -286,7 +277,7 @@ func (d *mt12864a) waitReady(l, r rpio.State) error {
|
||||
d.busInput() // Set bus to input
|
||||
for counter := 0; counter < maxWaitCycles; counter++ {
|
||||
if d.pinDB7.Read() != rpio.High {
|
||||
d.logger.Printf("BUS:%d%d%d%d%d%d%d%d\n", d.pinDB0.Read(), d.pinDB1.Read(), d.pinDB2.Read(), d.pinDB3.Read(), d.pinDB4.Read(), d.pinDB5.Read(), d.pinDB6.Read(), d.pinDB7.Read())
|
||||
//d.logger.Printf("BUS:%d%d%d%d%d%d%d%d\n", d.pinDB0.Read(), d.pinDB1.Read(), d.pinDB2.Read(), d.pinDB3.Read(), d.pinDB4.Read(), d.pinDB5.Read(), d.pinDB6.Read(), d.pinDB7.Read())
|
||||
ok = true
|
||||
break
|
||||
}
|
||||
@ -298,7 +289,7 @@ func (d *mt12864a) waitReady(l, r rpio.State) error {
|
||||
// Strobe end
|
||||
d.pinE.Low()
|
||||
time.Sleep(time.Millisecond - dataStrobeTimeout - adressWriteTimeout)
|
||||
d.logger.Println("Ready")
|
||||
// d.logger.Println("Ready")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user