Add the Flightmode events
Log RC mode selections to blackbox so that air mode, super expo, beeper on/off etc can be shown in blackbox viewer.
This commit is contained in:
parent
57c6f62590
commit
c5bd5d687f
|
@ -326,9 +326,14 @@ extern uint16_t rssi;
|
|||
//From gyro.c
|
||||
extern uint32_t targetLooptime;
|
||||
|
||||
//From rc_controls.c
|
||||
extern uint32_t rcModeActivationMask;
|
||||
|
||||
static BlackboxState blackboxState = BLACKBOX_STATE_DISABLED;
|
||||
|
||||
static uint32_t blackboxLastArmingBeep = 0;
|
||||
static uint32_t blackboxLastFlightModeFlags = 0; // New event tracking of flight modes
|
||||
|
||||
|
||||
static struct {
|
||||
uint32_t headerIndex;
|
||||
|
@ -860,6 +865,8 @@ void startBlackbox(void)
|
|||
* it finally plays the beep for this arming event.
|
||||
*/
|
||||
blackboxLastArmingBeep = getArmingBeepTimeMicros();
|
||||
blackboxLastFlightModeFlags = rcModeActivationMask; // record startup status
|
||||
|
||||
|
||||
blackboxSetState(BLACKBOX_STATE_PREPARE_LOG_FILE);
|
||||
}
|
||||
|
@ -1211,6 +1218,10 @@ void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data)
|
|||
case FLIGHT_LOG_EVENT_SYNC_BEEP:
|
||||
blackboxWriteUnsignedVB(data->syncBeep.time);
|
||||
break;
|
||||
case FLIGHT_LOG_EVENT_FLIGHTMODE: // New flightmode flags write
|
||||
blackboxWriteUnsignedVB(data->flightMode.flags);
|
||||
blackboxWriteUnsignedVB(data->flightMode.lastFlags);
|
||||
break;
|
||||
case FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT:
|
||||
if (data->inflightAdjustment.floatFlag) {
|
||||
blackboxWrite(data->inflightAdjustment.adjustmentFunction + FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT_FUNCTION_FLOAT_VALUE_FLAG);
|
||||
|
@ -1251,6 +1262,21 @@ static void blackboxCheckAndLogArmingBeep()
|
|||
}
|
||||
}
|
||||
|
||||
/* monitor the flight mode event status and trigger an event record if the state changes */
|
||||
static void blackboxCheckAndLogFlightMode()
|
||||
{
|
||||
flightLogEvent_flightMode_t eventData; // Add new data for current flight mode flags
|
||||
|
||||
// Use != so that we can still detect a change if the counter wraps
|
||||
if (rcModeActivationMask != blackboxLastFlightModeFlags) {
|
||||
eventData.lastFlags = blackboxLastFlightModeFlags;
|
||||
blackboxLastFlightModeFlags = rcModeActivationMask;
|
||||
eventData.flags = rcModeActivationMask;
|
||||
|
||||
blackboxLogEvent(FLIGHT_LOG_EVENT_FLIGHTMODE, (flightLogEventData_t *) &eventData);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the user's num/denom settings to decide if the P-frame of the given index should be logged, allowing the user to control
|
||||
* the portion of logged loop iterations.
|
||||
|
@ -1295,6 +1321,7 @@ static void blackboxLogIteration()
|
|||
writeIntraframe();
|
||||
} else {
|
||||
blackboxCheckAndLogArmingBeep();
|
||||
blackboxCheckAndLogFlightMode(); // Check for FlightMode status change event
|
||||
|
||||
if (blackboxShouldLogPFrame(blackboxPFrameIndex)) {
|
||||
/*
|
||||
|
|
|
@ -106,6 +106,7 @@ typedef enum FlightLogEvent {
|
|||
FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT = 13,
|
||||
FLIGHT_LOG_EVENT_LOGGING_RESUME = 14,
|
||||
FLIGHT_LOG_EVENT_GTUNE_RESULT = 20,
|
||||
FLIGHT_LOG_EVENT_FLIGHTMODE = 30, // Add new event type for flight mode status.
|
||||
FLIGHT_LOG_EVENT_LOG_END = 255
|
||||
} FlightLogEvent;
|
||||
|
||||
|
@ -113,6 +114,11 @@ typedef struct flightLogEvent_syncBeep_s {
|
|||
uint32_t time;
|
||||
} flightLogEvent_syncBeep_t;
|
||||
|
||||
typedef struct flightLogEvent_flightMode_s { // New Event Data type
|
||||
uint32_t flags;
|
||||
uint32_t lastFlags;
|
||||
} flightLogEvent_flightMode_t;
|
||||
|
||||
typedef struct flightLogEvent_inflightAdjustment_s {
|
||||
uint8_t adjustmentFunction;
|
||||
bool floatFlag;
|
||||
|
@ -135,6 +141,7 @@ typedef struct flightLogEvent_gtuneCycleResult_s {
|
|||
|
||||
typedef union flightLogEventData_u {
|
||||
flightLogEvent_syncBeep_t syncBeep;
|
||||
flightLogEvent_flightMode_t flightMode; // New event data
|
||||
flightLogEvent_inflightAdjustment_t inflightAdjustment;
|
||||
flightLogEvent_loggingResume_t loggingResume;
|
||||
flightLogEvent_gtuneCycleResult_t gtuneCycleResult;
|
||||
|
|
Loading…
Reference in New Issue