From c6f1956b9ce7eb129a5dd7ee707654b3bed97bba Mon Sep 17 00:00:00 2001 From: SRGDamia1 Date: Tue, 8 May 2018 16:51:56 -0400 Subject: [PATCH] Changed logging interval from uint8_t to uint16_t Hopefully fixes #142 --- src/LoggerBase.cpp | 12 +++++++----- src/LoggerBase.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 4c669f264..ba99e082b 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -49,7 +49,7 @@ void Logger::init(int8_t SDCardPin, int8_t mcuWakePin, _SDCardPin = SDCardPin; _mcuWakePin = mcuWakePin; _loggingIntervalMinutes = loggingIntervalMinutes; - _interruptRate = round(_loggingIntervalMinutes*60); // convert to even seconds + _loggingIntervalSeconds = round(_loggingIntervalMinutes*60); // convert to even seconds _loggerID = loggerID; _autoFileName = false; _isFileNameSet = false; @@ -247,10 +247,11 @@ bool Logger::checkInterval(void) bool retval; uint32_t checkTime = getNowEpoch(); MS_DBG(F("Current Unix Timestamp: "), checkTime, F("\n")); - MS_DBG(F("Mod of Logging Interval: "), checkTime % _interruptRate, F("\n")); + MS_DBG(F("Logging interval in seconds: "), _loggingIntervalSeconds, F("\n")); + MS_DBG(F("Mod of Logging Interval: "), checkTime % _loggingIntervalSeconds, F("\n")); MS_DBG(F("Number of Readings so far: "), _numTimepointsLogged, F("\n")); MS_DBG(F("Mod of 120: "), checkTime % 120, F("\n")); - if ((checkTime % _interruptRate == 0 ) or + if ((checkTime % _loggingIntervalSeconds == 0 ) or (_numTimepointsLogged < 10 and checkTime % 120 == 0)) { // Update the time variables with the current time @@ -283,11 +284,12 @@ bool Logger::checkMarkedInterval(void) { bool retval; MS_DBG(F("Marked Time: "), markedEpochTime, F("\n")); - MS_DBG(F("Mod of Logging Interval: "), markedEpochTime % _interruptRate, F("\n")); + MS_DBG(F("Logging interval in seconds: "), _loggingIntervalSeconds, F("\n")); + MS_DBG(F("Mod of Logging Interval: "), markedEpochTime % _loggingIntervalSeconds, F("\n")); MS_DBG(F("Number of Readings so far: "), _numTimepointsLogged, F("\n")); MS_DBG(F("Mod of 120: "), markedEpochTime % 120, F("\n")); if (markedEpochTime != 0 && - ((markedEpochTime % _interruptRate == 0 ) or + ((markedEpochTime % _loggingIntervalSeconds == 0 ) or (_numTimepointsLogged < 10 and markedEpochTime % 120 == 0))) { // Update the number of readings taken diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 44f247d3a..0ff054f6a 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -221,7 +221,7 @@ class Logger : public VariableArray int8_t _SDCardPin; int8_t _mcuWakePin; float _loggingIntervalMinutes; - uint8_t _interruptRate; + uint16_t _loggingIntervalSeconds; const char *_loggerID; bool _autoFileName; bool _isFileNameSet;