@@ -35,75 +35,94 @@ class Ticker
3535 typedef void (*callback_with_arg_t )(void *);
3636 typedef std::function<void (void )> callback_function_t ;
3737
38+ // callback will be called at following loop() after ticker fires
3839 void attach_scheduled (float seconds, callback_function_t callback)
3940 {
4041 _callback_function = [callback]() { schedule_function (callback); };
4142 _attach_ms (1000UL * seconds, true );
4243 }
4344
45+ // callback will be called in SYS ctx when ticker fires
4446 void attach (float seconds, callback_function_t callback)
4547 {
4648 _callback_function = std::move (callback);
4749 _attach_ms (1000UL * seconds, true );
4850 }
4951
52+ // callback will be called at following loop() after ticker fires
5053 void attach_ms_scheduled (uint32_t milliseconds, callback_function_t callback)
5154 {
5255 _callback_function = [callback]() { schedule_function (callback); };
5356 _attach_ms (milliseconds, true );
5457 }
5558
59+ // callback will be called at following yield() after ticker fires
60+ void attach_ms_scheduled_accurate (uint32_t milliseconds, callback_function_t callback)
61+ {
62+ _callback_function = [callback]() { schedule_recurrent_function_us ([callback]() { callback (); return false ; }, 0 ); };
63+ _attach_ms (milliseconds, true );
64+ }
65+
66+ // callback will be called in SYS ctx when ticker fires
5667 void attach_ms (uint32_t milliseconds, callback_function_t callback)
5768 {
5869 _callback_function = std::move (callback);
5970 _attach_ms (milliseconds, true );
6071 }
6172
73+ // callback will be called in SYS ctx when ticker fires
6274 template <typename TArg>
6375 void attach (float seconds, void (*callback)(TArg), TArg arg)
6476 {
6577 static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
6678 _attach_ms (1000UL * seconds, true , reinterpret_cast <callback_with_arg_t >(callback), reinterpret_cast <void *>(arg));
6779 }
6880
81+ // callback will be called in SYS ctx when ticker fires
6982 template <typename TArg>
7083 void attach_ms (uint32_t milliseconds, void (*callback)(TArg), TArg arg)
7184 {
7285 static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
7386 _attach_ms (milliseconds, true , reinterpret_cast <callback_with_arg_t >(callback), reinterpret_cast <void *>(arg));
7487 }
7588
89+ // callback will be called at following loop() after ticker fires
7690 void once_scheduled (float seconds, callback_function_t callback)
7791 {
7892 _callback_function = [callback]() { schedule_function (callback); };
7993 _attach_ms (1000UL * seconds, false );
8094 }
8195
96+ // callback will be called in SYS ctx when ticker fires
8297 void once (float seconds, callback_function_t callback)
8398 {
8499 _callback_function = std::move (callback);
85100 _attach_ms (1000UL * seconds, false );
86101 }
87102
103+ // callback will be called at following loop() after ticker fires
88104 void once_ms_scheduled (uint32_t milliseconds, callback_function_t callback)
89105 {
90106 _callback_function = [callback]() { schedule_function (callback); };
91107 _attach_ms (milliseconds, false );
92108 }
93109
110+ // callback will be called in SYS ctx when ticker fires
94111 void once_ms (uint32_t milliseconds, callback_function_t callback)
95112 {
96113 _callback_function = std::move (callback);
97114 _attach_ms (milliseconds, false );
98115 }
99116
117+ // callback will be called in SYS ctx when ticker fires
100118 template <typename TArg>
101119 void once (float seconds, void (*callback)(TArg), TArg arg)
102120 {
103121 static_assert (sizeof (TArg) <= sizeof (void *), " attach() callback argument size must be <= sizeof(void*)" );
104122 _attach_ms (1000UL * seconds, false , reinterpret_cast <callback_with_arg_t >(callback), reinterpret_cast <void *>(arg));
105123 }
106124
125+ // callback will be called in SYS ctx when ticker fires
107126 template <typename TArg>
108127 void once_ms (uint32_t milliseconds, void (*callback)(TArg), TArg arg)
109128 {
0 commit comments