Immediately display non-sent changes to CIV params to reduce apparent latency

This commit is contained in:
Nonoo 2020-11-06 10:20:00 +01:00
parent 286d213896
commit 07e85abf0e

View file

@ -534,6 +534,9 @@ func (s *civControlStruct) decodePreampAGCNR(d []byte) bool {
}
func (s *civControlStruct) setPwr(percent int) error {
s.state.pwrPercent = percent
statusLog.reportTxPower(s.state.pwrPercent)
s.state.setPwrSent = true
v := uint16(0x0255 * (float64(percent) / 100))
return s.st.send([]byte{254, 254, civAddress, 224, 0x14, 0x0a, byte(v >> 8), byte(v & 0xff), 253})
@ -554,6 +557,9 @@ func (s *civControlStruct) decPwr() error {
}
func (s *civControlStruct) setRFGain(percent int) error {
s.state.rfGainPercent = percent
statusLog.reportRFGain(s.state.rfGainPercent)
s.state.setRFGainSent = true
v := uint16(0x0255 * (float64(percent) / 100))
return s.st.send([]byte{254, 254, civAddress, 224, 0x14, 0x02, byte(v >> 8), byte(v & 0xff), 253})
@ -574,6 +580,9 @@ func (s *civControlStruct) decRFGain() error {
}
func (s *civControlStruct) setSQL(percent int) error {
s.state.sqlPercent = percent
statusLog.reportSQL(s.state.sqlPercent)
s.state.setSQLSent = true
v := uint16(0x0255 * (float64(percent) / 100))
return s.st.send([]byte{254, 254, civAddress, 224, 0x14, 0x03, byte(v >> 8), byte(v & 0xff), 253})
@ -594,6 +603,9 @@ func (s *civControlStruct) decSQL() error {
}
func (s *civControlStruct) setNR(percent int) error {
s.state.nrPercent = percent
statusLog.reportNR(s.state.nrPercent)
if !s.state.nrEnabled {
if err := s.toggleNR(); err != nil {
return err
@ -636,6 +648,9 @@ func (s *civControlStruct) decFreq() error {
}
func (s *civControlStruct) setFreq(f uint) error {
s.state.freq = f
statusLog.reportFrequency(s.state.freq)
s.state.setFreqSent = true
var b [5]byte
v0 := s.getDigit(f, 9)