Fix: double strobe
This commit is contained in:
parent
30359a0a22
commit
5d67d667d7
@ -62,7 +62,7 @@ func newMt12232a(logger *log.Logger) (Display, error) {
|
||||
}
|
||||
|
||||
func (d *displayMt12232a) status(label string) {
|
||||
d.logger.Printf("STATUS %s -- L: %08b R: %08b\n", label, d.dev.ReadStatus(0)&0xFF, d.dev.ReadStatus(1)&0xFF)
|
||||
//d.logger.Printf("STATUS %s -- L: %08b R: %08b\n", label, d.dev.ReadStatus(0)&0xFF, d.dev.ReadStatus(1)&0xFF)
|
||||
}
|
||||
|
||||
func (d *displayMt12232a) powerOn() error {
|
||||
@ -131,128 +131,46 @@ func (d *displayMt12232a) powerOn() error {
|
||||
}
|
||||
|
||||
func (d *displayMt12232a) Test(ctx context.Context) error {
|
||||
//d.logger.Println("Write")
|
||||
|
||||
d.dev.WriteCode(0, 0xB8)
|
||||
d.dev.WriteCode(0, 0x13)
|
||||
for range 61 {
|
||||
d.dev.WriteData(0, 0xFF)
|
||||
}
|
||||
|
||||
for c := range 256 {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return nil
|
||||
default:
|
||||
if c == 0xA0 {
|
||||
continue
|
||||
}
|
||||
|
||||
// Write
|
||||
d.dev.WriteCode(0, 0xB8)
|
||||
d.dev.WriteCode(0, 0x13)
|
||||
d.dev.WriteData(0, byte(c)) // 0x13
|
||||
d.dev.WriteData(0, byte(c)) // 0x14
|
||||
//d.logger.Printf("--- %x ---\n", c)
|
||||
|
||||
// Check status
|
||||
if d.dev.ReadStatus(0) != 0 {
|
||||
d.logger.Printf("error status on %x status: %08b\n", c, d.dev.ReadStatus(0))
|
||||
if err := d.dev.Reset(); err != nil {
|
||||
return fmt.Errorf("reset: %w", err)
|
||||
}
|
||||
if err := d.powerOn(); err != nil {
|
||||
return fmt.Errorf("power on: %w", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
// Read
|
||||
d.dev.WriteCode(0, 0x13)
|
||||
if _, err := d.dev.ReadData(0); err != nil { // Empty
|
||||
return fmt.Errorf("read data 0: %w", err)
|
||||
}
|
||||
rc0, err := d.dev.ReadData(0) // 0x13
|
||||
if err != nil {
|
||||
return fmt.Errorf("read data 1: %w", err)
|
||||
}
|
||||
rc1, err := d.dev.ReadData(0) // 0x13
|
||||
if err != nil {
|
||||
return fmt.Errorf("read data 1: %w", err)
|
||||
}
|
||||
|
||||
if rc0 != byte(c) {
|
||||
d.logger.Println("Not write 0x13", c)
|
||||
}
|
||||
if rc1 != byte(c) {
|
||||
d.logger.Println("Not write 0x14", c)
|
||||
}
|
||||
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
//d.dev.WriteData(0, 0xAE)
|
||||
return nil
|
||||
//d.logger.Println("Read")
|
||||
//d.dev.WriteCode(0, 0x14)
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
//d.logger.Println(d.dev.ReadData(0))
|
||||
|
||||
//color := []byte{1, 0, 1, 0, 1, 0, 1, 0}
|
||||
//color := []byte{1, 0, 1, 0, 1, 0, 0, 0}
|
||||
|
||||
//color := []byte{0, 0, 0, 0, 0, 0, 0, 0}
|
||||
//color := byte(3)
|
||||
//return
|
||||
d.dev.WriteCode(0, 0x14)
|
||||
d.dev.WriteData(0, 0xAE)
|
||||
start := time.Now()
|
||||
//d.dev.WriteCodeL(0xB8)
|
||||
//d.dev.WriteCodeL(0x13)
|
||||
//d.dev.WriteDatasL([]byte{0, 0, 0, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 0, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 0, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 1, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 1, 1, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 1, 1, 1, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 1, 1, 1, 1, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 1, 1, 1, 1, 1, 1, 1})
|
||||
//
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 0, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 1, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 1, 0, 1, 0})
|
||||
//d.dev.WriteCodeL(0xB8 | 1)
|
||||
//d.dev.WriteCodeL(0x13)
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 0, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 0, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 1, 0, 0, 0})
|
||||
//d.dev.WriteDatasL([]byte{1, 0, 1, 0, 1, 0, 1, 0})
|
||||
|
||||
d.status("4")
|
||||
for p := byte(0); p < 4; p++ {
|
||||
d.dev.WriteCode(0, p|0xB8)
|
||||
for p := 0; p < 4; p++ {
|
||||
// First
|
||||
|
||||
// d.dev.WriteCode(0, byte(p)|0xB8)
|
||||
// d.dev.WriteCode(0, 0x13)
|
||||
// for c := 0; c < 61; c++ {
|
||||
// d.dev.WriteData(0, 0)
|
||||
// }
|
||||
// d.dev.WriteCode(1, byte(p)|0xB8)
|
||||
// d.dev.WriteCode(1, 0x00)
|
||||
// for c := 0; c < 61; c++ {
|
||||
// d.dev.WriteData(1, 0)
|
||||
// }
|
||||
//
|
||||
// Second
|
||||
d.dev.WriteCode(0, byte(p)|0xB8)
|
||||
d.dev.WriteCode(0, 0x13)
|
||||
for c := 0; c < 61; c++ {
|
||||
//d.dev.WriteDatas(0, []byte{byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2)})
|
||||
//d.dev.WriteData(0, byte(0xF0^(0xFF*(c%2))))
|
||||
d.dev.WriteData(0, byte(rand.Int())>>1)
|
||||
//d.dev.WriteData(0, 0xF2)
|
||||
//d.dev.WriteData(0, 0xF0)
|
||||
d.dev.WriteData(0, byte(rand.Int()))
|
||||
// d.dev.WriteData(0, 0xFF)
|
||||
//d.dev.WriteData(0, byte(p*122+c))
|
||||
//time.Sleep(2 * time.Millisecond)
|
||||
}
|
||||
d.dev.WriteCode(1, p|0xB8)
|
||||
d.dev.WriteCode(1, byte(p)|0xB8)
|
||||
d.dev.WriteCode(1, 0x00)
|
||||
for c := 0; c < 61; c++ {
|
||||
//d.dev.WriteDatas(1, []byte{byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2), byte(rand.Int() % 2)})
|
||||
//d.dev.WriteData(1, byte(rand.Int()))
|
||||
d.dev.WriteData(1, byte(rand.Int()))
|
||||
// d.dev.WriteData(1, 0xFF)
|
||||
//d.dev.WriteData(1, byte(4*int(p)+c))
|
||||
//d.dev.WriteData(1, 0xF0+byte(rand.Int()%2))
|
||||
d.dev.WriteData(1, byte(rand.Int())>>1)
|
||||
//d.dev.WriteData(1, byte(p*122+c+61))
|
||||
//d.dev.WriteData(1, byte(rand.Int())>>1)
|
||||
//time.Sleep(2 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
@ -152,8 +152,10 @@ func (d *mt12232a) readByte(cd, cs rpio.State) (byte, error) {
|
||||
|
||||
// Wait, checking status byte
|
||||
func (d *mt12232a) waitReady(cs rpio.State) error {
|
||||
d.pinCS.Write(cs) // Select cristals
|
||||
return d.dev.WaitReady()
|
||||
// d.pinCS.Write(cs) // Select cristals
|
||||
// return d.dev.WaitReady()
|
||||
time.Sleep(time.Microsecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *mt12232a) ReadStatus(cs rpio.State) byte {
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
adressWriteTimeout = 5000 * time.Nanosecond // 40
|
||||
dataStrobeTimeout = 2000 * time.Nanosecond // (Data transfer) 160
|
||||
dataReadTimeout = 4000 * time.Nanosecond // 300
|
||||
gapTimeout = 20000 * time.Nanosecond // TIM // 2000
|
||||
adressWriteTimeout = 50 * time.Nanosecond // 40
|
||||
dataStrobeTimeout = 200 * time.Nanosecond // (Data transfer) 160
|
||||
dataReadTimeout = 400 * time.Nanosecond // 300
|
||||
gapTimeout = 2000 * time.Nanosecond // TIM // 2000
|
||||
maxWaitCycles = 100
|
||||
)
|
||||
|
||||
@ -102,8 +102,8 @@ func (d *device) WriteByte(b byte, cd rpio.State) {
|
||||
time.Sleep(dataStrobeTimeout)
|
||||
d.PinE.High() // Strobe end
|
||||
|
||||
// time.Sleep(time.Millisecond - dataStrobeTimeout - adressWriteTimeout)
|
||||
time.Sleep(time.Millisecond)
|
||||
time.Sleep(gapTimeout - dataStrobeTimeout - adressWriteTimeout)
|
||||
//time.Sleep(time.Millisecond)
|
||||
}
|
||||
|
||||
func (d *device) WriteBytes(b []byte, cd rpio.State) {
|
||||
@ -131,7 +131,6 @@ func (d *device) WriteBytes(b []byte, cd rpio.State) {
|
||||
d.PinE.High() // Strobe end
|
||||
|
||||
time.Sleep(gapTimeout - dataStrobeTimeout - adressWriteTimeout)
|
||||
//time.Sleep(time.Millisecond)
|
||||
}
|
||||
|
||||
func (d *device) ReadByte(cd rpio.State) byte {
|
||||
@ -204,9 +203,9 @@ func (d *device) WaitReady() error {
|
||||
|
||||
// Set bus Pins to output
|
||||
func (d *device) busOutput() {
|
||||
// if d.isBusOutput {
|
||||
// return
|
||||
// }
|
||||
if d.isBusOutput {
|
||||
return
|
||||
}
|
||||
d.PinDB0.Output()
|
||||
d.PinDB1.Output()
|
||||
d.PinDB2.Output()
|
||||
@ -219,9 +218,9 @@ func (d *device) busOutput() {
|
||||
}
|
||||
|
||||
func (d *device) busInput() {
|
||||
//if !d.isBusOutput {
|
||||
// return
|
||||
//}
|
||||
if !d.isBusOutput {
|
||||
return
|
||||
}
|
||||
d.PinDB0.Input()
|
||||
d.PinDB1.Input()
|
||||
d.PinDB2.Input()
|
||||
|
Loading…
Reference in New Issue
Block a user