Skip to content
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
16 changes: 2 additions & 14 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,18 +507,6 @@ bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm)
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)
{
/* Emergency rearm allowed within 5s timeout period after disarm if craft still flying */
Expand Down Expand Up @@ -892,6 +880,7 @@ static void applyThrottleTiltCompensation(void)

void taskMainPidLoop(timeUs_t currentTimeUs)
{

cycleTime = getTaskDeltaTime(TASK_SELF);
dT = (float)cycleTime * 0.000001f;

Expand All @@ -910,8 +899,7 @@ 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);
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/fc/fc_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ timeUs_t getLastDisarmTimeUs(void);
void tryArm(void);
disarmReason_t getDisarmReason(void);

uint16_t emergencyInFlightRearmTimeMS(void);
bool emergencyArmingUpdate(bool armingSwitchIsOn, bool forceArm);
bool emergInflightRearmEnabled(void);

bool areSensorsCalibrating(void);
float getFlightTime(void);
Expand Down
45 changes: 14 additions & 31 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <inttypes.h>

#include "platform.h"

Expand Down Expand Up @@ -4561,16 +4560,8 @@ static void osdShowStats(bool isSinglePageStatsCompatible, uint8_t page)
displayWrite(osdDisplayPort, statValuesX + multiValueLengthOffset, top++, buff);
}

uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0;

if (savingSettings == true) {
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) {
if (millis() > notify_settings_saved) {
notify_settings_saved = 0;
Expand Down Expand Up @@ -4870,10 +4861,9 @@ static void osdRefresh(timeUs_t currentTimeUs)
}

bool statsSinglePageCompatible = (osdDisplayPort->rows >= OSD_STATS_SINGLE_PAGE_MIN_ROWS);
static uint8_t statsCurrentPage = 0;
static timeMs_t statsRefreshTime = 0;
static bool statsDisplayed = false;
static bool statsAutoPagingEnabled = true;
static uint8_t statsCurrentPage = 0;
static bool statsDisplayed = false;
static bool statsAutoPagingEnabled = true;

// Detect arm/disarm
if (armState != ARMING_FLAG(ARMED)) {
Expand Down Expand Up @@ -4941,24 +4931,25 @@ static void osdRefresh(timeUs_t currentTimeUs)
// Alternate screens for multi-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 (statsCurrentPage == 0)
if (statsCurrentPage == 0) {
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
statsCurrentPage = 1;
}
} else {
if (statsCurrentPage == 1)
if (statsCurrentPage == 1) {
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
statsCurrentPage = 0;
}
}
} else {
// Process manual page change events for multi-page stats.
if (manualPageUpRequested)
if (manualPageUpRequested) {
osdShowStats(statsSinglePageCompatible, 1);
statsCurrentPage = 1;
else if (manualPageDownRequested)
} else if (manualPageDownRequested) {
osdShowStats(statsSinglePageCompatible, 0);
statsCurrentPage = 0;
}

// Only refresh the stats every 1/4 of a second.
if (statsRefreshTime <= millis()) {
statsRefreshTime = millis() + 250;
osdShowStats(statsSinglePageCompatible, statsCurrentPage);
}
}
}

Expand Down Expand Up @@ -5315,16 +5306,9 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
}

/* Messages that are shown regardless of Arming state */
uint16_t rearmMs = (emergInflightRearmEnabled()) ? emergencyInFlightRearmTimeMS() : 0;

if (savingSettings == true) {
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) {
if (millis() > notify_settings_saved) {
notify_settings_saved = 0;
Expand All @@ -5333,7 +5317,6 @@ textAttributes_t osdGetSystemMessage(char *buff, size_t buff_size, bool isCenter
}
}


if (messageCount > 0) {
message = messages[OSD_ALTERNATING_CHOICES(systemMessageCycleTime(messageCount, messages), messageCount)];
if (message == failsafeInfoMessage) {
Expand Down