5
5
#include < Service/Service.hpp>
6
6
#include < Timers/TimerMessage.hpp>
7
7
#include < log/log.hpp>
8
- #include < projdefs.h >
8
+ #include < ticks.hpp >
9
9
#include < memory>
10
10
11
11
#if DEBUG_TIMER == 1
16
16
17
17
namespace sys ::timer
18
18
{
19
- SystemTimer::SystemTimer (Service *parent,
20
- const std::string &name,
21
- std::chrono::milliseconds interval,
22
- timer::Type type)
23
- : cpp_freertos::Timer(name.c_str(), pdMS_TO_TICKS(interval.count()), type == timer::Type::Periodic), name{name},
24
- interval{interval}, type{type}, parent{parent}
19
+ SystemTimer::SystemTimer (Service *parent, const std::string &name, std::chrono::milliseconds interval, Type type)
20
+ : cpp_freertos::Timer(name.c_str(), cpp_freertos::Ticks::MsToTicks(interval.count()), type == Type::Periodic),
21
+ name{name}, interval{interval}, type{type}, parent{parent}
25
22
{
26
23
attachToService ();
27
24
log_debug (" %s %s timer created" , name.c_str (), type == Type::Periodic ? " periodic" : " single-shot" );
@@ -84,9 +81,9 @@ namespace sys::timer
84
81
85
82
void SystemTimer::setInterval (std::chrono::milliseconds value)
86
83
{
87
- log_debug (" Timer %s set interval to %ld ms!" , name.c_str (), static_cast < long int >( value.count () ));
84
+ log_debug (" Timer %s set interval to %" PRIi64 " ms!" , name.c_str (), value.count ());
88
85
interval = value;
89
- cpp_freertos::Timer::SetPeriod (pdMS_TO_TICKS (interval.count ()), 0 );
86
+ cpp_freertos::Timer::SetPeriod (cpp_freertos::Ticks::MsToTicks (interval.count ()), 0 );
90
87
}
91
88
92
89
void SystemTimer::onTimeout ()
@@ -101,7 +98,7 @@ namespace sys::timer
101
98
return ;
102
99
}
103
100
log_debug (" Timer %s runs callback" , name.c_str ());
104
- if (type == timer:: Type::SingleShot) {
101
+ if (type == Type::SingleShot) {
105
102
stop ();
106
103
}
107
104
callback (*this );
@@ -112,7 +109,7 @@ namespace sys::timer
112
109
return active;
113
110
}
114
111
115
- void SystemTimer::connect (timer:: TimerCallback &&newCallback) noexcept
112
+ void SystemTimer::connect (TimerCallback &&newCallback) noexcept
116
113
{
117
114
callback = std::move (newCallback);
118
115
}
0 commit comments