feat: Adding XIT RIT in the Flex panel

This commit is contained in:
2026-07-14 23:54:06 +02:00
parent 9718b8a78f
commit 9e2ffdb758
8 changed files with 198 additions and 2 deletions
+11
View File
@@ -304,6 +304,13 @@ type FlexTXState struct {
ANFLevel int `json:"anf_level"`
WNB bool `json:"wnb"`
WNBLevel int `json:"wnb_level"`
// RIT/XIT — offsets applied to the active slice's RX / TX frequency without
// moving the slice. The offset survives the switch being turned off, so
// re-enabling restores it, exactly like the radio's own knob.
RIT bool `json:"rit"`
RITFreq int `json:"rit_freq"`
XIT bool `json:"xit"`
XITFreq int `json:"xit_freq"`
// CW / mode-specific controls.
Mode string `json:"mode,omitempty"` // active slice mode (CW/USB/LSB/DIGU…)
CWSpeed int `json:"cw_speed"`
@@ -378,6 +385,10 @@ type FlexController interface {
SetAPFLevel(int) error
SetWNB(bool) error
SetWNBLevel(int) error
SetRIT(bool) error
SetRITFreq(int) error
SetXIT(bool) error
SetXITFreq(int) error
// CW keyer + mode-specific controls.
SetCWSpeed(int) error
SetCWPitch(int) error
+46 -2
View File
@@ -90,8 +90,12 @@ type flexSlice struct {
apfLevel int
wnb bool // wideband noise blanker
wnbLevel int
filterLo int // slice filter low cut (Hz)
filterHi int // slice filter high cut (Hz)
rit bool // receive incremental tuning enabled
ritFreq int // RIT offset in Hz (negative = down)
xit bool // transmit incremental tuning enabled
xitFreq int // XIT offset in Hz
filterLo int // slice filter low cut (Hz)
filterHi int // slice filter high cut (Hz)
rxAnt string // selected RX antenna (e.g. ANT1, ANT2, RX_A)
txAnt string // selected TX antenna
antList []string // antennas valid for this slice (RX side)
@@ -804,6 +808,14 @@ func (f *Flex) handleStatus(payload string) {
s.wnb = val == "1"
case "wnb_level":
s.wnbLevel = atoiDefault(val, s.wnbLevel)
case "rit_on":
s.rit = val == "1"
case "rit_freq":
s.ritFreq = atoiDefault(val, s.ritFreq)
case "xit_on":
s.xit = val == "1"
case "xit_freq":
s.xitFreq = atoiDefault(val, s.xitFreq)
case "filter_lo":
s.filterLo = atoiDefault(val, s.filterLo)
case "filter_hi":
@@ -1315,6 +1327,10 @@ func (f *Flex) FlexState() FlexTXState {
st.APFLevel = rx.apfLevel
st.WNB = rx.wnb
st.WNBLevel = rx.wnbLevel
st.RIT = rx.rit
st.RITFreq = rx.ritFreq
st.XIT = rx.xit
st.XITFreq = rx.xitFreq
st.FilterLo = rx.filterLo
st.FilterHi = rx.filterHi
st.RXAnt = rx.rxAnt
@@ -1383,6 +1399,14 @@ func (f *Flex) sendSlice(param string, val any) error {
rx.rxAnt = fmt.Sprint(val)
case "txant":
rx.txAnt = fmt.Sprint(val)
case "rit_on":
rx.rit = val == "1"
case "rit_freq":
rx.ritFreq = toInt(val)
case "xit_on":
rx.xit = val == "1"
case "xit_freq":
rx.xitFreq = toInt(val)
}
}
f.mu.Unlock()
@@ -1490,6 +1514,26 @@ func (f *Flex) SetNR(on bool) error { return f.sendSlice("nr", boolFlex(on))
func (f *Flex) SetNRLevel(l int) error { return f.sendSlice("nr_level", clampLevel(l)) }
func (f *Flex) SetANF(on bool) error { return f.sendSlice("anf", boolFlex(on)) }
func (f *Flex) SetANFLevel(l int) error { return f.sendSlice("anf_level", clampLevel(l)) }
// RIT/XIT — an offset applied to the RX (RIT) or TX (XIT) frequency of the active
// slice, without moving the slice itself. SmartSDR keeps the offset even while the
// switch is off, so turning RIT back on restores the last offset — same as the
// radio's own knob.
func (f *Flex) SetRIT(on bool) error { return f.sendSlice("rit_on", boolFlex(on)) }
func (f *Flex) SetRITFreq(hz int) error { return f.sendSlice("rit_freq", clampOffset(hz)) }
func (f *Flex) SetXIT(on bool) error { return f.sendSlice("xit_on", boolFlex(on)) }
func (f *Flex) SetXITFreq(hz int) error { return f.sendSlice("xit_freq", clampOffset(hz)) }
// clampOffset keeps a RIT/XIT offset inside what SmartSDR accepts (±99 999 Hz).
func clampOffset(hz int) int {
if hz > 99999 {
return 99999
}
if hz < -99999 {
return -99999
}
return hz
}
func (f *Flex) SetAPF(on bool) error { return f.sendSlice("apf", boolFlex(on)) }
func (f *Flex) SetAPFLevel(l int) error { return f.sendSlice("apf_level", clampLevel(l)) }
func (f *Flex) SetWNB(on bool) error { return f.sendSlice("wnb", boolFlex(on)) }