This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def baroReader(interval_secs,altitude) : | |
baro = BMP085() | |
while True : | |
slbaro = round(baro.readSeaLevelPressure(altitude) / 100 ,2) | |
yield(slbaro) | |
time.sleep(interval_secs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def readSeaLevelPressure(self, altitude=0) : | |
"Calculates the sea level pressure from a pressure at an altitude in metres" | |
pressure = float(self.readPressure()) | |
pressureSL = pressure / pow( ( 1.0 - float(altitude) / 44330) , 5.225) | |
if (self.debug) : | |
print("DBG: Sea Level Pressure = %d" % (pressureSL)) | |
return pressureSL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time, json, re, sys | |
from urllib.request import urlopen | |
from urllib.parse import quote_plus | |
from email.utils import parsedate_tz | |
# local modules | |
import speak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(: | |
a hack conversion from some forms of json to xml | |
presumption is that [ ] { } only used as json syntax not as characters in quoted strings | |
parsing of comma-separated text supports embedded , and : , relying on "\s*: as a separator | |
if the hint <rough is present in the flags, arrays will be split on comma - this is needed because the | |
recursive algorithm for text parsing causes stack overflow after 99 iterations. | |
embedded HTML is not supported | |
root is div | |
un named arrays or blocks are enclosed in divs | |
element names are expected to be valid XML names |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start up the monitor and talker processes | |
python start_barometer.py & | |
python barometer_talk.py & | |
python simple_clock.py & | |
# the controller will take stdin character input from keyboard or presenter | |
# yacht1 is the current version of the menu | |
python controller.py yacht1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This forecast method comes from | |
http://www.sciencecompany.com/-W135.aspx | |
input is the current baro (in hPa) and the trend over 3 hours | |
""" | |
forecast1_table = \ | |
( | |
(1022, ( (-0.1 , "Continued fair"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<item title="Clock" action="'Clock is '+ get('clock').status()"> | |
<item action="'Clock is now '+ get('clock').toggle().put().status()"/> | |
</item> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
import speak | |
from persistant import * | |
from switch import * | |
Switch("clock").put() | |
while True : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from persistant import * | |
class Switch(Persistant) : | |
def __init__(self,name) : | |
self.name = name | |
self.on = True | |
def switch_on(self) : | |
self.on= True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
import time | |
def get(name) : | |
file = open("obj/"+name+".pkl","r") | |
return pickle.load(file) | |
class Persistant(object) : | |
def __init__(self,name) : |