Merge pull request #1477 from opentx/projectkk2glider/cells_gtests
Tests and support for second FLVSS
This commit is contained in:
@@ -279,6 +279,8 @@ bool checkSportPacket(uint8_t *packet)
|
||||
#define SPORT_DATA_U32(packet) (*((uint32_t *)(packet+4)))
|
||||
#define HUB_DATA_U16(packet) (*((uint16_t *)(packet+4)))
|
||||
|
||||
uint8_t noCellsSensor[2];
|
||||
|
||||
void frskySportProcessPacket(uint8_t *packet)
|
||||
{
|
||||
uint8_t dataId = packet[0];
|
||||
@@ -465,9 +467,18 @@ void frskySportProcessPacket(uint8_t *packet)
|
||||
uint32_t data = SPORT_DATA_U32(packet);
|
||||
uint8_t battnumber = data & 0xF;
|
||||
uint8_t cells = (data & 0xF0) >> 4;
|
||||
bool useSecondCell = (battnumber+1 < cells);
|
||||
|
||||
if (dataId != DATA_ID_FLVSS) {
|
||||
// TODO second sensor connected
|
||||
if (dataId == DATA_ID_FLVSS) {
|
||||
// first sensor, remember its cell count
|
||||
noCellsSensor[0] = cells;
|
||||
cells += noCellsSensor[1];
|
||||
}
|
||||
else {
|
||||
// second sensor connected
|
||||
noCellsSensor[1] = cells;
|
||||
cells += noCellsSensor[0];
|
||||
battnumber += noCellsSensor[0];
|
||||
}
|
||||
|
||||
if (cells != frskyData.hub.cellsCount) {
|
||||
@@ -475,7 +486,9 @@ void frskySportProcessPacket(uint8_t *packet)
|
||||
}
|
||||
|
||||
frskySetCellVoltage(battnumber, (frskyCellVoltage_t) ((data & 0x000FFF00) >> 8) / 5);
|
||||
frskySetCellVoltage(battnumber+1, (frskyCellVoltage_t) ((data & 0xFFF00000) >> 20) / 5);
|
||||
if (useSecondCell) {
|
||||
frskySetCellVoltage(battnumber+1, (frskyCellVoltage_t) ((data & 0xFFF00000) >> 20) / 5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user