Implement GPIO pins

This commit is contained in:
Skylar Grant 2023-11-17 11:43:04 -05:00
parent 28ac67c834
commit 09c73ac619
2 changed files with 39 additions and 3 deletions

26
main.js
View File

@ -53,6 +53,32 @@ fn.commands.refreshConfig().then(res => {
});
function main(gpio) {
// Set the Igniter
switch (config.status.igniter) {
case 0:
fn.igniter.off();
break;
case 1:
fn.igniter.on();
break;
default:
fn.igniter.off();
break;
}
// Set the Exhaust
switch (config.status.exhaust) {
case 0:
fn.exhaust.off();
break;
case 1:
fn.exhaust.on();
break;
default:
fn.exhaust.off();
break;
}
// If the auger is enabled
if (config.status.auger == 1) {
// Run a cycle of the auger

View File

@ -362,12 +362,22 @@ const functions = {
gpio.setup(augerPin, gpio.DIR_OUT, (err) => {
if (err) reject(err);
if (process.env.DEBUG) console.log('== Auger pin initialized.');
// Resolve the promise now that all pins have been initialized
resolve('== GPIO Initialized.');
});
// Init the Igniter pin
gpio.setup(igniterPin, gpio.DIR_OUT, (err) => {
if (err) reject(err);
if (process.env.DEBUG) console.log('== Igniter pin initialized.');
});
// Init the Exhaust pin
gpio.setup(exhaustPin, gpio.DIR_OUT, (err) => {
if (err) reject(err);
if (process.env.DEBUG) console.log('== Exhaust pin initialized.');
});
// Resolve the promise now that all pins have been initialized
resolve('== GPIO Initialized.');
} else {
// Resolve the promise
resolve('== GPIO Not Available');
resolve('== GPIO Simulated');
}
});
},