Reimagined polling
This commit is contained in:
parent
c3e70ab9c7
commit
992ae238eb
@ -110,13 +110,12 @@ module.exports = {
|
||||
}
|
||||
};
|
||||
},
|
||||
async pollingLoop() {
|
||||
async poll() {
|
||||
for (const pin of pins) {
|
||||
if (pin.mode === 'IN') {
|
||||
this.readPin(pin.board, (err, state) => {
|
||||
if (err) throw err;
|
||||
console.log(`${pin.key}: ${state} [def: ${pin.defaultState}]`);
|
||||
sleep(1000).then(this.pollingLoop);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
const gpio = require('./custom_modules/VoidGPIO.js');
|
||||
|
||||
gpio.debugInit();
|
||||
gpio.pollingLoop();
|
||||
setInterval(gpio.poll, 1000);
|
Loading…
Reference in New Issue
Block a user