Skip to content

Commit

Permalink
Fall back to default naming scheme when no rtc battery is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
Master92 committed Nov 24, 2023
1 parent 010f102 commit 24bdf3b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/driver/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include <unistd.h>

#include <log/log.h>
#include <minIni.h>

#include "core/settings.h"
#include "ui/page_common.h"

/**
* Constants
Expand Down Expand Up @@ -173,19 +175,24 @@ void rtc_tv2rd(const struct timeval *tv, struct rtc_date *rd) {
}

/**
* Initialize both the hardware ans system clocks.
* Initialize both the hardware and system clocks.
*/
void rtc_init() {
struct rtc_date rd;
rtc_get_clock(&rd);

// Has time has accumulated since the
// the installation of the battery?
// Has time accumulated since the
// installation of the battery?
g_rtc_has_battery = rd.year > 1970;

LOGI("rtc_init %s detected a battery",
(g_rtc_has_battery ? "has" : "has NOT"));

if (!g_rtc_has_battery) {
g_setting.record.naming = SETTING_NAMING_CONTIGUOUS;
ini_putl("record", "naming", g_setting.record.naming, SETTING_INI);
}

if (rd.year == 1970) {
LOGI("rtc_init updating both clocks via settings");
rd.year = g_setting.clock.year;
Expand Down

0 comments on commit 24bdf3b

Please sign in to comment.