Start blower with igniter

This commit is contained in:
Skylar Grant 2022-12-18 21:29:50 -05:00
parent 9fc783d1f5
commit 5f97b8858a
2 changed files with 20 additions and 10 deletions

View File

@ -197,20 +197,26 @@ const functions = {
process.exit(); process.exit();
}, },
ignite(gpio) { ignite(gpio) {
config.status.igniter = 1;
config.status.auger = 1; config.status.auger = 1;
config.timestamps.igniterOn = Date.now(); config.timestamps.igniterOn = Date.now();
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) => { fs.unlink('./ignite', (err) => {
if (err) reject(err); if (err) reject(err);
if (config.debugMode) console.log(`[${(Date.now() - config.timestamps.procStart)/1000}] I: Delete the ignite file.`); 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
if (process.env.ONPI == 'true') { if (process.env.ONPI == 'true') {
gpio.write(igniterPin, true, (err) => { functions.power.blower.on(gpio).then(res => {
if (err) reject(err); // TODO move this to a fn.power function
resolve('Igniter turned on.'); // Turn on the igniter
functions.power.igniter.on(gpio).then(res => {
resolve('Auger enabled, combustion blower and igniter turned on.');
}).catch(err => {
reject(err);
});
}); });
} else { } else {
resolve('Simulated igniter turned on.'); resolve('Simulated igniter turned on.');
} }
@ -317,7 +323,8 @@ const functions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gpio.write(igniterPin, true, (err) => { gpio.write(igniterPin, true, (err) => {
if (err) reject(err); if (err) reject(err);
resolve(); config.status.igniter = 1;
resolve('Igniter turned on.');
}); });
}); });
}, },
@ -326,7 +333,8 @@ const functions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gpio.write(igniterPin, false, (err) => { gpio.write(igniterPin, false, (err) => {
if (err) reject(err); if (err) reject(err);
resolve(); config.status.igniter = 0;
resolve('Igniter turned off.');
}); });
}); });
}, },
@ -337,7 +345,8 @@ const functions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gpio.write(blowerPin, true, (err) => { gpio.write(blowerPin, true, (err) => {
if (err) reject(err); if (err) reject(err);
resolve(); config.status.blower = 1;
resolve('Blower turned on.');
}); });
}); });
}, },
@ -346,7 +355,8 @@ const functions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
gpio.write(blowerPin, false, (err) => { gpio.write(blowerPin, false, (err) => {
if (err) reject(err); if (err) reject(err);
resolve(); config.status.blower = 0;
resolve('Blower turned off.');
}); });
}); });
}, },

View File

@ -73,7 +73,7 @@ async function main(fn, gpio) {
fn.commands.shutdown(gpio); fn.commands.shutdown(gpio);
break; break;
case "ignite": case "ignite":
// Start the igniter and timer // Start the ignite sequence
fn.commands.ignite(gpio).then(res => { fn.commands.ignite(gpio).then(res => {
if (config.debugMode) console.log(res); if (config.debugMode) console.log(res);
statusCheck(fn, gpio); statusCheck(fn, gpio);