Skip to content

Commit b6c4ff8

Browse files
Merge pull request #11104 from iNavFlight/MrD_Update-SmartPort-modes-to-include-new-modes
Update SmartPort telemetry to reflect latest flight modes
2 parents c79f0ef + cc33f44 commit b6c4ff8

4 files changed

Lines changed: 43 additions & 17 deletions

File tree

docs/Telemetry.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ The following sensors are transmitted
102102
* **VSpd** : vertical speed, unit is cm/s.
103103
* **Hdg** : heading, North is 0°, South is 180°.
104104
* **AccX,Y,Z** : accelerometer values (not sent if `frsky_pitch_roll = ON`).
105-
* **470** : flight mode, sent as 5 digits. Number is sent as **ABCDE** detailed below. The numbers are additives (for example: if digit C is 6, it means both position hold and altitude hold are active) :
106-
* **A** : 1 = flaperon mode, 2 = auto tune mode, 4 = failsafe mode
107-
* **B** : 1 = return to home, 2 = waypoint mode, 4 = headfree mode
108-
* **C** : 1 = heading hold, 2 = altitude hold, 4 = position hold
109-
* **D** : 1 = angle mode, 2 = horizon mode, 4 = passthru mode
110-
* **E** : 1 = ok to arm, 2 = arming is prevented, 4 = armed
105+
* **470** : flight mode, sent as 7 digits. Number is sent as **ABCDEFG** detailed below. The numbers are additives (for example: if digit C is 6, it means both position hold and altitude hold are active) :
106+
* **A** : 1 = WRTH mode, 2 = Angle hold mode
107+
* **B** : 1 = Fixed Wing Auto-land, 2 = Turtle mode, 4 = Geofence action mode, 8 = Loiter mode
108+
* **C** : 1 = flaperon mode, 2 = auto tune mode, 4 = failsafe mode
109+
* **D** : 1 = return to home, 2 = waypoint mode, 4 = headfree mode, 8 = Course Hold
110+
* **E** : 1 = heading hold, 2 = altitude hold, 4 = position hold
111+
* **F** : 1 = angle mode, 2 = horizon mode, 4 = passthru mode
112+
* **G** : 1 = ok to arm, 2 = arming is prevented, 4 = armed
111113

112114
_NOTE_ This sensor used to be **Tmp1**. The ID has been reassigned in INAV 8.0. The old ID of **Tmp1** can still be used, by using `set frsky_use_legacy_gps_mode_sensor_ids = ON`. This is deprecated and will be removed in INAV 10.0. All tools and scripts using the old IDs should be updated to use the new ID.
113115
* **480** : GPS lock status, accuracy, home reset trigger, and number of satellites. Number is sent as **ABCD** detailed below. Typical minimum GPS 3D lock value is 3906 (GPS locked and home fixed, HDOP highest accuracy, 6 satellites).

src/main/io/osd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,7 @@ static bool osdDrawSingleElement(uint8_t item)
25652565
p = "MANU";
25662566
#ifdef USE_GEOZONE
25672567
else if (FLIGHT_MODE(NAV_SEND_TO) && !FLIGHT_MODE(NAV_WP_MODE))
2568-
p = "GEO";
2568+
p = "GEO ";
25692569
#endif
25702570
else if (FLIGHT_MODE(TURTLE_MODE))
25712571
p = "TURT";

src/main/telemetry/crsf.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ static void crsfFrameFlightMode(sbuf_t *dst)
349349
sbufWriteU8(dst, 0);
350350
crsfSerialize8(dst, CRSF_FRAMETYPE_FLIGHT_MODE);
351351

352+
static uint8_t hrstSent = 0;
353+
352354
// use same logic as OSD, so telemetry displays same flight text as OSD when armed
353355
const char *flightMode = "OK";
354356
if (ARMING_FLAG(ARMED)) {
@@ -359,7 +361,10 @@ static void crsfFrameFlightMode(sbuf_t *dst)
359361
} else
360362
#endif
361363
if (FLIGHT_MODE(FAILSAFE_MODE)) {
362-
flightMode = "!FS!";
364+
flightMode = "!FS!";
365+
} else if (IS_RC_MODE_ACTIVE(BOXHOMERESET) && hrstSent < 4 && !FLIGHT_MODE(NAV_RTH_MODE) && !FLIGHT_MODE(NAV_WP_MODE)) {
366+
flightMode = "HRST";
367+
hrstSent++;
363368
} else if (FLIGHT_MODE(MANUAL_MODE)) {
364369
flightMode = "MANU";
365370
#ifdef USE_GEOZONE
@@ -397,6 +402,9 @@ static void crsfFrameFlightMode(sbuf_t *dst)
397402
flightMode = "!ERR";
398403
}
399404

