Maybe fixed now
This commit is contained in:
parent
768e9faae5
commit
2a4393df73
@ -1,6 +1,7 @@
|
||||
const dotenv = require('dotenv').config();
|
||||
const debug = process.env.DEBUG === "TRUE";
|
||||
const { pins } = require('./config.json');
|
||||
const { gpio } = require('./VoidGPIO.js');
|
||||
|
||||
module.exports = {
|
||||
log(message) {
|
||||
@ -14,7 +15,7 @@ module.exports = {
|
||||
module.exports.log('Resetting all output pins.');
|
||||
pins.forEach(async (pin) => {
|
||||
if (pin.mode === 'OUT') {
|
||||
this.setPin(pin.board, pin.defaultState, err => {
|
||||
gpio.setPin(pin.board, pin.defaultState, err => {
|
||||
if (err) throw err;
|
||||
module.exports.log(`Set ${pin.key} pin to ${pin.defaultState}.`);
|
||||
});
|
||||
@ -23,19 +24,19 @@ module.exports = {
|
||||
for (const pin of pins) {
|
||||
switch (pin.mode) {
|
||||
case 'OUT':
|
||||
this.togglePin(pin.board, err => {
|
||||
gpio.togglePin(pin.board, err => {
|
||||
if (err) throw err;
|
||||
module.exports.log(`Toggled ${pin.key}`);
|
||||
});
|
||||
// Wait 1000ms before toggling again.
|
||||
await sleep(1000);
|
||||
this.togglePin(pin.board, err => {
|
||||
gpio.togglePin(pin.board, err => {
|
||||
if (err) throw err;
|
||||
module.exports.log(`Toggled ${pin.key}`);
|
||||
});
|
||||
break;
|
||||
case 'IN':
|
||||
this.readPin(pin.board, (err, state) => {
|
||||
gpio.readPin(pin.board, (err, state) => {
|
||||
if (err) throw err;
|
||||
module.exports.log(`${pin.key} state: ${state}`);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user