This commit is contained in:
Skylar Grant 2022-12-18 21:51:15 -05:00
parent 8506492a64
commit 2a19a8499d
2 changed files with 8 additions and 6 deletions

View File

@ -197,18 +197,19 @@ const functions = {
process.exit(); process.exit();
}, },
ignite(gpio) { ignite(gpio) {
// Enable the auger
config.status.auger = 1; config.status.auger = 1;
// Set the timestamp when the igniter turned on
config.timestamps.igniterOn = Date.now(); 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 config.timestamps.igniterOff = config.timestamps.igniterOn + config.intervals.igniterStart; // 7 Minutes, 420,000ms
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fs.unlink('./ignite', (err) => { // Check if we got here from a file, then delete it.
if (err) reject(err); if (fs.existsSync('./ignite')) fs.unlink('./ignite', (err) => { if (err) throw err; });
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Deleted the ignite file.`);
});
// Run the first block if this is being run on a Raspberry Pi // Run the first block if this is being run on a Raspberry Pi
if (process.env.ONPI == 'true') { if (process.env.ONPI == 'true') {
// Power the blower on
functions.power.blower.on(gpio).then(res => { functions.power.blower.on(gpio).then(res => {
// TODO move this to a fn.power function
// Turn on the igniter // Turn on the igniter
functions.power.igniter.on(gpio).then(res => { functions.power.igniter.on(gpio).then(res => {
resolve('Auger enabled, combustion blower and igniter turned on.'); resolve('Auger enabled, combustion blower and igniter turned on.');
@ -216,7 +217,6 @@ const functions = {
reject(err); reject(err);
}); });
}); });
} else { } else {
resolve('Simulated igniter turned on.'); resolve('Simulated igniter turned on.');
} }

View File

@ -107,6 +107,8 @@ async function main(fn, gpio) {
// main(fn, gpio); // main(fn, gpio);
}); });
} else { } else {
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Auger Status: ${config.status.auger}`);
fn.commands.pause().then(res => { fn.commands.pause().then(res => {
statusCheck(fn, gpio); statusCheck(fn, gpio);
}); });