1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 16:55:36 +03:00

Merge pull request #6104 from etracer65/beacon_arm_delay_osd

Display OSD message and countdown if arming is delayed due to beacon
This commit is contained in:
Michael Keller 2018-06-14 23:08:31 +12:00 committed by GitHub
commit 9a06900c83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View file

@ -717,6 +717,23 @@ static bool osdDrawSingleElement(uint8_t item)
const batteryState_e batteryState = getBatteryState();
#ifdef USE_DSHOT
if (isTryingToArm() && !ARMING_FLAG(ARMED)) {
int armingDelayTime = (getLastDshotBeaconCommandTimeUs() + DSHOT_BEACON_GUARD_DELAY_US - micros()) / 1e5;
if (armingDelayTime < 0) {
armingDelayTime = 0;
}
if (armingDelayTime >= (DSHOT_BEACON_GUARD_DELAY_US / 1e5 - 5)) {
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, " BEACON ON"); // Display this message for the first 0.5 seconds
} else {
char armingDelayMessage[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
tfp_sprintf(armingDelayMessage, "ARM IN %d.%d", armingDelayTime / 10, armingDelayTime % 10);
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, armingDelayMessage);
}
break;
}
#endif
if (osdWarnGetState(OSD_WARNING_BATTERY_CRITICAL) && batteryState == BATTERY_CRITICAL) {
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, " LAND NOW");
break;
@ -1098,12 +1115,22 @@ void osdUpdateAlarms(void)
CLR_BLINK(OSD_RSSI_VALUE);
}
if (getBatteryState() == BATTERY_OK) {
// Determine if the OSD_WARNINGS should blink
if (getBatteryState() != BATTERY_OK
&& (osdWarnGetState(OSD_WARNING_BATTERY_CRITICAL) || osdWarnGetState(OSD_WARNING_BATTERY_WARNING))
#ifdef USE_DSHOT
&& (!isTryingToArm())
#endif
) {
SET_BLINK(OSD_WARNINGS);
} else {
CLR_BLINK(OSD_WARNINGS);
}
if (getBatteryState() == BATTERY_OK) {
CLR_BLINK(OSD_MAIN_BATT_VOLTAGE);
CLR_BLINK(OSD_AVG_CELL_VOLTAGE);
} else {
SET_BLINK(OSD_WARNINGS);
SET_BLINK(OSD_MAIN_BATT_VOLTAGE);
SET_BLINK(OSD_AVG_CELL_VOLTAGE);
}

View file

@ -45,6 +45,7 @@ extern "C" {
#include "flight/pid.h"
#include "flight/imu.h"
#include "io/beeper.h"
#include "io/gps.h"
#include "io/osd.h"