updated the app to use tview because the bubbletea code was unmaintainable

This commit is contained in:
2026-01-29 06:06:21 -06:00
parent e5688ae361
commit 038bc3e88c
5 changed files with 204 additions and 357 deletions
+24 -5
View File
@@ -10,8 +10,8 @@ import (
// Device manages the serial connection to the Cardputer.
type Device struct {
PortName string
Port serial.Port
PortName string
Port serial.Port
Connected bool
}
@@ -59,9 +59,22 @@ func (d *Device) Connect() error {
d.Close()
return fmt.Errorf("failed to send dev mode request: %w", err)
}
// Allow some time for the device to respond or settle if needed
time.Sleep(100 * time.Millisecond)
// Allow some time for the device to respond or settle if needed
time.Sleep(100 * time.Millisecond)
return nil
}
// ExitDevMode sends the command to exit dev mode.
func (d *Device) ExitDevMode() error {
if !d.Connected || d.Port == nil {
return fmt.Errorf("device not connected")
}
// Send exit dev mode command
// TODO: Replace with the actual command sequence to exit dev mode
// This is currently not implemented on the Cardputer side.
return nil
}
@@ -69,6 +82,12 @@ func (d *Device) Connect() error {
// Close closes the serial port.
func (d *Device) Close() error {
if d.Port != nil {
// Try to exit dev mode before closing
_ = d.ExitDevMode()
// Allow some time for the command to be processed
time.Sleep(100 * time.Millisecond)
err := d.Port.Close()
d.Port = nil
d.Connected = false