-
Notifications
You must be signed in to change notification settings - Fork 13.3k
FunctionalInterrupt/ScheduledFunctions should be in a library, not in core_esp8266_wiring_digital #6038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
FunctionalInterrupt/ScheduledFunctions should be in a library, not in core_esp8266_wiring_digital #6038
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3720f4d
Remove special support for FunctionalInterrupt from core interrupt ha…
dok-net e4f6e6c
Add supporting function for interrupt arg memory management, linke wi…
dok-net 035551d
Bring back FunctionalInterrupt, and ScheduledFunctions, as example code.
dok-net bd339ec
Ridiculous port number mistake.
dok-net f4acddb
Merge branch 'master' into functional-shouldbe-lib
dok-net 4f621ea
Apply astyle to example INO.
dok-net 6002811
Merge branch 'master' into functional-shouldbe-lib
dok-net 4b045f5
Remove ScheduledFunctions.(h|cpp), per comment https://github.com/esp…
dok-net e7013ba
Merge remote-tracking branch 'origin/master' into functional-shouldbe…
dok-net 9e239ec
Invented void* detachInterruptArg() that returns the argument given i…
dok-net f89b22c
Modified example to showcase how general FunctionalInterrupt uses vio…
dok-net 346d3c3
Direct call or scheduled is either-or.
dok-net a844d43
Always apply astyle to examples.
dok-net eb6c493
Merge branch 'master' into functional-shouldbe-lib
dok-net 17e3692
Merge branch 'master' into functional-shouldbe-lib
dok-net f5092c6
Merge branch 'master' into functional-shouldbe-lib
dok-net e619e4c
Merge branch 'master' into functional-shouldbe-lib
dok-net 69ac313
Merge branch 'master' into functional-shouldbe-lib
dok-net fe56dc6
Merge branch 'master' into functional-shouldbe-lib
dok-net db7b1b1
Merge branch 'master' into functional-shouldbe-lib
dok-net c8c8bfb
astyle Arduino.h and core_esp8266_wiring_digital.cpp - reduced diff t…
dok-net 6a33d99
astyle libraries/esp8266/examples/GPIO/FunctionalInterrupt
dok-net dd066c9
Merge branch 'master' into functional-shouldbe-lib
dok-net 6a58725
Merge branch 'master' into functional-shouldbe-lib
dok-net File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
libraries/esp8266/examples/GPIO/FunctionalInterrupt/FunctionalInterrupt.ino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#include <Arduino.h> | ||
#include "FunctionalInterrupts.h" | ||
|
||
#if defined(ESP32) | ||
#define BUTTON1 16 | ||
#define BUTTON2 17 | ||
#elif defined(ARDUINO_ESP8266_WEMOS_D1MINI) | ||
#define BUTTON1 D4 | ||
#define BUTTON2 D3 | ||
#else | ||
#define BUTTON1 2 | ||
#define BUTTON2 0 | ||
#endif | ||
|
||
class Button { | ||
public: | ||
Button(uint8_t reqPin) : PIN(reqPin) { | ||
pinMode(PIN, INPUT_PULLUP); | ||
attachInterrupt(PIN, std::bind(&Button::isr, this), FALLING); | ||
}; | ||
~Button() { | ||
detachFunctionalInterrupt(PIN); | ||
} | ||
|
||
#if defined(ESP8266) | ||
void ICACHE_RAM_ATTR isr() | ||
#elif defined(ESP32) | ||
void IRAM_ATTR isr() | ||
#endif | ||
{ | ||
numberKeyPresses += 1; | ||
pressed = true; | ||
} | ||
|
||
void checkPressed() { | ||
if (pressed) { | ||
Serial.printf("Button on pin %u has been pressed %u times\n", PIN, numberKeyPresses); | ||
pressed = false; | ||
} | ||
} | ||
|
||
private: | ||
const uint8_t PIN; | ||
volatile uint32_t numberKeyPresses; | ||
volatile bool pressed; | ||
}; | ||
|
||
Button button1(BUTTON1); | ||
Button button2(BUTTON2); | ||
|
||
|
||
void setup() { | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() { | ||
button1.checkPressed(); | ||
button2.checkPressed(); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.