chat history, better turn queue updates

This commit is contained in:
legop3
2026-01-15 02:55:46 -05:00
parent 23fe03ca54
commit 37927d82af
20 changed files with 585 additions and 36 deletions
+10 -1
View File
@@ -20,6 +20,7 @@ type WSClient struct {
media *MediaSupervisor
servo *CameraServo
nightVision *NightVisionLight
ir *IRTransmitter
log *log.Logger
recoverMu sync.Mutex
recovering bool
@@ -30,7 +31,7 @@ type WSClient struct {
seekIssued bool
}
func NewWSClient(cfg *Config, adapter *SerialAdapter, frames <-chan []byte, events chan RoverEvent, media *MediaSupervisor, servo *CameraServo, nightVision *NightVisionLight, logger *log.Logger) *WSClient {
func NewWSClient(cfg *Config, adapter *SerialAdapter, frames <-chan []byte, events chan RoverEvent, media *MediaSupervisor, servo *CameraServo, nightVision *NightVisionLight, ir *IRTransmitter, logger *log.Logger) *WSClient {
var ttsQueue chan *ttsPayload
if cfg.Audio.TTSEnabled {
ttsQueue = make(chan *ttsPayload, 2)
@@ -43,6 +44,7 @@ func NewWSClient(cfg *Config, adapter *SerialAdapter, frames <-chan []byte, even
media: media,
servo: servo,
nightVision: nightVision,
ir: ir,
log: logger,
ttsQueue: ttsQueue,
}
@@ -181,6 +183,13 @@ func (c *WSClient) dispatch(ctx context.Context, msg *inboundMessage) error {
slot = clampInt(*msg.Song.Slot, 0, 4)
}
return c.adapter.PlaySong(slot, msg.Song.Notes)
case msg.IR != nil:
if c.ir == nil {
return fmt.Errorf("ir disabled")
}
code := clampInt(msg.IR.Code, 0, 255)
repeat := clampInt(msg.IR.Repeat, 0, 10)
return c.ir.Send(byte(code), repeat)
default:
return fmt.Errorf("unsupported command type: %s", msg.Type)
}