fix: Ultrabeam was not synchronizing after click on a spot.

This commit is contained in:
2026-07-07 21:54:53 +02:00
parent 2c47c5d052
commit b9b005ea36
5 changed files with 62 additions and 4 deletions
+45
View File
@@ -7762,9 +7762,54 @@ func (a *App) SetCATFrequency(hz int64) error {
if err != nil {
applog.Printf("cat: SetFrequency(%d Hz) dispatch error: %v", hz, err)
}
// Re-tune the Ultrabeam right away on a DELIBERATE freq set (spot click, band
// button, memory recall) instead of waiting for the ~1.5 s follow poll + the
// CAT echo — the reason it used to only follow after you nudged the VFO.
go a.ultrabeamFollowNow(hz)
return err
}
// ultrabeamFollowNow re-tunes the Ultrabeam to freqHz at once (best-effort),
// honouring the same enabled/follow/in-range/step-deadband rules as the follow
// loop. Called from SetCATFrequency so a spot click moves the antenna instantly.
func (a *App) ultrabeamFollowNow(freqHz int64) {
c := a.ultrabeam
if c == nil || freqHz <= 0 {
return
}
s, err := a.GetUltrabeamSettings()
if err != nil || !s.Enabled || !s.Follow {
return
}
step := s.StepKHz
if step <= 0 {
step = 50
}
st, err := c.GetStatus()
if err != nil || st == nil || !st.Connected {
return
}
if st.FreqMin > 0 && st.FreqMax > 0 {
mhz := freqHz / 1_000_000
if mhz < int64(st.FreqMin) || mhz > int64(st.FreqMax) {
return // outside the antenna's tunable range
}
}
khz := int(freqHz / 1000)
diff := khz - st.Frequency
if diff < 0 {
diff = -diff
}
if st.Frequency > 0 && diff < step {
return // within the deadband — don't chase a tiny QSY
}
if err := c.SetFrequency(khz, st.Direction); err != nil {
applog.Printf("ultrabeam: immediate re-tune to %d kHz failed: %v", khz, err)
} else {
applog.Printf("ultrabeam: re-tuned on freq set → %d kHz (dir %d)", khz, st.Direction)
}
}
// SetCATMode sets the rig's mode. ADIF mode names (SSB / CW / FT8 / …) are
// translated to backend-specific values by the backend itself.
func (a *App) SetCATMode(mode string) error {