Skip to content

Commit

Permalink
Merge pull request #3414 from shellixyz/add_sag_compensated_vbat_to_bb
Browse files Browse the repository at this point in the history
Add sag compensated VBat to BB slow frames
  • Loading branch information
fiam committed Jun 22, 2018
2 parents de87e8c + 25c8879 commit 5435e27
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/blackbox/blackbox.c
Expand Up @@ -338,6 +338,7 @@ static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {

{"hwHealthStatus", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"powerSupplyImpedance", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
{"sagCompensatedVBat", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
};

typedef enum BlackboxState {
Expand Down Expand Up @@ -434,6 +435,7 @@ typedef struct blackboxSlowState_s {
bool rxFlightChannelsValid;
int32_t hwHealthStatus;
uint16_t powerSupplyImpedance;
uint16_t sagCompensatedVBat;
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()

//From rc_controls.c
Expand Down Expand Up @@ -1017,6 +1019,7 @@ static void writeSlowFrame(void)
blackboxWriteUnsignedVB(slowHistory.hwHealthStatus);

blackboxWriteUnsignedVB(slowHistory.powerSupplyImpedance);
blackboxWriteUnsignedVB(slowHistory.sagCompensatedVBat);

blackboxSlowFrameIterationTimer = 0;
}
Expand All @@ -1039,6 +1042,7 @@ static void loadSlowState(blackboxSlowState_t *slow)
(getHwRangefinderStatus() << 2 * 5) |
(getHwPitotmeterStatus() << 2 * 6);
slow->powerSupplyImpedance = getPowerSupplyImpedance();
slow->sagCompensatedVBat = getBatterySagCompensatedVoltage();
}

/**
Expand Down

0 comments on commit 5435e27

Please sign in to comment.