mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-20 06:45:14 +03:00
Log last disarm reason to blackbox, report via LTM
This commit is contained in:
parent
ab12330ef0
commit
d3147b71e8
8 changed files with 41 additions and 14 deletions
|
@ -48,6 +48,7 @@
|
|||
#include "drivers/time.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/controlrate_profile.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
@ -1453,7 +1454,7 @@ void blackboxLogEvent(FlightLogEvent event, flightLogEventData_t *data)
|
|||
blackboxWrite(0);
|
||||
break;
|
||||
case FLIGHT_LOG_EVENT_LOG_END:
|
||||
blackboxPrint("End of log");
|
||||
blackboxPrintf("End of log (disarm reason:%d)", getDisarmReason());
|
||||
blackboxWrite(0);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "sensors/gyro.h"
|
||||
#include "sensors/battery.h"
|
||||
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/cli.h"
|
||||
#include "fc/config.h"
|
||||
#include "fc/controlrate_profile.h"
|
||||
|
@ -103,6 +104,7 @@ int16_t telemTemperature1; // gyro sensor temperature
|
|||
static uint32_t disarmAt; // Time of automatic disarm when "Don't spin the motors when armed" is enabled and auto_disarm_delay is nonzero
|
||||
|
||||
static bool isRXDataNew;
|
||||
static disarmReason_t lastDisarmReason = DISARM_NONE;
|
||||
|
||||
bool isCalibrating(void)
|
||||
{
|
||||
|
@ -222,9 +224,10 @@ void annexCode(void)
|
|||
}
|
||||
}
|
||||
|
||||
void mwDisarm(void)
|
||||
void mwDisarm(disarmReason_t disarmReason)
|
||||
{
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
lastDisarmReason = disarmReason;
|
||||
DISABLE_ARMING_FLAG(ARMED);
|
||||
|
||||
#ifdef BLACKBOX
|
||||
|
@ -237,6 +240,11 @@ void mwDisarm(void)
|
|||
}
|
||||
}
|
||||
|
||||
disarmReason_t getDisarmReason(void)
|
||||
{
|
||||
return lastDisarmReason;
|
||||
}
|
||||
|
||||
#define TELEMETRY_FUNCTION_MASK (FUNCTION_TELEMETRY_FRSKY | FUNCTION_TELEMETRY_HOTT | FUNCTION_TELEMETRY_SMARTPORT | FUNCTION_TELEMETRY_LTM | FUNCTION_TELEMETRY_MAVLINK | FUNCTION_TELEMETRY_IBUS)
|
||||
|
||||
void releaseSharedTelemetryPorts(void) {
|
||||
|
@ -302,7 +310,7 @@ void processRx(timeUs_t currentTimeUs)
|
|||
// in 3D mode, we need to be able to disarm by switch at any time
|
||||
if (feature(FEATURE_3D)) {
|
||||
if (!IS_RC_MODE_ACTIVE(BOXARM))
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_SWITCH_3D);
|
||||
}
|
||||
|
||||
updateRSSI(currentTimeUs);
|
||||
|
@ -329,7 +337,7 @@ void processRx(timeUs_t currentTimeUs)
|
|||
&& (int32_t)(disarmAt - millis()) < 0
|
||||
) {
|
||||
// auto-disarm configured and delay is over
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_TIMEOUT);
|
||||
armedBeeperOn = false;
|
||||
} else {
|
||||
// still armed; do warning beeps while armed
|
||||
|
|
|
@ -19,9 +19,21 @@
|
|||
|
||||
extern int16_t telemTemperature1;
|
||||
|
||||
typedef enum disarmReason_e {
|
||||
DISARM_NONE = 0,
|
||||
DISARM_TIMEOUT = 1,
|
||||
DISARM_STICKS = 2,
|
||||
DISARM_SWITCH_3D = 3,
|
||||
DISARM_SWITCH = 4,
|
||||
DISARM_KILLSWITCH = 5,
|
||||
DISARM_FAILSAFE = 6,
|
||||
DISARM_NAVIGATION = 7
|
||||
} disarmReason_t;
|
||||
|
||||
void handleInflightCalibrationStickPosition();
|
||||
|
||||
void mwDisarm(void);
|
||||
void mwDisarm(disarmReason_t disarmReason);
|
||||
void mwArm(void);
|
||||
disarmReason_t getDisarmReason(void);
|
||||
|
||||
bool isCalibrating(void);
|
|
@ -179,9 +179,9 @@ void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_s
|
|||
rcDisarmTicks++;
|
||||
if (rcDisarmTicks > 3) { // Wait for at least 3 RX ticks (60ms @ 50Hz RX)
|
||||
if (disarm_kill_switch) {
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_SWITCH);
|
||||
} else if (throttleStatus == THROTTLE_LOW) {
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_SWITCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_s
|
|||
|
||||
// KILLSWITCH disarms instantly
|
||||
if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) {
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_KILLSWITCH);
|
||||
}
|
||||
|
||||
if (rcDelayCommand != 20) {
|
||||
|
@ -208,7 +208,7 @@ void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_s
|
|||
return;
|
||||
}
|
||||
else if (ARMING_FLAG(ARMED)) {
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_STICKS);
|
||||
}
|
||||
else {
|
||||
beeper(BEEPER_DISARM_REPEAT); // sound tone while stick held
|
||||
|
|
|
@ -111,5 +111,3 @@ bool sensors(uint32_t mask);
|
|||
void sensorsSet(uint32_t mask);
|
||||
void sensorsClear(uint32_t mask);
|
||||
uint32_t sensorsMask(void);
|
||||
|
||||
void mwDisarm(void);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "io/beeper.h"
|
||||
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/config.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
@ -143,6 +144,11 @@ void failsafeReset(void)
|
|||
failsafeState.receivingRxDataPeriodPreset = 0;
|
||||
failsafeState.phase = FAILSAFE_IDLE;
|
||||
failsafeState.rxLinkState = FAILSAFE_RXLINK_DOWN;
|
||||
|
||||
failsafeState.lastGoodRcCommand[ROLL] = 0;
|
||||
failsafeState.lastGoodRcCommand[PITCH] = 0;
|
||||
failsafeState.lastGoodRcCommand[YAW] = 0;
|
||||
failsafeState.lastGoodRcCommand[THROTTLE] = 1000;
|
||||
}
|
||||
|
||||
void failsafeInit(void)
|
||||
|
@ -461,7 +467,7 @@ void failsafeUpdateState(void)
|
|||
|
||||
case FAILSAFE_LANDED:
|
||||
ENABLE_ARMING_FLAG(PREVENT_ARMING); // To prevent accidently rearming by an intermittent rx link
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_FAILSAFE);
|
||||
failsafeState.receivingRxDataPeriod = millis() + failsafeState.receivingRxDataPeriodPreset; // set required period of valid rxData
|
||||
failsafeState.phase = FAILSAFE_RX_LOSS_MONITORING;
|
||||
failsafeState.controlling = false; // Failsafe no longer in control of the machine - release control to pilot
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "drivers/time.h"
|
||||
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/config.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
@ -1015,7 +1016,7 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_FINISHING(navigatio
|
|||
UNUSED(previousState);
|
||||
|
||||
if (navConfig()->general.flags.disarm_on_landing) {
|
||||
mwDisarm();
|
||||
mwDisarm(DISARM_NAVIGATION);
|
||||
}
|
||||
|
||||
return NAV_FSM_EVENT_SUCCESS;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "io/serial.h"
|
||||
|
||||
#include "fc/config.h"
|
||||
#include "fc/fc_core.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
|
@ -259,7 +260,7 @@ void ltm_xframe(sbuf_t *dst)
|
|||
#endif
|
||||
ltm_serialise_8(dst, sensorStatus);
|
||||
ltm_serialise_8(dst, ltm_x_counter);
|
||||
ltm_serialise_8(dst, 0);
|
||||
ltm_serialise_8(dst, getDisarmReason());
|
||||
ltm_serialise_8(dst, 0);
|
||||
ltm_x_counter++; // overflow is OK
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue