mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Fix bug with non-working switch-ARM if using mode_range_operator=AND
This commit is contained in:
parent
32b13fdad6
commit
e1865ef699
2 changed files with 19 additions and 768 deletions
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#include "build/debug.h"
|
||||
|
||||
#include "blackbox/blackbox.h"
|
||||
|
||||
#include "common/axis.h"
|
||||
|
@ -64,6 +66,9 @@
|
|||
// true if arming is done via the sticks (as opposed to a switch)
|
||||
static bool isUsingSticksToArm = true;
|
||||
|
||||
// Count of mode activation ranged (per box mode)
|
||||
static uint8_t specifiedConditionCountPerMode[CHECKBOX_ITEM_COUNT];
|
||||
|
||||
#ifdef NAV
|
||||
// true if pilot has any of GPS modes configured
|
||||
static bool isUsingNAVModes = false;
|
||||
|
@ -373,20 +378,13 @@ void updateActivatedModes(void)
|
|||
// Unfortunately for AND logic it's not enough to simply check if any of the specified channel range conditions are valid for a mode.
|
||||
// We need to count the total number of conditions specified for each mode, and check that all those conditions are currently valid.
|
||||
|
||||
uint8_t specifiedConditionCountPerMode[CHECKBOX_ITEM_COUNT];
|
||||
uint8_t validConditionCountPerMode[CHECKBOX_ITEM_COUNT];
|
||||
uint8_t activeConditionCountPerMode[CHECKBOX_ITEM_COUNT];
|
||||
memset(activeConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||
|
||||
memset(specifiedConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||
memset(validConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||
|
||||
for (int modeIndex = 0; modeIndex < MAX_MODE_ACTIVATION_CONDITION_COUNT; modeIndex++) {
|
||||
|
||||
// Increment the number of specified conditions for this mode
|
||||
specifiedConditionCountPerMode[modeActivationConditions(modeIndex)->modeId]++;
|
||||
|
||||
if (isRangeActive(modeActivationConditions(modeIndex)->auxChannelIndex, &modeActivationConditions(modeIndex)->range)) {
|
||||
for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
if (isRangeActive(modeActivationConditions(index)->auxChannelIndex, &modeActivationConditions(index)->range)) {
|
||||
// Increment the number of valid conditions for this mode
|
||||
validConditionCountPerMode[modeActivationConditions(modeIndex)->modeId]++;
|
||||
activeConditionCountPerMode[modeActivationConditions(index)->modeId]++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,13 +400,13 @@ void updateActivatedModes(void)
|
|||
|
||||
if (modeActivationOperatorConfig()->modeActivationOperator == MODE_OPERATOR_AND) {
|
||||
// AND the conditions
|
||||
if (validConditionCountPerMode[modeIndex] == specifiedConditionCountPerMode[modeIndex]) {
|
||||
if (activeConditionCountPerMode[modeIndex] == specifiedConditionCountPerMode[modeIndex]) {
|
||||
ACTIVATE_RC_MODE(modeIndex);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// OR the conditions
|
||||
if (validConditionCountPerMode[modeIndex] > 0) {
|
||||
if (activeConditionCountPerMode[modeIndex] > 0) {
|
||||
ACTIVATE_RC_MODE(modeIndex);
|
||||
}
|
||||
}
|
||||
|
@ -422,6 +420,13 @@ int32_t getRcStickDeflection(int32_t axis, uint16_t midrc) {
|
|||
|
||||
void updateUsedModeActivationConditionFlags(void)
|
||||
{
|
||||
memset(specifiedConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||
for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
if (IS_RANGE_USABLE(&modeActivationConditions(index)->range)) {
|
||||
specifiedConditionCountPerMode[modeActivationConditions(index)->modeId]++;
|
||||
}
|
||||
}
|
||||
|
||||
isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM);
|
||||
|
||||
#ifdef NAV
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue