Implement GPIO pins
This commit is contained in:
parent
28ac67c834
commit
09c73ac619
26
main.js
26
main.js
@ -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
|
||||
|
@ -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.');
|
||||
});
|
||||
// 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');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user