mirror of
https://github.com/nonoo/kappanhang.git
synced 2025-12-06 08:02:00 +01:00
Add PTT and tune timeouts
This commit is contained in:
parent
01a6142232
commit
21eee30078
|
|
@ -10,6 +10,8 @@ import (
|
||||||
const civAddress = 0xa4
|
const civAddress = 0xa4
|
||||||
const statusPollInterval = time.Second
|
const statusPollInterval = time.Second
|
||||||
const commandRetryTimeout = 500 * time.Millisecond
|
const commandRetryTimeout = 500 * time.Millisecond
|
||||||
|
const pttTimeout = 3 * time.Minute
|
||||||
|
const tuneTimeout = 30 * time.Second
|
||||||
|
|
||||||
// Commands reference: https://www.icomeurope.com/wp-content/uploads/2020/08/IC-705_ENG_CI-V_1_20200721.pdf
|
// Commands reference: https://www.icomeurope.com/wp-content/uploads/2020/08/IC-705_ENG_CI-V_1_20200721.pdf
|
||||||
|
|
||||||
|
|
@ -132,6 +134,9 @@ type civControlStruct struct {
|
||||||
setVFO civCmd
|
setVFO civCmd
|
||||||
setSplit civCmd
|
setSplit civCmd
|
||||||
|
|
||||||
|
pttTimeoutTimer *time.Timer
|
||||||
|
tuneTimeoutTimer *time.Timer
|
||||||
|
|
||||||
freq uint
|
freq uint
|
||||||
ptt bool
|
ptt bool
|
||||||
tune bool
|
tune bool
|
||||||
|
|
@ -508,6 +513,7 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) bool {
|
||||||
} else {
|
} else {
|
||||||
if s.state.ptt { // PTT released?
|
if s.state.ptt { // PTT released?
|
||||||
s.state.ptt = false
|
s.state.ptt = false
|
||||||
|
s.state.pttTimeoutTimer.Stop()
|
||||||
_ = s.getVd()
|
_ = s.getVd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -527,6 +533,7 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) bool {
|
||||||
} else {
|
} else {
|
||||||
if s.state.tune { // Tune finished?
|
if s.state.tune { // Tune finished?
|
||||||
s.state.tune = false
|
s.state.tune = false
|
||||||
|
s.state.tuneTimeoutTimer.Stop()
|
||||||
_ = s.getVd()
|
_ = s.getVd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -885,19 +892,25 @@ func (s *civControlStruct) setPTT(enable bool) error {
|
||||||
var b byte
|
var b byte
|
||||||
if enable {
|
if enable {
|
||||||
b = 1
|
b = 1
|
||||||
|
s.state.pttTimeoutTimer = time.AfterFunc(pttTimeout, func() {
|
||||||
|
_ = s.setPTT(false)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
s.initCmd(&s.state.setPTT, "setPTT", []byte{254, 254, civAddress, 224, 0x1c, 0, b, 253})
|
s.initCmd(&s.state.setPTT, "setPTT", []byte{254, 254, civAddress, 224, 0x1c, 0, b, 253})
|
||||||
return s.sendCmd(&s.state.setPTT)
|
return s.sendCmd(&s.state.setPTT)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *civControlStruct) toggleTune() error {
|
func (s *civControlStruct) setTune(enable bool) error {
|
||||||
if s.state.ptt {
|
if s.state.ptt {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var b byte
|
var b byte
|
||||||
if !s.state.tune {
|
if enable {
|
||||||
b = 2
|
b = 2
|
||||||
|
s.state.tuneTimeoutTimer = time.AfterFunc(tuneTimeout, func() {
|
||||||
|
_ = s.setTune(false)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
b = 1
|
b = 1
|
||||||
}
|
}
|
||||||
|
|
@ -905,6 +918,10 @@ func (s *civControlStruct) toggleTune() error {
|
||||||
return s.sendCmd(&s.state.setTune)
|
return s.sendCmd(&s.state.setTune)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *civControlStruct) toggleTune() error {
|
||||||
|
return s.setTune(!s.state.tune)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *civControlStruct) setDataMode(enable bool) error {
|
func (s *civControlStruct) setDataMode(enable bool) error {
|
||||||
var b byte
|
var b byte
|
||||||
var f byte
|
var f byte
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue