Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_VideoTX / AP_OSD: Make VTX temperature available for OSD #28599

Closed
wants to merge 3 commits into from
Closed
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
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
30 changes: 30 additions & 0 deletions libraries/AP_OSD/AP_OSD_Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,22 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info2[] = {
AP_GROUPINFO("ESC_IDX", 10, AP_OSD_Screen, esc_index, 0),
#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", 11, AP_OSD_Screen, AP_OSD_Setting),

AP_GROUPEND
};

Expand Down Expand Up @@ -2550,6 +2566,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 +2676,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
5 changes: 5 additions & 0 deletions libraries/AP_VideoTX/AP_Tramp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ char AP_Tramp::handle_response(void)
if (temp != 0) {
// Got response, update device status
cur_temp = temp;

// propagate temperature to AP_VideoTX
AP_VideoTX& vtx = AP::vtx();
vtx.set_temperature((float) cur_temp);

return 's';
}
break;
Expand Down
8 changes: 8 additions & 0 deletions libraries/AP_VideoTX/AP_VideoTX.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ class AP_VideoTX {

static AP_VideoTX *singleton;

// set the vtx temperature from backend, at the moment only AP_Tramp provides temperature
void set_temperature(float temperature) { _internal_temperature = temperature; }
// get the vtx temperature, consumer is OSD, a value of -1.0f indicates an invalid value, i.e. the backend does not provide it.
float get_temperature() const { return _internal_temperature; }

private:
uint8_t find_current_power() const;
// channel frequency
Expand Down Expand Up @@ -212,6 +217,9 @@ class AP_VideoTX {

// types of VTX providers
uint8_t _types;

// VTX temperature provided by AP_Tramp backend, not by AP_SmartAudio
float _internal_temperature = -1.0f;
};

namespace AP {
Expand Down
Loading