Reimagined polling

This commit is contained in:
Skylar Grant 2024-08-18 14:02:14 -04:00
parent c3e70ab9c7
commit 992ae238eb
2 changed files with 2 additions and 3 deletions

View File

@ -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);
});
}
}

View File

@ -2,4 +2,4 @@
const gpio = require('./custom_modules/VoidGPIO.js');
gpio.debugInit();
gpio.pollingLoop();
setInterval(gpio.poll, 1000);