8000 Add void* for C-FP Delegate mode to capture state for scheduled funct… · dok-net/arduino-esp8266@09d8604 · GitHub
[go: up one dir, main page]

Skip to content

Commit 09d8604

Browse files
committed
Add void* for C-FP Delegate mode to capture state for scheduled functions.
1 parent 7ff889e commit 09d8604

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

cores/esp8266/Schedule.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "interrupts.h"
2424
#include "coredecls.h"
2525

26-
typedef Delegate<void()> mSchedFuncT;
26+
typedef Delegate<void(), void*> mSchedFuncT;
2727
struct scheduled_fn_t
2828
{
2929
scheduled_fn_t* mNext = nullptr;
@@ -35,13 +35,13 @@ static scheduled_fn_t* sLast = nullptr;
3535
static scheduled_fn_t* sUnused = nullptr;
3636
static int sCount = 0;
3737

38-
typedef Delegate<bool()> mRecFuncT;
38+
typedef Delegate<bool(), void*> mRecFuncT;
3939
struct recurrent_fn_t
4040
{
4141
recurrent_fn_t* mNext = nullptr;
4242
mRecFuncT mFunc;
4343
esp8266::polledTimeout::periodicFastUs callNow;
44-
Delegate<bool()> alarm = nullptr;
44+
Delegate<bool(), void*> alarm = nullptr;
4545
recurrent_fn_t(esp8266::polledTimeout::periodicFastUs interval) : callNow(interval) { }
4646
};
4747

@@ -79,7 +79,7 @@ static void recycle_fn_unsafe(scheduled_fn_t* fn)
7979
}
8080

8181
IRAM_ATTR // (not only) called from ISR
82-
bool schedule_function(const Delegate<void()>& fn)
82+
bool schedule_function(const Delegate<void(), void*>& fn)
8383
{
8484
if (!fn)
8585
return false;
@@ -103,8 +103,8 @@ bool schedule_function(const Delegate<void()>& fn)
103103
}
104104

105105
IRAM_ATTR // (not only) called from ISR
106-
bool schedule_recurrent_function_us(const Delegate<bool()>& fn,
107-
uint32_t repeat_us, const Delegate<bool()>& alarm)
106+
bool schedule_recurrent_function_us(const Delegate<bool(), void*>& fn,
107+
uint32_t repeat_us, const Delegate<bool(), void*>& alarm)
108108
{
109109
assert(repeat_us < decltype(recurrent_fn_t::callNow)::neverExpires); //~26800000us (26.8s)
110110

cores/esp8266/Schedule.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
// * Run the lambda only once next time.
5656
// * A scheduled function can schedule a function.
5757

58-
bool schedule_function (const Delegate<void()>& fn);
58+
bool schedule_function (const Delegate<void(), void*>& fn);
5959

6060
// Run all scheduled functions.
6161
// Use this function if your are not using `loop`,
@@ -80,8 +80,8 @@ void run_scheduled_functions();
8080
// * If alarm is used, anytime during scheduling when it returns true,
8181
// any remaining delay from repeat_us is disregarded, and fn is executed.
8282

83-
bool schedule_recurrent_function_us(const Delegate<bool()>& fn,
84-
uint32_t repeat_us, const Delegate<bool()>& alarm = nullptr);
83+
bool schedule_recurrent_function_us(const Delegate<bool(), void*>& fn,
84+
uint32_t repeat_us, const Delegate<bool(), void*>& alarm = nullptr);
8585

8686
// Test recurrence and run recurrent scheduled functions.
8787
// (internally called at every `yield()` and `loop()`)

0 commit comments

Comments
 (0)
0