Fix supply voltage display: correct constant per board type, hide on unsupported boards

Per Appendix A of openHPSDR Ethernet Protocol v4.3:
- Boards 1,2,3 (Hermes/Angelia): V = ADC/4095 * 3.3 (was always using this)
- Boards 4,5 (Orion/Orion MkII): V = ADC/4095 * 5.0 (was wrong, showing ~66% of real value)
- Board 0 (Atlas) has no supply voltage measurement per protocol spec
  ("not Atlas bus systems")
- Boards 6 (Hermes Lite), 10 (Saturn): constant not documented, hide Supply field

ADCToSupplyVolts now takes BoardType and returns -1.0 for unsupported boards.
DoUpdateStatus omits the Supply field when -1.0 is returned.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 22:06:27 +03:00
co-authored by Claude Sonnet 4.6
parent 0b4a13d444
commit cd0cf21876
2 changed files with 22 additions and 9 deletions
+12 -5
View File
@@ -388,8 +388,9 @@ function FreqToPhaseWord(FreqHz: Double): LongWord;
// Convert phase word back to frequency
function PhaseWordToFreq(PhaseWord: LongWord): Double;
// Convert raw ADC value to supply voltage
function ADCToSupplyVolts(RawADC: Word): Double;
// Convert raw ADC value to supply voltage.
// Returns -1.0 if the board has no supply voltage measurement.
function ADCToSupplyVolts(RawADC: Word; BoardType: Integer): Double;
// Convert raw ADC value to RF power in Watts (ANAN-100)
function ADCToWatts100(RawADC: Word): Double;
@@ -437,10 +438,16 @@ begin
Result := PhaseWord * DSP_CLOCK_HZ / 4294967296.0;
end;
function ADCToSupplyVolts(RawADC: Word): Double;
function ADCToSupplyVolts(RawADC: Word; BoardType: Integer): Double;
begin
// V = ADC / 4095 * 3.3
Result := (RawADC / 4095.0) * 3.3;
// Board 0 (Atlas) has no supply voltage measurement (protocol: "not Atlas bus systems")
// Boards 1,2,3 (Hermes/Angelia): V = ADC/4095 * 3.3 (Appendix A)
// Boards 4,5 (Orion): V = ADC/4095 * 5.0 (Appendix A)
case BoardType of
1, 2, 3: Result := (RawADC / 4095.0) * 3.3;
4, 5: Result := (RawADC / 4095.0) * 5.0;
else Result := -1.0; // not documented or not applicable
end;
end;
function ADCToWatts100(RawADC: Word): Double;
+8 -2
View File
@@ -2291,7 +2291,8 @@ begin
ExcPwr := (Status.ExciterPwr0Hi shl 8) or Status.ExciterPwr0Lo;
FwdPwr := (Status.FwdPwrAlex0Hi shl 8) or Status.FwdPwrAlex0Lo;
RevPwr := (Status.RevPwrAlex0Hi shl 8) or Status.RevPwrAlex0Lo;
SupplyV := ADCToSupplyVolts((Status.SupplyVoltsHi shl 8) or Status.SupplyVoltsLo);
SupplyV := ADCToSupplyVolts((Status.SupplyVoltsHi shl 8) or Status.SupplyVoltsLo,
FNetwork.Device.BoardType);
// FLastSMeter обновляется только из WDSP (GetSMeterDBm) в SpectrumTimerTick —
// ExciterPwr это мощность TX, не уровень принятого сигнала.
FwdW := ADCToWatts100(FwdPwr);
@@ -2319,9 +2320,14 @@ begin
LblFwdPwr.Caption := Format('%.0fW', [FwdW]);
LblSWRVal.Caption := Format('SWR:%.1f', [SWRV]);
if PLLLock then PLLStr := 'PLL OK' else PLLStr := 'PLL?';
if SupplyV >= 0 then
StatusBar1.Panels[2].Text :=
Format('Supply: %.1fV | FWD: %.0fW | SWR: %.1f | %s',
[SupplyV, FwdW, SWRV, PLLStr]);
[SupplyV, FwdW, SWRV, PLLStr])
else
StatusBar1.Panels[2].Text :=
Format('FWD: %.0fW | SWR: %.1f | %s',
[FwdW, SWRV, PLLStr]);
// Hardware PTT (foot switch / mic PTT) — обнаружение фронта
if HWPTT <> FHWPTTActive then