Skip to content

Commit df1460f

Browse files
committed
revert to std::function from Delegate to make easier to accept PR
1 parent 5011f88 commit df1460f

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

cores/esp8266/core_esp8266_main.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//#define CONT_STACKSIZE 4096
2525
#include <Arduino.h>
2626
#include "Schedule.h"
27-
#include "Delegate.h"
2827
extern "C" {
2928
#include "ets_sys.h"
3029
#include "os_type.h"
@@ -72,6 +71,7 @@ static uint32_t s_cycles_at_yield_start;
7271
static uint16_t ets_intr_lock_stack[ETS_INTR_LOCK_NEST_MAX];
7372
static byte ets_intr_lock_stack_ptr=0;
7473

74+
7575
extern "C" {
7676
extern const uint32_t __attribute__((section(".ver_number"))) core_version = ARDUINO_ESP8266_GIT_VER;
7777
const char* core_release =
@@ -153,7 +153,7 @@ extern "C" void __esp_delay(unsigned long ms) {
153153

154154
extern "C" void esp_delay(unsigned long ms) __attribute__((weak, alias("__esp_delay")));
155155

156-
using IsBlockedCB = Delegate<bool(), void*>;
156+
using IsBlockedCB = std::function<bool()>;
157157

158158
void esp_delay(const uint32_t timeout_ms, const IsBlockedCB& blocked, const uint32_t intvl_ms) {
159159
const auto start = millis();
@@ -174,7 +174,7 @@ extern "C" void __yield() {
174174
}
175175
}
176176

177-
extern "C" void yield() __attribute__ ((weak, alias("__yield")));
177+
extern "C" void yield(void) __attribute__ ((weak, alias("__yield")));
178178

179179
extern "C" void optimistic_yield(uint32_t interval_us) {
180180
const uint32_t intvl_cycles = interval_us *
@@ -205,6 +205,7 @@ extern "C" void IRAM_ATTR ets_intr_unlock() {
205205
xt_rsil(0);
206206
}
207207

208+
208209
// Save / Restore the PS state across the rom ets_post call as the rom code
209210
// does not implement this correctly.
210211
extern "C" bool ets_post_rom(uint8 prio, ETSSignal sig, ETSParam par);

cores/esp8266/coredecls.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff);
2828
#ifdef __cplusplus
2929
}
3030

31-
#include <Delegate.h>
31+
#include <functional>
3232

33-
using BoolCB = Delegate<void(bool), void*>;
34-
using TrivialCB = Delegate<void(), void*>;
33+
using BoolCB = std::function<void(bool)>;
34+
using TrivialCB = std::function<void()>;
3535

3636
void settimeofday_cb (BoolCB&& cb);
3737
void settimeofday_cb (const BoolCB& cb);
3838
void settimeofday_cb (const TrivialCB& cb);
3939

40-
using IsBlockedCB = Delegate<bool(), void*>;
40+
using IsBlockedCB = std::function<bool()>;
4141

4242
inline void esp_suspend() {
4343
esp_yield();

libraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m) {
434434
//tasks to wait correctly.
435435
constexpr unsigned int timeoutValue = 1000; //1 second
436436
if(can_yield()) {
437-
esp_delay(timeoutValue, { [](void* m) { return wifi_get_opmode() != *static_cast<WiFiMode_t*>(m); }, (void*)&m }, 5);
437+
esp_delay(timeoutValue, [m]() { return wifi_get_opmode() != m; }, 5);
438438

439439
//if at this point mode still hasn't been reached, give up
440440
if(wifi_get_opmode() != (uint8) m) {

libraries/ESP8266WiFi/src/include/ClientContext.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class ClientContext
145145
_op_start_time = millis();
146146
// will resume on timeout or when _connected or _notify_error fires
147147
// give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
148-
esp_delay(_timeout_ms, { [](void* self) { return static_cast<ClientContext*>(self)->_connect_pending; }, this }, 1);
148+
esp_delay(_timeout_ms, [this]() { return this->_connect_pending; }, 1);
149149
_connect_pending = false;
150150
if (!_pcb) {
151151
DEBUGV(":cabrt\r\n");
@@ -486,7 +486,7 @@ class ClientContext
486486
_send_waiting = true;
487487
// will resume on timeout or when _write_some_from_cb or _notify_error fires
488488
// give scheduled functions a chance to run (e.g. Ethernet uses recurrent)
489-
esp_delay(_timeout_ms, { [](void* self) { return static_cast<ClientContext*>(self)->_send_waiting; }, this }, 1);
489+
esp_delay(_timeout_ms, [this]() { return this->_send_waiting; }, 1);
490490
_send_waiting = false;
491491
} while(true);
492492

libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void setup() {
242242
// install callback - called when settimeofday is called (by SNTP or user)
243243
// once enabled (by DHCP), SNTP is updated every hour by default
244244
// ** optional boolean in callback function is true when triggered by SNTP **
245-
settimeofday_cb(static_cast<BoolCB>(time_is_set));
245+
settimeofday_cb(time_is_set);
246246

247247
// setup RTC time
248248
// it will be used until NTP server will send us real current time

tests/host/common/Arduino.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <sys/time.h>
1717
#include "Arduino.h"
18-
#include <Delegate.h>
18+
#include <functional>
1919

2020
#include <unistd.h>
2121

@@ -63,7 +63,7 @@ extern "C" void esp_delay (unsigned long ms)
6363
usleep(ms * 1000);
6464
}
6565

66-
using IsBlockedCB = Delegate<bool(), void*>;
66+
using IsBlockedCB = std::function<bool()>;
6767

6868
inline void esp_suspend() {
6969
esp_yield();

0 commit comments

Comments
 (0)