diff --git a/src/prog/domod/src/sequences/clock.cpp b/src/prog/domod/src/sequences/clock.cpp index fe1a6724..c63c9a9b 100644 --- a/src/prog/domod/src/sequences/clock.cpp +++ b/src/prog/domod/src/sequences/clock.cpp @@ -47,17 +47,6 @@ Clock::~Clock(void) { } -/*! ---------------------------------------------------------------------------- - * @fn set - * - * @brief Set a time (hour/minute) to the Clock. - */ -int Clock::set(void) -{ - m_now = time(NULL); - - return 0; -} /*! ---------------------------------------------------------------------------- * @fn is_equal_to_timer @@ -69,18 +58,19 @@ bool Clock::is_equal_to_timer(const Timer &a_timer) struct tm the_compared_time; double the_diff; - the_compared_time = *localtime(&m_now); + time_t the_time = time(NULL); - printf ("=>Hour: %.2d h %.2d\n", the_compared_time.tm_hour, the_compared_time.tm_min); + the_compared_time = *localtime(&the_time); + + printf ("=>Timer: (%.2d h %.2d) Now: (%.2d h %.2d)\n", a_timer.get_hour(),a_timer.get_minute(), + the_compared_time.tm_hour, the_compared_time.tm_min); the_compared_time.tm_hour = a_timer.get_hour(); the_compared_time.tm_min = a_timer.get_minute(); - the_diff = difftime(m_now, mktime(&the_compared_time)); - - printf ("=>Timer: %.2d h %.2d\n", a_timer.get_hour(),a_timer.get_minute()); - printf ("%.f seconds of diff between current time and Timer time.\n", the_diff); - + the_diff = difftime(the_time, mktime(&the_compared_time)); + // printf ("%.f seconds of diff between current time and Timer time.\n", the_diff); + if (the_diff == 0) return true; @@ -98,14 +88,15 @@ bool Clock::is_expired(uint16_t a_duration) struct tm the_compared_time; double the_diff; - the_compared_time = *localtime(&m_now); + time_t the_time = time(NULL); + the_compared_time = *localtime(&the_time); // the_compared_time.tm_hour = m_hour; // the_compared_time.tm_min = m_minute; the_expired = mktime(&the_compared_time) + (a_duration * 60); - the_diff = difftime(m_now, the_expired); + the_diff = difftime(the_time, the_expired); //printf ("%.f seconds of diff between %lld and %lld.\n", theDiff, mNow, theExpired); diff --git a/src/prog/domod/src/sequences/clock.h b/src/prog/domod/src/sequences/clock.h index 405ef05f..67f15965 100644 --- a/src/prog/domod/src/sequences/clock.h +++ b/src/prog/domod/src/sequences/clock.h @@ -44,13 +44,8 @@ class Clock Clock(void); ~Clock(void); - int set(void); - - bool is_equal_to_timer(const Timer &a_timer); - bool is_expired(uint16_t a_duration); - - private: - time_t m_now; + static bool is_equal_to_timer(const Timer &a_timer); + static bool is_expired(uint16_t a_duration); }; #endif /* _CLOCK_H */