Added getLegacyBatteryVoltage
This commit is contained in:
parent
9d5fb85474
commit
979e56e14d
|
@ -523,7 +523,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
|||
break;
|
||||
|
||||
case MSP_ANALOG:
|
||||
sbufWriteU8(dst, (uint8_t)constrain((getBatteryVoltage() + 5) / 10, 0, 255));
|
||||
sbufWriteU8(dst, (uint8_t)constrain(getLegacyBatteryVoltage(), 0, 255));
|
||||
sbufWriteU16(dst, (uint16_t)constrain(getMAhDrawn(), 0, 0xFFFF)); // milliamp hours drawn from battery
|
||||
sbufWriteU16(dst, getRssi());
|
||||
sbufWriteU16(dst, (int16_t)constrain(getAmperage(), -0x8000, 0x7FFF)); // send current in 0.01 A steps, range is -320A to 320A
|
||||
|
@ -560,7 +560,7 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
|
|||
sbufWriteU16(dst, batteryConfig()->batteryCapacity); // in mAh
|
||||
|
||||
// battery state
|
||||
sbufWriteU8(dst, (uint8_t)constrain((getBatteryVoltage() + 5) / 10, 0, 255)); // in 0.1V steps
|
||||
sbufWriteU8(dst, (uint8_t)constrain(getLegacyBatteryVoltage(), 0, 255)); // in 0.1V steps
|
||||
sbufWriteU16(dst, (uint16_t)constrain(getMAhDrawn(), 0, 0xFFFF)); // milliamp hours drawn from battery
|
||||
sbufWriteU16(dst, (int16_t)constrain(getAmperage(), -0x8000, 0x7FFF)); // send current in 0.01 A steps, range is -320A to 320A
|
||||
|
||||
|
|
|
@ -198,7 +198,7 @@ static void buildTelemetryFrame(uint8_t *packet)
|
|||
if (rxFrSkySpiConfig()->useExternalAdc) {
|
||||
a1Value = (uint8_t)((adcGetChannel(ADC_EXTERNAL1) & 0xfe0) >> 5);
|
||||
} else {
|
||||
a1Value = ((getBatteryVoltage() + 5) / 10) & 0x7f;
|
||||
a1Value = getLegacyBatteryVoltage() & 0x7f;
|
||||
}
|
||||
frame[4] = a1Value;
|
||||
}
|
||||
|
|
|
@ -480,6 +480,11 @@ uint16_t getBatteryVoltage(void)
|
|||
return voltageMeter.filtered;
|
||||
}
|
||||
|
||||
uint16_t getLegacyBatteryVoltage(void)
|
||||
{
|
||||
return (voltageMeter.filtered + 5) / 10;
|
||||
}
|
||||
|
||||
uint16_t getBatteryVoltageLatest(void)
|
||||
{
|
||||
return voltageMeter.unfiltered;
|
||||
|
|
|
@ -86,6 +86,7 @@ float calculateVbatPidCompensation(void);
|
|||
uint8_t calculateBatteryPercentageRemaining(void);
|
||||
bool isBatteryVoltageConfigured(void);
|
||||
uint16_t getBatteryVoltage(void);
|
||||
uint16_t getLegacyBatteryVoltage(void);
|
||||
uint16_t getBatteryVoltageLatest(void);
|
||||
uint8_t getBatteryCellCount(void);
|
||||
uint16_t getBatteryAverageCellVoltage(void);
|
||||
|
|
|
@ -203,7 +203,7 @@ void crsfFrameBatterySensor(sbuf_t *dst)
|
|||
if (telemetryConfig()->report_cell_voltage) {
|
||||
sbufWriteU16BigEndian(dst, (getBatteryAverageCellVoltage() + 5) / 10); // vbat is in units of 0.01V
|
||||
} else {
|
||||
sbufWriteU16BigEndian(dst, (getBatteryVoltage() + 5) / 10);
|
||||
sbufWriteU16BigEndian(dst, getLegacyBatteryVoltage());
|
||||
}
|
||||
sbufWriteU16BigEndian(dst, getAmperage() / 10);
|
||||
const uint32_t mAhDrawn = getMAhDrawn();
|
||||
|
|
|
@ -389,7 +389,7 @@ static void sendVoltageCells(void)
|
|||
*/
|
||||
static void sendVoltageAmp(void)
|
||||
{
|
||||
uint16_t voltage = (getBatteryVoltage() + 5) / 10;
|
||||
uint16_t voltage = getLegacyBatteryVoltage();
|
||||
const uint8_t cellCount = getBatteryCellCount();
|
||||
|
||||
if (telemetryConfig()->frsky_vfas_precision == FRSKY_VFAS_PRECISION_HIGH) {
|
||||
|
|
|
@ -279,7 +279,7 @@ static inline void updateAlarmBatteryStatus(HOTT_EAM_MSG_t *hottEAMMessage)
|
|||
|
||||
static inline void hottEAMUpdateBattery(HOTT_EAM_MSG_t *hottEAMMessage)
|
||||
{
|
||||
const uint16_t volt = (getBatteryVoltage() + 5) / 10;
|
||||
const uint16_t volt = getLegacyBatteryVoltage();
|
||||
hottEAMMessage->main_voltage_L = volt & 0xFF;
|
||||
hottEAMMessage->main_voltage_H = volt >> 8;
|
||||
hottEAMMessage->batt1_voltage_L = volt & 0xFF;
|
||||
|
|
|
@ -306,7 +306,7 @@ int32_t getSensorValue(uint8_t sensor)
|
|||
{
|
||||
switch (sensor) {
|
||||
case EX_VOLTAGE:
|
||||
return ((getBatteryVoltage() + 5) / 10);
|
||||
return getLegacyBatteryVoltage();
|
||||
break;
|
||||
|
||||
case EX_CURRENT:
|
||||
|
|
Loading…
Reference in New Issue