bug ub
This commit is contained in:
@@ -36,11 +36,12 @@ type DeviceManager struct {
|
|||||||
stopChan chan struct{}
|
stopChan chan struct{}
|
||||||
|
|
||||||
// Auto frequency tracking
|
// Auto frequency tracking
|
||||||
freqThreshold int // Threshold for triggering update (Hz)
|
freqThreshold int // Threshold for triggering update (Hz)
|
||||||
autoTrackEnabled bool
|
autoTrackEnabled bool
|
||||||
ultrabeamDirection int // User-selected direction (0=normal, 1=180, 2=bi-dir)
|
ultrabeamDirection int // User-selected direction (0=normal, 1=180, 2=bi-dir)
|
||||||
lastFreqUpdateTime time.Time // Last time we sent frequency update
|
ultrabeamDirectionSet bool // True if user has explicitly set a direction
|
||||||
freqUpdateCooldown time.Duration // Minimum time between updates
|
lastFreqUpdateTime time.Time // Last time we sent frequency update
|
||||||
|
freqUpdateCooldown time.Duration // Minimum time between updates
|
||||||
}
|
}
|
||||||
|
|
||||||
type SystemStatus struct {
|
type SystemStatus struct {
|
||||||
@@ -244,9 +245,9 @@ func (dm *DeviceManager) updateStatus() {
|
|||||||
if ubStatus, err := dm.ultrabeam.GetStatus(); err == nil {
|
if ubStatus, err := dm.ultrabeam.GetStatus(); err == nil {
|
||||||
status.Ultrabeam = ubStatus
|
status.Ultrabeam = ubStatus
|
||||||
|
|
||||||
// Sync direction with Ultrabeam if not yet set (first time or after restart)
|
// Sync direction with Ultrabeam if user hasn't explicitly set one
|
||||||
// This prevents auto-track from using wrong direction before user changes it
|
// This prevents auto-track from using wrong direction before user changes it
|
||||||
if dm.ultrabeamDirection == 0 && ubStatus.Direction != 0 {
|
if !dm.ultrabeamDirectionSet {
|
||||||
dm.ultrabeamDirection = ubStatus.Direction
|
dm.ultrabeamDirection = ubStatus.Direction
|
||||||
log.Printf("Auto-track: Initialized direction from Ultrabeam: %d", dm.ultrabeamDirection)
|
log.Printf("Auto-track: Initialized direction from Ultrabeam: %d", dm.ultrabeamDirection)
|
||||||
}
|
}
|
||||||
@@ -281,9 +282,9 @@ func (dm *DeviceManager) updateStatus() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if freqDiffHz >= dm.freqThreshold {
|
if freqDiffHz >= dm.freqThreshold {
|
||||||
// Use current Ultrabeam direction if user hasn't explicitly set one
|
// Use user's explicitly set direction, or fallback to current Ultrabeam direction
|
||||||
directionToUse := dm.ultrabeamDirection
|
directionToUse := dm.ultrabeamDirection
|
||||||
if directionToUse == 0 && status.Ultrabeam.Direction != 0 {
|
if !dm.ultrabeamDirectionSet && status.Ultrabeam.Direction != 0 {
|
||||||
directionToUse = status.Ultrabeam.Direction
|
directionToUse = status.Ultrabeam.Direction
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,5 +376,6 @@ func (dm *DeviceManager) SetAutoTrack(enabled bool, thresholdHz int) {
|
|||||||
|
|
||||||
func (dm *DeviceManager) SetUltrabeamDirection(direction int) {
|
func (dm *DeviceManager) SetUltrabeamDirection(direction int) {
|
||||||
dm.ultrabeamDirection = direction
|
dm.ultrabeamDirection = direction
|
||||||
log.Printf("Ultrabeam direction set to: %d", direction)
|
dm.ultrabeamDirectionSet = true // Mark that user has explicitly set direction
|
||||||
|
log.Printf("Ultrabeam direction set to: %d (user choice)", direction)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user