kopia lustrzana https://github.com/botheredbybees/kilnController
configuration in config.py
rodzic
30b450c9d3
commit
f706494ec3
|
@ -6,3 +6,4 @@
|
||||||
.DStore/
|
.DStore/
|
||||||
thumbs.db
|
thumbs.db
|
||||||
storage/profiles
|
storage/profiles
|
||||||
|
config.py
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log_level = logging.INFO
|
||||||
|
log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
|
||||||
|
|
||||||
|
gpio_heat = 11
|
||||||
|
gpio_cool = 10
|
||||||
|
gpio_air = 9
|
||||||
|
|
||||||
|
gpio_sensor_cs = 27
|
||||||
|
gpio_sensor_clock = 22
|
||||||
|
gpio_sensor_data = 17
|
36
oven.py
36
oven.py
|
@ -1,4 +1,5 @@
|
||||||
import threading,time,random,datetime,logging,json
|
import threading,time,random,datetime,logging,json
|
||||||
|
import config
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -9,17 +10,18 @@ except ImportError:
|
||||||
log.warning("Could not initialize temperature sensor, using dummy values!")
|
log.warning("Could not initialize temperature sensor, using dummy values!")
|
||||||
sensor_available = False
|
sensor_available = False
|
||||||
|
|
||||||
GPIO_HEAT = 11
|
config.gpio_heat = 11
|
||||||
GPIO_COOL = 10
|
config.gpio_cool = 10
|
||||||
GPIO_AIR = 9
|
config.gpio_air = 9
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
GPIO.setup(GPIO_HEAT, GPIO.OUT)
|
|
||||||
GPIO.setup(GPIO_COOL, GPIO.OUT)
|
|
||||||
GPIO.setup(GPIO_AIR, GPIO.OUT)
|
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
|
GPIO.setup(config.gpio_heat, GPIO.OUT)
|
||||||
|
GPIO.setup(config.gpio_cool, GPIO.OUT)
|
||||||
|
GPIO.setup(config.gpio_air, GPIO.OUT)
|
||||||
|
|
||||||
gpio_available = True
|
gpio_available = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
log.warning("Could not initialize GPIOs, oven operation will only be simulated!")
|
log.warning("Could not initialize GPIOs, oven operation will only be simulated!")
|
||||||
|
@ -83,31 +85,31 @@ class Oven (threading.Thread):
|
||||||
if value:
|
if value:
|
||||||
self.heat = 1.0
|
self.heat = 1.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_HEAT, GPIO.LOW)
|
GPIO.output(config.gpio_heat, GPIO.LOW)
|
||||||
else:
|
else:
|
||||||
self.heat = 0.0
|
self.heat = 0.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_HEAT, GPIO.HIGH)
|
GPIO.output(config.gpio_heat, GPIO.HIGH)
|
||||||
|
|
||||||
def set_cool(self,value):
|
def set_cool(self,value):
|
||||||
if value:
|
if value:
|
||||||
self.cool = 1.0
|
self.cool = 1.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_COOL, GPIO.LOW)
|
GPIO.output(config.gpio_cool, GPIO.LOW)
|
||||||
else:
|
else:
|
||||||
self.cool = 0.0
|
self.cool = 0.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_COOL, GPIO.HIGH)
|
GPIO.output(config.gpio_cool, GPIO.HIGH)
|
||||||
|
|
||||||
def set_air(self,value):
|
def set_air(self,value):
|
||||||
if value:
|
if value:
|
||||||
self.air = 1.0
|
self.air = 1.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_AIR, GPIO.LOW)
|
GPIO.output(config.gpio_air, GPIO.LOW)
|
||||||
else:
|
else:
|
||||||
self.air = 0.0
|
self.air = 0.0
|
||||||
if gpio_available:
|
if gpio_available:
|
||||||
GPIO.output(GPIO_AIR, GPIO.HIGH)
|
GPIO.output(config.gpio_air, GPIO.HIGH)
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
state = {
|
state = {
|
||||||
|
@ -131,11 +133,11 @@ class TempSensor(threading.Thread):
|
||||||
self.oven = oven
|
self.oven = oven
|
||||||
|
|
||||||
if sensor_available:
|
if sensor_available:
|
||||||
cs_pin = 27
|
self.thermocouple = MAX31855(gpio_sensor_cs,
|
||||||
clock_pin = 22
|
gpio_sensor_clock,
|
||||||
data_pin = 17
|
gpio_sensor_data,
|
||||||
units = "c"
|
"c"
|
||||||
self.thermocouple = MAX31855(cs_pin, clock_pin, data_pin, units)
|
)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -4,8 +4,14 @@ import bottle
|
||||||
from gevent.pywsgi import WSGIServer
|
from gevent.pywsgi import WSGIServer
|
||||||
from geventwebsocket import WebSocketHandler, WebSocketError
|
from geventwebsocket import WebSocketHandler, WebSocketError
|
||||||
|
|
||||||
log_format = '%(asctime)s %(levelname)s %(name)s: %(message)s'
|
try:
|
||||||
logging.basicConfig(level = logging.INFO, format = log_format)
|
import config
|
||||||
|
except:
|
||||||
|
print "Could not import config file."
|
||||||
|
print "Copy config.pyEXAMPLE to config.py and adapt it for your setup."
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
logging.basicConfig(level = config.log_level, format = config.log_format)
|
||||||
log = logging.getLogger("picoreflowd")
|
log = logging.getLogger("picoreflowd")
|
||||||
log.info("Starting picoreflowd")
|
log.info("Starting picoreflowd")
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue