Add support for DS1307 RTC module

DS1307 does not seem to have the lost lostPower function. So the time does not get set on upload and needs to be set manually as described in the [wiki](https://github.com/sanni/cartreader/wiki/Real%E2%80%90Time-Clock#setting-the-time).

In Config.h set like this:

````
#define RTC_installed
//#define DS3231
#define DS1307
````

Connect "Tiny RTC I2C module" or similar to the SDA/SCL/VCC/GND pins.
This commit is contained in:
sanni 2023-07-22 15:21:02 +02:00 committed by GitHub
parent 97eada64e7
commit 63aeb335a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

View File

@ -1645,7 +1645,11 @@ void draw_progressbar(uint32_t processed, uint32_t total) {
RTC Module
*****************************************/
#ifdef RTC_installed
#if defined(DS3231)
RTC_DS3231 rtc;
#elif defined(DS1307)
RTC_DS1307 rtc;
#endif
// Start Time
void RTCStart() {
@ -1654,11 +1658,14 @@ void RTCStart() {
abort();
}
// RTC_DS1307 does not have lostPower()
#if defined(DS3231)
// Set RTC Date/Time of Sketch Build if it lost battery power
// After initial setup it would have lost battery power ;)
if (rtc.lostPower()) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
#endif
}
// Set Date/Time Callback Funtion
@ -2674,24 +2681,24 @@ byte questionBox_Serial(const __FlashStringHelper* question, char answers[7][20]
// Page up (u)
if (incomingByte == 69) {
if (currPage > 1) {
lastPage = currPage;
currPage--;
} else {
root = 1;
}
if (currPage > 1) {
lastPage = currPage;
currPage--;
} else {
root = 1;
}
}
// Page down (d)
else if (incomingByte == 52) {
if (numPages > currPage) {
if (numPages > currPage) {
lastPage = currPage;
currPage++;
}
}
// Execute choice
else if ((incomingByte >= 0) && (incomingByte < 7)){
// Execute choice
else if ((incomingByte >= 0) && (incomingByte < 7)) {
numPages = 0;
}

View File

@ -61,6 +61,8 @@
*/
//#define RTC_installed
#define DS3231
//#define DS1307
/****/
@ -274,7 +276,7 @@
* other than HW5 and HW3.
*/
//#define ENABLE_UPDATER
#define ENABLE_UPDATER
/****/

View File

@ -15,7 +15,7 @@
/*==== SANITY CHECKS ==============================================*/
#if !(defined(HW1) || defined(HW2) || defined(HW3) || defined(HW4) || defined(HW5) || defined(SERIAL_MONITOR))
#error !!! PLEASE CHOOSE HARDWARE VERSION !!!
#error !!! PLEASE CHOOSE HARDWARE VERSION IN CONFIG.H !!!
#endif
#if defined(ENABLE_3V3FIX) && !defined(ENABLE_VSELECT)