AP_OSD: change for AP::terrain as a pointer

This commit is contained in:
Andrew Tridgell 2021-04-07 19:49:52 +10:00
parent d3e3e58466
commit 483ed19662

View File

@ -1934,10 +1934,10 @@ void AP_OSD_Screen::draw_vtx_power(uint8_t x, uint8_t y)
#if AP_TERRAIN_AVAILABLE #if AP_TERRAIN_AVAILABLE
void AP_OSD_Screen::draw_hgt_abvterr(uint8_t x, uint8_t y) void AP_OSD_Screen::draw_hgt_abvterr(uint8_t x, uint8_t y)
{ {
AP_Terrain &terrain = AP::terrain(); AP_Terrain *terrain = AP::terrain();
float terrain_altitude; float terrain_altitude;
if (terrain.height_above_terrain(terrain_altitude,true)) { if (terrain != nullptr && terrain->height_above_terrain(terrain_altitude,true)) {
backend->write(x, y, terrain_altitude < osd->warn_terr, "%4d%c", (int)u_scale(ALTITUDE, terrain_altitude), u_icon(ALTITUDE)); backend->write(x, y, terrain_altitude < osd->warn_terr, "%4d%c", (int)u_scale(ALTITUDE, terrain_altitude), u_icon(ALTITUDE));
} else { } else {
backend->write(x, y, false, " ---%c", u_icon(ALTITUDE)); backend->write(x, y, false, " ---%c", u_icon(ALTITUDE));