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

Added mission loaded to system message #7519

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 42 additions & 32 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4107,13 +4107,13 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
if (buff != NULL) {
const char *message = NULL;
char messageBuf[MAX(SETTING_MAX_NAME_LENGTH, OSD_MESSAGE_LENGTH+1)];
if (ARMING_FLAG(ARMED)) {
// Aircraft is armed. We might have up to 5
// messages to show.
const char *messages[5];
unsigned messageCount = 0;
const char *failsafeInfoMessage = NULL;
// We might have up to 5 messages to show.
const char *messages[5];
unsigned messageCount = 0;
const char *failsafeInfoMessage = NULL;
const char *invertedInfoMessage = NULL;

if (ARMING_FLAG(ARMED)) {
if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding()) {
if (isWaypointMissionRTHActive()) {
// if RTH activated whilst WP mode selected, remind pilot to cancel WP mode to exit RTH
Expand Down Expand Up @@ -4188,45 +4188,55 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
}
}
}
if (messageCount > 0) {
message = messages[OSD_ALTERNATING_CHOICES(1000, messageCount)];
if (message == failsafeInfoMessage) {
// failsafeInfoMessage is not useful for recovering
// a lost model, but might help avoiding a crash.
// Blink to grab user attention.
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
}
// We're shoing either failsafePhaseMessage or
// navStateMessage. Don't BLINK here since
// having this text available might be crucial
// during a lost aircraft recovery and blinking
// will cause it to be missing from some frames.
}
} else if (ARMING_FLAG(ARMING_DISABLED_ALL_FLAGS)) {
unsigned invalidIndex;

// Check if we're unable to arm for some reason
if (ARMING_FLAG(ARMING_DISABLED_INVALID_SETTING) && !settingsValidate(&invalidIndex)) {
if (OSD_ALTERNATING_CHOICES(1000, 2) == 0) {

const setting_t *setting = settingGet(invalidIndex);
settingGetName(setting, messageBuf);
for (int ii = 0; messageBuf[ii]; ii++) {
messageBuf[ii] = sl_toupper(messageBuf[ii]);
}
message = messageBuf;
} else {
message = OSD_MESSAGE_STR(OSD_MSG_INVALID_SETTING);
TEXT_ATTRIBUTES_ADD_INVERTED(elemAttr);
}
invertedInfoMessage = messageBuf;
messages[messageCount++] = invertedInfoMessage;

invertedInfoMessage = OSD_MESSAGE_STR(OSD_MSG_INVALID_SETTING);
messages[messageCount++] = invertedInfoMessage;

} else {
if (OSD_ALTERNATING_CHOICES(1000, 2) == 0) {
message = OSD_MESSAGE_STR(OSD_MSG_UNABLE_ARM);
TEXT_ATTRIBUTES_ADD_INVERTED(elemAttr);
} else {

invertedInfoMessage = OSD_MESSAGE_STR(OSD_MSG_UNABLE_ARM);
messages[messageCount++] = invertedInfoMessage;

// Show the reason for not arming
message = osdArmingDisabledReasonMessage();
}
messages[messageCount++] = osdArmingDisabledReasonMessage();

}
} else if (!ARMING_FLAG(ARMED)) {
if (isWaypointListValid()) {
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_WP_MISSION_LOADED);
}
}

if (messageCount > 0) {
message = messages[OSD_ALTERNATING_CHOICES(1000, messageCount)];
if (message == failsafeInfoMessage) {
// failsafeInfoMessage is not useful for recovering
// a lost model, but might help avoiding a crash.
// Blink to grab user attention.
TEXT_ATTRIBUTES_ADD_BLINK(elemAttr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that some boards do not work out of the box with "BLINK".

Copy link
Collaborator Author

@MrD-RC MrD-RC Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blink part has not been changed from the old code. It has only been moved. How blink is dealt with has not changed.

} else if (message == invertedInfoMessage) {
TEXT_ATTRIBUTES_ADD_INVERTED(elemAttr);
}
// We're shoing either failsafePhaseMessage or
// navStateMessage. Don't BLINK here since
// having this text available might be crucial
// during a lost aircraft recovery and blinking
// will cause it to be missing from some frames.
}

osdFormatMessage(buff, buff_size, message, isCenteredText);
}
return elemAttr;
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 @@ -86,6 +86,7 @@
#define OSD_MSG_WP_FINISHED "WP END>HOLDING POSITION"
#define OSD_MSG_PREPARE_NEXT_WP "PREPARING FOR NEXT WAYPOINT"
#define OSD_MSG_WP_RTH_CANCEL "CANCEL WP TO EXIT RTH"
#define OSD_MSG_WP_MISSION_LOADED "* MISSION LOADED *"
#define OSD_MSG_EMERG_LANDING "EMERGENCY LANDING"
#define OSD_MSG_LANDING "LANDING"
#define OSD_MSG_LOITERING_HOME "LOITERING AROUND HOME"
Expand Down