- improved tempsensor exception
This commit is contained in:
@@ -2,6 +2,11 @@ import abc
|
||||
from utils.value import AttributeChange
|
||||
|
||||
|
||||
class TemperatureSensorException(Exception):
|
||||
def __init__(self, error_txt):
|
||||
Exception.__init__(self, error_txt)
|
||||
|
||||
|
||||
class ATemperatureSensor(AttributeChange):
|
||||
def __init__(self):
|
||||
AttributeChange.__init__(self)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
from components import ATemperatureSensor
|
||||
from components import ATemperatureSensor, TemperatureSensorException
|
||||
import spidev
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ class TempSensor_max31865(ATemperatureSensor):
|
||||
lsb = self.read_reg(0x02)
|
||||
if lsb & 0x01 == 0x00:
|
||||
digits = (256*msb + lsb) >> 1
|
||||
else
|
||||
raise TemperatureSensorException("Could not read sensor!")
|
||||
|
||||
self.write_reg(0x00, 0xA3)
|
||||
return digits
|
||||
|
||||
Reference in New Issue
Block a user