From 2a19a8499d7a62b539eab996bf6a5e456559fd3e Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Sun, 18 Dec 2022 21:51:15 -0500 Subject: [PATCH] idk --- functions.js | 12 ++++++------ main.js | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/functions.js b/functions.js index ccae34b..293ba60 100644 --- a/functions.js +++ b/functions.js @@ -197,18 +197,19 @@ const functions = { process.exit(); }, ignite(gpio) { + // Enable the auger config.status.auger = 1; + // Set the timestamp when the igniter turned on config.timestamps.igniterOn = Date.now(); + // Set the timestamp for when the igniter will turn off config.timestamps.igniterOff = config.timestamps.igniterOn + config.intervals.igniterStart; // 7 Minutes, 420,000ms return new Promise((resolve, reject) => { - fs.unlink('./ignite', (err) => { - if (err) reject(err); - if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Deleted the ignite file.`); - }); + // Check if we got here from a file, then delete it. + if (fs.existsSync('./ignite')) fs.unlink('./ignite', (err) => { if (err) throw err; }); // Run the first block if this is being run on a Raspberry Pi if (process.env.ONPI == 'true') { + // Power the blower on functions.power.blower.on(gpio).then(res => { - // TODO move this to a fn.power function // Turn on the igniter functions.power.igniter.on(gpio).then(res => { resolve('Auger enabled, combustion blower and igniter turned on.'); @@ -216,7 +217,6 @@ const functions = { reject(err); }); }); - } else { resolve('Simulated igniter turned on.'); } diff --git a/main.js b/main.js index cf84cf2..ad71f8f 100644 --- a/main.js +++ b/main.js @@ -107,6 +107,8 @@ async function main(fn, gpio) { // main(fn, gpio); }); } else { + if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Auger Status: ${config.status.auger}`); + fn.commands.pause().then(res => { statusCheck(fn, gpio); });