add temperature logging with a file

master
James Gao 2014-10-18 12:43:41 -07:00
rodzic d1e295b85e
commit 8dd97524e9
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,14 @@
import manager
import thermo
import sys
if __name__ == "__main__":
start_time = None
if len(sys.argv) > 1:
start_time = float(sys.argv[1])
schedule = [[2*60*60, 176], [4*60*60, 620], [6*60*60, 1013], [6*60*60+20*60, 1013]]
mon = thermo.Monitor()
mon.start()
#schedule = [[20, 176], [40, 620], [60, 1013]]
kiln = manager.KilnController(schedule, mon, start_time=start_time, simulate=False)
kiln.run()

Wyświetl plik

@ -59,12 +59,16 @@ class Monitor(threading.Thread):
return self.history[-1][1]
def run(self):
with open("/home/pi/data.txt", "w") as f:
f.write("time\ttemp\n")
while self.running:
temp = self._read_temp()
now = time.time()
self.history.append((now, temp))
if self.callback is not None:
self.callback(now, temp)
with open("/home/pi/data.txt", "a") as f:
f.write("%f\t%f\n"%(now, temp))
if self.display is not None:
if temp > 50: