@@ -42,7 +42,7 @@ class Ticker
42
42
void attach (float seconds, callback_function_t callback)
43
43
{
44
44
_callback_function = std::move (callback);
45
- _attach_ms (seconds * 1000 , true , _static_callback, this );
45
+ _attach_s (seconds, true , _static_callback, this );
46
46
}
47
47
48
48
void attach_ms (uint32_t milliseconds, callback_function_t callback)
@@ -58,7 +58,7 @@ class Ticker
58
58
// C-cast serves two purposes:
59
59
// static_cast for smaller integer types,
60
60
// reinterpret_cast + const_cast for pointer types
61
- _attach_ms (seconds * 1000 , true , reinterpret_cast <callback_with_arg_t >(callback), (void *)arg);
61
+ _attach_s (seconds, true , reinterpret_cast <callback_with_arg_t >(callback), (void *)arg);
62
62
}
63
63
64
64
template <typename TArg>
@@ -71,7 +71,7 @@ class Ticker
71
71
void once (float seconds, callback_function_t callback)
72
72
{
73
73
_callback_function = std::move (callback);
74
- _attach_ms (seconds * 1000 , false , _static_callback, this );
74
+ _attach_s (seconds, false , _static_callback, this );
75
75
}
76
76
77
77
void once_ms (uint32_t milliseconds, callback_function_t callback)
@@ -84,7 +84,7 @@ class Ticker
84
84
void once (float seconds, void (*callback)(TArg), TArg arg)
85
85
{
86
86
static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
87
- _attach_ms (seconds * 1000 , false , reinterpret_cast <callback_with_arg_t >(callback), (void *)arg);
87
+ _attach_s (seconds, false , reinterpret_cast <callback_with_arg_t >(callback), (void *)arg);
88
88
}
89
89
90
90
template <typename TArg>
@@ -103,8 +103,11 @@ class Ticker
103
103
104
104
callback_function_t _callback_function = nullptr ;
105
105
106
- protected:
107
106
esp_timer_handle_t _timer;
107
+
108
+ private:
109
+ void _attach_us (uint32_t micros, bool repeat, callback_with_arg_t callback, void * arg);
110
+ void _attach_s (float seconds, bool repeat, callback_with_arg_t callback, void * arg);
108
111
};
109
112
110
113
0 commit comments