sensor stream throttle and new roster panel

This commit is contained in:
legop3
2025-11-20 14:55:59 -05:00
parent ff0bf30eac
commit bfdfa33b62
10 changed files with 111 additions and 69 deletions
+10 -2
View File
@@ -12,8 +12,9 @@ import (
)
const (
sensorHeader = 19
sensorReadTimeout = 150 * time.Millisecond
sensorHeader = 19
sensorReadTimeout = 150 * time.Millisecond
sensorThrottleMinimum = 80 * time.Millisecond
)
type SensorStreamer struct {
@@ -29,6 +30,7 @@ func NewSensorStreamer(r io.Reader, rawOut chan<- []byte, parsed chan<- SensorSa
func (s *SensorStreamer) Run(ctx context.Context) {
reader := bufio.NewReader(s.r)
var nextSend time.Time
for {
select {
case <-ctx.Done():
@@ -62,6 +64,12 @@ func (s *SensorStreamer) Run(ctx context.Context) {
continue
}
now := time.Now()
if !nextSend.IsZero() && now.Before(nextSend) {
continue
}
nextSend = now.Add(sensorThrottleMinimum)
select {
case s.rawOut <- frame:
default: