Mercurial > code > home > repos > light9
changeset 938:c2faa69099e6
asco: display update frequency and dim when updates stop. run slower updates on tablets and phones
Ignore-this: 2439d0f540c9eae00c4f18e26411c100
author | drewp@bigasterisk.com |
---|---|
date | Wed, 12 Jun 2013 23:47:12 +0000 |
parents | b0337e6f68f1 |
children | 331e67fa1492 |
files | bin/ascoltami2 light9/ascoltami/index.html light9/ascoltami/webapp.py static/style.css |
diffstat | 4 files changed, 50 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/ascoltami2 Wed Jun 12 19:46:26 2013 +0000 +++ b/bin/ascoltami2 Wed Jun 12 23:47:12 2013 +0000 @@ -42,6 +42,8 @@ help='show URI, like http://light9.bigasterisk.com/show/dance2008', default=showconfig.showUri()) parser.add_option("-v", "--verbose", action="store_true", help="logging.DEBUG") + parser.add_option("--twistedlog", action="store_true", + help="twisted logging") (options, args) = parser.parse_args() log.setLevel(logging.DEBUG if options.verbose else logging.INFO) @@ -51,6 +53,9 @@ graph = showconfig.getGraph() app = App(graph, URIRef(options.show)) + if options.twistedlog: + from twisted.python import log as twlog + twlog.startLogging(sys.stderr) reactor.listenTCP(networking.musicPlayer.port, makeWebApp(app)) log.info("listening on %s" % networking.musicPlayer.port) reactor.run()
--- a/light9/ascoltami/index.html Wed Jun 12 19:46:26 2013 +0000 +++ b/light9/ascoltami/index.html Wed Jun 12 23:47:12 2013 +0000 @@ -14,15 +14,17 @@ <h1>ascoltami on ${host}</h1> <div class="songs"/> - <div>Song: <span id="currentSong"/></div> - <div>Time: <span id="currentTime"/></div> - <div>Left: <span id="leftTime"/></div> - <div>Until autostop: <span id="leftAutoStopTime"/></div> - <div>States: <span id="states"/></div> - <div class="timeRow"> - <div id="timeSlider"/> + <div class="dimStalled"> + <div>Song: <span id="currentSong"/></div> + <div>Time: <span id="currentTime"/></div> + <div>Left: <span id="leftTime"/></div> + <div>Until autostop: <span id="leftAutoStopTime"/></div> + <div>Update freq: requested <span id="updateReq"/>, actual <span id="updateActual"/></div> + <div>States: <span id="states"/></div> + <div class="timeRow"> + <div id="timeSlider"/> + </div> </div> - <div class="commands"> <button id="cmd-stop" class="playMode">Stop<div class="key">s</div></button> <button id="cmd-play" class="playMode">Play <div class="key">p</div></button> @@ -33,16 +35,20 @@ <button id="cmd-out0">Output 0</button> <button id="cmd-out1">Output 1</button> </div> - + + <p>Running on <span id="nav"/></p> + todo: display next action <p><button onclick="window.open('/', '_blank', 'scrollbars=1,resizable=1,titlebar=0,location=0')">reopen this in a simpler window</button></p> - - todo: go button actions, display next action - <a href="">reload</a> + <p><a href="">reload</a></p> <script type="text/javascript"> // <![CDATA[ $(function () { + $("#nav").text(navigator.userAgent); + var updateFreq = (navigator.userAgent.indexOf("Linux") != -1) ? 10 : 2; + $("#updateReq").text(updateFreq); + var times = { // need to get these from server intro: 4, post: 4 @@ -145,12 +151,34 @@ window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame; + var recentUpdates = []; + function onUpdate() { + recentUpdates.push(+new Date()); + recentUpdates = recentUpdates.slice(Math.max(recentUpdates.length - 5, 0)); + refreshUpdateFreqs(); + } + + function refreshUpdateFreqs() { + if (recentUpdates.length > 1) { + if (+new Date() - recentUpdates[recentUpdates.length - 1] > 1000) { + $("#updateActual").text("(stalled)"); + $(".dimStalled").addClass("stalled"); + return; + } + + var avgMs = (recentUpdates[recentUpdates.length - 1] - recentUpdates[0]) / (recentUpdates.length - 1); + $("#updateActual").text(Math.round(1000 / avgMs)); + } + } + setInterval(refreshUpdateFreqs, 2000); + function updateLoop() { var whenDone = function () { setTimeout(function () { raf(updateLoop); - }, 50); + }, 1000 / updateFreq); }; + onUpdate(); updateCurrent(whenDone); } updateLoop();
--- a/light9/ascoltami/webapp.py Wed Jun 12 19:46:26 2013 +0000 +++ b/light9/ascoltami/webapp.py Wed Jun 12 23:47:12 2013 +0000 @@ -5,7 +5,7 @@ from light9.showconfig import getSongsFromShow, songOnDisk from rdflib import URIRef from web.contrib.template import render_genshi -render = render_genshi([sibpath(__file__, ".")]) +render = render_genshi([sibpath(__file__, ".")], auto_reload=True) try: import sys