1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

Add RTC date/time to OSD stats

Fixes #4575
This commit is contained in:
Dan Nixon 2017-11-19 10:13:41 +00:00
parent e7d2e84348
commit 2bb561aa61
4 changed files with 39 additions and 2 deletions

View file

@ -861,6 +861,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->enabled_stats[OSD_STAT_BLACKBOX_NUMBER] = true; osdConfig->enabled_stats[OSD_STAT_BLACKBOX_NUMBER] = true;
osdConfig->enabled_stats[OSD_STAT_TIMER_1] = false; osdConfig->enabled_stats[OSD_STAT_TIMER_1] = false;
osdConfig->enabled_stats[OSD_STAT_TIMER_2] = true; osdConfig->enabled_stats[OSD_STAT_TIMER_2] = true;
osdConfig->enabled_stats[OSD_STAT_RTC_DATE_TIME] = false;
osdConfig->units = OSD_UNIT_METRIC; osdConfig->units = OSD_UNIT_METRIC;
@ -1103,11 +1104,23 @@ static bool isSomeStatEnabled(void) {
static void osdShowStats(void) static void osdShowStats(void)
{ {
uint8_t top = 2; uint8_t top = 2;
char buff[10]; char buff[OSD_ELEMENT_BUFFER_LENGTH];
displayClearScreen(osdDisplayPort); displayClearScreen(osdDisplayPort);
displayWrite(osdDisplayPort, 2, top++, " --- STATS ---"); displayWrite(osdDisplayPort, 2, top++, " --- STATS ---");
if (osdConfig()->enabled_stats[OSD_STAT_RTC_DATE_TIME]) {
bool success = false;
#ifdef USE_RTC_TIME
success = printRtcDateTime(&buff[0]);
#endif
if (!success) {
tfp_sprintf(buff, "NO RTC");
}
displayWrite(osdDisplayPort, 2, top++, buff);
}
if (osdConfig()->enabled_stats[OSD_STAT_TIMER_1]) { if (osdConfig()->enabled_stats[OSD_STAT_TIMER_1]) {
osdFormatTimer(buff, false, OSD_TIMER_1); osdFormatTimer(buff, false, OSD_TIMER_1);
osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1])], buff); osdDisplayStatisticLabel(top++, osdTimerSourceNames[OSD_TIMER_SRC(osdConfig()->timers[OSD_TIMER_1])], buff);

View file

@ -102,6 +102,7 @@ typedef enum {
OSD_STAT_TIMER_2, OSD_STAT_TIMER_2,
OSD_STAT_MAX_DISTANCE, OSD_STAT_MAX_DISTANCE,
OSD_STAT_BLACKBOX_NUMBER, OSD_STAT_BLACKBOX_NUMBER,
OSD_STAT_RTC_DATE_TIME,
OSD_STAT_COUNT // MUST BE LAST OSD_STAT_COUNT // MUST BE LAST
} osd_stats_e; } osd_stats_e;

View file

@ -155,10 +155,12 @@ osd_unittest_SRC := \
$(USER_DIR)/drivers/display.c \ $(USER_DIR)/drivers/display.c \
$(USER_DIR)/common/maths.c \ $(USER_DIR)/common/maths.c \
$(USER_DIR)/common/printf.c \ $(USER_DIR)/common/printf.c \
$(USER_DIR)/common/time.c \
$(USER_DIR)/fc/runtime_config.c $(USER_DIR)/fc/runtime_config.c
osd_unittest_DEFINES := \ osd_unittest_DEFINES := \
USE_OSD USE_OSD \
USE_RTC_TIME
parameter_groups_unittest_SRC := \ parameter_groups_unittest_SRC := \

View file

@ -29,6 +29,8 @@ extern "C" {
#include "config/parameter_group_ids.h" #include "config/parameter_group_ids.h"
#include "common/time.h"
#include "drivers/max7456_symbols.h" #include "drivers/max7456_symbols.h"
#include "fc/config.h" #include "fc/config.h"
@ -291,6 +293,7 @@ TEST(OsdTest, TestStatsImperial)
osdConfigMutable()->enabled_stats[OSD_STAT_END_BATTERY] = true; osdConfigMutable()->enabled_stats[OSD_STAT_END_BATTERY] = true;
osdConfigMutable()->enabled_stats[OSD_STAT_TIMER_1] = true; osdConfigMutable()->enabled_stats[OSD_STAT_TIMER_1] = true;
osdConfigMutable()->enabled_stats[OSD_STAT_TIMER_2] = true; osdConfigMutable()->enabled_stats[OSD_STAT_TIMER_2] = true;
osdConfigMutable()->enabled_stats[OSD_STAT_RTC_DATE_TIME] = true;
osdConfigMutable()->enabled_stats[OSD_STAT_MAX_DISTANCE] = true; osdConfigMutable()->enabled_stats[OSD_STAT_MAX_DISTANCE] = true;
osdConfigMutable()->enabled_stats[OSD_STAT_BLACKBOX_NUMBER] = false; osdConfigMutable()->enabled_stats[OSD_STAT_BLACKBOX_NUMBER] = false;
@ -310,6 +313,18 @@ TEST(OsdTest, TestStatsImperial)
// a GPS fix is present // a GPS fix is present
stateFlags |= GPS_FIX | GPS_FIX_HOME; stateFlags |= GPS_FIX | GPS_FIX_HOME;
// and
// this RTC time
dateTime_t dateTime;
dateTime.year = 2017;
dateTime.month = 11;
dateTime.day = 19;
dateTime.hours = 10;
dateTime.minutes = 12;
dateTime.seconds = 0;
dateTime.millis = 0;
rtcSetDateTime(&dateTime);
// when // when
// the craft is armed // the craft is armed
doTestArm(); doTestArm();
@ -347,6 +362,7 @@ TEST(OsdTest, TestStatsImperial)
// then // then
// statistics screen should display the following // statistics screen should display the following
int row = 3; int row = 3;
displayPortTestBufferSubstring(2, row++, "2017-11-19 10:12:");
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:05.00"); displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:05.00");
displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:03"); displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:03");
displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28"); displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28");
@ -397,6 +413,7 @@ TEST(OsdTest, TestStatsMetric)
// then // then
// statistics screen should display the following // statistics screen should display the following
int row = 3; int row = 3;
displayPortTestBufferSubstring(2, row++, "2017-11-19 10:12:");
displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:07.50"); displayPortTestBufferSubstring(2, row++, "TOTAL ARM : 00:07.50");
displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:02"); displayPortTestBufferSubstring(2, row++, "LAST ARM : 00:02");
displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28"); displayPortTestBufferSubstring(2, row++, "MAX SPEED : 28");
@ -873,6 +890,10 @@ extern "C" {
return simulationTime; return simulationTime;
} }
uint32_t millis() {
return micros() / 1000;
}
bool isBeeperOn() { bool isBeeperOn() {
return false; return false;
} }