mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 04:15:44 +03:00
Added Logic AND to Modes
Added Mode Inversion configuration, CLI commands, and update. Changed Mode Inversion to Mode Logic. configure by AND/OR instead of output inversion. Fixed Mode Logic code after debugging. Added PG_REGISTER to cli unittest. Revert version to previous. Revamped Mode Logic using existing Conditions config. Requires coordination with BF-configurator, but works with CLI (added argument in 'aux' command). Coding standard changes. Cleaned up code. Added modeLogic enum. removed executable permissions. Code cleanup, cliAux backward compatible. changed bitArrayInv to bitArrayXor. allow for old 'aux' command (without last argument) to be made. asserts MODELOGIC_OR instead of resetting the memory.
This commit is contained in:
parent
625f083a3f
commit
b9272ae325
5 changed files with 60 additions and 20 deletions
|
@ -40,7 +40,6 @@ boxBitmask_t rcModeActivationMask; // one bit per mode defined in boxId_e
|
|||
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions,
|
||||
PG_MODE_ACTIVATION_PROFILE, 0);
|
||||
|
||||
|
||||
bool IS_RC_MODE_ACTIVE(boxId_e boxId)
|
||||
{
|
||||
return bitArrayGet(&rcModeActivationMask, boxId);
|
||||
|
@ -72,29 +71,35 @@ bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range) {
|
|||
|
||||
void updateActivatedModes(void)
|
||||
{
|
||||
boxBitmask_t newMask;
|
||||
boxBitmask_t newMask, andMask;
|
||||
memset(&newMask, 0, sizeof(newMask));
|
||||
memset(&andMask, 0, sizeof(andMask));
|
||||
|
||||
for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
const modeActivationCondition_t *modeActivationCondition = modeActivationConditions(index);
|
||||
// determine which conditions set/clear the mode
|
||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
const modeActivationCondition_t *mac = modeActivationConditions(i);
|
||||
|
||||
if (isRangeActive(modeActivationCondition->auxChannelIndex, &modeActivationCondition->range)) {
|
||||
boxId_e mode = modeActivationCondition->modeId;
|
||||
if (mode < CHECKBOX_ITEM_COUNT)
|
||||
boxId_e mode = mac->modeId;
|
||||
if (mode < CHECKBOX_ITEM_COUNT) {
|
||||
bool bAnd = (mac->modeLogic == MODELOGIC_AND) || bitArrayGet(&andMask, mode);
|
||||
bool bAct = isRangeActive(mac->auxChannelIndex, &mac->range);
|
||||
if (bAnd)
|
||||
bitArraySet(&andMask, mode);
|
||||
if (bAnd != bAct)
|
||||
bitArraySet(&newMask, mode);
|
||||
}
|
||||
}
|
||||
bitArrayXor(&newMask, sizeof(&newMask), &newMask, &andMask);
|
||||
|
||||
rcModeUpdate(&newMask);
|
||||
}
|
||||
|
||||
bool isModeActivationConditionPresent(boxId_e modeId)
|
||||
{
|
||||
uint8_t index;
|
||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||
const modeActivationCondition_t *mac = modeActivationConditions(i);
|
||||
|
||||
for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||
const modeActivationCondition_t *modeActivationCondition = modeActivationConditions(index);
|
||||
|
||||
if (modeActivationCondition->modeId == modeId && IS_RANGE_USABLE(&modeActivationCondition->range)) {
|
||||
if (mac->modeId == modeId && IS_RANGE_USABLE(&mac->range)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue