diff --git a/lib/max31856.py b/lib/max31856.py index 4a3841b..f6ade00 100644 --- a/lib/max31856.py +++ b/lib/max31856.py @@ -119,7 +119,7 @@ class MAX31856(object): # Handle hardware SPI if hardware_spi is not None: self._logger.debug('Using hardware SPI') - self._spi = hardware_spi + self._spi = SPI.SpiDev(hardware_spi['port'], hardware_spi['device']) elif software_spi is not None: self._logger.debug('Using software SPI') # Default to platform GPIO if not provided. diff --git a/lib/oven.py b/lib/oven.py index 7503fac..628ad60 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -133,12 +133,22 @@ class TempSensorReal(TempSensor): if config.max31856: log.info("init MAX31856") from max31856 import MAX31856 - software_spi = { 'cs': config.gpio_sensor_cs, - 'clk': config.gpio_sensor_clock, - 'do': config.gpio_sensor_data, - 'di': config.gpio_sensor_di } + if config.gpio_spi: + log.info("using software SPI") + software_spi = {'cs': config.gpio_sensor_cs, + 'clk': config.gpio_sensor_clock, + 'do': config.gpio_sensor_data, + 'di': config.gpio_sensor_di } + hardware_spi = None + else: + log.info("using hardware SPI") + software_spi = None + hardware_spi = {'port': config.spi_port, + 'device': config.spi_device} + self.thermocouple = MAX31856(tc_type=config.thermocouple_type, software_spi = software_spi, + hardware_spi = hardware_spi, units = config.temp_scale, ac_freq_50hz = config.ac_freq_50hz, ) diff --git a/lib/ovenDisplay.py b/lib/ovenDisplay.py new file mode 100644 index 0000000..0eed90b --- /dev/null +++ b/lib/ovenDisplay.py @@ -0,0 +1,35 @@ +import threading,logging,json,time,datetime +from oven import Oven +log = logging.getLogger(__name__) + +class OvenDisplay(threading.Thread): + def __init__(self,oven,ovenWatcher): + self.last_profile = None + self.last_log = [] + self.started = None + self.recording = False + self.observers = [] + threading.Thread.__init__(self) + self.daemon = True + self.oven = oven + self.ovenWatcher = ovenWatcher + ovenWatcher.add_observer(self) + # TODO - move to config + self.sleep_time = 0.1 + self.start() + + def run(self): + while True: + #oven_state = self.oven.get_state() + #update_display(oven_state) + time.sleep(self.sleep_time) + + def update_display(self, oven_state): + log.info(oven_state) + + def send(self,oven_state): + self.update_display(oven_state) + + + + \ No newline at end of file