mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 11:59:58 +03:00
Add box mode to disable stick commands
Adds a `STICK COMMAND DISABLE SW` mode used to prevent inadvertant triggering of controls, calibrations, or settings changes. Useful for USB HID mode when using the flight controller as a joystick (and auto-detect doesn't work), in "team" or "relay" racing where multiple quads might be bound to the same transmitter, or just in general if the user wants prevent stick commands. Will also prevent stick arming when the mode is active (but not stick disarming).
This commit is contained in:
parent
de35df8e07
commit
19ece68555
5 changed files with 8 additions and 4 deletions
|
@ -1214,7 +1214,7 @@ static void cmsUpdate(uint32_t currentTimeUs)
|
|||
|
||||
if (!cmsInMenu) {
|
||||
// Detect menu invocation
|
||||
if (IS_MID(THROTTLE) && IS_LO(YAW) && IS_HI(PITCH) && !ARMING_FLAG(ARMED)) {
|
||||
if (IS_MID(THROTTLE) && IS_LO(YAW) && IS_HI(PITCH) && !ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXSTICKCOMMANDDISABLE)) {
|
||||
cmsMenuOpen();
|
||||
rcDelayMs = BUTTON_PAUSE; // Tends to overshoot if BUTTON_TIME
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ void processRcStickPositions()
|
|||
}
|
||||
}
|
||||
return;
|
||||
} else if (rcSticks == THR_LO + YAW_HI + PIT_CE + ROL_CE) {
|
||||
} else if (rcSticks == THR_LO + YAW_HI + PIT_CE + ROL_CE && !IS_RC_MODE_ACTIVE(BOXSTICKCOMMANDDISABLE)) { // disable stick arming if STICK COMMAND DISABLE SW is active
|
||||
if (rcDelayMs >= ARM_DELAY_MS && !doNotRepeat) {
|
||||
doNotRepeat = true;
|
||||
if (!ARMING_FLAG(ARMED)) {
|
||||
|
@ -231,7 +231,7 @@ void processRcStickPositions()
|
|||
|
||||
#ifdef USE_USB_CDC_HID
|
||||
// If this target is used as a joystick, we should leave here.
|
||||
if (cdcDeviceIsMayBeActive()) {
|
||||
if (cdcDeviceIsMayBeActive() || IS_RC_MODE_ACTIVE(BOXSTICKCOMMANDDISABLE)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -75,6 +75,7 @@ typedef enum {
|
|||
BOXVTXCONTROLDISABLE,
|
||||
BOXLAUNCHCONTROL,
|
||||
BOXMSPOVERRIDE,
|
||||
BOXSTICKCOMMANDDISABLE,
|
||||
CHECKBOX_ITEM_COUNT
|
||||
} boxId_e;
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ static void rcdevice5KeySimulationProcess(timeUs_t currentTimeUs)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (ARMING_FLAG(ARMED) || (getArmingDisableFlags() & (ARMING_DISABLED_RUNAWAY_TAKEOFF | ARMING_DISABLED_CRASH_DETECTED))) {
|
||||
if (ARMING_FLAG(ARMED) || IS_RC_MODE_ACTIVE(BOXSTICKCOMMANDDISABLE) || (getArmingDisableFlags() & (ARMING_DISABLED_RUNAWAY_TAKEOFF | ARMING_DISABLED_CRASH_DETECTED))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT] = {
|
|||
{ BOXVTXCONTROLDISABLE, "DISABLE VTX CONTROL", 48},
|
||||
{ BOXLAUNCHCONTROL, "LAUNCH CONTROL", 49 },
|
||||
{ BOXMSPOVERRIDE, "MSP OVERRIDE", 50},
|
||||
{ BOXSTICKCOMMANDDISABLE, "STICK COMMAND DISABLE SW", 51}
|
||||
};
|
||||
|
||||
// mask of enabled IDs, calculated on startup based on enabled features. boxId_e is used as bit index
|
||||
|
@ -330,6 +331,8 @@ void initActiveBoxIds(void)
|
|||
BME(BOXLAUNCHCONTROL);
|
||||
#endif
|
||||
|
||||
BME(BOXSTICKCOMMANDDISABLE);
|
||||
|
||||
#undef BME
|
||||
// check that all enabled IDs are in boxes array (check may be skipped when using findBoxById() functions)
|
||||
for (boxId_e boxId = 0; boxId < CHECKBOX_ITEM_COUNT; boxId++)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue