mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-20 06:45:14 +03:00
Update Crossfire (crsf) telemetry flight modes to match OSD (#3912)
Refactor OSD flight mode logic As of 2.0.0 POSHOLD always includes ALTHOLD, so remove that unused legacy logic. Also reformatted as per coding style. First run at enhancing Crossfire telemetry
This commit is contained in:
parent
f49decfb54
commit
c0964cbb2c
1 changed files with 38 additions and 10 deletions
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "fc/config.h"
|
||||
#include "fc/rc_controls.h"
|
||||
#include "fc/rc_modes.h"
|
||||
#include "fc/runtime_config.h"
|
||||
|
||||
#include "flight/imu.h"
|
||||
|
@ -228,21 +229,49 @@ char[] Flight mode ( Nullterminated string )
|
|||
*/
|
||||
void crsfFrameFlightMode(sbuf_t *dst)
|
||||
{
|
||||
// just do Angle for the moment as a placeholder
|
||||
// just do "OK" for the moment as a placeholder
|
||||
// write zero for frame length, since we don't know it yet
|
||||
uint8_t *lengthPtr = sbufPtr(dst);
|
||||
sbufWriteU8(dst, 0);
|
||||
crsfSerialize8(dst, CRSF_FRAMETYPE_FLIGHT_MODE);
|
||||
|
||||
// use same logic as OSD, so telemetry displays same flight text as OSD
|
||||
const char *flightMode = "ACRO";
|
||||
// use same logic as OSD, so telemetry displays same flight text as OSD when armed
|
||||
const char *flightMode = "OK";
|
||||
if (ARMING_FLAG(ARMED)) {
|
||||
if (isAirmodeActive()) {
|
||||
flightMode = "AIR";
|
||||
} else {
|
||||
flightMode = "ACRO";
|
||||
}
|
||||
if (FLIGHT_MODE(FAILSAFE_MODE)) {
|
||||
flightMode = "!FS";
|
||||
flightMode = "!FS!";
|
||||
} else if (FLIGHT_MODE(MANUAL_MODE)) {
|
||||
flightMode = "MANU";
|
||||
} else if (FLIGHT_MODE(NAV_RTH_MODE)) {
|
||||
flightMode = "RTH";
|
||||
} else if (FLIGHT_MODE(NAV_POSHOLD_MODE)) {
|
||||
flightMode = "HOLD";
|
||||
} else if (FLIGHT_MODE(NAV_CRUISE_MODE) && FLIGHT_MODE(NAV_ALTHOLD_MODE)) {
|
||||
flightMode = "3CRS";
|
||||
} else if (FLIGHT_MODE(NAV_CRUISE_MODE)) {
|
||||
flightMode = "CRS";
|
||||
} else if (FLIGHT_MODE(NAV_ALTHOLD_MODE) && navigationRequiresAngleMode()) {
|
||||
flightMode = "AH";
|
||||
} else if (FLIGHT_MODE(NAV_WP_MODE)) {
|
||||
flightMode = "WP";
|
||||
} else if (FLIGHT_MODE(ANGLE_MODE)) {
|
||||
flightMode = "ANGL";
|
||||
} else if (FLIGHT_MODE(HORIZON_MODE)) {
|
||||
flightMode = "HOR";
|
||||
}
|
||||
#ifdef USE_GPS
|
||||
} else if (feature(FEATURE_GPS) && (!STATE(GPS_FIX) || !STATE(GPS_FIX_HOME))) {
|
||||
flightMode = "WAIT"; // Waiting for GPS lock
|
||||
#endif
|
||||
} else if (isArmingDisabled()) {
|
||||
flightMode = "!ERR";
|
||||
}
|
||||
|
||||
crsfSerializeData(dst, (const uint8_t*)flightMode, strlen(flightMode));
|
||||
crsfSerialize8(dst, 0); // zero terminator for string
|
||||
// write in the length
|
||||
|
@ -256,7 +285,6 @@ void crsfFrameFlightMode(sbuf_t *dst)
|
|||
static uint8_t crsfScheduleCount;
|
||||
static uint8_t crsfSchedule[CRSF_SCHEDULE_COUNT_MAX];
|
||||
|
||||
|
||||
static void processCrsf(void)
|
||||
{
|
||||
static uint8_t crsfScheduleIndex = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue