aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ClockTool.cc14
-rw-r--r--src/FbTk/Timer.cc4
-rw-r--r--src/FbTk/Timer.hh2
3 files changed, 14 insertions, 6 deletions
diff --git a/src/ClockTool.cc b/src/ClockTool.cc
index 514d45d..f11a793 100644
--- a/src/ClockTool.cc
+++ b/src/ClockTool.cc
@@ -52,10 +52,19 @@ const char SWITCHES_12_24H[] = "lIrkHT";
52const char SWITCHES_24_12H[] = "kHTlIr"; 52const char SWITCHES_24_12H[] = "kHTlIr";
53const char SWITCH_AM_PM[] = "pP"; 53const char SWITCH_AM_PM[] = "pP";
54 54
55uint64_t calcNextTimeout() { 55int showSeconds(const std::string& fmt) {
56
57 return FbTk::StringUtil::findCharFromAlphabetAfterTrigger(
58 fmt, '%', SWITCHES_SECONDS, sizeof(SWITCHES_SECONDS), 0) != std::string::npos;
59}
60
61uint64_t calcNextTimeout(const std::string& fmt) {
56 62
57 uint64_t now = FbTk::FbTime::system(); 63 uint64_t now = FbTk::FbTime::system();
58 uint64_t unit = FbTk::FbTime::IN_SECONDS; 64 uint64_t unit = FbTk::FbTime::IN_SECONDS;
65 if (!showSeconds(fmt)) { // microseconds till next full minute
66 unit *= 60L;
67 }
59 return FbTk::FbTime::remainingNext(now, unit); 68 return FbTk::FbTime::remainingNext(now, unit);
60} 69}
61 70
@@ -289,8 +298,7 @@ void ClockTool::updateTime() {
289 } 298 }
290 299
291restart_timer: 300restart_timer:
292 m_timer.setTimeout(calcNextTimeout()); 301 m_timer.setTimeout(calcNextTimeout(*m_timeformat), true);
293 m_timer.start();
294} 302}
295 303
296// Just change things that affect the size 304// Just change things that affect the size
diff --git a/src/FbTk/Timer.cc b/src/FbTk/Timer.cc
index 1806557..61875f7 100644
--- a/src/FbTk/Timer.cc
+++ b/src/FbTk/Timer.cc
@@ -91,7 +91,7 @@ Timer::~Timer() {
91} 91}
92 92
93 93
94void Timer::setTimeout(uint64_t timeout) { 94void Timer::setTimeout(uint64_t timeout, bool force_start) {
95 95
96 bool was_timing = isTiming(); 96 bool was_timing = isTiming();
97 if (was_timing) { 97 if (was_timing) {
@@ -99,7 +99,7 @@ void Timer::setTimeout(uint64_t timeout) {
99 } 99 }
100 m_timeout = timeout; 100 m_timeout = timeout;
101 101
102 if (was_timing) { 102 if (force_start || was_timing) {
103 start(); 103 start();
104 } 104 }
105} 105}
diff --git a/src/FbTk/Timer.hh b/src/FbTk/Timer.hh
index 4bdd13a..8904a85 100644
--- a/src/FbTk/Timer.hh
+++ b/src/FbTk/Timer.hh
@@ -43,7 +43,7 @@ public:
43 ~Timer(); 43 ~Timer();
44 44
45 void fireOnce(bool once) { m_once = once; } 45 void fireOnce(bool once) { m_once = once; }
46 void setTimeout(uint64_t timeout); 46 void setTimeout(uint64_t timeout, bool force_start = false);
47 void setCommand(const RefCount<Slot<void> > &cmd); 47 void setCommand(const RefCount<Slot<void> > &cmd);
48 48
49 template<typename Functor> 49 template<typename Functor>