Create an intval library for all the gpio logic

This commit is contained in:
mmcwilliams 2017-08-21 23:52:27 -04:00
parent 07d73d74bc
commit 16cf29adbb
2 changed files with 24 additions and 17 deletions

View File

@ -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)

21
lib/intval/index.js Normal file
View File

@ -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()