mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-02-18 21:44:14 +01:00
Add SWR display
This commit is contained in:
parent
4ce3ba8b26
commit
5ca603d108
|
|
@ -90,6 +90,8 @@ is up) with the following info:
|
|||
- `rfg`: RF gain in percent
|
||||
- `sql`: squelch level in percent
|
||||
- `nr`: noise reduction level in percent
|
||||
- `audio`: current status of the audio monitor (see the *Hotkeys* section
|
||||
in this README for more information about this feature)
|
||||
|
||||
- Second status bar line:
|
||||
- `state`: RX/TX/TUNE depending on the PTT status
|
||||
|
|
@ -100,8 +102,7 @@ is up) with the following info:
|
|||
- `preamp`: PAMP0 means the preamp is off
|
||||
- `voltage`: Vd voltage, updated when a TX/TUNE is over
|
||||
- `txpwr`: current transmit power setting in percent
|
||||
- `audio`: current status of the audio monitor (see the *Hotkeys* section
|
||||
in this README for more information about this feature)
|
||||
- `swr`: reported SWR, it seems that the Icom IC-705 always reports 0.0
|
||||
|
||||
- Third status bar line:
|
||||
- `up`: how long the audio/serial connection is active
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ type civControlStruct struct {
|
|||
state struct {
|
||||
getSSent bool
|
||||
getOVFSent bool
|
||||
getSWRSent bool
|
||||
|
||||
freq uint
|
||||
ptt bool
|
||||
|
|
@ -119,7 +120,7 @@ func (s *civControlStruct) decode(d []byte) bool {
|
|||
case 0x1c:
|
||||
s.decodeTransmitStatus(payload)
|
||||
case 0x15:
|
||||
return s.decodeVdAndS(payload)
|
||||
return s.decodeVdSWRS(payload)
|
||||
case 0x16:
|
||||
s.decodePreampAndNR(payload)
|
||||
}
|
||||
|
|
@ -324,7 +325,7 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
|
|||
statusLog.reportPTT(s.state.ptt, s.state.tune)
|
||||
}
|
||||
|
||||
func (s *civControlStruct) decodeVdAndS(d []byte) bool {
|
||||
func (s *civControlStruct) decodeVdSWRS(d []byte) bool {
|
||||
if len(d) < 1 {
|
||||
return true
|
||||
}
|
||||
|
|
@ -369,6 +370,15 @@ func (s *civControlStruct) decodeVdAndS(d []byte) bool {
|
|||
s.state.getSSent = false
|
||||
return false
|
||||
}
|
||||
case 0x12:
|
||||
if len(d) < 3 {
|
||||
return !s.state.getSWRSent
|
||||
}
|
||||
statusLog.reportSWR(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16)
|
||||
if s.state.getSWRSent {
|
||||
s.state.getSWRSent = false
|
||||
return false
|
||||
}
|
||||
case 0x15:
|
||||
if len(d) < 3 {
|
||||
return true
|
||||
|
|
@ -687,6 +697,11 @@ func (s *civControlStruct) getOVF() error {
|
|||
return s.st.send([]byte{254, 254, civAddress, 224, 0x1a, 0x09, 253})
|
||||
}
|
||||
|
||||
func (s *civControlStruct) getSWR() error {
|
||||
s.state.getSWRSent = true
|
||||
return s.st.send([]byte{254, 254, civAddress, 224, 0x15, 0x12, 253})
|
||||
}
|
||||
|
||||
func (s *civControlStruct) getTS() error {
|
||||
return s.st.send([]byte{254, 254, civAddress, 224, 0x10, 253})
|
||||
}
|
||||
|
|
@ -716,6 +731,7 @@ func (s *civControlStruct) loop() {
|
|||
case <-time.After(sReadInterval):
|
||||
_ = s.getS()
|
||||
_ = s.getOVF()
|
||||
_ = s.getSWR()
|
||||
case <-s.resetSReadTimer:
|
||||
}
|
||||
}
|
||||
|
|
@ -753,6 +769,9 @@ func (s *civControlStruct) init(st *serialStream) error {
|
|||
if err := s.getOVF(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.getSWR(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.getTS(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
19
statuslog.go
19
statuslog.go
|
|
@ -29,6 +29,7 @@ type statusLogData struct {
|
|||
nrEnabled bool
|
||||
s string
|
||||
ovf bool
|
||||
swr string
|
||||
ts string
|
||||
|
||||
startTime time.Time
|
||||
|
|
@ -195,6 +196,16 @@ func (s *statusLogStruct) reportOVF(ovf bool) {
|
|||
s.data.ovf = ovf
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportSWR(swr float64) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
return
|
||||
}
|
||||
s.data.swr = fmt.Sprintf("%.1f", swr)
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportTS(ts uint) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
|
@ -327,7 +338,7 @@ func (s *statusLogStruct) update() {
|
|||
nrStr += "-"
|
||||
}
|
||||
}
|
||||
s.data.line1 = fmt.Sprint(s.data.s, ovfStr, rfGainStr, sqlStr, nrStr)
|
||||
s.data.line1 = fmt.Sprint(s.data.s, ovfStr, rfGainStr, sqlStr, nrStr, " audio ", s.data.audioStateStr)
|
||||
|
||||
var tsStr string
|
||||
if s.data.ts != "" {
|
||||
|
|
@ -353,8 +364,12 @@ func (s *statusLogStruct) update() {
|
|||
if s.data.txPower != "" {
|
||||
txPowerStr = " txpwr " + s.data.txPower
|
||||
}
|
||||
var swrStr string
|
||||
if s.data.swr != "" {
|
||||
swrStr = " swr " + s.data.swr
|
||||
}
|
||||
s.data.line2 = fmt.Sprint(s.data.stateStr, " ", fmt.Sprintf("%.6f", float64(s.data.frequency)/1000000),
|
||||
tsStr, modeStr, filterStr, preampStr, vdStr, txPowerStr, " audio ", s.data.audioStateStr)
|
||||
tsStr, modeStr, filterStr, preampStr, vdStr, txPowerStr, swrStr)
|
||||
|
||||
up, down, lost, retransmits := netstat.get()
|
||||
lostStr := "0"
|
||||
|
|
|
|||
Loading…
Reference in a new issue