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) -> api.post '/v1/blink', (req, res) ->
utils.mixpanelTrack('Device blink') utils.mixpanelTrack('Device blink')
interval = setInterval(utils.blink, 400) utils.blink.pattern.start()
setTimeout(-> setTimeout(utils.blink.pattern.stop, 15000)
clearInterval(interval)
, 15000)
res.send(200) res.send(200)
api.post '/v1/update', (req, res) -> api.post '/v1/update', (req, res) ->

View File

@ -24,9 +24,14 @@ module.exports = exports = (ledFile) ->
.then -> .then ->
start(pattern) start(pattern)
return { return {
start: (pattern) -> start: (pattern = {}) ->
return false if blinking? 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 return
stop: -> stop: ->
return false if not blinking? return false if not blinking?

View File

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