Skip to content

Commit

Permalink
Merge pull request #11621 from limonspb/flip_over_warning_show_before…
Browse files Browse the repository at this point in the history
…_arm
  • Loading branch information
blckmn committed May 28, 2022
2 parents 930082f + bb33c65 commit 4fa2dc1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/fc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ void disarm(flightLogDisarmReason_e reason)
lastDisarmTimeUs = micros();

#ifdef USE_OSD
if (flipOverAfterCrashActive || isLaunchControlActive()) {
if (IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH) || isLaunchControlActive()) {
osdSuppressStats(true);
}
#endif
Expand Down
11 changes: 9 additions & 2 deletions src/main/osd/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "drivers/sdcard.h"
#include "drivers/time.h"

#include "fc/core.h"
#include "fc/rc_controls.h"
#include "fc/rc_modes.h"
#include "fc/runtime_config.h"
Expand All @@ -79,6 +80,7 @@

#include "osd/osd.h"
#include "osd/osd_elements.h"
#include "osd/osd_warnings.h"

#include "pg/motor.h"
#include "pg/pg.h"
Expand Down Expand Up @@ -1016,6 +1018,10 @@ static timeDelta_t osdShowArmed(void)
}
displayWrite(osdDisplayPort, 12, 7, DISPLAYPORT_ATTR_NONE, "ARMED");

if (isFlipOverAfterCrashActive()) {
displayWrite(osdDisplayPort, 8, 8, DISPLAYPORT_ATTR_NONE, CRASH_FLIP_WARNING);
}

return ret;
}

Expand Down Expand Up @@ -1087,8 +1093,9 @@ void osdProcessStats2(timeUs_t currentTimeUs)

if (resumeRefreshAt) {
if (cmp32(currentTimeUs, resumeRefreshAt) < 0) {
// in timeout period, check sticks for activity to resume display.
if (IS_HI(THROTTLE) || IS_HI(PITCH)) {
// in timeout period, check sticks for activity or CRASH FLIP switch to resume display.
if (!ARMING_FLAG(ARMED) &&
(IS_HI(THROTTLE) || IS_HI(PITCH) || IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH))) {
resumeRefreshAt = currentTimeUs;
}
return;
Expand Down
16 changes: 12 additions & 4 deletions src/main/osd/osd_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
#include "sensors/battery.h"
#include "sensors/sensors.h"

const char CRASH_FLIP_WARNING[] = "> CRASH FLIP <";

void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
{
const batteryState_e batteryState = getBatteryState();
Expand Down Expand Up @@ -132,10 +134,16 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr)
}

// Warn when in flip over after crash mode
if (osdWarnGetState(OSD_WARNING_CRASH_FLIP) && isFlipOverAfterCrashActive()) {
tfp_sprintf(warningText, "CRASH FLIP");
*displayAttr = DISPLAYPORT_ATTR_INFO;
return;
if (osdWarnGetState(OSD_WARNING_CRASH_FLIP) && IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) {
if (isFlipOverAfterCrashActive()) { // if was armed in crash flip mode
tfp_sprintf(warningText, CRASH_FLIP_WARNING);
*displayAttr = DISPLAYPORT_ATTR_INFO;
return;
} else if (!ARMING_FLAG(ARMED)) { // if disarmed, but crash flip mode is activated
tfp_sprintf(warningText, "CRASH FLIP SWITCH");
*displayAttr = DISPLAYPORT_ATTR_INFO;
return;
}
}

#ifdef USE_LAUNCH_CONTROL
Expand Down
2 changes: 2 additions & 0 deletions src/main/osd/osd_warnings.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define OSD_WARNINGS_MAX_SIZE 12
#define OSD_FORMAT_MESSAGE_BUFFER_SIZE (OSD_WARNINGS_MAX_SIZE + 1)

extern const char CRASH_FLIP_WARNING[];

STATIC_ASSERT(OSD_FORMAT_MESSAGE_BUFFER_SIZE <= OSD_ELEMENT_BUFFER_LENGTH, osd_warnings_size_exceeds_buffer_size);

void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr);

0 comments on commit 4fa2dc1

Please sign in to comment.