feat(bw): do not show time on main view when RTC not set (#5342)

This commit is contained in:
3djc
2024-07-29 20:13:47 +10:00
committed by GitHub
parent bdfb94ae83
commit 7fb3888b93
4 changed files with 17 additions and 3 deletions
+2 -2
View File
@@ -674,13 +674,13 @@ void menuMainView(event_t event)
lcdDrawText(15 * FW, 0, "BIND", 0);
}
#if defined(RTCLOCK)
else if (view_base != VIEW_CHAN_MONITOR) {
else if (view_base != VIEW_CHAN_MONITOR && rtcIsValid()) {
drawRtcTime(CLOCK_X, CLOCK_Y, LEFT|TIMEBLINK);
}
#endif
#else
#if defined(RTCLOCK)
if (view_base != VIEW_CHAN_MONITOR) {
if (view_base != VIEW_CHAN_MONITOR && rtcIsValid()) {
drawRtcTime(CLOCK_X, CLOCK_Y, LEFT|TIMEBLINK);
}
#endif
+1 -1
View File
@@ -335,7 +335,7 @@ void displayTopBar()
LCD_ICON(BAR_VOLUME_X, BAR_Y, ICON_SPEAKER3);
/* RTC time */
drawRtcTime(BAR_TIME_X, BAR_Y+1, LEFT|TIMEBLINK);
if (rtcIsValid()) drawRtcTime(BAR_TIME_X, BAR_Y+1, LEFT|TIMEBLINK);
/* The background */
lcdDrawFilledRect(BAR_X, BAR_Y, BAR_W, BAR_H, SOLID, FILL_WHITE|GREY(12)|ROUND);
+13
View File
@@ -493,3 +493,16 @@ uint8_t rtcAdjust(uint16_t year, uint8_t mon, uint8_t day, uint8_t hour, uint8_t
}
return 0;
}
bool rtcIsValid()
{
struct gtm t;
gettime(&t);
// If year is 2000, rtc circuit aren't working
// No RTC battery or other issue
if (t.tm_year <= 100)
return false;
return true;
}
+1
View File
@@ -50,6 +50,7 @@ struct gtm
extern gtime_t g_rtcTime;
extern uint8_t g_ms100; // global to allow time set function to reset to zero
bool rtcIsValid();
void rtcInit();
void rtcSetTime(const struct gtm * tm);
gtime_t gmktime (struct gtm *tm);