From b6bdcf594ade52d8d4000e69b607c4f629f307f1 Mon Sep 17 00:00:00 2001 From: vierfuffzig Date: Sat, 14 Jul 2018 20:08:06 +0200 Subject: [PATCH] AP_OSD: added temperature item --- libraries/AP_OSD/AP_OSD.h | 2 ++ libraries/AP_OSD/AP_OSD_Screen.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/libraries/AP_OSD/AP_OSD.h b/libraries/AP_OSD/AP_OSD.h index e3f0422953..bd8a24065d 100644 --- a/libraries/AP_OSD/AP_OSD.h +++ b/libraries/AP_OSD/AP_OSD.h @@ -100,6 +100,7 @@ private: AP_OSD_Setting gps_longitude{true, 9, 14}; AP_OSD_Setting roll_angle{false, 0, 0}; AP_OSD_Setting pitch_angle{false, 0, 0}; + AP_OSD_Setting temp{false, 0, 0}; bool check_option(uint32_t option); @@ -148,6 +149,7 @@ private: void draw_gps_longitude(uint8_t x, uint8_t y); void draw_roll_angle(uint8_t x, uint8_t y); void draw_pitch_angle(uint8_t x, uint8_t y); + void draw_temp(uint8_t x, uint8_t y); }; class AP_OSD { diff --git a/libraries/AP_OSD/AP_OSD_Screen.cpp b/libraries/AP_OSD/AP_OSD_Screen.cpp index 9e56da722d..2d474828f5 100644 --- a/libraries/AP_OSD/AP_OSD_Screen.cpp +++ b/libraries/AP_OSD/AP_OSD_Screen.cpp @@ -153,6 +153,10 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = { // @Path: AP_OSD_Setting.cpp AP_SUBGROUPINFO(pitch_angle, "PITCH", 27, AP_OSD_Screen, AP_OSD_Setting), + // @Group: TEMP + // @Path: AP_OSD_Setting.cpp + AP_SUBGROUPINFO(temp, "TEMP", 28, AP_OSD_Screen, AP_OSD_Setting), + AP_GROUPEND }; @@ -771,6 +775,13 @@ void AP_OSD_Screen::draw_pitch_angle(uint8_t x, uint8_t y) backend->write(x, y, false, "%c%3d%c", p, pitch, SYM_DEGR); } +void AP_OSD_Screen::draw_temp(uint8_t x, uint8_t y) +{ + AP_Baro &barometer = AP::baro(); + float tmp = barometer.get_temperature(); + backend->write(x, y, false, "%3d%c", (int)u_scale(TEMPERATURE, tmp), u_icon(TEMPERATURE)); +} + #define DRAW_SETTING(n) if (n.enabled) draw_ ## n(n.xpos, n.ypos) void AP_OSD_Screen::draw(void) @@ -801,6 +812,7 @@ void AP_OSD_Screen::draw(void) DRAW_SETTING(home); DRAW_SETTING(roll_angle); DRAW_SETTING(pitch_angle); + DRAW_SETTING(temp); #ifdef HAVE_AP_BLHELI_SUPPORT DRAW_SETTING(blh_temp);