@@ -197,7 +197,7 @@ namespace debug { | |||
tmElements_t time; | |||
rtc::getTime(time); | |||
NOTICE_FORMAT("getAndDisplayRtcTime", "%d/%d/%d %d:%d:%d %t %d", tmYearToCalendar(time.year), time.month, time.day, time.hour, time.minute, time.second, rtc::isAccurate(), rtc::getTemperature()); | |||
NOTICE_FORMAT("getAndDisplayRtcTime", "%d/%d/%d %d:%d:%d %t %d", time.year, time.month, time.day, time.hour, time.minute, time.second, rtc::isAccurate(), rtc::getTemperature()); | |||
} | |||
void setRtcTime() { | |||
@@ -105,13 +105,13 @@ namespace gps { | |||
VERBOSE_FORMAT("getTime", "%s", timeStr); | |||
time.year = calendarYrToTm(details::parseSubstring(buffer, timeStr + TIME_YEAR_OFFSET, 4)); | |||
time.year = details::parseSubstring(buffer, timeStr + TIME_YEAR_OFFSET, 4); | |||
time.month = details::parseSubstring(buffer, timeStr + TIME_MONTH_OFFSET, 2); | |||
time.day = details::parseSubstring(buffer, timeStr + TIME_DAY_OFFSET, 2); | |||
time.hour = details::parseSubstring(buffer, timeStr + TIME_HOUR_OFFSET, 2); | |||
time.minute = details::parseSubstring(buffer, timeStr + TIME_MINUTE_OFFSET, 2); | |||
time.second = details::parseSubstring(buffer, timeStr + TIME_SECOND_OFFSET, 2); | |||
NOTICE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.year), time.month, time.day, time.hour, time.minute, time.second); | |||
NOTICE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second); | |||
} | |||
} |
@@ -48,11 +48,11 @@ namespace rtc { | |||
RTC_A.readTime(time); | |||
hardware::i2c::powerOff(); | |||
VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.year), time.month, time.day, time.hour, time.minute, time.second); | |||
VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second); | |||
} | |||
void setTime(const tmElements_t &time) { | |||
VERBOSE_FORMAT("setTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.year), time.month, time.day, time.hour, time.minute, time.second); | |||
VERBOSE_FORMAT("setTime", "%d/%d/%d %d:%d:%d", time.year, time.month, time.day, time.hour, time.minute, time.second); | |||
hardware::i2c::powerOn(); | |||
RTC_A.writeTime(time); | |||
@@ -1,49 +1,47 @@ | |||
#include "RtcAbstraction.h" | |||
#ifndef USE_UDS3231 | |||
#ifdef STOCK_MD_DS3231 | |||
void MDS3231_Ext::unpack(tmElements_t &time) { | |||
time.second = s; | |||
time.minute = m; | |||
time.hour = h; | |||
time.day = dd; | |||
time.month = mm; | |||
time.year = yyyy; | |||
void MD_DS3231_Ext::unpack(tmElements_t &time) { | |||
time.second = MD_DS3231::s; | |||
time.minute = MD_DS3231::m; | |||
time.hour = MD_DS3231::h; | |||
time.day = MD_DS3231::dd; | |||
time.month = MD_DS3231::mm; | |||
time.year = MD_DS3231::yyyy; | |||
} | |||
void MDS3231_Ext::pack(const tmElements_t &time) { | |||
s = time.second; | |||
m = time.minute; | |||
h = time.hour; | |||
dd = time.day; | |||
mm = time.month; | |||
yyyy = time.year; | |||
void MD_DS3231_Ext::pack(const tmElements_t &time) { | |||
MD_DS3231::s = time.second; | |||
MD_DS3231::m = time.minute; | |||
MD_DS3231::h = time.hour; | |||
MD_DS3231::dd = time.day; | |||
MD_DS3231::mm = time.month; | |||
MD_DS3231::yyyy = time.year; | |||
} | |||
boolean MDS3231_Ext::readTime(tmElements_t &time) { | |||
boolean MD_DS3231_Ext::readTime(tmElements_t &time) { | |||
bool result = MD_DS3231::readTime(); | |||
unpack(time); | |||
return result; | |||
} | |||
boolean MDS3231_Ext::writeTime(const tmElements_t &time) { | |||
boolean MD_DS3231_Ext::writeTime(const tmElements_t &time) { | |||
pack(time); | |||
return MD_DS3231::writeTime(); | |||
} | |||
boolean MDS3231_Ext::readAlarm1(alm1Type_t &almType, tmElements_t &time) { | |||
boolean MD_DS3231_Ext::readAlarm1(almType_t &almType, tmElements_t &time) { | |||
almType = MD_DS3231::getAlarm1Type(); | |||
bool result = MD_DS3231::readAlarm1(); | |||
return result; | |||
} | |||
boolean MDS3231_Ext::writeAlarm1(alm1Type_t almType, const tmElements_t &time) { | |||
boolean MD_DS3231_Ext::writeAlarm1(almType_t almType, const tmElements_t &time) { | |||
pack(time); | |||
return MD_DS3231::writeAlarm1(almType); | |||
} | |||
#endif | |||
#endif |
@@ -6,7 +6,6 @@ | |||
* the stock MD_DS3231 one. | |||
*/ | |||
// #define USE_UDS3231 | |||
//#define STOCK_MD_DS3231 | |||
#ifdef USE_UDS3231 | |||
#include <uDS3231.h> | |||
@@ -14,40 +13,30 @@ | |||
#define RTC_A_CLASS uDS3231 | |||
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t) | |||
#else | |||
#ifdef STOCK_MD_DS3231 | |||
#include <MD_DS3231.h> | |||
typedef unsigned long timestamp_t; | |||
typedef struct tmElements_t { | |||
uint8_t Second; | |||
uint8_t Minute; | |||
uint8_t Hour; | |||
uint8_t Day; | |||
uint8_t month; | |||
uint8_t year; // year from 2000 | |||
}; | |||
class MD_DS3231_Ext : public MD_DS3231 | |||
{ | |||
private: | |||
void unpack(tmElements_t &time); | |||
void pack(const tmElements_t &time); | |||
public: | |||
boolean readTime(tmElements_t &time); | |||
boolean writeTime(const tmElements_t &time); | |||
boolean readAlarm1(almType_t &almType, tmElements_t &time); | |||
boolean writeAlarm1(almType_t almType, const tmElements_t &time); | |||
}; | |||
#define RTC_A_CLASS MD_DS3231_Ext | |||
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t) | |||
#else | |||
#include <MD_DS3231.h> | |||
#define RTC_A_CLASS MD_DS3231 | |||
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(alm1Type_t::ALM_HMS, t) | |||
typedef unsigned long timestamp_t; | |||
#endif | |||
#include <MD_DS3231.h> | |||
typedef struct tmElements_t { | |||
uint8_t second = 0; | |||
uint8_t minute = 0; | |||
uint8_t hour = 0; | |||
uint8_t day = 0; | |||
uint8_t month = 0; | |||
uint16_t year = 0; // year from 2000 | |||
}; | |||
class MD_DS3231_Ext : public MD_DS3231 | |||
{ | |||
private: | |||
void unpack(tmElements_t &time); | |||
void pack(const tmElements_t &time); | |||
public: | |||
boolean readTime(tmElements_t &time); | |||
boolean writeTime(const tmElements_t &time); | |||
boolean readAlarm1(almType_t &almType, tmElements_t &time); | |||
boolean writeAlarm1(almType_t almType, const tmElements_t &time); | |||
}; | |||
#define RTC_A_CLASS MD_DS3231_Ext | |||
#define WRITE_ALARM_1(t) RTC_A.writeAlarm1(DS3231_ALM_HMS, t) | |||
#endif |
@@ -3,6 +3,8 @@ | |||
#include <Arduino.h> | |||
#include "RtcAbstraction.h" | |||
typedef unsigned long timestamp_t; | |||
namespace utils { | |||
namespace time { | |||
@@ -20,7 +20,7 @@ | |||
\def VERSION | |||
Version string, only used for indicative purpose | |||
*/ | |||
#define VERSION "1.22" | |||
#define VERSION "1.30" | |||
/** | |||