Accept the pattern as an argument for the blink module.

This commit is contained in:
Pagan Gazzard 2014-12-17 17:54:49 +00:00 committed by Pablo Carranza Vélez
parent cd2603f228
commit b63e7fd595
2 changed files with 11 additions and 11 deletions

View File

@ -14,24 +14,19 @@ module.exports = exports = (ledFile) ->
.then(ledOff)
blink.pattern = do ->
pattern =
onDuration: 200
offDuration: 200
blinks: 4
pause: 1000
blinking = null
start = ->
start = (pattern) ->
Promise.resolve([0...pattern.blinks]).cancellable()
.each ->
blink(pattern.onDuration)
.delay(pattern.offDuration)
.delay(pattern.pause)
.then ->
start()
start(pattern)
return {
start: ->
start: (pattern) ->
return false if blinking?
blinking = start()
blinking = start(pattern)
return
stop: ->
return false if not blinking?

View File

@ -60,8 +60,13 @@ exports.findIpAddrs = ->
return ipAddr
.filter(Boolean)
exports.blink = blink
networkPattern =
onDuration: 200
offDuration: 200
blinks: 4
pause: 1000
exports.blink = blink
exports.connectivityCheck = _.once ->
networkCheck.monitorURL
url: config.heartbeatEndpoint
@ -72,4 +77,4 @@ exports.connectivityCheck = _.once ->
blink.pattern.stop()
else
console.log('Waiting for connectivity...')
blink.pattern.start()
blink.pattern.start(networkPattern)