-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update including a doList fix, new macro, pin settings and new examples.
- Loading branch information
1 parent
0520812
commit 5713534
Showing
9 changed files
with
423 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* | ||
* ADJUST TIMER TO PAD EXAMPLE FOR TWEAKLY | ||
* Created By Mirko Pacioni | ||
* | ||
* Functionality to straighten the timing of the pads, | ||
* if you need to customize and optimize the response times of events on the pads, you can use the padSettings object. | ||
* | ||
*/ | ||
#include "Tweakly.h" | ||
|
||
//Create button Pad | ||
Pad button(8, INPUT); | ||
|
||
padSettings myButtonSettings; | ||
|
||
void setup() { | ||
|
||
//Start serial | ||
Serial.begin(115200); | ||
|
||
//Set the debouncing time to 25 milliseconds. | ||
myButtonSettings.debounceTimer = 25; | ||
|
||
//Set the double click event timeout to 400 millisecons. | ||
myButtonSettings.doubleClickTimer = 400; | ||
|
||
//Set the long press time to 2000 milliseconds. | ||
//Tweakly automatically corrects the relationship between the double click timer from the moment | ||
//it recognizes that a long double click is being performed. (long click timer - double click timeout) | ||
myButtonSettings.longPressTimer = 2000; | ||
|
||
//Applies the settings contained in myButtonSettings to the button. | ||
button.adjust(myButtonSettings); | ||
|
||
//Attach click event to button Pad | ||
button.onEvent(CLICK, [] { | ||
Serial.println("click!"); | ||
}); | ||
|
||
//Attach double click event to button Pad | ||
button.onEvent(DOUBLE_CLICK, [] { | ||
Serial.println("double click!"); | ||
}); | ||
|
||
//Attach long press event to button Pad | ||
button.onEvent(LONG_PRESS, [] { | ||
Serial.println("long press!"); | ||
}); | ||
|
||
} | ||
|
||
void loop() { | ||
//Call Tweakly for ever | ||
TweaklyRun(); | ||
//Put your code here :-) | ||
} |
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,60 @@ | ||
/* | ||
* | ||
* PAD EVENTS EXAMPLE FOR TWEAKLY | ||
* Created By Mirko Pacioni | ||
* | ||
* Tweakly monitors events on pins, | ||
* this is a modern feature that allows you to perform an operation when a pin's state changes. | ||
* | ||
*/ | ||
#include "Tweakly.h" | ||
|
||
//Create button Pad | ||
Pad button(12, INPUT_PULLUP); | ||
|
||
//Create led Pad | ||
Pad led(13); | ||
|
||
void setup() { | ||
|
||
//Start serial | ||
Serial.begin(115200); | ||
|
||
//Attach click event to button Pad | ||
button.onEvent(CLICK, [] { | ||
Serial.println("click!"); | ||
led.toggle(); | ||
}); | ||
|
||
//Attach double click event to button Pad | ||
button.onEvent(DOUBLE_CLICK, [] { | ||
Serial.println("double click!"); | ||
}); | ||
|
||
//Attach long press event to button Pad | ||
button.onEvent(LONG_PRESS, [] { | ||
Serial.println("long press!"); | ||
}); | ||
|
||
//Attach release event to button Pad | ||
button.onEvent(RELEASE, [] { | ||
Serial.println("release!"); | ||
}); | ||
|
||
//Attach To On Event to led Pad | ||
led.onEvent(TO_ON, [] { | ||
Serial.println("led on!"); | ||
}); | ||
|
||
//Attach To Off Event to led Pad | ||
led.onEvent(TO_OFF, [] { | ||
Serial.println("led off!"); | ||
}); | ||
|
||
} | ||
|
||
void loop() { | ||
//Call Tweakly for ever | ||
TweaklyRun(); | ||
//Put your code here :-) | ||
} |
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 @@ | ||
/* | ||
* | ||
* ROLLUP EXAMPLE (BLINK) FOR TWEAKLY | ||
* Created By Mirko Pacioni | ||
* | ||
* The rollup macro allows you to turn off a portion of code within the loop for a certain period of time. | ||
* Tweakly Rollup is a non-blocking alternative to classic delay. | ||
* to rewind the desired portion of code, the time to be controlled must be indicated with the sleep_for(milliseconds) macro. | ||
* | ||
*/ | ||
#include "Tweakly.h" | ||
|
||
//Create led Pad | ||
Pad led(6); | ||
|
||
void setup() { | ||
|
||
//Start serial | ||
Serial.begin(115200); | ||
|
||
} | ||
|
||
void loop() { | ||
//Call Tweakly for ever | ||
TweaklyRun(); | ||
|
||
//Start rollup | ||
//The first rollup interrupts part of the code for 1000 milliseconds, | ||
//when the time is exceeded the current state of the LED is switched. | ||
TWEAKLY_ROLLUP | ||
sleep_for(1000); | ||
led.toggle(); | ||
END_ROLLUP | ||
//Finish rollup | ||
|
||
//Start rollup | ||
//The second rollup prints the current status of the LED every 3000 milliseconds. | ||
TWEAKLY_ROLLUP | ||
sleep_for(3000); | ||
Serial.print("led status = "); | ||
Serial.print(led.read()); | ||
Serial.print("\n"); | ||
END_ROLLUP | ||
//Finish rollup | ||
|
||
//Your code continues without interruption | ||
//Put your code here :-) | ||
} |
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
Oops, something went wrong.