Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Prearm #6562

Merged
merged 3 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ static void updateArmingStatus(void)
DISABLE_ARMING_FLAG(ARMING_DISABLED_SERVO_AUTOTRIM);
}

if (isModeActivationConditionPresent(BOXPREARM)) {
digitalentity marked this conversation as resolved.
Show resolved Hide resolved
if (IS_RC_MODE_ACTIVE(BOXPREARM)) {
DISABLE_ARMING_FLAG(ARMING_DISABLED_NO_PREARM);
digitalentity marked this conversation as resolved.
Show resolved Hide resolved
} else {
ENABLE_ARMING_FLAG(ARMING_DISABLED_NO_PREARM);
}
} else {
DISABLE_ARMING_FLAG(ARMING_DISABLED_NO_PREARM);
}

/* CHECK: Arming switch */
// If arming is disabled and the ARM switch is on
// Note that this should be last check so all other blockers could be cleared correctly
Expand Down Expand Up @@ -506,6 +516,7 @@ void tryArm(void)
#else
beeper(BEEPER_ARMING);
#endif

statsOnArm();

return;
Expand Down
2 changes: 2 additions & 0 deletions src/main/fc/fc_msp_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT + 1] = {
{ BOXUSER2, "USER2", BOX_PERMANENT_ID_USER2 },
{ BOXLOITERDIRCHN, "LOITER CHANGE", 49 },
{ BOXMSPRCOVERRIDE, "MSP RC OVERRIDE", 50 },
{ BOXPREARM, "PREARM", 51 },
{ CHECKBOX_ITEM_COUNT, NULL, 0xFF }
};

Expand Down Expand Up @@ -163,6 +164,7 @@ void initActiveBoxIds(void)

activeBoxIdCount = 0;
activeBoxIds[activeBoxIdCount++] = BOXARM;
activeBoxIds[activeBoxIdCount++] = BOXPREARM;

if (sensors(SENSOR_ACC) && STATE(ALTITUDE_CONTROL)) {
activeBoxIds[activeBoxIdCount++] = BOXANGLE;
Expand Down
8 changes: 1 addition & 7 deletions src/main/fc/rc_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ void rcModeUpdate(boxBitmask_t *newState)

bool isModeActivationConditionPresent(boxId_e modeId)
{
for (int index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
if (modeActivationConditions(index)->modeId == modeId && IS_RANGE_USABLE(&modeActivationConditions(index)->range)) {
return true;
}
}

return false;
return specifiedConditionCountPerMode[modeId] > 0;
digitalentity marked this conversation as resolved.
Show resolved Hide resolved
}

bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range)
Expand Down
1 change: 1 addition & 0 deletions src/main/fc/rc_modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum {
BOXFPVANGLEMIX = 39,
BOXLOITERDIRCHN = 40,
BOXMSPRCOVERRIDE = 41,
BOXPREARM = 42,
CHECKBOX_ITEM_COUNT
} boxId_e;

Expand Down
5 changes: 3 additions & 2 deletions src/main/fc/runtime_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const char *armingDisableFlagNames[]= {
"FS", "ANGLE", "CAL", "OVRLD", "NAV", "COMPASS",
"ACC", "ARMSW", "HWFAIL", "BOXFS", "KILLSW", "RX",
"THR", "CLI", "CMS", "OSD", "ROLL/PITCH", "AUTOTRIM", "OOM",
"SETTINGFAIL", "PWMOUT"
"SETTINGFAIL", "PWMOUT", "NOPREARM"
};
#endif

Expand All @@ -57,7 +57,8 @@ const armingFlag_e armDisableReasonsChecklist[] = {
ARMING_DISABLED_OSD_MENU,
ARMING_DISABLED_ROLLPITCH_NOT_CENTERED,
ARMING_DISABLED_SERVO_AUTOTRIM,
ARMING_DISABLED_OOM
ARMING_DISABLED_OOM,
ARMING_DISABLED_NO_PREARM
};

