Skip to content

Commit 2f8526f

Browse files
committed
Merge branch 'ticker_api' into add-schedule
2 parents 21129f8 + 4b57b0b commit 2f8526f

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ set(LIBRARY_SRCS
6060
libraries/SimpleBLE/src/SimpleBLE.cpp
6161
libraries/SPIFFS/src/SPIFFS.cpp
6262
libraries/SPI/src/SPI.cpp
63+
libraries/Ticker/src/Ticker.cpp
6364
libraries/Update/src/Updater.cpp
6465
libraries/WebServer/src/WebServer.cpp
6566
libraries/WebServer/src/Parsing.cpp
@@ -196,6 +197,7 @@ set(COMPONENT_ADD_INCLUDEDIRS
196197
libraries/SimpleBLE/src
197198
libraries/SPIFFS/src
198199
libraries/SPI/src
200+
libraries/Ticker/src
199201
libraries/Update/src
200202
libraries/WebServer/src
201203
libraries/WiFiClientSecure/src

cores/esp32/Ticker.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ class Ticker
6969
// C-cast serves two purposes:
7070
// static_cast for smaller integer types,
7171
// reinterpret_cast + const_cast for pointer types
72-
_attach_ms(seconds * 1000, true, callback, arg);
72+
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
7373
}
7474

7575
template<typename TArg>
7676
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
7777
{
7878
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
79-
_attach_ms(milliseconds, true, callback, arg);
79+
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
8080
}
8181

8282
void once_scheduled(float seconds, callback_function_t callback)
@@ -105,14 +105,14 @@ class Ticker
105105
void once(float seconds, void (*callback)(TArg), TArg arg)
106106
{
107107
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
108-
_attach_ms(seconds * 1000, false, callback, arg);
108+
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
109109
}
110110

111111
template<typename TArg>
112112
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
113113
{
114114
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
115-
_attach_ms(milliseconds, false, callback, arg);
115+
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
116116
}
117117

118118
void detach();

libraries/Ticker/src/Ticker.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ class Ticker
6969
// C-cast serves two purposes:
7070
// static_cast for smaller integer types,
7171
// reinterpret_cast + const_cast for pointer types
72-
_attach_ms(seconds * 1000, true, callback, arg);
72+
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
7373
}
7474

7575
template<typename TArg>
7676
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
7777
{
7878
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
79-
_attach_ms(milliseconds, true, callback, arg);
79+
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
8080
}
8181

8282
void once_scheduled(float seconds, callback_function_t callback)
@@ -105,14 +105,14 @@ class Ticker
105105
void once(float seconds, void (*callback)(TArg), TArg arg)
106106
{
107107
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
108-
_attach_ms(seconds * 1000, false, callback, arg);
108+
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
109109
}
110110

111111
template<typename TArg>
112112
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
113113
{
114114
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
115-
_attach_ms(milliseconds, false, callback, arg);
115+
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
116116
}
117117

118118
void detach();

0 commit comments

Comments
 (0)