diff --git a/package.json b/package.json index cd7f20f..98a2bad 100644 --- a/package.json +++ b/package.json @@ -11,5 +11,8 @@ "url": "https://git.vfsh.dev/voidf1sh/hestia" }, "author": "Skylar Grant", - "license": "MIT" + "license": "MIT", + "dependencies": { + "dotenv": "^16.4.5" + } } diff --git a/src/custom_modules/functions.js b/src/custom_modules/functions.js index 30971c5..3314879 100644 --- a/src/custom_modules/functions.js +++ b/src/custom_modules/functions.js @@ -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 = { }; } } -} \ No newline at end of file +}