3
This commit is contained in:
parent
1413decbe0
commit
f596ea1bda
@ -13,8 +13,9 @@ pins.forEach(pin => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Function to toggle a pin on-then-off
|
module.exports = {
|
||||||
export function togglePin(pin, callback) {
|
// Function to toggle a pin on-then-off
|
||||||
|
togglePin(pin, callback) {
|
||||||
exec(`python3 src/python/gpio_interface.py toggle ${pin}`, (error, stdout, stderr) => {
|
exec(`python3 src/python/gpio_interface.py toggle ${pin}`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
return callback(error);
|
return callback(error);
|
||||||
@ -24,10 +25,9 @@ export function togglePin(pin, callback) {
|
|||||||
}
|
}
|
||||||
console.log(`Successfully toggled pin ${pin}`);
|
console.log(`Successfully toggled pin ${pin}`);
|
||||||
});
|
});
|
||||||
}
|
}.
|
||||||
|
// Function to sense a pin state
|
||||||
// Function to sense a pin state
|
sensePin(pin, callback) {
|
||||||
export function sensePin(pin, callback) {
|
|
||||||
exec(`python3 src/python/gpio_interface.py sense ${pin}`, (error, stdout, stderr) => {
|
exec(`python3 src/python/gpio_interface.py sense ${pin}`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Error sensing pin ${pin}: ${error.message}`);
|
console.error(`Error sensing pin ${pin}: ${error.message}`);
|
||||||
@ -40,10 +40,9 @@ export function sensePin(pin, callback) {
|
|||||||
console.log(`Pin ${pin} state: ${stdout.trim()}`);
|
console.log(`Pin ${pin} state: ${stdout.trim()}`);
|
||||||
callback(stdout.trim(), null);
|
callback(stdout.trim(), null);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
// Toggle pins sequentially and then sense pin states
|
||||||
// Toggle pins sequentially and then sense pin states
|
debugInit() {
|
||||||
export function debugInit() {
|
|
||||||
pins.forEach(async (pin) => {
|
pins.forEach(async (pin) => {
|
||||||
switch (pin.mode) {
|
switch (pin.mode) {
|
||||||
case 'OUT':
|
case 'OUT':
|
||||||
@ -64,4 +63,5 @@ export function debugInit() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user