Use sensible defaults for the blink patterns, and make use of it for the API blink.

This commit is contained in:
Pagan Gazzard 2014-12-19 12:39:36 +00:00 committed by Pablo Carranza Vélez
parent b63e7fd595
commit e054b36d58
3 changed files with 9 additions and 8 deletions

View File

@ -11,10 +11,8 @@ api.use(express.bodyParser())
api.post '/v1/blink', (req, res) ->
utils.mixpanelTrack('Device blink')
interval = setInterval(utils.blink, 400)
setTimeout(->
clearInterval(interval)
, 15000)
utils.blink.pattern.start()
setTimeout(utils.blink.pattern.stop, 15000)
res.send(200)
api.post '/v1/update', (req, res) ->

View File

@ -24,9 +24,14 @@ module.exports = exports = (ledFile) ->
.then ->
start(pattern)
return {
start: (pattern) ->
start: (pattern = {}) ->
return false if blinking?
blinking = start(pattern)
fullPattern =
blinks: pattern.blinks ? 1
onDuration: pattern.onDuration ? 200
offDuration: pattern.offDuration ? 200
pause: pattern.pause ? 0
blinking = start(fullPattern)
return
stop: ->
return false if not blinking?

View File

@ -61,8 +61,6 @@ exports.findIpAddrs = ->
.filter(Boolean)
networkPattern =
onDuration: 200
offDuration: 200
blinks: 4
pause: 1000