Adding new gpio assignments
This commit is contained in:
parent
96339fa208
commit
4d682ae984
25
.vscode/pssnippets.code-snippets
vendored
Normal file
25
.vscode/pssnippets.code-snippets
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
// Place your pscontrolpanel workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
|
||||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
|
||||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
|
||||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
|
||||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
|
||||
// Placeholders with the same ids are connected.
|
||||
// Example:
|
||||
// "Print to console": {
|
||||
// "scope": "javascript,typescript",
|
||||
// "prefix": "log",
|
||||
// "body": [
|
||||
// "console.log('$1');",
|
||||
// "$2"
|
||||
// ],
|
||||
// "description": "Log output to console"
|
||||
// }
|
||||
|
||||
"Log if in Debug mode": {
|
||||
"scope": "javascript",
|
||||
"prefix": "log",
|
||||
"body": "if (process.env.DEBUG == 'true') console.log('$1');\n$0",
|
||||
"description": "Log output to console if in debug mode"
|
||||
}
|
||||
}
|
52
functions.js
52
functions.js
@ -1,3 +1,11 @@
|
||||
// Physical Pin numbers for GPIO
|
||||
const augerPin = 7; // Pin for controlling the relay for the pellet auger motor.
|
||||
const igniterPin = 13; // Pin for controlling the relay for the igniter.
|
||||
const blowerPin = 15; // Pin for controlling the relay for the combustion blower/exhaust.
|
||||
const pofPin = 16; // Pin for sensing the status (open/closed) of the Proof of Fire switch.
|
||||
const tempPin = 18; // Pin for receiving data from a DS18B20 OneWire temperature sensor.
|
||||
const vacuumPin = 22; // Pin for sensing the status (open/closed) of the vacuum switch.
|
||||
|
||||
// Get environment variables
|
||||
const dotenv = require('dotenv').config();
|
||||
// Module for working with files
|
||||
@ -140,7 +148,7 @@ const functions = {
|
||||
process.exit();
|
||||
},
|
||||
},
|
||||
// Sleeps for any given milliseconds, call with await
|
||||
// Sleeps for any given milliseconds
|
||||
sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
if (process.env.DEBUG == "true") console.log(`Sleeping for ${ms}ms`);
|
||||
@ -157,14 +165,46 @@ const functions = {
|
||||
init(gpio) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Write the current env vars to console
|
||||
console.log('Environment variables:');
|
||||
console.log(`ONTIME=${process.env.ONTIME}\nOFFTIME=${process.env.OFFTIME}\nPAUSETIME=${process.env.PAUSETIME}\nDEBUG=${process.env.DEBUG}\nONPI=${process.env.ONPI}`);
|
||||
console.log(`Environment variables:\n
|
||||
ONTIME=${process.env.ONTIME}\n
|
||||
OFFTIME=${process.env.OFFTIME}\n
|
||||
PAUSETIME=${process.env.PAUSETIME}\n
|
||||
DEBUG=${process.env.DEBUG}\n
|
||||
ONPI=${process.env.ONPI}
|
||||
`);
|
||||
// Set up GPIO 4 (pysical pin 7) as output, then call functions.auger.ready()
|
||||
if (process.env.ONPI == 'true') {
|
||||
gpio.setup(7, gpio.DIR_OUT, (err) => {
|
||||
// Init the Auger pin
|
||||
gpio.setup(augerPin, gpio.DIR_OUT, (err) => {
|
||||
if (err) reject(err);
|
||||
// Resolve the promise
|
||||
resolve('GPIO Initialized');
|
||||
if (process.env.DEBUG == 'true') console.log('Auger pin initialized.');
|
||||
// Init the igniter pin
|
||||
gpio.setup(igniterPin, gpio.DIR_OUT, (err) => {
|
||||
if (err) reject(err);
|
||||
if (process.env.DEBUG == 'true') console.log('Igniter pin initialized.');
|
||||
// Init the blower pin
|
||||
gpio.setup(blowerPin, gpio.DIR_OUT, (err) => {
|
||||
if (err) reject(err);
|
||||
if (process.env.DEBUG == 'true') console.log('Combustion blower pin initialized.');
|
||||
// Init the Proof of Fire pin
|
||||
gpio.setup(pofPin, gpio.DIR_IN, (err) => {
|
||||
if (err) reject(err);
|
||||
if (process.env.DEBUG == 'true') console.log('Proof of Fire pin initialized.');
|
||||
// Init the Temp Sensor pin
|
||||
gpio.setup(tempPin, gpio.DIR_IN, (err) => {
|
||||
if (err) reject(err);
|
||||
if (process.env.DEBUG == 'true') console.log('Temperature pin initialized.');
|
||||
// Init the Vacuum Switch pin
|
||||
gpio.setup(vacuumPin, gpio.DIR_IN, (err) => {
|
||||
if (err) reject(err);
|
||||
if (process.env.DEBUG == 'true') console.log('Vacuum Switch pin initialized.');
|
||||
// Resolve the promise now that all pins have been initialized
|
||||
resolve('GPIO Initialized.');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// Resolve the promise
|
||||
|
9
main.js
9
main.js
@ -1,3 +1,12 @@
|
||||
/* Pellet Stove Control Panel
|
||||
* Written by Skylar Grant
|
||||
* v0.2.0
|
||||
*
|
||||
* TODO:
|
||||
* Add logic for other sensors
|
||||
* More documentation?
|
||||
*/
|
||||
|
||||
// Custom functions module to keep main script clean
|
||||
const fn = require('./functions.js').functions;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pscontrolpanel",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"requires": true,
|
||||
"packages": {},
|
||||
"dependencies": {
|
||||
|
Loading…
Reference in New Issue
Block a user