working on the peripheral state handling
This commit is contained in:
+27
-4
@@ -2,28 +2,33 @@
|
||||
package devices
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"esdi/devices/cdashdisplay"
|
||||
"esdi/devices/uidevice"
|
||||
"esdi/peripheral"
|
||||
)
|
||||
|
||||
var ErrInvalidDevice = errors.New("invalid device")
|
||||
|
||||
type Device struct {
|
||||
Name string
|
||||
Discover func() (peripheral.Peripheral, error)
|
||||
// DefaultSetup func(peripheral.Peripheral) error
|
||||
}
|
||||
|
||||
var List map[string]*Device = map[string]*Device{
|
||||
uidevice.NAME: {
|
||||
Name: uidevice.NAME,
|
||||
Discover: DiscoverUIDevice,
|
||||
Discover: UIDeviceDiscover,
|
||||
},
|
||||
cdashdisplay.NAME: {
|
||||
Name: cdashdisplay.NAME,
|
||||
Discover: DiscoverCDashDisplay,
|
||||
Discover: CDashDisplayDiscover,
|
||||
},
|
||||
}
|
||||
|
||||
func DiscoverUIDevice() (peripheral.Peripheral, error) {
|
||||
func UIDeviceDiscover() (peripheral.Peripheral, error) {
|
||||
uidev, err := uidevice.NewUIDevice()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -32,7 +37,11 @@ func DiscoverUIDevice() (peripheral.Peripheral, error) {
|
||||
return uidev, nil
|
||||
}
|
||||
|
||||
func DiscoverCDashDisplay() (peripheral.Peripheral, error) {
|
||||
// func UIDeviceSetup(peripheral peripheral.Peripheral) error {
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func CDashDisplayDiscover() (peripheral.Peripheral, error) {
|
||||
// Create a cdashdisplay
|
||||
display, err := cdashdisplay.NewCDashDisplay()
|
||||
if err != nil {
|
||||
@@ -41,3 +50,17 @@ func DiscoverCDashDisplay() (peripheral.Peripheral, error) {
|
||||
|
||||
return display, nil
|
||||
}
|
||||
|
||||
// func CDashDisplaySetup(peripheral peripheral.Peripheral) error {
|
||||
// cdash, ok := peripheral.(*cdashdisplay.CDashDisplay)
|
||||
// if !ok {
|
||||
// return ErrInvalidDevice
|
||||
// }
|
||||
//
|
||||
// err := cdash.LoadLayout("layout.yaml")
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// return nil
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user