mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Add Paralyze mode support
During team relay races it's unsafe to retrieve crashed quads because the course is continuously hot. In order to safely fly a backup quad with the primary quad crashed in the field (but powered up) it's necessary to: * Disable arming, so that the crashed quad doesn't unintentionally arm as well. This is specifically a problem when a transmitter can send signals to all powered up receivers (like FrSky and others). * Change VTX to an unused channel with low power output * Turn off telemetry This change introduces a new mode called paralyze which disables arming and prevents mode changes (except beeper). It can only be invoked while the quad isn't armed. Once it's invoked, the FC has to be power cycled. In order to invoke it, the mode needs to be in a disengaged state at least once, so that forgetting to flip the switch back after crashing doesn't immediately invoke graveyard on the backup quad. _Legal disclaimer: I am making my contributions/submissions to this project solely in my personal capacity and am not conveying any rights to any intellectual property of any third parties._
This commit is contained in:
parent
3af1610d0b
commit
092baf5805
9 changed files with 164 additions and 4 deletions
|
@ -39,6 +39,7 @@
|
|||
#include "rx/rx.h"
|
||||
|
||||
boxBitmask_t rcModeActivationMask; // one bit per mode defined in boxId_e
|
||||
static bool modeChangesDisabled = false;
|
||||
|
||||
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions,
|
||||
PG_MODE_ACTIVATION_PROFILE, 0);
|
||||
|
@ -53,6 +54,10 @@ void rcModeUpdate(boxBitmask_t *newState)
|
|||
rcModeActivationMask = *newState;
|
||||
}
|
||||
|
||||
void preventModeChanges(void) {
|
||||
modeChangesDisabled = true;
|
||||
}
|
||||
|
||||
bool isAirmodeActive(void) {
|
||||
return (IS_RC_MODE_ACTIVE(BOXAIRMODE) || feature(FEATURE_AIRMODE));
|
||||
}
|
||||
|
@ -75,14 +80,24 @@ bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range) {
|
|||
void updateActivatedModes(void)
|
||||
{
|
||||
boxBitmask_t newMask, andMask;
|
||||
memset(&newMask, 0, sizeof(newMask));
|
||||
memset(&andMask, 0, sizeof(andMask));
|
||||
|
||||
if (!modeChangesDisabled) {
|
||||
memset(&newMask, 0, sizeof(newMask));
|
||||
} else {
|
||||
memcpy(&newMask, &rcModeActivationMask, sizeof(newMask));
|
||||
}
|
||||
|
||||
// determine which conditions set/clear the mode
|
||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
const modeActivationCondition_t *mac = modeActivationConditions(i);
|
||||
|
||||
boxId_e mode = mac->modeId;
|
||||
|
||||
if (modeChangesDisabled && mode != BOXBEEPERON) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mode < CHECKBOX_ITEM_COUNT) {
|
||||
bool bAnd = (mac->modeLogic == MODELOGIC_AND) || bitArrayGet(&andMask, mode);
|
||||
bool bAct = isRangeActive(mac->auxChannelIndex, &mac->range);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue