Преглед изворни кода

Fixed setAlarm(seconds)

tags/v1.2.0
Bertrand Lemasle пре 7 година
родитељ
комит
b2ec826cfb
4 измењених фајлова са 18 додато и 9 уклоњено
  1. +15
    -1
      GpsTracker/Rtc.cpp
  2. +1
    -6
      GpsTracker/Rtc.h
  3. +1
    -1
      GpsTracker/Time2.cpp
  4. +1
    -1
      GpsTracker/Time2.h

+ 15
- 1
GpsTracker/Rtc.cpp Прегледај датотеку

@@ -47,13 +47,27 @@ namespace rtc {
RTC.writeTime();
}

void setAlarm(uint16_t seconds) {
tmElements_t currentTime;
tmElements_t alarmTime;

getTime(currentTime);

breakTime(makeTimestamp(currentTime) + seconds, alarmTime);

setAlarm(alarmTime);
}

void setAlarm(tmElements_t &time) {
tmElements_t currentTime;
getTime(currentTime);
Log.verbose(F("Current time : %d/%d/%d %d:%d:%d\n"), tmYearToCalendar(currentTime.Year), currentTime.Month, currentTime.Day, currentTime.Hour, currentTime.Minute, currentTime.Second);
Log.notice(F("Set alarm to : %d/%d/%d %d:%d:%d\n"), tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second);
details::writeTimeToRegisters(time);
RTC.writeAlarm1(DS3231_ALM_DTHMS);
getTime(currentTime);
Log.notice(F("Set alarm to : %d/%d/%d %d:%d:%d\n"), tmYearToCalendar(time.Year), time.Month, time.Day, time.Hour, time.Minute, time.Second);

RTC.control(DS3231_A1_FLAG, DS3231_OFF); //reset Alarm 1 flag
RTC.control(DS3231_A1_INT_ENABLE, DS3231_ON); //Alarm 1 ON


+ 1
- 6
GpsTracker/Rtc.h Прегледај датотеку

@@ -17,11 +17,6 @@ namespace rtc {
void getTime(tmElements_t &time);
void setTime(tmElements_t &time);

inline void setAlarm(uint16_t seconds) {
tmElements_t time;
getTime(time);
setAlarm(makeTime(time) + seconds);
}

void setAlarm(uint16_t seconds);
void setAlarm(tmElements_t &time);
}

+ 1
- 1
GpsTracker/Time2.cpp Прегледај датотеку

@@ -95,7 +95,7 @@ void breakTime(const timestamp_t timeInput, tmElements_t &tm) {
}

__attribute__((__optimize__("O2")))
timestamp_t makeTime(const tmElements_t &tm) {
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)
// previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9


+ 1
- 1
GpsTracker/Time2.h Прегледај датотеку

@@ -24,4 +24,4 @@ typedef struct {

/* 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 makeTime(const tmElements_t &tm); // convert time elements into timestamp_t
timestamp_t makeTimestamp(const tmElements_t &tm); // convert time elements into timestamp_t

Loading…
Откажи
Сачувај