From f5438b845f1fc04199b09964512d074c361275c0 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Mon, 12 Mar 2018 23:06:46 +1300 Subject: [PATCH 1/6] swtiched to uDS3231 lib --- GpsTracker/Rtc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GpsTracker/Rtc.cpp b/GpsTracker/Rtc.cpp index 9c7ad98..8a2b4ab 100644 --- a/GpsTracker/Rtc.cpp +++ b/GpsTracker/Rtc.cpp @@ -4,7 +4,7 @@ #include "Pins.h" #include -#include +#include #define LOGGER_NAME "Rtc" From 31fcdba7c0ec5bc1105ae61412b7824eadec1acc Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Tue, 13 Mar 2018 13:22:05 +1300 Subject: [PATCH 2/6] Adapted code to uDS3231 code trim --- GpsTracker/Debug.h | 2 +- GpsTracker/Rtc.cpp | 4 ++-- GpsTracker/Time2.cpp | 2 +- GpsTracker/Time2.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/GpsTracker/Debug.h b/GpsTracker/Debug.h index 875593e..624d99f 100644 --- a/GpsTracker/Debug.h +++ b/GpsTracker/Debug.h @@ -19,7 +19,7 @@ #define VERBOSE_FORMAT(f, msg, ...) LOG_FORMAT(verbose, f, msg, __VA_ARGS__) #else -#define DISABLE_LOGGING 1 +#define DISABLE_LOGGING 1 //TODO : does nothing if not included before ArduinoLog.h #define VERBOSE(f) #define VERBOSE_MSG(f, msg) diff --git a/GpsTracker/Rtc.cpp b/GpsTracker/Rtc.cpp index 8a2b4ab..c7705bc 100644 --- a/GpsTracker/Rtc.cpp +++ b/GpsTracker/Rtc.cpp @@ -16,7 +16,7 @@ namespace rtc { time.Second = RTC.s; time.Minute = RTC.m; time.Hour = RTC.h; - time.Wday = RTC.dow; + //time.Wday = RTC.dow; time.Day = RTC.dd; time.Month = RTC.mm; time.Year = CalendarYrToTm(RTC.yyyy); @@ -26,7 +26,7 @@ namespace rtc { RTC.s = time.Second; RTC.m = time.Minute; RTC.h = time.Hour; - RTC.dow = time.Wday; + //RTC.dow = time.Wday; RTC.dd = time.Day; RTC.mm = time.Month; RTC.yyyy = tmYearToCalendar(time.Year); diff --git a/GpsTracker/Time2.cpp b/GpsTracker/Time2.cpp index 2bee65c..49c7225 100644 --- a/GpsTracker/Time2.cpp +++ b/GpsTracker/Time2.cpp @@ -55,7 +55,7 @@ void breakTime(const timestamp_t timeInput, tmElements_t &tm) { time /= 60; // now it is hours tm.Hour = time % 24; time /= 24; // now it is days - tm.Wday = ((time + 4) % 7) + 1; // Sunday is day 1 + //tm.Wday = ((time + 4) % 7) + 1; // Sunday is day 1 year = 0; days = 0; diff --git a/GpsTracker/Time2.h b/GpsTracker/Time2.h index b21a4e2..bba52fa 100644 --- a/GpsTracker/Time2.h +++ b/GpsTracker/Time2.h @@ -16,11 +16,11 @@ typedef struct { uint8_t Second; uint8_t Minute; uint8_t Hour; - uint8_t Wday; // day of week, sunday is day 1 + //uint8_t Wday; // day of week, sunday is day 1 uint8_t Day; uint8_t Month; uint8_t Year; // offset from 1970; -} tmElements_t, TimeElements, *tmElementsPtr_t; +} tmElements_t; /* low level functions to convert to and from system time */ void breakTime(const timestamp_t time, tmElements_t &tm); // break timestamp_t into elements From 84e09577aec0e2f6d0b9724674c99e4431e3237c Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Tue, 13 Mar 2018 14:02:27 +1300 Subject: [PATCH 3/6] Use tmElements_t struct (offset from 2000) to set and get time --- GpsTracker/Rtc.cpp | 8 ++++---- GpsTracker/Time2.cpp | 14 +++++++------- GpsTracker/Time2.h | 27 ++++++++++++--------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/GpsTracker/Rtc.cpp b/GpsTracker/Rtc.cpp index c7705bc..8f4527b 100644 --- a/GpsTracker/Rtc.cpp +++ b/GpsTracker/Rtc.cpp @@ -61,10 +61,10 @@ namespace rtc { void getTime(tmElements_t &time) { hardware::i2c::powerOn(); - RTC.readTime(); + RTC.readTime(time); hardware::i2c::powerOff(); - details::readTimeFromRegisters(time); + //details::readTimeFromRegisters(time); VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second); } @@ -76,10 +76,10 @@ namespace rtc { 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); - details::writeTimeToRegisters(time); + //details::writeTimeToRegisters(time); hardware::i2c::powerOn(); - RTC.writeTime(); + RTC.writeTime(time); hardware::i2c::powerOff(); } diff --git a/GpsTracker/Time2.cpp b/GpsTracker/Time2.cpp index 49c7225..1395634 100644 --- a/GpsTracker/Time2.cpp +++ b/GpsTracker/Time2.cpp @@ -15,7 +15,7 @@ #define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) #define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR) #define dayOfWeek(_time_) ((( _time_ / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday -#define elapsedDays(_time_) ( _time_ / SECS_PER_DAY) // this is number of days since Jan 1 1970 +#define elapsedDays(_time_) ( _time_ / SECS_PER_DAY) // this is number of days since Jan 1 2000 #define elapsedSecsToday(_time_) (_time_ % SECS_PER_DAY) // the number of seconds since last midnight // The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971 // Always set the correct time before settting alarms @@ -32,8 +32,8 @@ #define daysTotimestamp_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011 #define weeksTotimestamp_t ((W)) ( (W) * SECS_PER_WEEK) -// leap year calulator expects year argument as years offset from 1970 -#define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) ) +// leap year calulator expects year argument as years offset from 2000 +#define LEAP_YEAR(Y) ( ((2000+Y)>0) && !((2000+Y)%4) && ( ((2000+Y)%100) || !((2000+Y)%400) ) ) static const uint8_t monthDays[] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; // API starts months from 1, this array starts from 0 @@ -41,7 +41,7 @@ __attribute__((__optimize__("O2"))) void breakTime(const timestamp_t timeInput, tmElements_t &tm) { // break the given timestamp_t into time components // this is a more compact version of the C library localtime function - // note that year is offset from 1970 !!! + // note that year is offset from 2000 !!! uint8_t year; uint8_t month, monthLength; @@ -62,7 +62,7 @@ void breakTime(const timestamp_t timeInput, tmElements_t &tm) { while ((unsigned)(days += (LEAP_YEAR(year) ? 366 : 365)) <= time) { year++; } - tm.Year = year; // year is offset from 1970 + tm.Year = year; // year is offset from 2000 days -= LEAP_YEAR(year) ? 366 : 365; time -= days; // now it is days in this year, starting at 0 @@ -97,13 +97,13 @@ void breakTime(const timestamp_t timeInput, tmElements_t &tm) { __attribute__((__optimize__("O2"))) timestamp_t makeTimestamp(const tmElements_t &tm) { // assemble time elements into timestamp_t - // note year argument is offset from 1970 (see macros in time.h to convert to other formats) + // note year argument is offset from 2000 (see macros in time.h to convert to other formats) // previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9 int i; uint32_t seconds; - // seconds from 1970 till 1 jan 00:00:00 of the given year + // seconds from 2000 till 1 jan 00:00:00 of the given year seconds = tm.Year*(SECS_PER_DAY * 365); for (i = 0; i < tm.Year; i++) { if (LEAP_YEAR(i)) { diff --git a/GpsTracker/Time2.h b/GpsTracker/Time2.h index bba52fa..f491ad0 100644 --- a/GpsTracker/Time2.h +++ b/GpsTracker/Time2.h @@ -1,26 +1,23 @@ #pragma once #include +#include + -//convenience macros to convert to and from tm years -#define tmYearToCalendar(Y) ((Y) + 1970) // full four digit year -#define CalendarYrToTm(Y) ((Y) - 1970) -#define tmYearToY2k(Y) ((Y) - 30) // offset is from 2000 -#define y2kYearToTm(Y) ((Y) + 30) /*============================================================================*/ -typedef unsigned long timestamp_t; +//typedef unsigned long timestamp_t; -typedef struct { - uint8_t Second; - uint8_t Minute; - uint8_t Hour; - //uint8_t Wday; // day of week, sunday is day 1 - uint8_t Day; - uint8_t Month; - uint8_t Year; // offset from 1970; -} tmElements_t; +//typedef struct { +// uint8_t Second; +// uint8_t Minute; +// uint8_t Hour; +// //uint8_t Wday; // day of week, sunday is day 1 +// uint8_t Day; +// uint8_t Month; +// uint8_t Year; // offset from 1970; +//} tmElements_t; /* low level functions to convert to and from system time */ void breakTime(const timestamp_t time, tmElements_t &tm); // break timestamp_t into elements From f4516c0301661f756c661d108184962b3097bb2d Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Tue, 13 Mar 2018 14:55:21 +1300 Subject: [PATCH 4/6] Switched time reading and writing to parameter based function rather than private variables --- GpsTracker/Rtc.cpp | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/GpsTracker/Rtc.cpp b/GpsTracker/Rtc.cpp index 8f4527b..34bf3b3 100644 --- a/GpsTracker/Rtc.cpp +++ b/GpsTracker/Rtc.cpp @@ -9,30 +9,6 @@ #define LOGGER_NAME "Rtc" namespace rtc { - - namespace details { - - void readTimeFromRegisters(tmElements_t &time) { - time.Second = RTC.s; - time.Minute = RTC.m; - time.Hour = RTC.h; - //time.Wday = RTC.dow; - time.Day = RTC.dd; - time.Month = RTC.mm; - time.Year = CalendarYrToTm(RTC.yyyy); - } - - void writeTimeToRegisters(const tmElements_t &time) { - RTC.s = time.Second; - RTC.m = time.Minute; - RTC.h = time.Hour; - //RTC.dow = time.Wday; - RTC.dd = time.Day; - RTC.mm = time.Month; - RTC.yyyy = tmYearToCalendar(time.Year); - } - - } void setup() { VERBOSE("setup"); @@ -64,7 +40,6 @@ namespace rtc { RTC.readTime(time); hardware::i2c::powerOff(); - //details::readTimeFromRegisters(time); VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second); } @@ -76,7 +51,6 @@ namespace rtc { 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); - //details::writeTimeToRegisters(time); hardware::i2c::powerOn(); RTC.writeTime(time); @@ -94,10 +68,8 @@ namespace rtc { } void setAlarm(const tmElements_t &time) { - details::writeTimeToRegisters(time); - hardware::i2c::powerOn(); - RTC.writeAlarm1(DS3231_ALM_DTHMS); + RTC.writeAlarm1(DS3231_ALM_DTHMS, time); RTC.control(DS3231_A1_FLAG, DS3231_OFF); //reset Alarm 1 flag RTC.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON From b64990c0a546846af4edc94f8b96e72595d2c2b3 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Tue, 13 Mar 2018 17:48:43 +1300 Subject: [PATCH 5/6] Code cleanup after DS3231 trim --- GpsTracker/Core.cpp | 2 + GpsTracker/Debug.cpp | 2 + GpsTracker/Flash.h | 10 ++-- GpsTracker/Rtc.cpp | 19 +++--- GpsTracker/Rtc.h | 1 - GpsTracker/Time2.cpp | 137 ++++++++----------------------------------- GpsTracker/Time2.h | 24 ++------ 7 files changed, 50 insertions(+), 145 deletions(-) diff --git a/GpsTracker/Core.cpp b/GpsTracker/Core.cpp index d6461a3..f44c85f 100644 --- a/GpsTracker/Core.cpp +++ b/GpsTracker/Core.cpp @@ -4,6 +4,8 @@ #define LOGGER_NAME "Core" +using namespace utils; + namespace core { uint16_t sleepTime = SLEEP_DEFAULT_TIME_SECONDS;; diff --git a/GpsTracker/Debug.cpp b/GpsTracker/Debug.cpp index f54508a..15697cf 100644 --- a/GpsTracker/Debug.cpp +++ b/GpsTracker/Debug.cpp @@ -103,6 +103,8 @@ int freeRam2() { // dirty hack because putting it in namespace doesn't compile return (int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval); } +using namespace utils; + namespace debug { namespace details { diff --git a/GpsTracker/Flash.h b/GpsTracker/Flash.h index 653d417..c78f251 100644 --- a/GpsTracker/Flash.h +++ b/GpsTracker/Flash.h @@ -2,10 +2,12 @@ #include -namespace flash { +namespace utils { + namespace flash { - template size_t getArraySize(T(&)[N]) { return N; } - template void read(const T *source, T &dest) { - memcpy_P(&dest, source, sizeof(T)); + template size_t getArraySize(T(&)[N]) { return N; } + template void read(const T *source, T &dest) { + memcpy_P(&dest, source, sizeof(T)); + } } } \ No newline at end of file diff --git a/GpsTracker/Rtc.cpp b/GpsTracker/Rtc.cpp index 34bf3b3..308ff4c 100644 --- a/GpsTracker/Rtc.cpp +++ b/GpsTracker/Rtc.cpp @@ -8,6 +8,8 @@ #define LOGGER_NAME "Rtc" +using namespace utils; + namespace rtc { void setup() { @@ -32,7 +34,7 @@ namespace rtc { timestamp_t getTime() { tmElements_t time; getTime(time); - return makeTimestamp(time); + return time::makeTimestamp(time); } void getTime(tmElements_t &time) { @@ -43,12 +45,6 @@ namespace rtc { VERBOSE_FORMAT("getTime", "%d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second); } - void setTime(const timestamp_t timestamp) { - tmElements_t time; - breakTime(timestamp, time); - setTime(time); - } - 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); @@ -62,21 +58,22 @@ namespace rtc { tmElements_t alarmTime; getTime(currentTime); - breakTime(makeTimestamp(currentTime) + seconds, alarmTime); + time::breakTime(time::makeTimestamp(currentTime) + seconds, alarmTime); setAlarm(alarmTime); } void setAlarm(const tmElements_t &time) { hardware::i2c::powerOn(); - RTC.writeAlarm1(DS3231_ALM_DTHMS, time); + RTC.writeAlarm1(DS3231_ALM_HMS, time); RTC.control(DS3231_A1_FLAG, DS3231_OFF); //reset Alarm 1 flag RTC.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON RTC.control(DS3231_INT_ENABLE, DS3231_ON); //INTCN ON - hardware::i2c::powerOff(); - NOTICE_FORMAT("setAlarm", "Next alarm : %d/%d/%d %d:%d:%d", tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second); + NOTICE_FORMAT("setAlarm", "Next alarm : %d:%d:%d", time.Hour, time.Minute, time.Second); + + hardware::i2c::powerOff(); } } \ No newline at end of file diff --git a/GpsTracker/Rtc.h b/GpsTracker/Rtc.h index ab32750..1236f53 100644 --- a/GpsTracker/Rtc.h +++ b/GpsTracker/Rtc.h @@ -9,7 +9,6 @@ namespace rtc { timestamp_t getTime(); void getTime(tmElements_t &time); - void setTime(timestamp_t time); void setTime(const tmElements_t &time); void setAlarm(uint16_t seconds); diff --git a/GpsTracker/Time2.cpp b/GpsTracker/Time2.cpp index 1395634..fce361c 100644 --- a/GpsTracker/Time2.cpp +++ b/GpsTracker/Time2.cpp @@ -10,123 +10,38 @@ #define SECS_PER_YEAR (SECS_PER_WEEK * 52UL) #define SECS_YR_2000 (946684800UL) // the time at the start of y2k -/* Useful Macros for getting elapsed time */ -#define numberOfSeconds(_time_) (_time_ % SECS_PER_MIN) -#define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN) -#define numberOfHours(_time_) (( _time_% SECS_PER_DAY) / SECS_PER_HOUR) -#define dayOfWeek(_time_) ((( _time_ / SECS_PER_DAY + 4) % DAYS_PER_WEEK)+1) // 1 = Sunday -#define elapsedDays(_time_) ( _time_ / SECS_PER_DAY) // this is number of days since Jan 1 2000 -#define elapsedSecsToday(_time_) (_time_ % SECS_PER_DAY) // the number of seconds since last midnight -// The following macros are used in calculating alarms and assume the clock is set to a date later than Jan 1 1971 -// Always set the correct time before settting alarms -#define previousMidnight(_time_) (( _time_ / SECS_PER_DAY) * SECS_PER_DAY) // time at the start of the given day -#define nextMidnight(_time_) ( previousMidnight(_time_) + SECS_PER_DAY ) // time at the end of the given day -#define elapsedSecsThisWeek(_time_) (elapsedSecsToday(_time_) + ((dayOfWeek(_time_)-1) * SECS_PER_DAY) ) // note that week starts on day 1 -#define previousSunday(_time_) (_time_ - elapsedSecsThisWeek(_time_)) // time at the start of the week for the given time -#define nextSunday(_time_) ( previousSunday(_time_)+SECS_PER_WEEK) // time at the end of the week for the given time - - -/* Useful Macros for converting elapsed time to a timestamp_t */ -#define minutesTotimestamp_t ((M)) ( (M) * SECS_PER_MIN) -#define hoursTotimestamp_t ((H)) ( (H) * SECS_PER_HOUR) -#define daysTotimestamp_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011 -#define weeksTotimestamp_t ((W)) ( (W) * SECS_PER_WEEK) - -// leap year calulator expects year argument as years offset from 2000 -#define LEAP_YEAR(Y) ( ((2000+Y)>0) && !((2000+Y)%4) && ( ((2000+Y)%100) || !((2000+Y)%400) ) ) - -static const uint8_t monthDays[] = { 31,28,31,30,31,30,31,31,30,31,30,31 }; // API starts months from 1, this array starts from 0 +/*==============================================================================*/ +/* Utility functions */ -__attribute__((__optimize__("O2"))) -void breakTime(const timestamp_t timeInput, tmElements_t &tm) { - // break the given timestamp_t into time components - // this is a more compact version of the C library localtime function - // note that year is offset from 2000 !!! +namespace utils { + namespace time { - uint8_t year; - uint8_t month, monthLength; - uint32_t time; - unsigned long days; + __attribute__((__optimize__("O2"))) + timestamp_t makeTimestamp(const tmElements_t &time) { + timestamp_t timestamp; - time = (uint32_t)timeInput; - tm.Second = time % 60; - time /= 60; // now it is minutes - tm.Minute = time % 60; - time /= 60; // now it is hours - tm.Hour = time % 24; - time /= 24; // now it is days - //tm.Wday = ((time + 4) % 7) + 1; // Sunday is day 1 + timestamp += (time.Day - 1) * SECS_PER_DAY; + timestamp += time.Hour * SECS_PER_HOUR; + timestamp += time.Minute * SECS_PER_MIN; + timestamp += time.Second; - year = 0; - days = 0; - while ((unsigned)(days += (LEAP_YEAR(year) ? 366 : 365)) <= time) { - year++; + return timestamp; } - tm.Year = year; // year is offset from 2000 - - days -= LEAP_YEAR(year) ? 366 : 365; - time -= days; // now it is days in this year, starting at 0 - days = 0; - month = 0; - monthLength = 0; - for (month = 0; month<12; month++) { - if (month == 1) { // february - if (LEAP_YEAR(year)) { - monthLength = 29; - } - else { - monthLength = 28; - } - } - else { - monthLength = monthDays[month]; - } - - if (time >= monthLength) { - time -= monthLength; - } - else { - break; - } + __attribute__((__optimize__("O2"))) + void breakTime(timestamp_t timestamp, tmElements_t &time) { + time.Year = 0; + time.Month = 0; + + time.Day = 0; + time.Second = timestamp % 60; + timestamp /= 60; // now it is minutes + time.Minute = timestamp % 60; + timestamp /= 60; // now it is hours + time.Hour = timestamp % 24; + timestamp /= 24; // now it is days + time.Day = timestamp; //this is purely for indication / computation only as it might get over the number of days in a month } - tm.Month = month + 1; // jan is month 1 - tm.Day = time + 1; // day of month -} - -__attribute__((__optimize__("O2"))) -timestamp_t makeTimestamp(const tmElements_t &tm) { - // assemble time elements into timestamp_t - // note year argument is offset from 2000 (see macros in time.h to convert to other formats) - // previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9 - int i; - uint32_t seconds; - - // seconds from 2000 till 1 jan 00:00:00 of the given year - seconds = tm.Year*(SECS_PER_DAY * 365); - for (i = 0; i < tm.Year; i++) { - if (LEAP_YEAR(i)) { - seconds += SECS_PER_DAY; // add extra days for leap years - } } - - // add days for this year, months start from 1 - for (i = 1; i < tm.Month; i++) { - if ((i == 2) && LEAP_YEAR(tm.Year)) { - seconds += SECS_PER_DAY * 29; - } - else { - seconds += SECS_PER_DAY * monthDays[i - 1]; //monthDay array starts from 0 - } - } - seconds += (tm.Day - 1) * SECS_PER_DAY; - seconds += tm.Hour * SECS_PER_HOUR; - seconds += tm.Minute * SECS_PER_MIN; - seconds += tm.Second; - return (timestamp_t)seconds; -} -/*=====================================================*/ -/* Low level system time functions */ - -//TODO : + and - operator between tmElements_t and timestamp_t \ No newline at end of file +} \ No newline at end of file diff --git a/GpsTracker/Time2.h b/GpsTracker/Time2.h index f491ad0..11a091b 100644 --- a/GpsTracker/Time2.h +++ b/GpsTracker/Time2.h @@ -3,22 +3,10 @@ #include #include +namespace utils { + namespace time { - -/*============================================================================*/ - -//typedef unsigned long timestamp_t; - -//typedef struct { -// uint8_t Second; -// uint8_t Minute; -// uint8_t Hour; -// //uint8_t Wday; // day of week, sunday is day 1 -// uint8_t Day; -// uint8_t Month; -// uint8_t Year; // offset from 1970; -//} tmElements_t; - -/* low level functions to convert to and from system time */ -void breakTime(const timestamp_t time, tmElements_t &tm); // break timestamp_t into elements -timestamp_t makeTimestamp(const tmElements_t &tm); // convert time elements into timestamp_t + void breakTime(const timestamp_t time, tmElements_t &tm); + timestamp_t makeTimestamp(const tmElements_t &tm); + } +} From 2f5fa03d61f6bc29ebbbda7cdc32588cc8511ef9 Mon Sep 17 00:00:00 2001 From: Bertrand Lemasle Date: Tue, 13 Mar 2018 17:52:55 +1300 Subject: [PATCH 6/6] Time3.h has been removed from uDS3231 library --- GpsTracker/Time2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GpsTracker/Time2.h b/GpsTracker/Time2.h index 11a091b..fee192d 100644 --- a/GpsTracker/Time2.h +++ b/GpsTracker/Time2.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace utils { namespace time {