From 16cf29adbbc8f124ac2922d5415cd17e66bb6892 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Mon, 21 Aug 2017 23:52:27 -0400 Subject: [PATCH] Create an intval library for all the gpio logic --- index.js | 20 +++----------------- lib/intval/index.js | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 lib/intval/index.js diff --git a/index.js b/index.js index 8d9a63e..61ad1a1 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ 'use strict' const ble = require('./lib/blootstrap') +const intval = require('intval') const restify = require('restify') const logger = require('winston') -const gpio = require('gpio') const fs = require('fs') const pin = {} @@ -17,20 +17,10 @@ let app = restify.createServer({ version: '0.0.1' }) -function createPins () { - pin.four = gpio.export(4, { - direction: 'out', - interval: 100, - ready : () => { - logger.info(`Set pin 4 to OUTPUT`) - } - }) -} - function createServer () { app.get('/', index) - //app.all('/frame', rFrame) - app.get('/status', status) + app.all('/frame', rFrame) + app.get('/status', rStatus) app.listen(PORT, () => { console.log(`${APPNAME} listening on port ${PORT}!`) }) @@ -41,10 +31,6 @@ function rFrame (req, res, next) { return next() } -function frame (dir = true, length = 0, delay = 0) { - -} - function rStatus (req, res, next) { const obj = status() res.send(obj) diff --git a/lib/intval/index.js b/lib/intval/index.js new file mode 100644 index 0000000..7f56a32 --- /dev/null +++ b/lib/intval/index.js @@ -0,0 +1,21 @@ +'use strict' + +const gpio = require('gpio') + +class Intval { + constructor () { + this._pin = {} + this._declarePins() + } + _declarePins () { + this._pin.four = gpio.export(4, { + direction: 'out', + interval: 100, + ready : () => { + console.info(`Set pin 4 to OUTPUT`) + } + }) + } +} + +module.exports = new Intval() \ No newline at end of file