405+
if (!IS_RC_MODE_ACTIVE(BOXHOMERESET) && hrstSent > 0)
406+
hrstSent = 0;
407+
400408
crsfSerializeData(dst, (const uint8_t*)flightMode, strlen(flightMode));
401409
crsfSerialize8(dst, 0); // zero terminator for string
402410
// write in the length

src/main/telemetry/smartport.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,36 +162,36 @@ static smartPortWriteFrameFn *smartPortWriteFrame;
162162
static bool smartPortMspReplyPending = false;
163163
#endif
164164

165-
static uint16_t frskyGetFlightMode(void)
165+
static uint32_t frskyGetFlightMode(void)
166166
{
167-
uint16_t tmpi = 0;
167+
uint32_t tmpi = 0;
168168

169-
// ones column
169+
// ones column (G)
170170
if (!isArmingDisabled())
171171
tmpi += 1;
172172
else
173173
tmpi += 2;
174174
if (ARMING_FLAG(ARMED))
175175
tmpi += 4;
176176

177-
// tens column
177+
// tens column (F)
178178
if (FLIGHT_MODE(ANGLE_MODE))
179179
tmpi += 10;
180180
if (FLIGHT_MODE(HORIZON_MODE))
181181
tmpi += 20;
182182
if (FLIGHT_MODE(MANUAL_MODE))
183183
tmpi += 40;
184184

185-
// hundreds column
185+
// hundreds column (E)
186186
if (FLIGHT_MODE(HEADING_MODE))
187187
tmpi += 100;
188188
if (FLIGHT_MODE(NAV_ALTHOLD_MODE))
189189
tmpi += 200;
190-
if (FLIGHT_MODE(NAV_POSHOLD_MODE))
190+
if (FLIGHT_MODE(NAV_POSHOLD_MODE) && !STATE(AIRPLANE))
191191
tmpi += 400;
192192

193-
// thousands column
194-
if (FLIGHT_MODE(NAV_RTH_MODE))
193+
// thousands column (D)
194+
if (FLIGHT_MODE(NAV_RTH_MODE) && !isWaypointMissionRTHActive())
195195
tmpi += 1000;
196196
if (FLIGHT_MODE(NAV_COURSE_HOLD_MODE)) // intentionally out of order and 'else-ifs' to prevent column overflow
197197
tmpi += 8000;
@@ -200,14 +200,30 @@ static uint16_t frskyGetFlightMode(void)
200200
else if (FLIGHT_MODE(HEADFREE_MODE))
201201
tmpi += 4000;
202202

203-
// ten thousands column
203+
// ten thousands column (C)
204204
if (FLIGHT_MODE(FLAPERON))
205205
tmpi += 10000;
206206
if (FLIGHT_MODE(FAILSAFE_MODE))
207207
tmpi += 40000;
208208
else if (FLIGHT_MODE(AUTO_TUNE)) // intentionally reverse order and 'else-if' to prevent 16-bit overflow
209209
tmpi += 20000;
210210

211+
// hundred thousands column (B)
212+
if (FLIGHT_MODE(NAV_FW_AUTOLAND))
213+
tmpi += 100000;
214+
if (FLIGHT_MODE(TURTLE_MODE))
215+
tmpi += 200000;
216+
else if (FLIGHT_MODE(NAV_POSHOLD_MODE) && STATE(AIRPLANE))
217+
tmpi += 800000;
218+
if (FLIGHT_MODE(NAV_SEND_TO))
219+
tmpi += 400000;
220+
221+
// million column (A)
222+
if (FLIGHT_MODE(NAV_RTH_MODE) && isWaypointMissionRTHActive())
223+
tmpi += 1000000;
224+
if (FLIGHT_MODE(ANGLEHOLD_MODE))
225+
tmpi += 2000000;
226+
211227
return tmpi;
212228
}
213229

0 commit comments

Comments
 (0)