mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-16 21:05:32 +03:00
Added modeActivationConditions parameter group
This commit is contained in:
parent
7aaa5643c0
commit
b7cdd63db1
16 changed files with 89 additions and 86 deletions
|
@ -1025,7 +1025,7 @@ void startBlackbox(void)
|
||||||
*/
|
*/
|
||||||
blackboxBuildConditionCache();
|
blackboxBuildConditionCache();
|
||||||
|
|
||||||
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(masterConfig.modeActivationConditions, BOXBLACKBOX);
|
blackboxModeActivationConditionPresent = isModeActivationConditionPresent(BOXBLACKBOX);
|
||||||
|
|
||||||
blackboxIteration = 0;
|
blackboxIteration = 0;
|
||||||
blackboxPFrameIndex = 0;
|
blackboxPFrameIndex = 0;
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "io/flashfs.h"
|
#include "io/flashfs.h"
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
|
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
|
|
||||||
#include "cms/cms.h"
|
#include "cms/cms.h"
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "cms/cms_menu_vtx.h"
|
#include "cms/cms_menu_vtx.h"
|
||||||
|
|
||||||
#include "config/config_profile.h"
|
#include "config/config_profile.h"
|
||||||
#include "config/config_master.h"
|
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
|
|
||||||
#ifdef CMS
|
#ifdef CMS
|
||||||
|
|
|
@ -70,9 +70,6 @@ typedef struct master_s {
|
||||||
servoMixer_t customServoMixer[MAX_SERVO_RULES];
|
servoMixer_t customServoMixer[MAX_SERVO_RULES];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
modeActivationCondition_t modeActivationConditions[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
|
||||||
modeActivationOperator_e modeActivationOperator;
|
|
||||||
|
|
||||||
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
adjustmentRange_t adjustmentRanges[MAX_ADJUSTMENT_RANGE_COUNT];
|
||||||
|
|
||||||
// Radio/ESC-related configuration
|
// Radio/ESC-related configuration
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
#define PG_BAROMETER_CONFIG 38
|
#define PG_BAROMETER_CONFIG 38
|
||||||
//#define PG_THROTTLE_CORRECTION_CONFIG 39
|
//#define PG_THROTTLE_CORRECTION_CONFIG 39
|
||||||
#define PG_COMPASS_CONFIG 40
|
#define PG_COMPASS_CONFIG 40
|
||||||
//#define PG_MODE_ACTIVATION_PROFILE 41
|
#define PG_MODE_ACTIVATION_PROFILE 41
|
||||||
//#define PG_SERVO_PROFILE 42
|
//#define PG_SERVO_PROFILE 42
|
||||||
#define PG_RX_FAILSAFE_CHANNEL_CONFIG 43
|
#define PG_RX_FAILSAFE_CHANNEL_CONFIG 43
|
||||||
#define PG_RX_CHANNEL_RANGE_CONFIG 44
|
#define PG_RX_CHANNEL_RANGE_CONFIG 44
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
#define PG_PITOTMETER_CONFIG 1000
|
#define PG_PITOTMETER_CONFIG 1000
|
||||||
#define PG_POSITION_ESTIMATION_CONFIG 1001
|
#define PG_POSITION_ESTIMATION_CONFIG 1001
|
||||||
#define PG_NAV_CONFIG 1002
|
#define PG_NAV_CONFIG 1002
|
||||||
|
#define PG_MODE_ACTIVATION_OPERATOR_CONFIG 1003
|
||||||
// OSD configuration (subject to change)
|
// OSD configuration (subject to change)
|
||||||
//#define PG_OSD_FONT_CONFIG 2047
|
//#define PG_OSD_FONT_CONFIG 2047
|
||||||
//#define PG_OSD_VIDEO_CONFIG 2046
|
//#define PG_OSD_VIDEO_CONFIG 2046
|
||||||
|
|
|
@ -185,8 +185,6 @@ void createDefaultConfig(master_t *config)
|
||||||
// for (int i = 0; i < CHECKBOXITEMS; i++)
|
// for (int i = 0; i < CHECKBOXITEMS; i++)
|
||||||
// cfg.activate[i] = 0;
|
// cfg.activate[i] = 0;
|
||||||
|
|
||||||
config->modeActivationOperator = MODE_OPERATOR_OR; // default is to OR multiple-channel mode activation conditions
|
|
||||||
|
|
||||||
// Radio
|
// Radio
|
||||||
#ifdef RX_CHANNELS_TAER
|
#ifdef RX_CHANNELS_TAER
|
||||||
parseRcChannels("TAER1234");
|
parseRcChannels("TAER1234");
|
||||||
|
@ -332,8 +330,6 @@ static void activateConfig(void)
|
||||||
|
|
||||||
resetAdjustmentStates();
|
resetAdjustmentStates();
|
||||||
|
|
||||||
useRcControlsConfig(masterConfig.modeActivationConditions);
|
|
||||||
|
|
||||||
failsafeReset();
|
failsafeReset();
|
||||||
|
|
||||||
setAccelerationCalibrationValues();
|
setAccelerationCalibrationValues();
|
||||||
|
|
|
@ -517,7 +517,7 @@ void init(void)
|
||||||
|
|
||||||
failsafeInit(flight3DConfig()->deadband3d_throttle);
|
failsafeInit(flight3DConfig()->deadband3d_throttle);
|
||||||
|
|
||||||
rxInit(masterConfig.modeActivationConditions);
|
rxInit();
|
||||||
|
|
||||||
#ifdef GPS
|
#ifdef GPS
|
||||||
if (feature(FEATURE_GPS)) {
|
if (feature(FEATURE_GPS)) {
|
||||||
|
|
|
@ -714,7 +714,7 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
|
|
||||||
case MSP_MODE_RANGES:
|
case MSP_MODE_RANGES:
|
||||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
const modeActivationCondition_t *mac = modeActivationConditions(i);
|
||||||
const box_t *box = findBoxByActiveBoxId(mac->modeId);
|
const box_t *box = findBoxByActiveBoxId(mac->modeId);
|
||||||
sbufWriteU8(dst, box ? box->permanentId : 0);
|
sbufWriteU8(dst, box ? box->permanentId : 0);
|
||||||
sbufWriteU8(dst, mac->auxChannelIndex);
|
sbufWriteU8(dst, mac->auxChannelIndex);
|
||||||
|
@ -1337,7 +1337,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
case MSP_SET_MODE_RANGE:
|
case MSP_SET_MODE_RANGE:
|
||||||
i = sbufReadU8(src);
|
i = sbufReadU8(src);
|
||||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
modeActivationCondition_t *mac = modeActivationConditionsMutable(i);
|
||||||
i = sbufReadU8(src);
|
i = sbufReadU8(src);
|
||||||
const box_t *box = findBoxByPermenantId(i);
|
const box_t *box = findBoxByPermenantId(i);
|
||||||
if (box) {
|
if (box) {
|
||||||
|
@ -1346,7 +1346,7 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
mac->range.startStep = sbufReadU8(src);
|
mac->range.startStep = sbufReadU8(src);
|
||||||
mac->range.endStep = sbufReadU8(src);
|
mac->range.endStep = sbufReadU8(src);
|
||||||
|
|
||||||
useRcControlsConfig(masterConfig.modeActivationConditions);
|
useRcControlsConfig();
|
||||||
} else {
|
} else {
|
||||||
return MSP_RESULT_ERROR;
|
return MSP_RESULT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,7 +360,7 @@ void processRx(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
processRcStickPositions(throttleStatus, armingConfig()->disarm_kill_switch, armingConfig()->fixed_wing_auto_arm);
|
processRcStickPositions(throttleStatus, armingConfig()->disarm_kill_switch, armingConfig()->fixed_wing_auto_arm);
|
||||||
|
|
||||||
updateActivatedModes(masterConfig.modeActivationConditions, masterConfig.modeActivationOperator);
|
updateActivatedModes();
|
||||||
|
|
||||||
if (!cliMode) {
|
if (!cliMode) {
|
||||||
updateAdjustmentStates(masterConfig.adjustmentRanges);
|
updateAdjustmentStates(masterConfig.adjustmentRanges);
|
||||||
|
|
|
@ -87,35 +87,8 @@ PG_RESET_TEMPLATE(armingConfig_t, armingConfig,
|
||||||
.auto_disarm_delay = 5
|
.auto_disarm_delay = 5
|
||||||
);
|
);
|
||||||
|
|
||||||
void blackboxLogInflightAdjustmentEvent(adjustmentFunction_e adjustmentFunction, int32_t newValue) {
|
PG_REGISTER_ARR(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 0);
|
||||||
#ifndef BLACKBOX
|
PG_REGISTER(modeActivationOperatorConfig_t, modeActivationOperatorConfig, PG_MODE_ACTIVATION_OPERATOR_CONFIG, 0);
|
||||||
UNUSED(adjustmentFunction);
|
|
||||||
UNUSED(newValue);
|
|
||||||
#else
|
|
||||||
if (feature(FEATURE_BLACKBOX)) {
|
|
||||||
flightLogEvent_inflightAdjustment_t eventData;
|
|
||||||
eventData.adjustmentFunction = adjustmentFunction;
|
|
||||||
eventData.newValue = newValue;
|
|
||||||
eventData.floatFlag = false;
|
|
||||||
blackboxLogEvent(FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT, (flightLogEventData_t*)&eventData);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void blackboxLogInflightAdjustmentEventFloat(adjustmentFunction_e adjustmentFunction, float newFloatValue) {
|
|
||||||
#ifndef BLACKBOX
|
|
||||||
UNUSED(adjustmentFunction);
|
|
||||||
UNUSED(newFloatValue);
|
|
||||||
#else
|
|
||||||
if (feature(FEATURE_BLACKBOX)) {
|
|
||||||
flightLogEvent_inflightAdjustment_t eventData;
|
|
||||||
eventData.adjustmentFunction = adjustmentFunction;
|
|
||||||
eventData.newFloatValue = newFloatValue;
|
|
||||||
eventData.floatFlag = true;
|
|
||||||
blackboxLogEvent(FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT, (flightLogEventData_t*)&eventData);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isUsingSticksForArming(void)
|
bool isUsingSticksForArming(void)
|
||||||
{
|
{
|
||||||
|
@ -313,14 +286,10 @@ void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isModeActivationConditionPresent(modeActivationCondition_t *modeActivationConditions, boxId_e modeId)
|
bool isModeActivationConditionPresent(boxId_e modeId)
|
||||||
{
|
{
|
||||||
uint8_t index;
|
for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||||
|
if (modeActivationConditions(index)->modeId == modeId && IS_RANGE_USABLE(&modeActivationConditions(index)->range)) {
|
||||||
for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
|
||||||
modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index];
|
|
||||||
|
|
||||||
if (modeActivationCondition->modeId == modeId && IS_RANGE_USABLE(&modeActivationCondition->range)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +297,7 @@ bool isModeActivationConditionPresent(modeActivationCondition_t *modeActivationC
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRangeActive(uint8_t auxChannelIndex, channelRange_t *range) {
|
static bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range) {
|
||||||
if (!IS_RANGE_USABLE(range)) {
|
if (!IS_RANGE_USABLE(range)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -338,10 +307,8 @@ bool isRangeActive(uint8_t auxChannelIndex, channelRange_t *range) {
|
||||||
channelValue < 900 + (range->endStep * 25));
|
channelValue < 900 + (range->endStep * 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateActivatedModes(modeActivationCondition_t *modeActivationConditions, modeActivationOperator_e modeActivationOperator)
|
void updateActivatedModes(void)
|
||||||
{
|
{
|
||||||
uint8_t modeIndex;
|
|
||||||
|
|
||||||
// Unfortunately for AND logic it's not enough to simply check if any of the specified channel range conditions are valid for a mode.
|
// 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.
|
// We need to count the total number of conditions specified for each mode, and check that all those conditions are currently valid.
|
||||||
|
|
||||||
|
@ -351,15 +318,14 @@ void updateActivatedModes(modeActivationCondition_t *modeActivationConditions, m
|
||||||
memset(specifiedConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
memset(specifiedConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||||
memset(validConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
memset(validConditionCountPerMode, 0, CHECKBOX_ITEM_COUNT);
|
||||||
|
|
||||||
for (modeIndex = 0; modeIndex < MAX_MODE_ACTIVATION_CONDITION_COUNT; modeIndex++) {
|
for (int modeIndex = 0; modeIndex < MAX_MODE_ACTIVATION_CONDITION_COUNT; modeIndex++) {
|
||||||
modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[modeIndex];
|
|
||||||
|
|
||||||
// Increment the number of specified conditions for this mode
|
// Increment the number of specified conditions for this mode
|
||||||
specifiedConditionCountPerMode[modeActivationCondition->modeId]++;
|
specifiedConditionCountPerMode[modeActivationConditions(modeIndex)->modeId]++;
|
||||||
|
|
||||||
if (isRangeActive(modeActivationCondition->auxChannelIndex, &modeActivationCondition->range)) {
|
if (isRangeActive(modeActivationConditions(modeIndex)->auxChannelIndex, &modeActivationConditions(modeIndex)->range)) {
|
||||||
// Increment the number of valid conditions for this mode
|
// Increment the number of valid conditions for this mode
|
||||||
validConditionCountPerMode[modeActivationCondition->modeId]++;
|
validConditionCountPerMode[modeActivationConditions(modeIndex)->modeId]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,13 +333,13 @@ void updateActivatedModes(modeActivationCondition_t *modeActivationConditions, m
|
||||||
rcModeActivationMask = 0;
|
rcModeActivationMask = 0;
|
||||||
|
|
||||||
// Now see which modes should be enabled
|
// Now see which modes should be enabled
|
||||||
for (modeIndex = 0; modeIndex < CHECKBOX_ITEM_COUNT; modeIndex++) {
|
for (int modeIndex = 0; modeIndex < CHECKBOX_ITEM_COUNT; modeIndex++) {
|
||||||
// only modes with conditions specified are considered
|
// only modes with conditions specified are considered
|
||||||
if (specifiedConditionCountPerMode[modeIndex] > 0) {
|
if (specifiedConditionCountPerMode[modeIndex] > 0) {
|
||||||
// For AND logic, the specified condition count and valid condition count must be the same.
|
// 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.
|
// For OR logic, the valid condition count must be greater than zero.
|
||||||
|
|
||||||
if (modeActivationOperator == MODE_OPERATOR_AND) {
|
if (modeActivationOperatorConfig()->modeActivationOperator == MODE_OPERATOR_AND) {
|
||||||
// AND the conditions
|
// AND the conditions
|
||||||
if (validConditionCountPerMode[modeIndex] == specifiedConditionCountPerMode[modeIndex]) {
|
if (validConditionCountPerMode[modeIndex] == specifiedConditionCountPerMode[modeIndex]) {
|
||||||
ACTIVATE_RC_MODE(modeIndex);
|
ACTIVATE_RC_MODE(modeIndex);
|
||||||
|
@ -518,6 +484,38 @@ void configureAdjustment(uint8_t index, uint8_t auxSwitchChannelIndex, const adj
|
||||||
MARK_ADJUSTMENT_FUNCTION_AS_READY(index);
|
MARK_ADJUSTMENT_FUNCTION_AS_READY(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void blackboxLogInflightAdjustmentEvent(adjustmentFunction_e adjustmentFunction, int32_t newValue) {
|
||||||
|
#ifndef BLACKBOX
|
||||||
|
UNUSED(adjustmentFunction);
|
||||||
|
UNUSED(newValue);
|
||||||
|
#else
|
||||||
|
if (feature(FEATURE_BLACKBOX)) {
|
||||||
|
flightLogEvent_inflightAdjustment_t eventData;
|
||||||
|
eventData.adjustmentFunction = adjustmentFunction;
|
||||||
|
eventData.newValue = newValue;
|
||||||
|
eventData.floatFlag = false;
|
||||||
|
blackboxLogEvent(FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT, (flightLogEventData_t*)&eventData);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void blackboxLogInflightAdjustmentEventFloat(adjustmentFunction_e adjustmentFunction, float newFloatValue) {
|
||||||
|
#ifndef BLACKBOX
|
||||||
|
UNUSED(adjustmentFunction);
|
||||||
|
UNUSED(newFloatValue);
|
||||||
|
#else
|
||||||
|
if (feature(FEATURE_BLACKBOX)) {
|
||||||
|
flightLogEvent_inflightAdjustment_t eventData;
|
||||||
|
eventData.adjustmentFunction = adjustmentFunction;
|
||||||
|
eventData.newFloatValue = newFloatValue;
|
||||||
|
eventData.floatFlag = true;
|
||||||
|
blackboxLogEvent(FLIGHT_LOG_EVENT_INFLIGHT_ADJUSTMENT, (flightLogEventData_t*)&eventData);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentFunction, int delta) {
|
static void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentFunction, int delta) {
|
||||||
int newValue;
|
int newValue;
|
||||||
|
|
||||||
|
@ -735,14 +733,14 @@ int32_t getRcStickDeflection(int32_t axis, uint16_t midrc) {
|
||||||
return MIN(ABS(rcData[axis] - midrc), 500);
|
return MIN(ABS(rcData[axis] - midrc), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions)
|
void useRcControlsConfig(void)
|
||||||
{
|
{
|
||||||
isUsingSticksToArm = !isModeActivationConditionPresent(modeActivationConditions, BOXARM);
|
isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM);
|
||||||
|
|
||||||
#ifdef NAV
|
#ifdef NAV
|
||||||
isUsingNAVModes = isModeActivationConditionPresent(modeActivationConditions, BOXNAVPOSHOLD) ||
|
isUsingNAVModes = isModeActivationConditionPresent(BOXNAVPOSHOLD) ||
|
||||||
isModeActivationConditionPresent(modeActivationConditions, BOXNAVRTH) ||
|
isModeActivationConditionPresent(BOXNAVRTH) ||
|
||||||
isModeActivationConditionPresent(modeActivationConditions, BOXNAVWP);
|
isModeActivationConditionPresent(BOXNAVWP);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,11 +123,19 @@ typedef struct modeActivationCondition_s {
|
||||||
|
|
||||||
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
|
#define IS_RANGE_USABLE(range) ((range)->startStep < (range)->endStep)
|
||||||
|
|
||||||
|
PG_DECLARE_ARR(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MODE_OPERATOR_OR,
|
MODE_OPERATOR_OR, // default
|
||||||
MODE_OPERATOR_AND
|
MODE_OPERATOR_AND
|
||||||
} modeActivationOperator_e;
|
} modeActivationOperator_e;
|
||||||
|
|
||||||
|
typedef struct modeActivationOperatorConfig_s {
|
||||||
|
modeActivationOperator_e modeActivationOperator;
|
||||||
|
} modeActivationOperatorConfig_t;
|
||||||
|
|
||||||
|
PG_DECLARE(modeActivationOperatorConfig_t, modeActivationOperatorConfig);
|
||||||
|
|
||||||
extern int16_t rcCommand[4];
|
extern int16_t rcCommand[4];
|
||||||
|
|
||||||
typedef struct rcControlsConfig_s {
|
typedef struct rcControlsConfig_s {
|
||||||
|
@ -154,7 +162,7 @@ throttleStatus_e calculateThrottleStatus(uint16_t deadband3d_throttle);
|
||||||
rollPitchStatus_e calculateRollPitchCenterStatus(void);
|
rollPitchStatus_e calculateRollPitchCenterStatus(void);
|
||||||
void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_switch, bool fixed_wing_auto_arm);
|
void processRcStickPositions(throttleStatus_e throttleStatus, bool disarm_kill_switch, bool fixed_wing_auto_arm);
|
||||||
|
|
||||||
void updateActivatedModes(modeActivationCondition_t *modeActivationConditions, modeActivationOperator_e modeActivationOperator);
|
void updateActivatedModes(void);
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -246,5 +254,5 @@ bool isUsingSticksForArming(void);
|
||||||
bool isUsingNavigationModes(void);
|
bool isUsingNavigationModes(void);
|
||||||
|
|
||||||
int32_t getRcStickDeflection(int32_t axis, uint16_t midrc);
|
int32_t getRcStickDeflection(int32_t axis, uint16_t midrc);
|
||||||
bool isModeActivationConditionPresent(modeActivationCondition_t *modeActivationConditions, boxId_e modeId);
|
bool isModeActivationConditionPresent(boxId_e modeId);
|
||||||
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions);
|
void useRcControlsConfig(void);
|
||||||
|
|
|
@ -1147,6 +1147,7 @@ static navConfig_t navConfigCopy;
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
static telemetryConfig_t telemetryConfigCopy;
|
static telemetryConfig_t telemetryConfigCopy;
|
||||||
#endif
|
#endif
|
||||||
|
static modeActivationCondition_t modeActivationConditionsCopy[MAX_MODE_ACTIVATION_CONDITION_COUNT];
|
||||||
|
|
||||||
static void backupConfigs(void)
|
static void backupConfigs(void)
|
||||||
{
|
{
|
||||||
|
@ -1200,6 +1201,9 @@ static void backupConfigs(void)
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
telemetryConfigCopy = *telemetryConfig();
|
telemetryConfigCopy = *telemetryConfig();
|
||||||
#endif
|
#endif
|
||||||
|
for (int ii = 0; ii < MAX_MODE_ACTIVATION_CONDITION_COUNT; ++ii) {
|
||||||
|
modeActivationConditionsCopy[ii] = *modeActivationConditions(ii);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void restoreConfigs(void)
|
static void restoreConfigs(void)
|
||||||
|
@ -1253,6 +1257,9 @@ static void restoreConfigs(void)
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
*telemetryConfigMutable() = telemetryConfigCopy;
|
*telemetryConfigMutable() = telemetryConfigCopy;
|
||||||
#endif
|
#endif
|
||||||
|
for (int ii = 0; ii < MAX_MODE_ACTIVATION_CONDITION_COUNT; ++ii) {
|
||||||
|
*modeActivationConditionsMutable(ii) = modeActivationConditionsCopy[ii];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
static void *getDefaultPointer(const void *valuePointer, const master_t *defaultConfig)
|
||||||
|
@ -1669,12 +1676,12 @@ static void cliAux(char *cmdline)
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
if (isEmpty(cmdline)) {
|
if (isEmpty(cmdline)) {
|
||||||
printAux(DUMP_MASTER, masterConfig.modeActivationConditions, NULL);
|
printAux(DUMP_MASTER, modeActivationConditions(0), NULL);
|
||||||
} else {
|
} else {
|
||||||
ptr = cmdline;
|
ptr = cmdline;
|
||||||
i = atoi(ptr++);
|
i = atoi(ptr++);
|
||||||
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
if (i < MAX_MODE_ACTIVATION_CONDITION_COUNT) {
|
||||||
modeActivationCondition_t *mac = &masterConfig.modeActivationConditions[i];
|
modeActivationCondition_t *mac = modeActivationConditionsMutable(i);
|
||||||
uint8_t validArgumentCount = 0;
|
uint8_t validArgumentCount = 0;
|
||||||
ptr = nextArg(ptr);
|
ptr = nextArg(ptr);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
|
@ -3512,7 +3519,7 @@ static void printConfig(char *cmdline, bool doDiff)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cliPrintHashLine("aux");
|
cliPrintHashLine("aux");
|
||||||
printAux(dumpMask, masterConfig.modeActivationConditions, defaultConfig.modeActivationConditions);
|
printAux(dumpMask, modeActivationConditionsCopy, modeActivationConditions(0));
|
||||||
|
|
||||||
cliPrintHashLine("adjrange");
|
cliPrintHashLine("adjrange");
|
||||||
printAdjustmentRange(dumpMask, masterConfig.adjustmentRanges, defaultConfig.adjustmentRanges);
|
printAdjustmentRange(dumpMask, masterConfig.adjustmentRanges, defaultConfig.adjustmentRanges);
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
@ -58,6 +59,7 @@
|
||||||
#include "io/displayport_max7456.h"
|
#include "io/displayport_max7456.h"
|
||||||
#include "io/flashfs.h"
|
#include "io/flashfs.h"
|
||||||
#include "io/gimbal.h"
|
#include "io/gimbal.h"
|
||||||
|
#include "io/gps.h"
|
||||||
#include "io/osd.h"
|
#include "io/osd.h"
|
||||||
|
|
||||||
#include "fc/config.h"
|
#include "fc/config.h"
|
||||||
|
|
|
@ -251,7 +251,7 @@ bool serialRxInit(const rxConfig_t *rxConfig, rxRuntimeConfig_t *rxRuntimeConfig
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rxInit(const modeActivationCondition_t *modeActivationConditions)
|
void rxInit(void)
|
||||||
{
|
{
|
||||||
rxRuntimeConfig.rcReadRawFn = nullReadRawRC;
|
rxRuntimeConfig.rcReadRawFn = nullReadRawRC;
|
||||||
rxRuntimeConfig.rcFrameStatusFn = nullFrameStatus;
|
rxRuntimeConfig.rcFrameStatusFn = nullFrameStatus;
|
||||||
|
@ -267,17 +267,16 @@ void rxInit(const modeActivationCondition_t *modeActivationConditions)
|
||||||
|
|
||||||
// Initialize ARM switch to OFF position when arming via switch is defined
|
// Initialize ARM switch to OFF position when arming via switch is defined
|
||||||
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
for (int i = 0; i < MAX_MODE_ACTIVATION_CONDITION_COUNT; i++) {
|
||||||
const modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[i];
|
if (modeActivationConditions(i)->modeId == BOXARM && IS_RANGE_USABLE(&modeActivationConditions(i)->range)) {
|
||||||
if (modeActivationCondition->modeId == BOXARM && IS_RANGE_USABLE(&modeActivationCondition->range)) {
|
|
||||||
// ARM switch is defined, determine an OFF value
|
// ARM switch is defined, determine an OFF value
|
||||||
uint16_t value;
|
uint16_t value;
|
||||||
if (modeActivationCondition->range.startStep > 0) {
|
if (modeActivationConditions(i)->range.startStep > 0) {
|
||||||
value = MODE_STEP_TO_CHANNEL_VALUE((modeActivationCondition->range.startStep - 1));
|
value = MODE_STEP_TO_CHANNEL_VALUE((modeActivationConditions(i)->range.startStep - 1));
|
||||||
} else {
|
} else {
|
||||||
value = MODE_STEP_TO_CHANNEL_VALUE((modeActivationCondition->range.endStep + 1));
|
value = MODE_STEP_TO_CHANNEL_VALUE((modeActivationConditions(i)->range.endStep + 1));
|
||||||
}
|
}
|
||||||
// Initialize ARM AUX channel to OFF value
|
// Initialize ARM AUX channel to OFF value
|
||||||
rcData[modeActivationCondition->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = value;
|
rcData[modeActivationConditions(i)->auxChannelIndex + NON_AUX_CHANNEL_COUNT] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,7 @@ typedef struct rxRuntimeConfig_s {
|
||||||
|
|
||||||
extern rxRuntimeConfig_t rxRuntimeConfig; //!!TODO remove this extern, only needed once for channelCount
|
extern rxRuntimeConfig_t rxRuntimeConfig; //!!TODO remove this extern, only needed once for channelCount
|
||||||
|
|
||||||
struct modeActivationCondition_s;
|
void rxInit(void);
|
||||||
void rxInit(const struct modeActivationCondition_s *modeActivationConditions);
|
|
||||||
bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime);
|
bool rxUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTime);
|
||||||
bool rxIsReceivingSignal(void);
|
bool rxIsReceivingSignal(void);
|
||||||
bool rxAreFlightChannelsValid(void);
|
bool rxAreFlightChannelsValid(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue