Fix keyboard delay (#152)
This commit is contained in:
parent
6edd7ecf11
commit
bde5767314
|
@ -49,6 +49,7 @@ body:
|
||||||
label: Driver Version
|
label: Driver Version
|
||||||
description: What version of the driver are you running? Check with `RPI a2version`
|
description: What version of the driver are you running? Check with `RPI a2version`
|
||||||
options:
|
options:
|
||||||
|
- 002B (fix keyboard delay)
|
||||||
- 002A (reduce CPU usage)
|
- 002A (reduce CPU usage)
|
||||||
- 0029 (fix hang after shell exit)
|
- 0029 (fix hang after shell exit)
|
||||||
- 0028 (add live drive loading and regeneration)
|
- 0028 (add live drive loading and regeneration)
|
||||||
|
|
|
@ -15,7 +15,7 @@ type A2Io interface {
|
||||||
WriteString(outString string) error
|
WriteString(outString string) error
|
||||||
WriteBlock(buffer []byte) error
|
WriteBlock(buffer []byte) error
|
||||||
WriteBuffer(buffer []byte) error
|
WriteBuffer(buffer []byte) error
|
||||||
ReadByte() (byte, error)
|
ReadByte(noDelay ...bool) (byte, error)
|
||||||
ReadString() (string, error)
|
ReadString() (string, error)
|
||||||
ReadBlock(buffer []byte) error
|
ReadBlock(buffer []byte) error
|
||||||
SendCharacter(character byte)
|
SendCharacter(character byte)
|
||||||
|
|
|
@ -154,7 +154,7 @@ func (a2 A2Gpio) WriteString(outString string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadByte reads a byte from the Apple II via Raspberry Pi's GPIO ports
|
// ReadByte reads a byte from the Apple II via Raspberry Pi's GPIO ports
|
||||||
func (a2 A2Gpio) ReadByte() (byte, error) {
|
func (a2 A2Gpio) ReadByte(noDelay ...bool) (byte, error) {
|
||||||
// let the Apple II know we are ready to read
|
// let the Apple II know we are ready to read
|
||||||
outRead.Low()
|
outRead.Low()
|
||||||
|
|
||||||
|
@ -168,7 +168,9 @@ func (a2 A2Gpio) ReadByte() (byte, error) {
|
||||||
return 0, errors.New("timed out reading byte -- write stuck high")
|
return 0, errors.New("timed out reading byte -- write stuck high")
|
||||||
}
|
}
|
||||||
if time.Since(lastSleepTime) > edgeTimeout/10 {
|
if time.Since(lastSleepTime) > edgeTimeout/10 {
|
||||||
sleepDuration *= 3;
|
if len(noDelay) == 0 || !noDelay[0] {
|
||||||
|
sleepDuration *= 3;
|
||||||
|
}
|
||||||
time.Sleep(time.Millisecond * time.Duration(sleepDuration));
|
time.Sleep(time.Millisecond * time.Duration(sleepDuration));
|
||||||
lastSleepTime = time.Now()
|
lastSleepTime = time.Now()
|
||||||
}
|
}
|
||||||
|
@ -225,7 +227,9 @@ func (a2 A2Gpio) ReadByte() (byte, error) {
|
||||||
return 0, errors.New("timed out reading byte -- write stuck low")
|
return 0, errors.New("timed out reading byte -- write stuck low")
|
||||||
}
|
}
|
||||||
if time.Since(lastSleepTime) > edgeTimeout/10 {
|
if time.Since(lastSleepTime) > edgeTimeout/10 {
|
||||||
sleepDuration *= 3;
|
if len(noDelay) == 0 || !noDelay[0] {
|
||||||
|
sleepDuration *= 3;
|
||||||
|
}
|
||||||
time.Sleep(time.Millisecond * time.Duration(sleepDuration));
|
time.Sleep(time.Millisecond * time.Duration(sleepDuration));
|
||||||
lastSleepTime = time.Now()
|
lastSleepTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ func (mockIo MockIo) WriteBuffer(buffer []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadByte mocks reading a byte from the Apple II
|
// ReadByte mocks reading a byte from the Apple II
|
||||||
func (mockIo MockIo) ReadByte() (byte, error) {
|
func (mockIo MockIo) ReadByte(noDelay ...bool) (byte, error) {
|
||||||
b := mockIo.Data.BytesToRead[mockIo.Data.NumberBytesRead]
|
b := mockIo.Data.BytesToRead[mockIo.Data.NumberBytesRead]
|
||||||
mockIo.Data.NumberBytesRead++
|
mockIo.Data.NumberBytesRead++
|
||||||
return b, mockIo.Data.ErrorToThrow
|
return b, mockIo.Data.ErrorToThrow
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (userIo UserIo) WriteBuffer(buffer []byte) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadByte simulates reading to the Apple II but uses stdin instead
|
// ReadByte simulates reading to the Apple II but uses stdin instead
|
||||||
func (userIo UserIo) ReadByte() (byte, error) {
|
func (userIo UserIo) ReadByte(noDelay ...bool) (byte, error) {
|
||||||
fmt.Printf("ReadByte: ")
|
fmt.Printf("ReadByte: ")
|
||||||
var b byte
|
var b byte
|
||||||
fmt.Scanf("%x", &b)
|
fmt.Scanf("%x", &b)
|
||||||
|
|
|
@ -220,7 +220,7 @@ func sendCharacter(comm A2Io, b byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readCharacter(comm A2Io) (string, error) {
|
func readCharacter(comm A2Io) (string, error) {
|
||||||
b, err := comm.ReadByte()
|
b, err := comm.ReadByte(true)
|
||||||
var s = string(b)
|
var s = string(b)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if applicationMode {
|
if applicationMode {
|
||||||
|
|
|
@ -75,7 +75,7 @@ func main() {
|
||||||
}
|
}
|
||||||
// temporary workaround for busy wait loop heating up the RPi
|
// temporary workaround for busy wait loop heating up the RPi
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(time.Millisecond * 100)
|
time.Sleep(time.Millisecond * 200)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,4 +8,4 @@ package info
|
||||||
|
|
||||||
// Version is the hexadecimal version number that
|
// Version is the hexadecimal version number that
|
||||||
// should be incremented with each driver update
|
// should be incremented with each driver update
|
||||||
const Version = "002A"
|
const Version = "002B"
|
||||||
|
|
Loading…
Reference in New Issue