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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user