mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 16:25:26 +03:00
Merge pull request #9769 from iNavFlight/MrD_Show-OSD-message-for-inflight-rearm-possible
Show a timeout for in flight rearming
This commit is contained in:
commit
f025ee570c
3 changed files with 47 additions and 16 deletions
|
@ -507,6 +507,18 @@ bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm)
|
||||||
return counter >= EMERGENCY_ARMING_MIN_ARM_COUNT;
|
return counter >= EMERGENCY_ARMING_MIN_ARM_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t emergencyInFlightRearmTimeMS(void)
|
||||||
|
{
|
||||||
|
uint16_t rearmMS = 0;
|
||||||
|
|
||||||
|
if (STATE(IN_FLIGHT_EMERG_REARM)) {
|
||||||
|
timeMs_t currentTimeMs = millis();
|
||||||
|
rearmMS = (uint16_t)((US2MS(lastDisarmTimeUs) + EMERGENCY_INFLIGHT_REARM_TIME_WINDOW_MS) - currentTimeMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rearmMS;
|
||||||
|
}
|
||||||
|
|
||||||
bool emergInflightRearmEnabled(void)
|
bool emergInflightRearmEnabled(void)
|
||||||
{
|
{
|
||||||
/* Emergency rearm allowed within 5s timeout period after disarm if craft still flying */
|
/* Emergency rearm allowed within 5s timeout period after disarm if craft still flying */
|
||||||
|
@ -880,7 +892,6 @@ static void applyThrottleTiltCompensation(void)
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -899,7 +910,8 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (armTime > 1 * USECS_PER_SEC) { // reset in flight emerg rearm flag 1 sec after arming once it's served its purpose
|
if (armTime > 1 * USECS_PER_SEC) {
|
||||||
|
// reset in flight emerg rearm flag 1 sec after arming once it's served its purpose
|
||||||
DISABLE_STATE(IN_FLIGHT_EMERG_REARM);
|
DISABLE_STATE(IN_FLIGHT_EMERG_REARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,9 @@ timeUs_t getLastDisarmTimeUs(void);
|
||||||
void tryArm(void);
|
void tryArm(void);
|
||||||
disarmReason_t getDisarmReason(void);
|
disarmReason_t getDisarmReason(void);
|
||||||
|
|
||||||
|
uint16_t emergencyInFlightRearmTimeMS(void);
|
||||||
bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm);
|
bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm);
|
||||||
|
bool emergInflightRearmEnabled(void);
|
||||||
|
|
||||||
bool areSensorsCalibrating(void);
|
bool areSensorsCalibrating(void);
|
||||||
float getFlightTime(void);
|
float getFlightTime(void);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -4560,8 +4561,16 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
|
||||||
displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff);
|
displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0;
|
||||||
|
|
||||||
if (savingSettings == true) {
|
if (savingSettings == true) {
|
||||||
displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS));
|
displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS));
|
||||||
|
} else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available.
|
||||||
|
char emReArmMsg[23];
|
||||||
|
tfp_sprintf(emReArmMsg, "** REARM PERIOD: ");
|
||||||
|
tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs));
|
||||||
|
strcat(emReArmMsg, " **\0");
|
||||||
|
displayWrite(osdDisplayPort, statNameX, top++, OSD_MESSAGE_STR(emReArmMsg));
|
||||||
} else if (notify_settings_saved > 0) {
|
} else if (notify_settings_saved > 0) {
|
||||||
if (millis() > notify_settings_saved) {
|
if (millis() > notify_settings_saved) {
|
||||||
notify_settings_saved = 0;
|
notify_settings_saved = 0;
|
||||||
|
@ -4861,9 +4870,10 @@ static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool statsSinglePageCompatible = (osdDisplayPort->rows >= OSD_STATS_SINGLE_PAGE_MIN_ROWS);
|
bool statsSinglePageCompatible = (osdDisplayPort->rows >= OSD_STATS_SINGLE_PAGE_MIN_ROWS);
|
||||||
static uint8_t statsCurrentPage = 0;
|
static uint8_t statsCurrentPage = 0;
|
||||||
static bool statsDisplayed = false;
|
static timeMs_t statsRefreshTime = 0;
|
||||||
static bool statsAutoPagingEnabled = true;
|
static bool statsDisplayed = false;
|
||||||
|
static bool statsAutoPagingEnabled = true;
|
||||||
|
|
||||||
// Detect arm/disarm
|
// Detect arm/disarm
|
||||||
if (armState != ARMING_FLAG(ARMED)) {
|
if (armState != ARMING_FLAG(ARMED)) {
|
||||||
|
@ -4931,25 +4941,24 @@ static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
// Alternate screens for multi-page stats.
|
// Alternate screens for multi-page stats.
|
||||||
// Also, refreshes screen at swap interval for single-page stats.
|
// Also, refreshes screen at swap interval for single-page stats.
|
||||||
if (OSD_ALTERNATING_CHOICES((osdConfig()->stats_page_auto_swap_time * 1000), 2)) {
|
if (OSD_ALTERNATING_CHOICES((osdConfig()->stats_page_auto_swap_time * 1000), 2)) {
|
||||||
if (statsCurrentPage == 0) {
|
if (statsCurrentPage == 0)
|
||||||
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
|
|
||||||
statsCurrentPage = 1;
|
statsCurrentPage = 1;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (statsCurrentPage == 1) {
|
if (statsCurrentPage == 1)
|
||||||
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
|
|
||||||
statsCurrentPage = 0;
|
statsCurrentPage = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Process manual page change events for multi-page stats.
|
// Process manual page change events for multi-page stats.
|
||||||
if (manualPageUpRequested) {
|
if (manualPageUpRequested)
|
||||||
osdShowStats(statsSinglePageCompatible, 1);
|
|
||||||
statsCurrentPage = 1;
|
statsCurrentPage = 1;
|
||||||
} else if (manualPageDownRequested) {
|
else if (manualPageDownRequested)
|
||||||
osdShowStats(statsSinglePageCompatible, 0);
|
|
||||||
statsCurrentPage = 0;
|
statsCurrentPage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only refresh the stats every 1/4 of a second.
|
||||||
|
if (statsRefreshTime <= millis()) {
|
||||||
|
statsRefreshTime = millis() + 250;
|
||||||
|
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5306,9 +5315,16 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Messages that are shown regardless of Arming state */
|
/* Messages that are shown regardless of Arming state */
|
||||||
|
uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0;
|
||||||
|
|
||||||
if (savingSettings == true) {
|
if (savingSettings == true) {
|
||||||
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS);
|
messages[messageCount++] = OSD_MESSAGE_STR(OSD_MSG_SAVING_SETTNGS);
|
||||||
|
} else if (rearmMs > 0) { // Show rearming time if settings not actively being saved. Ignore the settings saved message if rearm available.
|
||||||
|
char emReArmMsg[23];
|
||||||
|
tfp_sprintf(emReArmMsg, "** REARM PERIOD: ");
|
||||||
|
tfp_sprintf(emReArmMsg + strlen(emReArmMsg), "%02d", (uint8_t)MS2S(rearmMs));
|
||||||
|
strcat(emReArmMsg, " **\0");
|
||||||
|
messages[messageCount++] = OSD_MESSAGE_STR(emReArmMsg);
|
||||||
} else if (notify_settings_saved > 0) {
|
} else if (notify_settings_saved > 0) {
|
||||||
if (millis() > notify_settings_saved) {
|
if (millis() > notify_settings_saved) {
|
||||||
notify_settings_saved = 0;
|
notify_settings_saved = 0;
|
||||||
|
@ -5317,6 +5333,7 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (messageCount > 0) {
|
if (messageCount > 0) {
|
||||||
message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)];
|
message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)];
|
||||||
if (message == failsafeInfoMessage) {
|
if (message == failsafeInfoMessage) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue