@@ -37,17 +37,20 @@ class Ticker
3737
3838 void attach_scheduled (float seconds, callback_function_t callback)
3939 {
40- attach (seconds, [callback]() { schedule_function (callback); });
40+ _callback_function = [callback]() { schedule_function (callback); };
41+ _attach_ms (1000UL * seconds, true , _static_callback, this );
4142 }
4243
4344 void attach (float seconds, callback_function_t callback)
4445 {
45- attach_ms (1000UL * seconds, callback);
46+ _callback_function = std::move (callback);
47+ _attach_ms (1000UL * seconds, true , _static_callback, this );
4648 }
4749
4850 void attach_ms_scheduled (uint32_t milliseconds, callback_function_t callback)
4951 {
50- attach_ms (milliseconds, [callback]() { schedule_function (callback); });
52+ _callback_function = [callback]() { schedule_function (callback); };
53+ _attach_ms (milliseconds, true , _static_callback, this );
5154 }
5255
5356 void attach_ms (uint32_t milliseconds, callback_function_t callback)
@@ -60,7 +63,7 @@ class Ticker
6063 void attach (float seconds, void (*callback)(TArg), TArg arg)
6164 {
6265 static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
63- attach_ms (1000UL * seconds, callback, arg);
66+ _attach_ms (1000UL * seconds, true , reinterpret_cast < callback_with_arg_t >( callback), reinterpret_cast < void *>( arg) );
6467 }
6568
6669 template <typename TArg>
@@ -72,17 +75,20 @@ class Ticker
7275
7376 void once_scheduled (float seconds, callback_function_t callback)
7477 {
75- once (seconds, [callback]() { schedule_function (callback); });
78+ _callback_function = [callback]() { schedule_function (callback); };
79+ _attach_ms (1000UL * seconds, false , _static_callback, this );
7680 }
7781
7882 void once (float seconds, callback_function_t callback)
7983 {
80- once_ms (1000UL * seconds, callback);
84+ _callback_function = std::move (callback);
85+ _attach_ms (1000UL * seconds, false , _static_callback, this );
8186 }
8287
8388 void once_ms_scheduled (uint32_t milliseconds, callback_function_t callback)
8489 {
85- once_ms (milliseconds, [callback]() { schedule_function (callback); });
90+ _callback_function = [callback]() { schedule_function (callback); };
91+ _attach_ms (milliseconds, false , _static_callback, this );
8692 }
8793
8894 void once_ms (uint32_t milliseconds, callback_function_t callback)
@@ -95,7 +101,7 @@ class Ticker
95101 void once (float seconds, void (*callback)(TArg), TArg arg)
96102 {
97103 static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
98- once_ms (1000UL * seconds, callback, arg);
104+ _attach_ms (1000UL * seconds, false , reinterpret_cast < callback_with_arg_t >( callback), reinterpret_cast < void *>( arg) );
99105 }
100106
101107 template <typename TArg>
0 commit comments