-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESP32 defines in examples and documentation
- Loading branch information
Showing
5 changed files
with
106 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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 contains 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 contains 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,48 @@ | ||
/** | ||
* FunctionalButton.ino - Example for the OneButtonLibrary library. | ||
* This is a sample sketch to show how to use OneClick library functionally on ESP32,ESP8266... | ||
* | ||
*/ | ||
#include <Arduino.h> | ||
#include <OneButton.h> | ||
|
||
class Button{ | ||
private: | ||
OneButton button; | ||
int value; | ||
public: | ||
explicit Button(uint8_t pin):button(pin) { | ||
button.attachClick([](void *scope) { ((Button *) scope)->Clicked();}, this); | ||
button.attachDoubleClick([](void *scope) { ((Button *) scope)->DoubleClicked();}, this); | ||
button.attachLongPressStart([](void *scope) { ((Button *) scope)->LongPressed();}, this); | ||
} | ||
|
||
void Clicked(){ | ||
Serial.println("Click then value++"); | ||
value++; | ||
} | ||
|
||
void DoubleClicked(){ | ||
|
||
Serial.println("DoubleClick"); | ||
} | ||
|
||
void LongPressed(){ | ||
Serial.println("LongPress and the value is"); | ||
Serial.println(value); | ||
} | ||
|
||
void handle(){ | ||
button.tick(); | ||
} | ||
}; | ||
|
||
Button button(0); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
} | ||
|
||
void loop() { | ||
button.handle(); | ||
} |
This file contains 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 contains 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