Aug. 30 2013 update. See README.md

This commit is contained in:
Dan-in-CA 2013-08-31 12:20:37 -07:00
parent fe1cd15783
commit f0883741f1
4 changed files with 23 additions and 8 deletions

View File

@ -12,6 +12,13 @@ UPDATES
===========
***********
August 30 2013
--------------
Additions, bug fixes:<br/>
1. Modified the program to use only the time zone setting from the Options page and not the tz setting from the py.
2. Made the CPU temperature readout on the home page clickable to toggle between C and F.
3. Added a copy of Denny Fox's init.d auto startup script
August 25 2013
--------------
Additions, bug fixes:<br/>

12
ospi.py
View File

@ -1,5 +1,5 @@
#!/usr/bin/python
"""Updated 25/August/2013."""
"""Updated 30/August/2013."""
import re, os, json, time, base64, thread # standard Python modules
import web # the Web.py module. See webpy.org (Enables the OpenSprinkler web interface)
import gv # 'global vars' An empty module, used for storing vars (as attributes), that need to be 'global' across threads.
@ -88,7 +88,8 @@ def log_run(datetime):
else:
pgr = str(gv.lrun[1])
datastr = (pgr +', '+str(zones[gv.lrun[0]])+', '+str(gv.lrun[2]/60)+'m'+str(gv.lrun[2]%60)+
's, '+time.strftime("%H:%M:%S, %a. %d %b %Y", time.localtime(datetime))+'\n')
's, '+time.strftime("%H:%M:%S, %a. %d %b %Y", time.gmtime(datetime+((gv.sd['tz']/4)-12)*3600))+'\n')
#lt = time.gmtime(now+((gv.sd['tz']/4)-12)*3600)
f = open('./static/log/water_log.csv', 'r')
log = f.readlines()
f.close()
@ -105,7 +106,7 @@ def prog_match(now, prog):
"""Test a program for current date and time match."""
if not prog[0]: return 0 # Skip if program is not enabled
devday = int(now/86400) # Check day match
lt = time.localtime(now)
lt = time.gmtime(now+((gv.sd['tz']/4)-12)*3600)
if (prog[1]>=128) and (prog[2]>1): #Inverval program
if (devday %prog[2]) != (prog[1] - 128): return 0
else: # Weekday program
@ -166,7 +167,7 @@ def main_loop(): # Runs in a seperate thread
match = 0
now = time.time()
if gv.sd['en'] and not gv.sd['mm'] and (not gv.sd['bsy'] or not gv.sd['seq']) and not gv.sd['rd']:
lt = time.localtime(now)
lt = time.gmtime(now+((gv.sd['tz']/4)-12)*3600)
if (lt[3]*60)+lt[4] != last_min: # only check programs once a minute
last_min = (lt[3]*60)+lt[4]
for i, p in enumerate(gv.pd): # get both index and prog item
@ -555,6 +556,7 @@ class change_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]
@ -963,7 +965,7 @@ class toggle_temp:
gv.sd['tu'] = "F"
else:
gv.sd['tu'] = "C"
jsave(gv.sd, 'sd')
jsave(gv.sd, 'sd')
raise web.seeother('/')

View File

@ -31,11 +31,11 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Open Sprinkler Raspberry Pi"
HOST=$(hostname -I | sed 's/ *$//g')
PORT=:80 # Edit if different on your system
PORT=:8080 # Edit if different on your Raspberry Pi
NAME=ospi.py
DAEMON=/usr/bin/python
DAEMON_ARGS="ospi.py $HOST$PORT"
HOMEDIR=/home/pi/OSPi/ # Edit if different on your system
HOMEDIR=/home/pi/OSPi/ # Edit if different on your Raspberry Pi
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

View File

@ -14,6 +14,11 @@ function datestr(t) {var _t=tz-48; return (new Date(t)).toUTCString()+((_t>=0)?"
// 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>");
function bluebg(heat){
heat.style.backgroundColor='lightblue';}
function nobg(heat){
heat.style.backgroundColor='transparent';}
// 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>");
@ -26,7 +31,8 @@ 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>: <span style='cursor:pointer' onclick='toggle(tt)' title='Click to toggle Celsius <> Fahrenheit'>"+cputemp+"&deg;"+tempunit+"</span><hr>");
w("<b>CPU Temp</b>: <span id='heat' onmouseover='bluebg(this)' onmouseout='nobg(this)' style='cursor:pointer' onclick='toggle(tt)' title='Click to toggle Celsius <> Fahrenheit'>"+cputemp+"&deg;"+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")));