From c3e70ab9c706376cafbde2f4aece7e0375093efe Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 18 Aug 2024 13:59:11 -0400 Subject: [PATCH] Testing polling loop --- src/custom_modules/VoidGPIO.js | 11 +++++++++++ src/main.js | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) 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