TODOs and documenting
This commit is contained in:
parent
be54f6f769
commit
202472bfbb
10
main.js
10
main.js
@ -1,8 +1,12 @@
|
||||
// npm module for Raspberri Pi GPIO
|
||||
var gpio = require('rpi-gpio');
|
||||
// Module for importing environment variables
|
||||
var dotenv = require('dotenv').config();
|
||||
|
||||
// Set up GPIO 4 (pysical pin 7) as output, then call cycleAuger()
|
||||
gpio.setup(7, gpio.DIR_OUT, cycleAuger);
|
||||
|
||||
// Turns the auger on (Pin 7 high)
|
||||
function augerOn(err) {
|
||||
if (err) throw err;
|
||||
gpio.write(7, true, function(err) {
|
||||
@ -11,6 +15,7 @@ function augerOn(err) {
|
||||
});
|
||||
}
|
||||
|
||||
// Turns the auger off (pin 7 low)
|
||||
function augerOff(err) {
|
||||
if (err) throw err;
|
||||
gpio.write(7, false, function(err) {
|
||||
@ -27,7 +32,8 @@ function augerOff(err) {
|
||||
// function augerOn() {
|
||||
// console.log('Auger turned on.');
|
||||
// }
|
||||
|
||||
|
||||
// Sleeps for any given milliseconds, call with await
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms);
|
||||
@ -35,8 +41,10 @@ function sleep(ms) {
|
||||
});
|
||||
}
|
||||
|
||||
// Main function, turns the auger on, sleeps for the time given in environment variables, then turns the auger off, sleeps, repeats.
|
||||
async function cycleAuger(err) {
|
||||
if (err) throw err;
|
||||
// TODO: Detect file 'pause', 'reload', 'quit'
|
||||
augerOn();
|
||||
await sleep(process.env.ONTIME);
|
||||
augerOff();
|
||||
|
Loading…
Reference in New Issue
Block a user