AP_MSP: add and use an AP_RTC_config.h

This commit is contained in:
Peter Barker 2023-10-04 18:03:32 +11:00 committed by Andrew Tridgell
parent 48b10a3105
commit 8f2c35d1e9
1 changed files with 6 additions and 0 deletions

View File

@ -989,10 +989,12 @@ MSPCommandResult AP_MSP_Telem_Backend::msp_process_out_rtc(sbuf_t *dst)
{ {
tm localtime_tm {}; // year is relative to 1900 tm localtime_tm {}; // year is relative to 1900
uint64_t time_usec = 0; uint64_t time_usec = 0;
#if AP_RTC_ENABLED
if (AP::rtc().get_utc_usec(time_usec)) { // may fail, leaving time_unix at 0 if (AP::rtc().get_utc_usec(time_usec)) { // may fail, leaving time_unix at 0
const time_t time_sec = time_usec / 1000000; const time_t time_sec = time_usec / 1000000;
localtime_tm = *gmtime(&time_sec); localtime_tm = *gmtime(&time_sec);
} }
#endif
const struct PACKED { const struct PACKED {
uint16_t year; uint16_t year;
uint8_t mon; uint8_t mon;
@ -1150,10 +1152,14 @@ void AP_MSP_Telem_Backend::hide_osd_items(void)
BIT_SET(osd_hidden_items_bitmask, OSD_MAIN_BATT_VOLTAGE); BIT_SET(osd_hidden_items_bitmask, OSD_MAIN_BATT_VOLTAGE);
} }
// flash rtc if no time available // flash rtc if no time available
#if AP_RTC_ENABLED
uint64_t time_usec; uint64_t time_usec;
if (!AP::rtc().get_utc_usec(time_usec)) { if (!AP::rtc().get_utc_usec(time_usec)) {
BIT_SET(osd_hidden_items_bitmask, OSD_RTC_DATETIME); BIT_SET(osd_hidden_items_bitmask, OSD_RTC_DATETIME);
} }
#else
BIT_SET(osd_hidden_items_bitmask, OSD_RTC_DATETIME);
#endif
// flash rssi if disabled // flash rssi if disabled
float rssi; float rssi;
if (!get_rssi(rssi)) { if (!get_rssi(rssi)) {