From a0b0d16c7383266777605560c0107cabf2368c78 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Wed, 21 Aug 2024 22:18:38 -0400 Subject: [PATCH] Boop --- src/custom_modules/functions.js | 7 +++++++ src/main.js | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/custom_modules/functions.js b/src/custom_modules/functions.js index af65c92..b620dd3 100644 --- a/src/custom_modules/functions.js +++ b/src/custom_modules/functions.js @@ -145,5 +145,12 @@ module.exports = { }); } } + }, + handlers: { + stateChange(change) { + gpio.togglePin(pinMap[change.name].board).then(() => { + console.log(`Pin ${config.states[change.name].pin} set to ${change.on}`); + }).catch(e => console.error(e)); + } } } diff --git a/src/main.js b/src/main.js index ef12670..4f7595a 100644 --- a/src/main.js +++ b/src/main.js @@ -24,7 +24,5 @@ setInterval(() => { comms.on('stateChange', (change) => { console.log(`State change detected: ${change.name}`); - gpio.togglePin(config.states[change.name].board).then(() => { - console.log(`Pin ${config.states[change.name].pin} set to ${change.on}`); - }).catch(e => console.error(e)); + fn.handlers.stateChange(change); }); \ No newline at end of file