Skip to content
Open
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
14 changes: 9 additions & 5 deletions docs/Terrain.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ Copying can be done via **iNav MSC (Mass Storage Class)** is not recommended.

# Enabling and Displaying Terrain Data

To display altitude above terrain in iNav, the OSD element **“Rangefinder distance”** must be enabled. If terrain data are
available on the SD card and no valid data are available from a dedicated rangefinder, the value calculated by the terrain
system will be displayed. If a rangefinder is present and providing valid data, its measurements always take priority and the
actual distance to the ground will be shown.
There are two OSD elements that can display altitude above terrain:

- **“Terrain AGL”** — a dedicated element that shows the altitude above ground level calculated **exclusively by the terrain
subsystem**. Rangefinder measurements are never shown by this element. If no valid terrain value is available, dashes are
displayed. Use this element if you want to see the terrain-derived value regardless of whether a rangefinder is fitted.
- **“Rangefinder distance”** — behaves as before. If a rangefinder is present and providing valid data, its measurements
always take priority and the actual distance to the ground is shown. Only when no valid rangefinder data are available and
terrain data are present on the SD card is the value calculated by the terrain system displayed instead.

Loading terrain data from the SD card is enabled via the CLI using the following command:

Expand All @@ -82,7 +86,7 @@ display dropouts, or automatic disabling of the feature during flight. Using a q
stability and reliability of the terrain feature.

# Troubleshooting
- OSD shows no terrain value / "Rangefinder distance" is dash:
- OSD shows no terrain value / "Terrain AGL" or "Rangefinder distance" is dash:
- Verify `terrain_enabled = ON` is set and saved (`set terrain_enabled = ON` → `save` → reboot)
- Confirm the SD card is mounted: check `status` in the CLI for SD card state
- Confirm a valid GPS fix is present before expecting any terrain value to appear
Expand Down
19 changes: 16 additions & 3 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static bool osdDisplayHasCanvas;
#define AH_MAX_PITCH_DEFAULT 20 // Specify default maximum AHI pitch value displayed (degrees)

PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 0);
PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 3);
PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 4);

/* OSD formatting helpers replacing common tfp_sprintf patterns
* for reduced code size and CPU overhead. */
Expand Down Expand Up @@ -2502,7 +2502,6 @@ static bool osdDrawSingleElement(uint8_t item)
#elif defined(USE_TERRAIN)
range = terrainGetLastDistanceCm();
#endif

if (range < 0) {
buff[0] = buff[1] = buff[2] = '-';
} else {
Expand All @@ -2511,7 +2510,21 @@ static bool osdDrawSingleElement(uint8_t item)
}
break;
#endif

#ifdef USE_TERRAIN
case OSD_TERRAIN_AGL:
{
int32_t range = terrainGetLastDistanceCm();
if (range < 0) {
for(uint8_t i = 1; i < osdConfig()->decimals_altitude + 1; i++){
buff[i] = '-';
}
} else {
osdFormatAltitudeSymbol(buff, range);
}
buff[0] = SYM_TERRAIN_FOLLOWING;
break;
}
#endif
case OSD_ONTIME:
{
osdFormatOnTime(buff);
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ typedef enum {
OSD_THROTTLE_GAUGE,
OSD_GPS_EXTRA_STATS,
OSD_AUTO_SPEED, // 170
OSD_TERRAIN_AGL, // 171,
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;

Expand Down
Loading