forked from brycesub/silvia-pi
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.py
executable file
·57 lines (44 loc) · 1.28 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
import jsonpickle
filename = '/home/pi/silvia-pi/conf.json'
class Config:
def __init__(self):
pass
def set_defaults(self):
# Sensor pins. Not using SPI because spi1 bus is busted and spi0 is used by PiTFT
self.SCK = 21
self.MISO = 19
self.MOSI = 20
self.CS = 5
# Pin # for relay connected to heating element
self.he_pins = [12, 16]
# Default goal temperature
self.celsius = True
self.set_temp = 96.
# Default alarm time
self.snooze = '07:00'
# Main loop sample rate in seconds
self.sample_time = 0.3
# PID Proportional, Integral, and Derivative values
self.Pc = 4
self.Ic = 0.3
self.Dc = 60.0
self.Sc = 0.5
self.windup = 20.0
#Web/REST Server Options
self.port = 8080
#kivy options
self.refresh_rate = 1./5.
self.fps = 1./self.refresh_rate
self.seconds_to_display = 10
def save(self):
with open(filename, 'w') as f:
f.write(jsonpickle.encode(self))
config = None
try:
with open(filename, 'r') as f:
config = jsonpickle.decode(f.read())
except Exception as e:
print(e)
config = Config()
config.set_defaults()