void updateAdjustmentStates(void) { for (int index = 0; index < MAX_ADJUSTMENT_RANGE_COUNT; index++) { const adjustmentRange_t * const adjustmentRange = adjustmentRanges(index); if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range)) { const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentFunction - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET]; configureAdjustment(adjustmentRange->adjustmentIndex, adjustmentRange->auxSwitchChannelIndex, adjustmentConfig); } } }
void rcModeUpdateActivated(modeActivationCondition_t *modeActivationConditions) { uint32_t newRcModeMask = 0; for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) { modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index]; if (isRangeActive(modeActivationCondition->auxChannelIndex, &modeActivationCondition->range)) { newRcModeMask |= 1 << modeActivationCondition->modeId; } } rcModeActivationMask = newRcModeMask; }
void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges) { uint8_t index; for (index = 0; index < MAX_ADJUSTMENT_RANGE_COUNT; index++) { adjustmentRange_t *adjustmentRange = &adjustmentRanges[index]; if (isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range)) { configureAdjustmentState(adjustmentRange); } } }
void updateActivatedModes(modeActivationCondition_t *modeActivationConditions) { rcModeActivationMask = 0; uint8_t index; for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) { modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index]; if (isRangeActive(modeActivationCondition->auxChannelIndex, &modeActivationCondition->range)) { ACTIVATE_RC_MODE(modeActivationCondition->modeId); } } }
void updateActivatedModes(void) { // Disable all modes to begin with boxBitmask_t newMask; memset(&newMask, 0, sizeof(newMask)); // 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 activeConditionCountPerMode[CHECKBOX_ITEM_COUNT]; memset(activeConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT); 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 activeConditionCountPerMode[modeActivationConditions(index)->modeId]++; } } // Now see which modes should be enabled for (int modeIndex = 0; modeIndex < CHECKBOX_ITEM_COUNT; modeIndex++) { // only modes with conditions specified are considered if (specifiedConditionCountPerMode[modeIndex] > 0) { // For AND logic, the specified condition count and valid condition count must be the same. // For OR logic, the valid condition count must be greater than zero. if (modeActivationOperatorConfig()->modeActivationOperator == MODE_OPERATOR_AND) { // AND the conditions if (activeConditionCountPerMode[modeIndex] == specifiedConditionCountPerMode[modeIndex]) { bitArraySet(newMask.bits, modeIndex); } } else { // OR the conditions if (activeConditionCountPerMode[modeIndex] > 0) { bitArraySet(newMask.bits, modeIndex); } } } } rcModeUpdate(&newMask); }
void updateAdjustmentStates(bool canUseRxData) { for (int index = 0; index < MAX_ADJUSTMENT_RANGE_COUNT; index++) { const adjustmentRange_t * const adjustmentRange = adjustmentRanges(index); if (adjustmentRange->adjustmentFunction == ADJUSTMENT_NONE) { // Range not set up continue; } const adjustmentConfig_t *adjustmentConfig = &defaultAdjustmentConfigs[adjustmentRange->adjustmentFunction - ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET]; adjustmentState_t * const adjustmentState = &adjustmentStates[adjustmentRange->adjustmentIndex]; if (canUseRxData && isRangeActive(adjustmentRange->auxChannelIndex, &adjustmentRange->range)) { if (!adjustmentState->config) { configureAdjustment(adjustmentRange->adjustmentIndex, adjustmentRange->auxSwitchChannelIndex, adjustmentConfig); } } else { if (adjustmentState->config == adjustmentConfig) { adjustmentState->config = NULL; } } } }