Skip to content

Commit

Permalink
AP_OSD: Add VTX temperature
Browse files Browse the repository at this point in the history
Make VTX temperature visible through OSD.
  • Loading branch information
menschel committed Nov 13, 2024
1 parent 0118c03 commit a315bad
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libraries/AP_OSD/AP_OSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ class AP_OSD_Screen : public AP_OSD_AbstractScreen
bool load_attempted;
const char *str;
} callsign_data;

// VTX temperature for AP_Tramp
AP_OSD_Setting vtx_temp;
void draw_vtx_temp(uint8_t x, uint8_t y);
};
#endif // OSD_ENABLED

Expand Down
31 changes: 31 additions & 0 deletions libraries/AP_OSD/AP_OSD_Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,23 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
AP_SUBGROUPINFO(rrpm, "RPM", 62, AP_OSD_Screen, AP_OSD_Setting),
#endif


// @Param: VTX_TEMP_EN
// @DisplayName: VTX_TEMP_EN
// @Description: Displays the VTX Temperature. A Value of '-1' indicates that temperature is not available.
// @Values: 0:Disabled,1:Enabled

// @Param: VTX_TEMP_X
// @DisplayName: VTX_TEMP_X
// @Description: Horizontal position on screen for VTX_TEMP item
// @Range: 0 59

// @Param: VTX_TEMP_Y
// @DisplayName: VTX_TEMP_Y
// @Description: Vertical position on screen for VTX_TEMP item
// @Range: 0 21
AP_SUBGROUPINFO(vtx_temp, "VTX_TEMP", 63, AP_OSD_Screen, AP_OSD_Setting),

AP_GROUPEND
};

Expand Down Expand Up @@ -2550,6 +2567,17 @@ void AP_OSD_Screen::draw_rngf(uint8_t x, uint8_t y)
}
#endif


void AP_OSD_Screen::draw_vtx_temp(uint8_t x, uint8_t y)
{
AP_VideoTX *vtx = AP_VideoTX::get_singleton();
if (!vtx) {
return;
}
float vtx_temperature = vtx->get_temperature();
backend->write(x, y, false, "%3.1f%c", u_scale(TEMPERATURE, vtx_temperature), u_icon(TEMPERATURE));
}

#define DRAW_SETTING(n) if (n.enabled) draw_ ## n(n.xpos, n.ypos)

#if HAL_WITH_OSD_BITMAP || HAL_WITH_MSP_DISPLAYPORT
Expand Down Expand Up @@ -2649,6 +2677,9 @@ void AP_OSD_Screen::draw(void)
DRAW_SETTING(rc_active_antenna);
DRAW_SETTING(rc_lq);
#endif
#if AP_VIDEOTX_ENABLED
DRAW_SETTING(vtx_temp);
#endif
}
#endif
#endif // OSD_ENABLED

0 comments on commit a315bad

Please sign in to comment.