Skip to content

Commit

Permalink
feat:add average cell voltage in CRSF telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas.bridi committed Aug 23, 2018
1 parent a02e1dd commit 50d287a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/telemetry/crsf.c
Expand Up @@ -200,7 +200,11 @@ void crsfFrameBatterySensor(sbuf_t *dst)
// use sbufWrite since CRC does not include frame length
sbufWriteU8(dst, CRSF_FRAME_BATTERY_SENSOR_PAYLOAD_SIZE + CRSF_FRAME_LENGTH_TYPE_CRC);
sbufWriteU8(dst, CRSF_FRAMETYPE_BATTERY_SENSOR);
sbufWriteU16BigEndian(dst, getBatteryVoltage()); // vbat is in units of 0.1V
if (telemetryConfig()->report_cell_voltage) {
sbufWriteU16BigEndian(dst, getBatteryAverageCellVoltage()); // vbat is in units of 0.1V
} else {
sbufWriteU16BigEndian(dst, getBatteryVoltage());
}
sbufWriteU16BigEndian(dst, getAmperage() / 10);
const uint32_t mAhDrawn = getMAhDrawn();
const uint8_t batteryRemainingPercentage = calculateBatteryPercentageRemaining();
Expand Down
4 changes: 4 additions & 0 deletions src/test/unit/telemetry_crsf_msp_unittest.cc
Expand Up @@ -69,6 +69,7 @@ extern "C" {
int sbufBytesRemaining(sbuf_t *buf);
void initSharedMsp();
uint16_t testBatteryVoltage = 0;
uint16_t testAvgCellVoltage = 0;
int32_t testAmperage = 0;
uint8_t mspTxData[64]; //max frame size
sbuf_t mspTxDataBuf;
Expand Down Expand Up @@ -259,6 +260,9 @@ extern "C" {
uint16_t getBatteryVoltage(void) {
return testBatteryVoltage;
}
uint16_t getBatteryAverageCellVoltage(void) {
return testAvgCellVoltage;
}
bool isAmperageConfigured(void) { return true; }
int32_t getAmperage(void) {
return testAmperage;
Expand Down

0 comments on commit 50d287a

Please sign in to comment.