armingFlag_e isArmingDisabledReason(void)
Expand Down
6 changes: 3 additions & 3 deletions src/main/fc/runtime_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ typedef enum {
WAS_EVER_ARMED = (1 << 3),

ARMING_DISABLED_FAILSAFE_SYSTEM = (1 << 7),

ARMING_DISABLED_NOT_LEVEL = (1 << 8),
ARMING_DISABLED_SENSORS_CALIBRATING = (1 << 9),
ARMING_DISABLED_SYSTEM_OVERLOADED = (1 << 10),
Expand All @@ -44,6 +43,7 @@ typedef enum {
ARMING_DISABLED_OOM = (1 << 25),
ARMING_DISABLED_INVALID_SETTING = (1 << 26),
ARMING_DISABLED_PWM_OUTPUT_ERROR = (1 << 27),
ARMING_DISABLED_NO_PREARM = (1 << 28),

ARMING_DISABLED_ALL_FLAGS = (ARMING_DISABLED_FAILSAFE_SYSTEM | ARMING_DISABLED_NOT_LEVEL | ARMING_DISABLED_SENSORS_CALIBRATING |
ARMING_DISABLED_SYSTEM_OVERLOADED | ARMING_DISABLED_NAVIGATION_UNSAFE |
Expand All @@ -52,7 +52,7 @@ typedef enum {
ARMING_DISABLED_BOXKILLSWITCH | ARMING_DISABLED_RC_LINK | ARMING_DISABLED_THROTTLE | ARMING_DISABLED_CLI |
ARMING_DISABLED_CMS_MENU | ARMING_DISABLED_OSD_MENU | ARMING_DISABLED_ROLLPITCH_NOT_CENTERED |
ARMING_DISABLED_SERVO_AUTOTRIM | ARMING_DISABLED_OOM | ARMING_DISABLED_INVALID_SETTING |
ARMING_DISABLED_PWM_OUTPUT_ERROR),
ARMING_DISABLED_PWM_OUTPUT_ERROR | ARMING_DISABLED_NO_PREARM),
} armingFlag_e;

// Arming blockers that can be overriden by emergency arming.
Expand All @@ -78,7 +78,7 @@ extern const char *armingDisableFlagNames[];
#define ARMING_FLAG(mask) (armingFlags & (mask))

// Returns the 1st flag from ARMING_DISABLED_ALL_FLAGS which is
// preventing arming, or zero is arming is not disabled.
// preventing arming, or zero if arming is not disabled.
armingFlag_e isArmingDisabledReason(void);

typedef enum {
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,8 @@ static const char * osdArmingDisabledReasonMessage(void)
return OSD_MESSAGE_STR(OSD_MSG_CLI_ACTIVE);
case ARMING_DISABLED_PWM_OUTPUT_ERROR:
return OSD_MESSAGE_STR(OSD_MSG_PWM_INIT_ERROR);
case ARMING_DISABLED_NO_PREARM:
return OSD_MESSAGE_STR(OSD_MSG_NO_PREARM);
// Cases without message
case ARMING_DISABLED_CMS_MENU:
FALLTHROUGH;
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#define OSD_MSG_INVALID_SETTING "INVALID SETTING"
#define OSD_MSG_CLI_ACTIVE "CLI IS ACTIVE"
#define OSD_MSG_PWM_INIT_ERROR "PWM INIT ERROR"
#define OSD_MSG_NO_PREARM "NO PREARM"
#define OSD_MSG_RTH_FS "(RTH)"
#define OSD_MSG_EMERG_LANDING_FS "(EMERGENCY LANDING)"
#define OSD_MSG_MOVE_EXIT_FS "!MOVE STICKS TO EXIT FS!"
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/osd_dji_hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ static const char * osdArmingDisabledReasonMessage(void)
return OSD_MESSAGE_STR("CLI");
case ARMING_DISABLED_PWM_OUTPUT_ERROR:
return OSD_MESSAGE_STR("PWM ERR");
case ARMING_DISABLED_NO_PREARM:
return OSD_MESSAGE_STR("NO PREARM");
// Cases without message
case ARMING_DISABLED_CMS_MENU:
FALLTHROUGH;
Expand Down