mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 17:25:18 +03:00
Update system messages
This commit is contained in:
parent
49008f47c9
commit
943e16f81f
1 changed files with 167 additions and 167 deletions
|
@ -5631,24 +5631,19 @@ 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)]; //warning: shared buffer. Make sure it is used by single message in code below!
|
||||
// We might have up to 5 messages to show.
|
||||
const char *messages[5];
|
||||
// Warning: messageBuf is shared. Make sure it is used by single message in code below!
|
||||
char messageBuf[MAX(SETTING_MAX_NAME_LENGTH, OSD_MESSAGE_LENGTH + 1)];
|
||||
// We might have up to 6 messages to show.
|
||||
const char *messages[6];
|
||||
unsigned messageCount = 0;
|
||||
const char *failsafeInfoMessage = NULL;
|
||||
const char *invertedInfoMessage = NULL;
|
||||
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
#ifdef USE_FW_AUTOLAND
|
||||
if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding() || FLIGHT_MODE(NAV_FW_AUTOLAND)) {
|
||||
if (isWaypointMissionRTHActive() && !posControl.fwLandState.landWp) {
|
||||
#else
|
||||
if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding()) {
|
||||
if (isWaypointMissionRTHActive()) {
|
||||
#endif
|
||||
// if RTH activated whilst WP mode selected, remind pilot to cancel WP mode to exit RTH
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_WP_RTH_CANCEL);
|
||||
}
|
||||
if (STATE(LANDING_DETECTED)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_LANDED);
|
||||
} else if (FLIGHT_MODE(FAILSAFE_MODE) || FLIGHT_MODE(NAV_RTH_MODE) || FLIGHT_MODE(NAV_WP_MODE) || navigationIsExecutingAnEmergencyLanding()) {
|
||||
// Returns maximum of 5 messages
|
||||
if (navGetCurrentStateFlags() & NAV_AUTO_WP_DONE) {
|
||||
messages[messageCount++] = STATE(LANDING_DETECTED) ? OSD_MESSAGE_STR(OSD_MSG_WP_LANDED) : OSD_MESSAGE_STR(OSD_MSG_WP_FINISHED);
|
||||
} else if (NAV_Status.state == MW_NAV_STATE_WP_ENROUTE) {
|
||||
|
@ -5670,36 +5665,27 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
|||
|
||||
messages[messageCount++] = messageBuf;
|
||||
}
|
||||
} else if (NAV_Status.state == MW_NAV_STATE_LAND_SETTLE && posControl.landingDelay > 0) {
|
||||
uint16_t remainingHoldSec = MS2S(posControl.landingDelay - millis());
|
||||
tfp_sprintf(messageBuf, "LANDING DELAY: %3u SECONDS", remainingHoldSec);
|
||||
|
||||
messages[messageCount++] = messageBuf;
|
||||
}
|
||||
|
||||
else {
|
||||
#ifdef USE_FW_AUTOLAND
|
||||
if (canFwLandingBeCancelled()) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MOVE_STICKS);
|
||||
} else if (!FLIGHT_MODE(NAV_FW_AUTOLAND)) {
|
||||
#endif
|
||||
const char *navStateMessage = navigationStateMessage();
|
||||
if (navStateMessage) {
|
||||
messages[messageCount++] = navStateMessage;
|
||||
}
|
||||
#ifdef USE_FW_AUTOLAND
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(USE_SAFE_HOME)
|
||||
const char *safehomeMessage = divertingToSafehomeMessage();
|
||||
if (safehomeMessage) {
|
||||
messages[messageCount++] = safehomeMessage;
|
||||
}
|
||||
#endif
|
||||
if (FLIGHT_MODE(FAILSAFE_MODE)) {
|
||||
// In FS mode while being armed too
|
||||
if (FLIGHT_MODE(FAILSAFE_MODE)) { // In FS mode while armed
|
||||
if (NAV_Status.state == MW_NAV_STATE_LAND_SETTLE && posControl.landingDelay > 0) {
|
||||
uint16_t remainingHoldSec = MS2S(posControl.landingDelay - millis());
|
||||
tfp_sprintf(messageBuf, "LANDING DELAY: %3u SECONDS", remainingHoldSec);
|
||||
|
||||
messages[messageCount++] = messageBuf;
|
||||
}
|
||||
|
||||
const char *failsafePhaseMessage = osdFailsafePhaseMessage();
|
||||
failsafeInfoMessage = osdFailsafeInfoMessage();
|
||||
|
||||
|
@ -5709,56 +5695,52 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
|||
if (failsafeInfoMessage) {
|
||||
messages[messageCount++] = failsafeInfoMessage;
|
||||
}
|
||||
} else if (isWaypointMissionRTHActive()) {
|
||||
// if RTH activated whilst WP mode selected, remind pilot to cancel WP mode to exit RTH
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_WP_RTH_CANCEL);
|
||||
}
|
||||
} else { /* messages shown only when Failsafe, WP, RTH or Emergency Landing not active */
|
||||
if (STATE(FIXED_WING_LEGACY) && (navGetCurrentStateFlags() & NAV_CTL_LAUNCH)) {
|
||||
if (STATE(AIRPLANE)) { // Returns maximum of 3 messages
|
||||
#ifdef USE_FW_AUTOLAND
|
||||
if (canFwLandingBeCancelled()) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MOVE_STICKS);
|
||||
} else
|
||||
#endif
|
||||
if (navGetCurrentStateFlags() & NAV_CTL_LAUNCH) {
|
||||
messages[messageCount++] = navConfig()->fw.launch_manual_throttle ? OSD_MESSAGE_STR(OSD_MSG_AUTOLAUNCH_MANUAL) :
|
||||
OSD_MESSAGE_STR(OSD_MSG_AUTOLAUNCH);
|
||||
const char *launchStateMessage = fixedWingLaunchStateMessage();
|
||||
if (launchStateMessage) {
|
||||
messages[messageCount++] = launchStateMessage;
|
||||
}
|
||||
} else if (FLIGHT_MODE(SOARING_MODE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_NAV_SOARING);
|
||||
} else {
|
||||
if (FLIGHT_MODE(NAV_ALTHOLD_MODE) && !navigationRequiresAngleMode()) {
|
||||
// ALTHOLD might be enabled alongside ANGLE/HORIZON/ANGLEHOLD/ACRO
|
||||
// when it doesn't require ANGLE mode (required only in FW
|
||||
// right now). If it requires ANGLE, its display is handled by OSD_FLYMODE.
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_ALTITUDE_HOLD);
|
||||
}
|
||||
if (STATE(MULTIROTOR) && FLIGHT_MODE(NAV_COURSE_HOLD_MODE)) {
|
||||
if (posControl.cruise.multicopterSpeed >= 50.0f) {
|
||||
char buf[6];
|
||||
osdFormatVelocityStr(buf, posControl.cruise.multicopterSpeed, false, false);
|
||||
tfp_sprintf(messageBuf, "(SPD %s)", buf);
|
||||
} else {
|
||||
strcpy(messageBuf, "(HOLD)");
|
||||
}
|
||||
messages[messageCount++] = messageBuf;
|
||||
strcpy(messageBuf, "(AUTO-");
|
||||
if (isFixedWingLevelTrimActive()) {
|
||||
strcat(messageBuf, OSD_MSG_AUTOLEVEL);
|
||||
}
|
||||
if (IS_RC_MODE_ACTIVE(BOXAUTOTRIM) && !feature(FEATURE_FW_AUTOTRIM)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_AUTOTRIM);
|
||||
if (messageBuf[6] != '\0') {
|
||||
strcat(messageBuf, ":");
|
||||
}
|
||||
strcat(messageBuf, OSD_MSG_AUTOTRIM);
|
||||
}
|
||||
if (IS_RC_MODE_ACTIVE(BOXAUTOTUNE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_AUTOTUNE);
|
||||
if (messageBuf[6] != '\0') {
|
||||
strcat(messageBuf, ":");
|
||||
}
|
||||
strcat(messageBuf, OSD_MSG_AUTOTUNE);
|
||||
if (FLIGHT_MODE(MANUAL_MODE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_AUTOTUNE_ACRO);
|
||||
}
|
||||
}
|
||||
if (isFixedWingLevelTrimActive()) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_AUTOLEVEL);
|
||||
if (messageBuf[6] != '\0') {
|
||||
strcat(messageBuf, ")");
|
||||
messages[messageCount++] = messageBuf;
|
||||
}
|
||||
if (FLIGHT_MODE(HEADFREE_MODE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_HEADFREE);
|
||||
}
|
||||
if (FLIGHT_MODE(SOARING_MODE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_NAV_SOARING);
|
||||
}
|
||||
if (posControl.flags.wpMissionPlannerActive) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MISSION_PLANNER);
|
||||
}
|
||||
if (STATE(LANDING_DETECTED)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_LANDED);
|
||||
}
|
||||
|
||||
if (IS_RC_MODE_ACTIVE(BOXANGLEHOLD)) {
|
||||
int8_t navAngleHoldAxis = navCheckActiveAngleHoldAxis();
|
||||
if (isAngleHoldLevel()) {
|
||||
|
@ -5769,14 +5751,37 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
|||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_ANGLEHOLD_PITCH);
|
||||
}
|
||||
}
|
||||
} else if (STATE(MULTIROTOR)) { // Returns maximum of 1 messages
|
||||
if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE)) {
|
||||
if (posControl.cruise.multicopterSpeed >= 50.0f) {
|
||||
char buf[6];
|
||||
osdFormatVelocityStr(buf, posControl.cruise.multicopterSpeed, false, false);
|
||||
tfp_sprintf(messageBuf, "(SPD %s)", buf);
|
||||
} else {
|
||||
strcpy(messageBuf, "(HOLD)");
|
||||
}
|
||||
messages[messageCount++] = messageBuf;
|
||||
} else if (FLIGHT_MODE(HEADFREE_MODE)) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_HEADFREE);
|
||||
}
|
||||
}
|
||||
} else if (ARMING_FLAG(ARMING_DISABLED_ALL_FLAGS)) {
|
||||
|
||||
if (FLIGHT_MODE(NAV_ALTHOLD_MODE) && !navigationRequiresAngleMode()) {
|
||||
// ALTHOLD might be enabled alongside ANGLE/HORIZON/ANGLEHOLD/ACRO
|
||||
// when it doesn't require ANGLE mode (required only in FW
|
||||
// right now). If it requires ANGLE, its display is handled by OSD_FLYMODE.
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_ALTITUDE_HOLD);
|
||||
}
|
||||
|
||||
if (posControl.flags.wpMissionPlannerActive) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_MISSION_PLANNER);
|
||||
}
|
||||
}
|
||||
} else if (ARMING_FLAG(ARMING_DISABLED_ALL_FLAGS)) { // Returns maximum of 2 messages
|
||||
unsigned invalidIndex;
|
||||
|
||||
// Check if we're unable to arm for some reason
|
||||
if (ARMING_FLAG(ARMING_DISABLED_INVALID_SETTING) && !settingsValidate(&invalidIndex)) {
|
||||
|
||||
const setting_t *setting = settingGet(invalidIndex);
|
||||
settingGetName(setting, messageBuf);
|
||||
for (int ii = 0; messageBuf[ii]; ii++) {
|
||||
|
@ -5787,22 +5792,17 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
|||
|
||||
invertedInfoMessage = OSD_MESSAGE_STR(OSD_MSG_INVALID_SETTING);
|
||||
messages[messageCount++] = invertedInfoMessage;
|
||||
|
||||
} else {
|
||||
|
||||
invertedInfoMessage = OSD_MESSAGE_STR(OSD_MSG_UNABLE_ARM);
|
||||
messages[messageCount++] = invertedInfoMessage;
|
||||
|
||||
// Show the reason for not arming
|
||||
messages[messageCount++] = osdArmingDisabledReasonMessage();
|
||||
|
||||
}
|
||||
} else if (!ARMING_FLAG(ARMED)) {
|
||||
if (isWaypointListValid()) {
|
||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_WP_MISSION_LOADED);
|
||||
}
|
||||
}
|
||||
|
||||
/* Messages that are shown regardless of Arming state */
|
||||
|
||||
// The following has been commented out as it will be added in #9688
|
||||
|
@ -5834,7 +5834,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
|||
} else if (message == invertedInfoMessage) {
|
||||
TEXT_ATTRIBUTES_ADD_INVERTED(elemAttr);
|
||||
}
|
||||
// We're shoing either failsafePhaseMessage or
|
||||
// We're showing either failsafePhaseMessage or
|
||||
// navStateMessage. Don't BLINK here since
|
||||
// having this text available might be crucial
|
||||
// during a lost aircraft recovery and blinking
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue