Semi fixed...

This commit is contained in:
Skylar Grant 2024-08-18 14:34:23 -04:00
parent 1eb1dc8270
commit 768e9faae5
2 changed files with 11 additions and 7 deletions

View File

@ -11,5 +11,8 @@
"url": "https://git.vfsh.dev/voidf1sh/hestia"
},
"author": "Skylar Grant",
"license": "MIT"
"license": "MIT",
"dependencies": {
"dotenv": "^16.4.5"
}
}

View File

@ -1,5 +1,6 @@
const dotenv = require('dotenv').config();
const debug = process.env.DEBUG === "TRUE";
const { pins } = require('./config.json');
module.exports = {
log(message) {
@ -10,12 +11,12 @@ module.exports = {
gpio: {
// Boot up sanity check during debug mode
async debugInit() {
exports.log('Resetting all output pins.');
module.exports.log('Resetting all output pins.');
pins.forEach(async (pin) => {
if (pin.mode === 'OUT') {
this.setPin(pin.board, pin.defaultState, err => {
if (err) throw err;
exports.log(`Set ${pin.key} pin to ${pin.defaultState}.`);
module.exports.log(`Set ${pin.key} pin to ${pin.defaultState}.`);
});
};
});
@ -24,19 +25,19 @@ module.exports = {
case 'OUT':
this.togglePin(pin.board, err => {
if (err) throw err;
exports.log(`Toggled ${pin.key}`);
module.exports.log(`Toggled ${pin.key}`);
});
// Wait 1000ms before toggling again.
await sleep(1000);
this.togglePin(pin.board, err => {
if (err) throw err;
exports.log(`Toggled ${pin.key}`);
module.exports.log(`Toggled ${pin.key}`);
});
break;
case 'IN':
this.readPin(pin.board, (err, state) => {
if (err) throw err;
exports.log(`${pin.key} state: ${state}`);
module.exports.log(`${pin.key} state: ${state}`);
});
default:
break;
@ -44,4 +45,4 @@ module.exports = {
};
}
}
}
}