initial
This commit is contained in:
29
node_modules/onoff/test/wait-for-many-interrupts.js
generated
vendored
Normal file
29
node_modules/onoff/test/wait-for-many-interrupts.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
|
||||
const Gpio = require('../onoff').Gpio;
|
||||
const assert = require('assert');
|
||||
const button = new Gpio(4, 'in', 'rising', {
|
||||
debounceTimeout : 10
|
||||
});
|
||||
let count = 0;
|
||||
|
||||
assert(button.direction() === 'in');
|
||||
assert(button.edge() === 'rising');
|
||||
|
||||
console.info('Please press button connected to GPIO4 5 times...');
|
||||
|
||||
button.watch((err, value) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
count += 1;
|
||||
|
||||
console.log('button pressed ' + count + ' times, value was ' + value);
|
||||
|
||||
if (count === 5) {
|
||||
button.unexport();
|
||||
console.log('ok - ' + __filename);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user