From 09c73ac6199624133a75842362ab0693fa735fa0 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Fri, 17 Nov 2023 11:43:04 -0500 Subject: [PATCH] Implement GPIO pins --- main.js | 26 ++++++++++++++++++++++++++ modules/functions.js | 16 +++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 9ff12ef..8513bd2 100644 --- a/main.js +++ b/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 diff --git a/modules/functions.js b/modules/functions.js index 625d074..07dfb58 100644 --- a/modules/functions.js +++ b/modules/functions.js @@ -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'); } }); },