This commit is contained in:
Skylar Grant 2024-08-18 13:14:28 -04:00
parent 1413decbe0
commit f596ea1bda

View File

@ -13,8 +13,9 @@ pins.forEach(pin => {
});
module.exports = {
// Function to toggle a pin on-then-off
export function togglePin(pin, callback) {
togglePin(pin, callback) {
exec(`python3 src/python/gpio_interface.py toggle ${pin}`, (error, stdout, stderr) => {
if (error) {
return callback(error);
@ -24,10 +25,9 @@ export function togglePin(pin, callback) {
}
console.log(`Successfully toggled pin ${pin}`);
});
}
}.
// Function to sense a pin state
export function sensePin(pin, callback) {
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}`);
@ -40,10 +40,9 @@ export function sensePin(pin, callback) {
console.log(`Pin ${pin} state: ${stdout.trim()}`);
callback(stdout.trim(), null);
});
}
},
// Toggle pins sequentially and then sense pin states
export function debugInit() {
debugInit() {
pins.forEach(async (pin) => {
switch (pin.mode) {
case 'OUT':
@ -65,3 +64,4 @@ export function debugInit() {
}
});
}
}