diff --git a/src/custom_modules/VoidGPIO.js b/src/custom_modules/VoidGPIO.js index ded7ef5..7ab6d7e 100644 --- a/src/custom_modules/VoidGPIO.js +++ b/src/custom_modules/VoidGPIO.js @@ -109,5 +109,16 @@ module.exports = { break; } }; + }, + async pollingLoop() { + 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); + }); + } + } } } \ No newline at end of file diff --git a/src/main.js b/src/main.js index aca8cd4..d44e2b1 100644 --- a/src/main.js +++ b/src/main.js @@ -1,4 +1,5 @@ // Import modules const gpio = require('./custom_modules/VoidGPIO.js'); -gpio.debugInit(); \ No newline at end of file +gpio.debugInit(); +gpio.pollingLoop(); \ No newline at end of file