Added an interface to support multiple games

- In the same way, I expect the addition of the ability of holding
multiple sinks in memory like outputting to a TUI, GUI and other
hardware devices
This commit is contained in:
2024-10-19 21:42:54 +01:00
commit eea5925b90
6 changed files with 204 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"log"
"github.com/tarm/serial"
)
type ESDI struct {
SerialConfig *serial.Config
SerialConn *serial.Port
Source GameSource
}
func (e *ESDI) Close() {
err := e.SerialConn.Close()
if err != nil {
log.Fatalf("couldn't close serial connection: %v", err)
}
}
func ESDIInit(port string, baud int) (ESDI, error) {
sConfig := &serial.Config{
Name: port,
Baud: baud,
}
// Open the serial port
sPort, err := serial.OpenPort(sConfig)
if err != nil {
return ESDI{}, err
}
return ESDI{sConfig, sPort, nil}, nil
}