Add hotkey for switching between VFO A/B

This commit is contained in:
Nonoo 2020-11-07 16:25:31 +01:00
parent 6c0135ed30
commit 0efe58b892
3 changed files with 43 additions and 0 deletions

View file

@ -160,6 +160,7 @@ Some basic CAT control hotkeys are also supported:
- `v`, `b`: cycles through bands
- `p`: toggles preamp
- `a`: toggles AGC
- `o`: toggles VFO A/B
## Icom IC-705 Wi-Fi notes

View file

@ -97,6 +97,7 @@ type civControlStruct struct {
setAGCSent bool
setNREnabledSent bool
setTSSent bool
setVFOSent bool
freq uint
ptt bool
@ -115,6 +116,7 @@ type civControlStruct struct {
agc int
tsValue byte
ts uint
vfoBActive bool
}
}
@ -141,6 +143,8 @@ func (s *civControlStruct) decode(d []byte) bool {
return s.decodeFreq(payload)
case 0x06:
return s.decodeMode(payload)
case 0x07:
return s.decodeVFO(payload)
case 0x10:
return s.decodeTS(payload)
case 0x1a:
@ -237,6 +241,29 @@ func (s *civControlStruct) decodeMode(d []byte) bool {
return true
}
func (s *civControlStruct) decodeVFO(d []byte) bool {
if len(d) < 1 {
return !s.state.setVFOSent
}
if d[0] == 1 {
s.state.vfoBActive = true
log.Print("active vfo: B")
} else {
s.state.vfoBActive = false
log.Print("active vfo: A")
}
if s.state.setVFOSent {
// The radio does not send the VFO's frequency automatically.
_ = s.getFreq()
s.state.setVFOSent = false
return false
}
return true
}
func (s *civControlStruct) decodeTS(d []byte) bool {
if len(d) < 1 {
return !s.state.setTSSent
@ -820,6 +847,15 @@ func (s *civControlStruct) decTS() error {
return s.st.send([]byte{254, 254, civAddress, 224, 0x10, b, 253})
}
func (s *civControlStruct) toggleVFO() error {
s.state.setVFOSent = true
var b byte
if !s.state.vfoBActive {
b = 1
}
return s.st.send([]byte{254, 254, civAddress, 224, 0x07, b, 253})
}
func (s *civControlStruct) getFreq() error {
s.state.getFreqSent = true
return s.st.send([]byte{254, 254, civAddress, 224, 3, 253})

View file

@ -212,6 +212,12 @@ func handleHotkey(k byte) {
log.Error("can't change agc: ", err)
}
}
case 'o':
if civControl != nil {
if err := civControl.toggleVFO(); err != nil {
log.Error("can't change vfo: ", err)
}
}
case '\n':
if statusLog.isRealtime() {
statusLog.mutex.Lock()