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