diff --git a/ospi.py b/ospi.py index ea398c1..c2b2dcb 100644 --- a/ospi.py +++ b/ospi.py @@ -82,6 +82,25 @@ def CPU_temperature(): except: pass +def get_temperature(): + """Returns the temperature given the stored location info""" + import urllib2 + + weatherBaseURL = "http://api.openweathermap.org/data/2.5/weather?" + weatherFormat = "units=metric&" + weatherURL = weatherBaseURL + weatherFormat + + latitude = gv.sd['loc'].split(",")[0] + longitude = gv.sd['loc'].split(",")[1] + + queryURL = weatherURL + "lat=" + str(latitude) + "&lon=" + str(longitude) + response = urllib2.urlopen(queryURL) + + decoder = json.JSONDecoder() + temperature = decoder.decode(response.read())["main"]["temp"] + + return (str(temperature)) + def log_run(): """add run data to csv file - most recent first.""" if gv.lg: @@ -536,6 +555,7 @@ class home: else: try: homepg += '\n' + homepg += '\n' except ValueError: pass homepg += '' diff --git a/static/scripts/java/svc1.8.3/home.js b/static/scripts/java/svc1.8.3/home.js index 02dcb9f..2ab08cf 100644 --- a/static/scripts/java/svc1.8.3/home.js +++ b/static/scripts/java/svc1.8.3/home.js @@ -33,7 +33,8 @@ else w("Firmware version: "+(ver/10>>0)+"."+(ver%10)+"
"); w("Device time: "+datestr(devt*1000)+"
"); if (typeof cputemp === 'undefined') cputemp=""; -w("CPU Temp: "+cputemp+"°"+tempunit+"
"); +w("CPU Temp: "+cputemp+"°"+tempunit+"
"); +w("Location Temp: "+temp+"°"+tempunit+"
"); w(""); // print status and other information w("
Operation: "+(sd['en']?("on").fontcolor("green"):("OFF").fontcolor("red"))); diff --git a/static/scripts/java/svc1.8.3/viewoptions.js b/static/scripts/java/svc1.8.3/viewoptions.js index a01893b..8bab625 100755 --- a/static/scripts/java/svc1.8.3/viewoptions.js +++ b/static/scripts/java/svc1.8.3/viewoptions.js @@ -29,6 +29,25 @@ function ftoggle() { } document.getElementById("tooltips").innerHTML = (state?"Hide Tooltips":"Show Tooltips"); } + +function lookupLocation() { + var x=document.getElementsByName("oloc")[0]; + x.value="Looking up location..."; + if (navigator.geolocation) + { + navigator.geolocation.getCurrentPosition(showPosition); + + } + else{x.value="Geolocation is not supported by this browser.";} +} + +function showPosition(position) + { + var x=document.getElementsByName("oloc")[0]; + x.value=position.coords.latitude + "," + position.coords.longitude; + + } + w("
"); w("Set Options:
(Hover on each option to see tooltip)
"); w("

"); @@ -46,7 +65,14 @@ for(oid=0;oid"+label+": 0?"checked":"")+" name=o"+name+">"); } else if (datatype == "string") { - w("

"+label+": "); + switch (name) { + case "loc": + w("

"+label+": "); + w(""); + break; + default: + w("

"+label+": "); + } } else { switch (name) { case "tz":