mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 08:15:26 +03:00
Add define for functions only
This commit is contained in:
parent
993c007a04
commit
1b79cbd232
7 changed files with 35 additions and 14 deletions
|
@ -177,7 +177,7 @@ int16_t getAxisRcCommand(int16_t rawData, int16_t rate, int16_t deadband)
|
||||||
{
|
{
|
||||||
int16_t stickDeflection = 0;
|
int16_t stickDeflection = 0;
|
||||||
|
|
||||||
#if defined(SITL_BUILD) // Workaround due to strange bug in GCC > 10.2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108914
|
#if defined(SITL_BUILD) // Workaround due to strange bug in GCC > 10.2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108914
|
||||||
const int16_t value = rawData - PWM_RANGE_MIDDLE;
|
const int16_t value = rawData - PWM_RANGE_MIDDLE;
|
||||||
if (value < -500) {
|
if (value < -500) {
|
||||||
stickDeflection = -500;
|
stickDeflection = -500;
|
||||||
|
@ -187,9 +187,9 @@ int16_t getAxisRcCommand(int16_t rawData, int16_t rate, int16_t deadband)
|
||||||
stickDeflection = value;
|
stickDeflection = value;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
stickDeflection = constrain(rawData - PWM_RANGE_MIDDLE, -500, 500);
|
stickDeflection = constrain(rawData - PWM_RANGE_MIDDLE, -500, 500);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stickDeflection = applyDeadbandRescaled(stickDeflection, deadband, -500, 500);
|
stickDeflection = applyDeadbandRescaled(stickDeflection, deadband, -500, 500);
|
||||||
return rcLookup(stickDeflection, rate);
|
return rcLookup(stickDeflection, rate);
|
||||||
}
|
}
|
||||||
|
@ -523,9 +523,12 @@ void tryArm(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (STATE(MULTIROTOR) && (IS_RC_MODE_ACTIVE(BOXTURTLE) || MULTI_FUNC_FLAG(MF_TURTLE_MODE)) && !FLIGHT_MODE(TURTLE_MODE) &&
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
emergencyArmingCanOverrideArmingDisabled() && isMotorProtocolDshot()
|
const bool turtleIsActive = IS_RC_MODE_ACTIVE(BOXTURTLE) || MULTI_FUNC_FLAG(MF_TURTLE_MODE);
|
||||||
) {
|
#else
|
||||||
|
const bool turtleIsActive = IS_RC_MODE_ACTIVE(BOXTURTLE);
|
||||||
|
#endif
|
||||||
|
if (STATE(MULTIROTOR) && turtleIsActive && !FLIGHT_MODE(TURTLE_MODE) && emergencyArmingCanOverrideArmingDisabled() && isMotorProtocolDshot()) {
|
||||||
sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_REVERSED);
|
sendDShotCommand(DSHOT_CMD_SPIN_DIRECTION_REVERSED);
|
||||||
ENABLE_ARMING_FLAG(ARMED);
|
ENABLE_ARMING_FLAG(ARMED);
|
||||||
enableFlightMode(TURTLE_MODE);
|
enableFlightMode(TURTLE_MODE);
|
||||||
|
@ -842,7 +845,7 @@ static float calculateThrottleTiltCompensationFactor(uint8_t throttleTiltCompens
|
||||||
|
|
||||||
void taskMainPidLoop(timeUs_t currentTimeUs)
|
void taskMainPidLoop(timeUs_t currentTimeUs)
|
||||||
{
|
{
|
||||||
|
|
||||||
cycleTime = getTaskDeltaTime(TASK_SELF);
|
cycleTime = getTaskDeltaTime(TASK_SELF);
|
||||||
dT = (float)cycleTime * 0.000001f;
|
dT = (float)cycleTime * 0.000001f;
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,9 @@ void initActiveBoxIds(void)
|
||||||
RESET_BOX_ID_COUNT;
|
RESET_BOX_ID_COUNT;
|
||||||
ADD_ACTIVE_BOX(BOXARM);
|
ADD_ACTIVE_BOX(BOXARM);
|
||||||
ADD_ACTIVE_BOX(BOXPREARM);
|
ADD_ACTIVE_BOX(BOXPREARM);
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
ADD_ACTIVE_BOX(BOXMULTIFUNCTION);
|
ADD_ACTIVE_BOX(BOXMULTIFUNCTION);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (sensors(SENSOR_ACC) && STATE(ALTITUDE_CONTROL)) {
|
if (sensors(SENSOR_ACC) && STATE(ALTITUDE_CONTROL)) {
|
||||||
ADD_ACTIVE_BOX(BOXANGLE);
|
ADD_ACTIVE_BOX(BOXANGLE);
|
||||||
|
@ -414,8 +416,9 @@ void packBoxModeFlags(boxBitmask_t * mspBoxModeFlags)
|
||||||
#ifdef USE_MULTI_MISSION
|
#ifdef USE_MULTI_MISSION
|
||||||
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCHANGEMISSION)), BOXCHANGEMISSION);
|
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXCHANGEMISSION)), BOXCHANGEMISSION);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXMULTIFUNCTION)), BOXMULTIFUNCTION);
|
CHECK_ACTIVE_BOX(IS_ENABLED(IS_RC_MODE_ACTIVE(BOXMULTIFUNCTION)), BOXMULTIFUNCTION);
|
||||||
|
#endif
|
||||||
memset(mspBoxModeFlags, 0, sizeof(boxBitmask_t));
|
memset(mspBoxModeFlags, 0, sizeof(boxBitmask_t));
|
||||||
for (uint32_t i = 0; i < activeBoxIdCount; i++) {
|
for (uint32_t i = 0; i < activeBoxIdCount; i++) {
|
||||||
if (activeBoxes[activeBoxIds[i]]) {
|
if (activeBoxes[activeBoxIds[i]]) {
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#include "build/debug.h"
|
#include "build/debug.h"
|
||||||
#include "drivers/time.h"
|
#include "drivers/time.h"
|
||||||
|
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
|
|
||||||
#include "fc/fc_core.h"
|
#include "fc/fc_core.h"
|
||||||
#include "fc/multifunction.h"
|
#include "fc/multifunction.h"
|
||||||
#include "fc/rc_modes.h"
|
#include "fc/rc_modes.h"
|
||||||
|
@ -127,3 +129,4 @@ multi_function_e multiFunctionSelection(void)
|
||||||
|
|
||||||
return selectedItem;
|
return selectedItem;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
|
|
||||||
extern uint8_t multiFunctionFlags;
|
extern uint8_t multiFunctionFlags;
|
||||||
|
|
||||||
#define MULTI_FUNC_FLAG_DISABLE(mask) (multiFunctionFlags &= ~(mask))
|
#define MULTI_FUNC_FLAG_DISABLE(mask) (multiFunctionFlags &= ~(mask))
|
||||||
|
@ -50,3 +52,4 @@ typedef enum {
|
||||||
multi_function_e multiFunctionSelection(void);
|
multi_function_e multiFunctionSelection(void);
|
||||||
bool isNextMultifunctionItemAvailable(void);
|
bool isNextMultifunctionItemAvailable(void);
|
||||||
void setMultifunctionSelection(multi_function_e item);
|
void setMultifunctionSelection(multi_function_e item);
|
||||||
|
#endif
|
||||||
|
|
|
@ -5053,6 +5053,7 @@ static textAttributes_t osdGetMultiFunctionMessage(char *buff)
|
||||||
static uint8_t warningsCount;
|
static uint8_t warningsCount;
|
||||||
const char *message = NULL;
|
const char *message = NULL;
|
||||||
|
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
/* --- FUNCTIONS --- */
|
/* --- FUNCTIONS --- */
|
||||||
multi_function_e selectedFunction = multiFunctionSelection();
|
multi_function_e selectedFunction = multiFunctionSelection();
|
||||||
|
|
||||||
|
@ -5086,7 +5087,7 @@ static textAttributes_t osdGetMultiFunctionMessage(char *buff)
|
||||||
case MULTI_FUNC_5:
|
case MULTI_FUNC_5:
|
||||||
#ifdef USE_DSHOT
|
#ifdef USE_DSHOT
|
||||||
if (STATE(MULTIROTOR)) {
|
if (STATE(MULTIROTOR)) {
|
||||||
message = MULTI_FUNC_FLAG(MF_TURTLE_MODE) ? "USE TURTLE" : "END TURTLE";
|
message = MULTI_FUNC_FLAG(MF_TURTLE_MODE) ? "END TURTLE" : "USE TURTLE";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -5112,6 +5113,7 @@ static textAttributes_t osdGetMultiFunctionMessage(char *buff)
|
||||||
|
|
||||||
return elemAttr;
|
return elemAttr;
|
||||||
}
|
}
|
||||||
|
#endif // MULTIFUNCTION - functions only, warnings always defined
|
||||||
|
|
||||||
/* --- WARNINGS --- */
|
/* --- WARNINGS --- */
|
||||||
const char *messages[7];
|
const char *messages[7];
|
||||||
|
|
|
@ -1305,8 +1305,13 @@ static navigationFSMEvent_t navOnEnteringState_NAV_STATE_RTH_TRACKBACK(navigatio
|
||||||
|
|
||||||
if (posControl.flags.estPosStatus >= EST_USABLE) {
|
if (posControl.flags.estPosStatus >= EST_USABLE) {
|
||||||
const int32_t distFromStartTrackback = calculateDistanceToDestination(&posControl.rthTBPointsList[posControl.rthTBLastSavedIndex]) / 100;
|
const int32_t distFromStartTrackback = calculateDistanceToDestination(&posControl.rthTBPointsList[posControl.rthTBLastSavedIndex]) / 100;
|
||||||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
|
const bool overrideTrackback = rthAltControlStickOverrideCheck(ROLL) || MULTI_FUNC_FLAG(MF_SUSPEND_TRACKBACK);
|
||||||
|
#else
|
||||||
|
const bool overrideTrackback = rthAltControlStickOverrideCheck(ROLL);
|
||||||
|
#endif
|
||||||
const bool cancelTrackback = distFromStartTrackback > navConfig()->general.rth_trackback_distance ||
|
const bool cancelTrackback = distFromStartTrackback > navConfig()->general.rth_trackback_distance ||
|
||||||
((rthAltControlStickOverrideCheck(ROLL) || MULTI_FUNC_FLAG(MF_SUSPEND_TRACKBACK)) && !posControl.flags.forcedRTHActivated);
|
(overrideTrackback && !posControl.flags.forcedRTHActivated);
|
||||||
|
|
||||||
if (posControl.activeRthTBPointIndex < 0 || cancelTrackback) {
|
if (posControl.activeRthTBPointIndex < 0 || cancelTrackback) {
|
||||||
posControl.rthTBWrapAroundCounter = posControl.activeRthTBPointIndex = -1;
|
posControl.rthTBWrapAroundCounter = posControl.activeRthTBPointIndex = -1;
|
||||||
|
@ -2437,10 +2442,11 @@ static navigationHomeFlags_t navigationActualStateHomeValidity(void)
|
||||||
#if defined(USE_SAFE_HOME)
|
#if defined(USE_SAFE_HOME)
|
||||||
void checkSafeHomeState(bool shouldBeEnabled)
|
void checkSafeHomeState(bool shouldBeEnabled)
|
||||||
{
|
{
|
||||||
const bool safehomeNotApplicable = navConfig()->general.flags.safehome_usage_mode == SAFEHOME_USAGE_OFF ||
|
bool safehomeNotApplicable = navConfig()->general.flags.safehome_usage_mode == SAFEHOME_USAGE_OFF || posControl.flags.rthTrackbackActive ||
|
||||||
(MULTI_FUNC_FLAG(MF_SUSPEND_SAFEHOMES) && !posControl.flags.forcedRTHActivated) ||
|
(!posControl.safehomeState.isApplied && posControl.homeDistance < navConfig()->general.min_rth_distance);
|
||||||
posControl.flags.rthTrackbackActive ||
|
#ifdef USE_MULTI_FUNCTIONS
|
||||||
(!posControl.safehomeState.isApplied && posControl.homeDistance < navConfig()->general.min_rth_distance);
|
safehomeNotApplicable = safehomeNotApplicable || (MULTI_FUNC_FLAG(MF_SUSPEND_SAFEHOMES) && !posControl.flags.forcedRTHActivated);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (safehomeNotApplicable) {
|
if (safehomeNotApplicable) {
|
||||||
shouldBeEnabled = false;
|
shouldBeEnabled = false;
|
||||||
|
|
|
@ -161,6 +161,7 @@
|
||||||
#define NAV_MAX_WAYPOINTS 120
|
#define NAV_MAX_WAYPOINTS 120
|
||||||
#define USE_RCDEVICE
|
#define USE_RCDEVICE
|
||||||
#define USE_MULTI_MISSION
|
#define USE_MULTI_MISSION
|
||||||
|
#define USE_MULTI_FUNCTIONS // defines functions only, warnings always defined
|
||||||
|
|
||||||
//Enable VTX control
|
//Enable VTX control
|
||||||
#define USE_VTX_CONTROL
|
#define USE_VTX_CONTROL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue