mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-04-21 06:13:43 +00:00
Move S value calculation
This commit is contained in:
parent
9087140130
commit
3c331eac47
2 changed files with 18 additions and 16 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -243,7 +244,21 @@ func (s *civControlStruct) decodeVdAndS(d []byte) {
|
||||||
|
|
||||||
switch d[0] {
|
switch d[0] {
|
||||||
case 0x02:
|
case 0x02:
|
||||||
statusLog.reportS(int(math.Round(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 18)))
|
sValue := (int(math.Round(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 18)))
|
||||||
|
sStr := "S"
|
||||||
|
if sValue <= 9 {
|
||||||
|
sStr += fmt.Sprint(sValue)
|
||||||
|
} else {
|
||||||
|
sStr += "9+"
|
||||||
|
|
||||||
|
if sValue > 18 {
|
||||||
|
sStr += "60"
|
||||||
|
} else {
|
||||||
|
dB := (float64((sValue - 9)) / 9) * 60
|
||||||
|
sStr += fmt.Sprint(int(math.Round(dB/10) * 10))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statusLog.reportS(sStr)
|
||||||
case 0x15:
|
case 0x15:
|
||||||
statusLog.reportVd(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16)
|
statusLog.reportVd(((float64(int(d[1])<<8) + float64(d[2])) / 0x0241) * 16)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
statuslog.go
17
statuslog.go
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -157,26 +156,14 @@ func (s *statusLogStruct) reportVd(voltage float64) {
|
||||||
s.data.vd = fmt.Sprintf("%.1fV", voltage)
|
s.data.vd = fmt.Sprintf("%.1fV", voltage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusLogStruct) reportS(sValue int) {
|
func (s *statusLogStruct) reportS(sValue string) {
|
||||||
s.mutex.Lock()
|
s.mutex.Lock()
|
||||||
defer s.mutex.Unlock()
|
defer s.mutex.Unlock()
|
||||||
|
|
||||||
if s.data == nil {
|
if s.data == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.data.s = "S"
|
s.data.s = sValue
|
||||||
if sValue <= 9 {
|
|
||||||
s.data.s += fmt.Sprint(sValue)
|
|
||||||
} else {
|
|
||||||
s.data.s += "9+"
|
|
||||||
|
|
||||||
if sValue > 18 {
|
|
||||||
s.data.s += "60"
|
|
||||||
} else {
|
|
||||||
dB := (float64((sValue - 9)) / 9) * 60
|
|
||||||
s.data.s += fmt.Sprint(int(math.Round(dB/10) * 10))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *statusLogStruct) reportPTT(ptt, tune bool) {
|
func (s *statusLogStruct) reportPTT(ptt, tune bool) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue