mirror of
https://github.com/nonoo/kappanhang.git
synced 2025-12-06 08:02:00 +01:00
Read and display Vd voltage
This commit is contained in:
parent
8422814eb0
commit
7ce8b9e347
|
|
@ -87,7 +87,7 @@ is up) with the following info:
|
|||
- First status bar line:
|
||||
- `state`: RX/TX/TUNE depending on the PTT status
|
||||
- `freq`: operating frequency in MHz, mode (LSB/USB/FM...), active filter,
|
||||
preamp (PAMP0 means the preamp is off)
|
||||
preamp (PAMP0 means the preamp is off), Vd voltage
|
||||
- `txpwr`: current transmit power setting in percent
|
||||
- `audiomon`: current status of the audio monitor (see the *Hotkeys* section
|
||||
in this README for more information about this feature)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
)
|
||||
|
||||
const civAddress = 0xa4
|
||||
const vdReadInterval = time.Minute
|
||||
|
||||
type civOperatingMode struct {
|
||||
name string
|
||||
|
|
@ -61,7 +62,8 @@ var civBands = []civBand{
|
|||
}
|
||||
|
||||
type civControlStruct struct {
|
||||
st *serialStream
|
||||
st *serialStream
|
||||
vdReadTimer *time.Timer
|
||||
|
||||
state struct {
|
||||
freq uint
|
||||
|
|
@ -101,6 +103,8 @@ func (s *civControlStruct) decode(d []byte) {
|
|||
s.decodePower(payload)
|
||||
case 0x1c:
|
||||
s.decodeTransmitStatus(payload)
|
||||
case 0x15:
|
||||
s.decodeVd(payload)
|
||||
case 0x16:
|
||||
s.decodePreamp(payload)
|
||||
}
|
||||
|
|
@ -224,6 +228,23 @@ func (s *civControlStruct) decodeTransmitStatus(d []byte) {
|
|||
statusLog.reportPTT(s.state.ptt, s.state.tune)
|
||||
}
|
||||
|
||||
func (s *civControlStruct) decodeVd(d []byte) {
|
||||
if len(d) < 2 {
|
||||
return
|
||||
}
|
||||
|
||||
switch d[0] {
|
||||
case 0x15:
|
||||
if len(d) < 3 {
|
||||
return
|
||||
}
|
||||
statusLog.reportVd(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16)
|
||||
s.vdReadTimer = time.AfterFunc(vdReadInterval, func() {
|
||||
_ = s.getVd()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (s *civControlStruct) decodePreamp(d []byte) {
|
||||
if len(d) < 2 {
|
||||
return
|
||||
|
|
@ -427,6 +448,10 @@ func (s *civControlStruct) getTransmitStatus() error {
|
|||
return s.st.send([]byte{254, 254, civAddress, 224, 0x1c, 1, 253})
|
||||
}
|
||||
|
||||
func (s *civControlStruct) getVd() error {
|
||||
return s.st.send([]byte{254, 254, civAddress, 224, 0x15, 0x15, 253})
|
||||
}
|
||||
|
||||
func (s *civControlStruct) init(st *serialStream) error {
|
||||
s.st = st
|
||||
|
||||
|
|
@ -450,5 +475,15 @@ func (s *civControlStruct) init(st *serialStream) error {
|
|||
if err := s.st.send([]byte{254, 254, civAddress, 224, 0x16, 0x02, 253}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.getVd(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *civControlStruct) deinit(st *serialStream) {
|
||||
if s.vdReadTimer != nil {
|
||||
s.vdReadTimer.Stop()
|
||||
s.vdReadTimer = nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -270,6 +270,9 @@ func (s *serialStream) deinit() {
|
|||
s.deinitNeededChan <- true
|
||||
<-s.deinitFinishedChan
|
||||
}
|
||||
if civControl != nil {
|
||||
civControl.deinit()
|
||||
}
|
||||
civControl = nil
|
||||
s.common.deinit()
|
||||
s.rxSeqBuf.deinit()
|
||||
|
|
|
|||
17
statuslog.go
17
statuslog.go
|
|
@ -20,6 +20,7 @@ type statusLogData struct {
|
|||
dataMode string
|
||||
filter string
|
||||
preamp string
|
||||
vd string
|
||||
txPowerStr string
|
||||
|
||||
startTime time.Time
|
||||
|
|
@ -144,6 +145,16 @@ func (s *statusLogStruct) reportPreamp(preamp int) {
|
|||
s.data.preamp = fmt.Sprint("PAMP", preamp)
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportVd(voltage float64) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
return
|
||||
}
|
||||
s.data.vd = fmt.Sprintf("%.1fV", voltage)
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportPTT(ptt, tune bool) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
|
@ -214,12 +225,16 @@ func (s *statusLogStruct) update() {
|
|||
if s.data.preamp != "" {
|
||||
preampStr = " " + s.data.preamp
|
||||
}
|
||||
var vdStr string
|
||||
if s.data.vd != "" {
|
||||
vdStr = " " + s.data.vd
|
||||
}
|
||||
var txPowerStr string
|
||||
if s.data.txPowerStr != "" {
|
||||
txPowerStr = " txpwr " + s.data.txPowerStr
|
||||
}
|
||||
s.data.line1 = fmt.Sprint("state ", s.data.stateStr, " freq: ", fmt.Sprintf("%.6f", float64(s.data.frequency)/1000000),
|
||||
modeStr, filterStr, preampStr, txPowerStr, " audio ", s.data.audioStateStr)
|
||||
modeStr, filterStr, preampStr, vdStr, txPowerStr, " audio ", s.data.audioStateStr)
|
||||
|
||||
up, down, lost, retransmits := netstat.get()
|
||||
lostStr := "0"
|
||||
|
|
|
|||
Loading…
Reference in a new issue