API to provide more feedback / options to the single tessel 'config' button
npm install tessel-buttonA tiny ~2kb library to provide higher level events allowing advanced options via user input with the config button. In addition it provides visual feedback (LEDs) to the user to make counting easier.
Note: The purpose of the button may change in the future.
``bash`
npm install tessel-button --save
`js
var button = require('tessel-button');
// Hold Count Event
button.on('hold', function(count){
console.log("HOLD COUNT", count);
switch(count){
case 1: flushLogs(); break;
case 2: checkWifi(); break;
case 3: clearLogs(); break;
case 4: reset(); break;
default:
break;
}
});
// Quick Tap Event
button.on('click', function(clicks){
console.log('CLICK COUNT', clicks);
});
`
You should see the pattern.
| Count | LED2 | LED1 | Conn | Error |
|---|---|---|---|---|
| 1 | X | |||
| 2 | X | X | ||
| 3 | X | X | X | |
| 4 | X | X | X | X |
| 5 | X | X | X | |
| 6 | X | X | ||
| 7 | X | |||
| 8 | ||||
| 9 | X | |||
| 10 | X | X | ||
| 11 | X | X | X | |
| 12 | X | X | X | X |
| 13 | X | X | X | |
| 14 | X | X | ||
| 15 | X |
#### button.hold_duration
Default: __500__
This option controls the time that needs to elapse before the hold count is incremented.
#### button.click_timeout
Default: __300__
The time in between presses in order for a group of clicks to count. This value should be lower then button.hold_duration.
#### hold
add an event listener onto the button. Returns the hold count.
`js
button.on('hold', function(count){
});
`
#### click
add an event listener onto the button. Returns the click count.
`js
button.on('click', function(count){
});
`
I have notice bizarre behavior when registering multiple listeners on the button press and release` events. Haven't had time to research it deeper. I believe there maybe an issue inside the firmware.