- refactored
git-svn-id: http://moon:8086/svn/projects/HendiControl@380 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
@@ -4,9 +4,9 @@ import spidev
|
||||
from atemperatureSensor import ATemperatureSensor
|
||||
|
||||
|
||||
class Max31865(ATemperatureSensor):
|
||||
class TempSensor_max31865(ATemperatureSensor):
|
||||
def name(self):
|
||||
return "TemperatureSensor"
|
||||
return "Max31865"
|
||||
|
||||
def __init__(self):
|
||||
# Open SPI bus
|
||||
@@ -18,7 +18,7 @@ class Max31865(ATemperatureSensor):
|
||||
self.write_reg(0x00, 0xA3)
|
||||
time.sleep(0.100)
|
||||
self.digits = 0
|
||||
self.log("Create Max31865")
|
||||
self.log("Created")
|
||||
|
||||
def read_reg(self, addr):
|
||||
reg = self.spi.xfer([addr, 0xFF])
|
||||
@@ -45,8 +45,8 @@ class Max31865(ATemperatureSensor):
|
||||
digits = self.read_digits()
|
||||
except:
|
||||
return None
|
||||
R = Max31865.calc_R(430, digits)
|
||||
T = Max31865.vanDusen_temp(R) + self.temp_correction
|
||||
R = TempSensor_max31865.calc_R(430, digits)
|
||||
T = TempSensor_max31865.vanDusen_temp(R) + self.temp_correction
|
||||
# print("R={:.3f} Ohm, T={:.2f} degC".format(R, T))
|
||||
return T
|
||||
|
||||
@@ -80,7 +80,7 @@ class Max31865(ATemperatureSensor):
|
||||
|
||||
@staticmethod
|
||||
def vanDusen_temp(Rmeas):
|
||||
RLut, TLut = Max31865.vanDusenLut(100, -150, +500, 1.0)
|
||||
RLut, TLut = TempSensor_max31865.vanDusenLut(100, -150, +500, 1.0)
|
||||
|
||||
# Find candidate
|
||||
i = 0
|
||||
@@ -108,11 +108,11 @@ class Max31865(ATemperatureSensor):
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
max31865 = Max31865()
|
||||
TempSensor_max31865 = TempSensor_max31865()
|
||||
for i in range (0, 8):
|
||||
print("Reg[0x{}]: 0x{:02X}".format(i, max31865.read_reg(i)))
|
||||
print("Reg[0x{}]: 0x{:02X}".format(i, TempSensor_max31865.read_reg(i)))
|
||||
|
||||
max31865.temperature()
|
||||
TempSensor_max31865.temperature()
|
||||
|
||||
print("End of program")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user