Improve radio status bar

This commit is contained in:
2026-05-21 15:19:43 +03:00
parent 343735389e
commit 5800e9ec35
2 changed files with 262 additions and 102 deletions
+19 -1
View File
@@ -392,6 +392,12 @@ function PhaseWordToFreq(PhaseWord: LongWord): Double;
// Returns -1.0 if the board has no supply voltage measurement.
function ADCToSupplyVolts(RawADC: Word; BoardType: Integer): Double;
// True when the board type reports supply voltage in HP Status.
function BoardSupportsSupplyVoltage(BoardType: Integer): Boolean;
// True when the board type reports supply current in HP Status.
function BoardSupportsSupplyCurrent(BoardType: Integer): Boolean;
// Convert raw ADC value to supply current in Amps (Board 5 / Orion MkII only)
// Uses UserADC1 (bytes 55-56). Returns -1 for unsupported boards.
function ADCToSupplyCurrent(RawADC: Word; BoardType: Integer): Double;
@@ -448,16 +454,28 @@ begin
// The PCB voltage divider (from Thetis source) must also be applied.
// Board 0 (Atlas): no supply voltage measurement.
// Boards 1,2,3 (Hermes/Angelia): Vref=3.3V, PCB divider R1=4.7kΩ/R2=0.82kΩ.
// Board 4 (Orion): protocol reports supply voltage with a 5.0V constant.
// Board 5 (Orion MkII): Vref=5.0V, PCB divider R1=22kΩ/R2=1.1kΩ.
// NOTE: for board 5 caller must pass UserADC0, not supply_volts bytes.
// Board 4 (Orion) and others: not available (return -1).
// Other boards: not available (return -1).
case BoardType of
1, 2, 3: Result := (RawADC / 4095.0) * 3.3 * ((4.7 + 0.82) / 0.82);
4: Result := (RawADC / 4095.0) * 5.0;
5: Result := (RawADC / 4095.0) * 5.0 * ((22.0 + 1.0) / 1.1);
else Result := -1.0;
end;
end;
function BoardSupportsSupplyVoltage(BoardType: Integer): Boolean;
begin
Result := BoardType in [1, 2, 3, 4, 5];
end;
function BoardSupportsSupplyCurrent(BoardType: Integer): Boolean;
begin
Result := BoardType = 5;
end;
function ADCToSupplyCurrent(RawADC: Word; BoardType: Integer): Double;
begin
// Board 5 (Orion MkII): UserADC1, Vref=5V → mV = adc/4095*5000.