AP_OSD: add flytime item

This commit is contained in:
Hwurzburg 2018-07-16 01:40:40 -05:00 committed by Andrew Tridgell
parent a0ce604721
commit 7c79175309
2 changed files with 18 additions and 1 deletions

View File

@ -106,6 +106,7 @@ private:
AP_OSD_Setting xtrack_error{false, 0, 0};
AP_OSD_Setting dist{false,22,11};
AP_OSD_Setting stat{false,0,0};
AP_OSD_Setting flightime{false, 23, 10};
bool check_option(uint32_t option);
@ -160,6 +161,7 @@ private:
void draw_xtrack_error(uint8_t x, uint8_t y);
void draw_dist(uint8_t x, uint8_t y);
void draw_stat(uint8_t x, uint8_t y);
void draw_flightime(uint8_t x, uint8_t y);
};
class AP_OSD {

View File

@ -28,6 +28,7 @@
#include <AP_Math/AP_Math.h>
#include <AP_RSSI/AP_RSSI.h>
#include <AP_Notify/AP_Notify.h>
#include <AP_Stats/AP_Stats.h>
#include <ctype.h>
#include <GCS_MAVLink/GCS.h>
@ -177,6 +178,9 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
// @Path: AP_OSD_Setting.cpp
AP_SUBGROUPINFO(stat, "STATS", 33, AP_OSD_Screen, AP_OSD_Setting),
// @Group: FLTIME
// @Path: AP_OSD_Setting.cpp
AP_SUBGROUPINFO(flightime, "FLTIME", 34, AP_OSD_Screen, AP_OSD_Setting),
AP_GROUPEND
};
@ -269,6 +273,7 @@ AP_OSD_Screen::AP_OSD_Screen()
#define SYM_KN 0xF0
#define SYM_NM 0xF1
#define SYM_DIST 0x22
#define SYM_FLY 0x9C
void AP_OSD_Screen::set_backend(AP_OSD_Backend *_backend)
{
@ -440,7 +445,7 @@ void AP_OSD_Screen::draw_sats(uint8_t x, uint8_t y)
{
AP_GPS & gps = AP::gps();
int nsat = gps.num_sats();
backend->write(x, y, nsat < osd->warn_nsat , "%c%c%2d", SYM_SAT_L, SYM_SAT_R, nsat);
backend->write(x, y, nsat < osd->warn_nsat, "%c%c%2d", SYM_SAT_L, SYM_SAT_R, nsat);
}
void AP_OSD_Screen::draw_batused(uint8_t x, uint8_t y)
@ -851,6 +856,15 @@ void AP_OSD_Screen::draw_dist(uint8_t x, uint8_t y)
draw_distance(x+1, y, osd->last_distance_m);
}
void AP_OSD_Screen::draw_flightime(uint8_t x, uint8_t y)
{
AP_Stats *stats = AP::stats();
if (stats) {
uint32_t t = stats->get_flight_time_s();
backend->write(x, y, false, "%c%3u:%02u", SYM_FLY, t/60, t%60);
}
}
#define DRAW_SETTING(n) if (n.enabled) draw_ ## n(n.xpos, n.ypos)
void AP_OSD_Screen::draw(void)
@ -885,6 +899,7 @@ void AP_OSD_Screen::draw(void)
DRAW_SETTING(pitch_angle);
DRAW_SETTING(temp);
DRAW_SETTING(hdop);
DRAW_SETTING(flightime);
#ifdef HAVE_AP_BLHELI_SUPPORT
DRAW_SETTING(blh_temp);