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;