AP_OSD: add clock panel

This commit is contained in:
Andrew Tridgell 2019-11-17 11:36:07 +11:00
parent c3bc1e3dd4
commit d3d4dff9ba
2 changed files with 34 additions and 1 deletions

View File

@ -115,6 +115,7 @@ private:
AP_OSD_Setting atemp{false, 0, 0};
AP_OSD_Setting bat2_vlt{false, 0, 0};
AP_OSD_Setting bat2used{false, 0, 0};
AP_OSD_Setting clk{false, 0, 0};
bool check_option(uint32_t option);
@ -179,6 +180,7 @@ private:
void draw_atemp(uint8_t x, uint8_t y);
void draw_bat2_vlt(uint8_t x, uint8_t y);
void draw_bat2used(uint8_t x, uint8_t y);
void draw_clk(uint8_t x, uint8_t y);
};
class AP_OSD {

View File

@ -33,6 +33,7 @@
#include <AP_BattMonitor/AP_BattMonitor.h>
#include <AP_GPS/AP_GPS.h>
#include <AP_Baro/AP_Baro.h>
#include <AP_RTC/AP_RTC.h>
#include <ctype.h>
#include <GCS_MAVLink/GCS.h>
@ -687,7 +688,23 @@ const AP_Param::GroupInfo AP_OSD_Screen::var_info[] = {
// @Description: Vertical position on screen
// @Range: 0 15
AP_SUBGROUPINFO(aspd1, "ASPD1", 42, AP_OSD_Screen, AP_OSD_Setting),
// @Param: CLK_EN
// @DisplayName: CLK_EN
// @Description: Displays a clock panel based on AP_RTC local time
// @Values: 0:Disabled,1:Enabled
// @Param: CLK_X
// @DisplayName: CLK_X
// @Description: Horizontal position on screen
// @Range: 0 29
// @Param: CLK_Y
// @DisplayName: CLK_Y
// @Description: Vertical position on screen
// @Range: 0 15
AP_SUBGROUPINFO(clk, "CLK", 43, AP_OSD_Screen, AP_OSD_Setting),
AP_GROUPEND
};
@ -782,6 +799,7 @@ AP_OSD_Screen::AP_OSD_Screen()
#define SYM_FLY 0x9C
#define SYM_EFF 0xF2
#define SYM_AH 0xF3
#define SYM_CLK 0xBC
void AP_OSD_Screen::set_backend(AP_OSD_Backend *_backend)
{
@ -1516,6 +1534,18 @@ void AP_OSD_Screen::draw_aspd2(uint8_t x, uint8_t y)
}
}
void AP_OSD_Screen::draw_clk(uint8_t x, uint8_t y)
{
AP_RTC &rtc = AP::rtc();
uint8_t hour, min, sec;
uint16_t ms;
if (!rtc.get_local_time(hour, min, sec, ms)) {
backend->write(x, y, false, "%c--:--%", SYM_CLK);
} else {
backend->write(x, y, false, "%c%02u:%02u", SYM_CLK, hour, min);
}
}
#define DRAW_SETTING(n) if (n.enabled) draw_ ## n(n.xpos, n.ypos)
void AP_OSD_Screen::draw(void)
@ -1557,6 +1587,7 @@ void AP_OSD_Screen::draw(void)
DRAW_SETTING(atemp);
DRAW_SETTING(hdop);
DRAW_SETTING(flightime);
DRAW_SETTING(clk);
#ifdef HAVE_AP_BLHELI_SUPPORT
DRAW_SETTING(blh_temp);