Skip to content

Commit d336ca2

Browse files
author
dave
committed
#24 scheduling using lambda functions is now supported on 32 bit boards. Specifically all ESP, SAMD and mbed hardware.
1 parent 51100b1 commit d336ca2

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

examples/eventHandling/eventHandling.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public:
7272
* @param pin the interrupt pin
7373
*/
7474
InterruptEvent(pintype_t pin) {
75-
pinMode(INT_PIN, INPUT_PULLUP);
75+
pinMode(pin, INPUT_PULLUP);
7676
::attachInterrupt(digitalPinToInterrupt(pin), interruptHandler, RISING);
7777
}
7878

@@ -92,7 +92,9 @@ public:
9292
void exec() override {
9393
Serial.println("interrupt event was triggered");
9494
}
95-
} interruptEvent(INT_PIN);
95+
};
96+
97+
InterruptEvent interruptEvent(INT_PIN);
9698

9799
/**
98100
* THis is a raw ISR, do very little here. In this case we just mark the event as triggered

src/TaskPlatformDeps.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,10 @@ namespace tm_internal {
328328
}
329329
}
330330

331+
//
332+
// Here we define an attribute needed for interrupt support on ESP8266 and ESP32 boards, any interrupt code that is
333+
// going to run on these boards should be marked with this attribute.
334+
//
331335
#undef ISR_ATTR
332336
#if defined(ESP8266)
333337
# define ISR_ATTR ICACHE_RAM_ATTR
@@ -337,4 +341,14 @@ namespace tm_internal {
337341
# define ISR_ATTR
338342
#endif
339343

344+
//
345+
// Here we have one last go at determining if we should enable capture lambdas by checking if the functional include
346+
// is available, we only do so if we are on GCC > 5
347+
//
348+
# if !defined(TM_ALLOW_CAPTURED_LAMBDA) && __GNUC__ >= 5
349+
#if __has_include(<functional>)
350+
# define TM_ALLOW_CAPTURED_LAMBDA
351+
#endif
352+
#endif // GCC>=5 and !TM_ALLOW_CAPTURED_LAMBDA
353+
340354
#endif //TASKMANGERIO_PLATFORMDETERMINATION_H

0 commit comments

Comments
 (0)