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