mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
parent
c49bd407bf
commit
b6a75cb3f1
2 changed files with 25 additions and 7 deletions
|
@ -242,9 +242,12 @@ static const blackboxSimpleFieldDefinition_t blackboxGpsHFields[] = {
|
|||
|
||||
// Rarely-updated fields
|
||||
static const blackboxSimpleFieldDefinition_t blackboxSlowFields[] = {
|
||||
{"flightModeFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
|
||||
{"stateFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
|
||||
{"failsafePhase", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)}
|
||||
{"flightModeFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
|
||||
{"stateFlags", -1, UNSIGNED, PREDICT(0), ENCODING(UNSIGNED_VB)},
|
||||
|
||||
{"failsafePhase", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)},
|
||||
{"rxSignalReceived", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)},
|
||||
{"rxFlightChannelsValid", -1, UNSIGNED, PREDICT(0), ENCODING(TAG2_3S32)}
|
||||
};
|
||||
|
||||
typedef enum BlackboxState {
|
||||
|
@ -297,6 +300,8 @@ typedef struct blackboxSlowState_t {
|
|||
uint16_t flightModeFlags;
|
||||
uint8_t stateFlags;
|
||||
uint8_t failsafePhase;
|
||||
bool rxSignalReceived;
|
||||
bool rxFlightChannelsValid;
|
||||
} __attribute__((__packed__)) blackboxSlowState_t; // We pack this struct so that padding doesn't interfere with memcmp()
|
||||
|
||||
//From mixer.c:
|
||||
|
@ -307,6 +312,8 @@ extern uint32_t currentTime;
|
|||
|
||||
//From rx.c:
|
||||
extern uint16_t rssi;
|
||||
bool rxSignalReceived;
|
||||
bool rxFlightChannelsValid;
|
||||
|
||||
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
|
||||
|
||||
|
@ -679,11 +686,20 @@ static void writeInterframe(void)
|
|||
* infrequently, delta updates are not reasonable, so we log independent frames. */
|
||||
static void writeSlowFrame(void)
|
||||
{
|
||||
int32_t values[3];
|
||||
|
||||
blackboxWrite('S');
|
||||
|
||||
blackboxWriteUnsignedVB(slowHistory.flightModeFlags);
|
||||
blackboxWriteUnsignedVB(slowHistory.stateFlags);
|
||||
blackboxWriteUnsignedVB(slowHistory.failsafePhase);
|
||||
|
||||
/*
|
||||
* Most of the time these three values will be able to pack into one byte for us:
|
||||
*/
|
||||
values[0] = slowHistory.failsafePhase;
|
||||
values[1] = slowHistory.rxSignalReceived ? 1 : 0;
|
||||
values[2] = slowHistory.rxFlightChannelsValid ? 1 : 0;
|
||||
blackboxWriteTag2_3S32(values);
|
||||
|
||||
blackboxSlowFrameIterationTimer = 0;
|
||||
}
|
||||
|
@ -696,6 +712,8 @@ static void loadSlowState(blackboxSlowState_t *slow)
|
|||
slow->flightModeFlags = flightModeFlags;
|
||||
slow->stateFlags = stateFlags;
|
||||
slow->failsafePhase = failsafePhase();
|
||||
slow->rxSignalReceived = rxSignalReceived;
|
||||
slow->rxFlightChannelsValid = rxFlightChannelsValid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1388,4 +1406,4 @@ void initBlackbox(void)
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue