MTtripleButton en détail
Event management for Uno, Nano, Mega
Button like a mouse button. Can call functions during a single, double or triple click...
Include to add
#include <MTobjects.h> // See http://arduino.dansetrad.fr/en/MTobjects
I strongly advise to leave the comment, if another person wanted to try the program, they would have a download link directly. This is valid for all the libraries you use.
Useful comment
if_not_pressed
This comment is a word that can be added anywhere and which is ignored by the compiler.
Constructeurs
MTtripleButton(pin, onTripleSelectFunction = NO_ACTION, onDoubleSelectFunction = NO_ACTION, onSelectFunction = NO_ACTION, rest = HIGH);
pin (uint8_t): pin to which the button is connected
onTripleSelectFunction: what happens when you triple click the button
NO_ACTION -> nothing happens
function -> call a function "void myFunction(void) {...}"
onDoubleSelectFunction: what happens when you double click the button
NO_ACTION -> nothing happens
function -> call a function "void myFunction(void) {...}"
onSelectFunction: what happens when you simple click the button
NO_ACTION -> nothing happens
function -> call a function "void myFunction(void) {...}"
rest (boolean): pin state if the button is release
HIGH -> if it is wired between GND and pin (recommended). The pullup resistor is automatically added
LOW -> if it is wired between VCC and pin, with a pulldown resistance between pin and GND
Useful variable
bounce doubleBounce tripleBounce
bounce (word): time during which rebounds are ignored. By default 32ms, rounded up to packages of 16ms upper. f.ex. BOUNCE = 50
milli_seconds; gives 64ms maximum rebounds.
doubleBounce (word): time during which we wait a doble click. By default 256ms, rounded up to
packages of 16ms upper.
tripleBounce (word): time during which we wait a doble or a triple click. By default 304ms,
rounded up to packages of 16ms upper.
Please note: taking into account a single click and doble is delayed: at the first click, we do not yet know if there will be a
second, a triple or not. In the event of a simple click, you have to wait a tripleBounce time to find out. The simple click is
therefore detected with this late time.
It is the same with the detection of the double click. It takes a triplebounce time to find out.
Useful functions
boolean getSelect(void); void onTripleSelect(void); virtual void onDoubleSelect(void); virtual void onSelect(void);
getSelect return true if the button is pushed
onTripleSelect: overload function called when triple pressing the button
onDoubleSelect: overload function called when double pressing the button
onSelect: overload function called when simple pressing the button
Bonus functions
void setTripleSelectFunction(onUnselectFunction); void setTripleSelectFunction(); void setDoubleSelectFunction(onUnselectFunction); void setDoubleSelectFunction(); void setOnSelectFunction(onSelectFunction); void setOnSelectFunction();
setTripleSelectFunction overload function called when triple pressing the button
setTripleSelectFunction without parameters removes the function called when triple pressing the button
setDoubleSelectFunction overload function called when double pressing the button
setDoubleSelectFunction swithout parameters removes the function called when double pressing the button
setOnSelectFunction overload function called when simple pressing the button
setOnSelectFunction without parameters removes the function called when simle pressing the button
Examples