Permalink
Browse files

Added inactivity timeout

  • Loading branch information...
1 parent 8ad7741 commit d79d1b023752d07fcd0ce6606145994d6876233a @jawj committed Apr 17, 2012
Showing with 24 additions and 6 deletions.
  1. +1 −1 web_client/index.html
  2. +12 −2 web_client/pigeon_sim.coffee
  3. +11 −3 web_client/pigeon_sim.js
View
@@ -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>
@@ -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
@@ -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
@@ -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 = ->
@@ -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)
@@ -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
View
Oops, something went wrong.

0 comments on commit d79d1b0

Please sign in to comment.