From 992ae238ebec6a2a5823887dd130d96956c91525 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 18 Aug 2024 14:02:14 -0400 Subject: [PATCH] Reimagined polling --- src/custom_modules/VoidGPIO.js | 3 +-- src/main.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/custom_modules/VoidGPIO.js b/src/custom_modules/VoidGPIO.js index 7ab6d7e..3c4a8be 100644 --- a/src/custom_modules/VoidGPIO.js +++ b/src/custom_modules/VoidGPIO.js @@ -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); }); } } diff --git a/src/main.js b/src/main.js index d44e2b1..d26b1a6 100644 --- a/src/main.js +++ b/src/main.js @@ -2,4 +2,4 @@ const gpio = require('./custom_modules/VoidGPIO.js'); gpio.debugInit(); -gpio.pollingLoop(); \ No newline at end of file +setInterval(gpio.poll, 1000); \ No newline at end of file