mirror of https://github.com/noisymime/OSPi.git
Added toggle of temperature units, added temporary fix for upgrade problem related to adding Sequential to options.txt
This commit is contained in:
parent
5263d3336f
commit
2dfb5428f0
26
ospi.py
26
ospi.py
|
@ -27,6 +27,7 @@ urls = [
|
|||
'/cl', 'clear_log',
|
||||
'/lo', 'log_options',
|
||||
'/rp', 'run_now',
|
||||
'/ttu', 'toggle_temp',
|
||||
]
|
||||
|
||||
#### Import ospi_addon module (ospi_addon.py) if it exists. ####
|
||||
|
@ -366,12 +367,13 @@ try:
|
|||
if not 'lg' in gv.sd: gv.sd['lg'] = 0
|
||||
if not 'lr' in gv.sd: gv.sd['lr'] = 100
|
||||
if not 'seq' in gv.sd: gv.sd['seq'] = 1
|
||||
if not 'tu' in gv.sd: gv.sd['tu'] = "C"
|
||||
except IOError: # If file does not exist, create with defaults.
|
||||
gv.sd = ({"en": 1, "seq": 1, "mnp": 32, "rsn": 0, "htp": 80, "nst": 8,
|
||||
"rdst": 0, "loc": "", "tz": 48, "rs": 0, "rd": 0, "mton": 0,
|
||||
"lr": "100", "sdt": 0, "mas": 0, "wl": 100, "bsy": 0, "lg": "",
|
||||
"urs": 0, "nopts": 13, "pwd": "b3BlbmRvb3I=", "ipas": 0, "rst": 1,
|
||||
"mm": 0, "mo": [0], "rbt": 0, "mtoff": 0, "nprogs": 1, "nbrd": 1})
|
||||
"mm": 0, "mo": [0], "rbt": 0, "mtoff": 0, "nprogs": 1, "nbrd": 1, "tu": "C"})
|
||||
sdf = open('./data/sd.json', 'w')
|
||||
json.dump(gv.sd, sdf)
|
||||
sdf.close()
|
||||
|
@ -465,8 +467,11 @@ class home:
|
|||
homepg += '<script>var en='+str(gv.sd['en'])+',rd='+str(gv.sd['rd'])+',mm='+str(gv.sd['mm'])+',rdst='+str(gv.sd['rdst'])+',mas='+str(gv.sd['mas'])+',urs='+str(gv.sd['urs'])+',rs='+str(gv.sd['rs'])+',wl='+str(gv.sd['wl'])+',ipas='+str(gv.sd['ipas'])+',loc="'+str(gv.sd['loc'])+'";</script>\n'
|
||||
homepg += '<script>var sbits='+str(gv.sbits).replace(' ', '')+',ps='+str(gv.ps).replace(' ', '')+';</script>\n'
|
||||
homepg += '<script>var lrun='+str(gv.lrun).replace(' ', '')+';</script>\n'
|
||||
homepg += '<script>var snames='+data('snames')+';</script>\n'
|
||||
homepg += '<script>var cputemp='+str(9.0/5.0*int(float(CPU_temperature()))+32)+';</script>\n'
|
||||
homepg += '<script>var snames='+data('snames')+'; var tempunit="'+str(gv.sd['tu'])+'";</script>\n'
|
||||
if gv.sd['tu'] == "F":
|
||||
homepg += '<script>var cputemp='+str(9.0/5.0*int(float(CPU_temperature()))+32)+'; var tempunit="F";</script>\n'
|
||||
else:
|
||||
homepg += '<script>var cputemp='+str(float(CPU_temperature()))+'; var tempunit="C";</script>\n'
|
||||
homepg += '<script src=\"'+baseurl()+'/static/scripts/java/svc1.8.3/home.js\"></script>'
|
||||
return homepg
|
||||
|
||||
|
@ -547,6 +552,9 @@ class change_options:
|
|||
except KeyError:
|
||||
pass
|
||||
vstr = data('options')
|
||||
if vstr.find("Sequential:") == -1: ### Temp fix for upgrade bug
|
||||
os.remove("./data/options.txt")
|
||||
vstr = data('options')
|
||||
ops = vstr.index('[')+1
|
||||
ope = vstr.index(']')
|
||||
optstr = vstr[ops:ope]
|
||||
|
@ -947,6 +955,18 @@ class run_now:
|
|||
schedule_stations(time.time())
|
||||
raise web.seeother('/')
|
||||
|
||||
class toggle_temp:
|
||||
"""Change units of Raspi's CPU temperature display on nome page."""
|
||||
def GET(self):
|
||||
qdict = web.input()
|
||||
if qdict['tunit'] == "C":
|
||||
gv.sd['tu'] = "F"
|
||||
else:
|
||||
gv.sd['tu'] = "C"
|
||||
jsave(gv.sd, 'sd')
|
||||
raise web.seeother('/')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = web.application(urls, globals())
|
||||
thread.start_new_thread(main_loop, ())
|
||||
|
|
|
@ -35,4 +35,7 @@ nst:8 number of stations
|
|||
|
||||
for logging:
|
||||
lg:0 log runs if = "checked"
|
||||
lr:100 limit number of log records to keep, 0 = no limit
|
||||
lr:100 limit number of log records to keep, 0 = no limit
|
||||
|
||||
Raspberry Pi specific:
|
||||
tu:"C" Temperature unit for Pi' CPU temperature readout (C or F)
|
|
@ -11,6 +11,9 @@ function linkn(s){window.open(s, '_blank');}
|
|||
function setrd(form,idx) {var h=prompt("Enter hours to delay","0");if(h!=null){form.elements[idx].value=h;form.submit()};}
|
||||
function imgstr(s) {return "<img src=\""+baseurl+"/static/images/icons/svc_"+s+".png\" height=20 align=absmiddle> ";}
|
||||
function datestr(t) {var _t=tz-48; return (new Date(t)).toUTCString()+((_t>=0)?"+":"-")+(Math.abs(_t)/4>>0)+":"+((Math.abs(_t)%4)*15/10>>0)+((Math.abs(_t)%4)*15%10);}
|
||||
// raspi CPU temp unit
|
||||
function toggle(form) {form.elements[0].value=tempunit;form.submit();}
|
||||
w("<form name=tt action=ttu method=get><input type=hidden name=tunit></form>");
|
||||
// print menu links
|
||||
w("<button style=\"height:44\" onclick=link(\"/\")>"+imgstr("reset")+"Refresh</button>");
|
||||
w("<button style=\"height:44\" onclick=link(\"/vo\")>"+imgstr("options")+"Options</button>");
|
||||
|
@ -23,7 +26,7 @@ if(ver>=100) w("<b>Firmware version</b>: "+(ver/100>>0)+"."+((ver/10>>0)%10)+"."
|
|||
else w("<b>Firmware version</b>: "+(ver/10>>0)+"."+(ver%10)+"<br>");
|
||||
w("<b>Device time</b>: "+datestr(devt*1000)+"<br>");
|
||||
if (typeof cputemp === 'undefined') cputemp="";
|
||||
w("<b>CPU Temp</b>: "+cputemp+"°F"+"<hr>");
|
||||
w("<b>CPU Temp</b>: <span style='cursor:pointer' onclick='toggle(tt)' title='Click to toggle Celsius <> Fahrenheit'>"+cputemp+"°"+tempunit+"</span><hr>");
|
||||
w("<script type=\"text/javascript\" src=\""+baseurl+"/static/scripts/java/svc1.8.3/"+((mm)?"manualmode.js":"progmode.js")+"\"></script>");
|
||||
// print status and other information
|
||||
w("<br><b>Operation</b>: "+(en?("on").fontcolor("green"):("OFF").fontcolor("red")));
|
||||
|
|
BIN
web/__init__.pyc
BIN
web/__init__.pyc
Binary file not shown.
Binary file not shown.
BIN
web/browser.pyc
BIN
web/browser.pyc
Binary file not shown.
BIN
web/db.pyc
BIN
web/db.pyc
Binary file not shown.
Binary file not shown.
BIN
web/form.pyc
BIN
web/form.pyc
Binary file not shown.
BIN
web/http.pyc
BIN
web/http.pyc
Binary file not shown.
Binary file not shown.
BIN
web/net.pyc
BIN
web/net.pyc
Binary file not shown.
BIN
web/session.pyc
BIN
web/session.pyc
Binary file not shown.
BIN
web/template.pyc
BIN
web/template.pyc
Binary file not shown.
BIN
web/utils.pyc
BIN
web/utils.pyc
Binary file not shown.
BIN
web/webapi.pyc
BIN
web/webapi.pyc
Binary file not shown.
Binary file not shown.
BIN
web/wsgi.pyc
BIN
web/wsgi.pyc
Binary file not shown.
Loading…
Reference in New Issue