Skip to content

Commit

Permalink
Added inactivity timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jawj committed Apr 17, 2012
1 parent 8ad7741 commit d79d1b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion web_client/index.html
Expand Up @@ -37,7 +37,7 @@
<span id="debugEarthAPI"></span>
<span id="debugTicks"></span>
<span id="debugTicks"></span>
<div id="credit"><span>CASA Smart Cities 2012</span></div>
<div id="credit"><span>CASA Smart Cities</span></div>
</div></div>
<div id="earth"></div>
</body>
Expand Down
14 changes: 12 additions & 2 deletions web_client/pigeon_sim.coffee
Expand Up @@ -38,6 +38,7 @@ window.onload = ->
atmosphere: 1 # show atmosphere
sun: 0 # show sun
timeControl: 0 # show Google Earth time controller (if sun is 1)
resetTimeout: 60 # seconds, after which to reset if no flight
featureSkip: 12 # update features every n movement frames
debugBox: 0 # show the box that determines visibility of features

Expand All @@ -60,7 +61,7 @@ window.onload = ->
(el(id) for id in w('title alt debugData debugEarthAPI debugTicks heading'))

cam = {}
ge = seenCam = flown = animTimeout = fm = null
ge = seenCam = flown = animTimeout = fm = lastMove = null
animTicks = camMoves = inMsgs = 0
lastFlap = flapAmount = 0

Expand All @@ -81,6 +82,7 @@ window.onload = ->
cam.alt = params.startAlt
cam.roll = 0.0000001 # a plain 0 is ignored
cam.tilt = params.cruiseTilt
lastMove = new Date()
flown = no

moveCam = ->
Expand All @@ -89,6 +91,8 @@ window.onload = ->
unmoved = objsEq(cam, seenCam)
return no if unmoved

lastMove = new Date()

view = ge.getView()
c = view.copyAsCamera(ge.ALTITUDE_ABSOLUTE)
c.setLatitude(cam.lat)
Expand Down Expand Up @@ -159,7 +163,13 @@ window.onload = ->
altStatus.innerHTML = "#{Math.round(cam.alt)}m"

moved = moveCam()
fm.update() if animTicks % params.featureSkip is 0

if animTicks % params.featureSkip is 0
if flown and new Date() - lastMove > params.resetTimeout * 1000
resetCam()
fm.reset()
else
fm.update()

clearTimeout(animTimeout) if animTimeout?
animTimeout = null
Expand Down
14 changes: 11 additions & 3 deletions web_client/pigeon_sim.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d79d1b0

Please sign in to comment.