From 1413decbe0f2358afb27172ee780ae32f433d347 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 18 Aug 2024 13:10:10 -0400 Subject: [PATCH] 2 --- src/custom_modules/VoidGPIO.js | 6 +++--- src/main.js | 8 ++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/custom_modules/VoidGPIO.js b/src/custom_modules/VoidGPIO.js index 49b0164..b4452b6 100644 --- a/src/custom_modules/VoidGPIO.js +++ b/src/custom_modules/VoidGPIO.js @@ -14,7 +14,7 @@ pins.forEach(pin => { // Function to toggle a pin on-then-off -function togglePin(pin, callback) { +export function togglePin(pin, callback) { exec(`python3 src/python/gpio_interface.py toggle ${pin}`, (error, stdout, stderr) => { if (error) { return callback(error); @@ -27,7 +27,7 @@ function togglePin(pin, callback) { } // Function to sense a pin state -function sensePin(pin, callback) { +export function sensePin(pin, callback) { exec(`python3 src/python/gpio_interface.py sense ${pin}`, (error, stdout, stderr) => { if (error) { console.error(`Error sensing pin ${pin}: ${error.message}`); @@ -43,7 +43,7 @@ function sensePin(pin, callback) { } // Toggle pins sequentially and then sense pin states -function debugInit() { +export function debugInit() { pins.forEach(async (pin) => { switch (pin.mode) { case 'OUT': diff --git a/src/main.js b/src/main.js index f4cbf35..aca8cd4 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,4 @@ // Import modules -import gpio from './custom_modules/VoidGPIO.js'; - -// List of pins for toggling -const togglePins = [7, 13]; -// List of pins for sensing -const sensePins = [16, 22]; +const gpio = require('./custom_modules/VoidGPIO.js'); +gpio.debugInit(); \ No newline at end of file