this is a doozy - device auto discovery and handling

The main goal was to decouple more things
We got devices being looked for in the background and the stream view
is like a device now too
This commit is contained in:
2026-09-17 22:55:17 +01:00
parent 20025dae1b
commit 65f03fd4c9
17 changed files with 327 additions and 111 deletions
+53
View File
@@ -0,0 +1,53 @@
package uidevice
import (
"esdi/peripheral"
"esdi/telemetry"
)
type UIDevice struct {
dataChan chan telemetry.TelemetryData
}
const NAME = "UIView"
func NewUIDevice() (peripheral.Peripheral, error) {
return &UIDevice{
dataChan: make(chan telemetry.TelemetryData, 1),
}, nil
}
func (uid *UIDevice) SendData(data *telemetry.TelemetryData) {
if data == nil {
return
}
select {
case uid.dataChan <- *data:
default:
// Drop frame if buffer is full
}
}
func (uid *UIDevice) Name() string {
return NAME
}
func (uid *UIDevice) DataChannel() <-chan telemetry.TelemetryData {
return uid.dataChan
}
func (uid *UIDevice) RequiredFields() map[int16]telemetry.FieldID {
subscribeTo := []telemetry.FieldID{
telemetry.Speed,
telemetry.Gear,
telemetry.RPM,
}
fields := make(map[int16]telemetry.FieldID, len(subscribeTo))
for k, field := range subscribeTo {
fields[int16(k)] = field
}
return fields
}