reading onewire sensors
This commit is contained in:
17
controller/drivers/onewire/__init__.py
Normal file
17
controller/drivers/onewire/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import re
|
||||
|
||||
def read_one_thermo(filename):
|
||||
NO_OF_DECIMALS = 3
|
||||
textfile = open(filename, 'r')
|
||||
filetext = textfile.read()
|
||||
textfile.close()
|
||||
matches = re.findall("t=(\d+)", filetext)
|
||||
return int(matches[0][0:-NO_OF_DECIMALS]) + (int(matches[0][-NO_OF_DECIMALS:]) / 1000.0)
|
||||
|
||||
def read_many_thermo(filenames):
|
||||
result = []
|
||||
for filename in list(filenames):
|
||||
if filename is None:
|
||||
continue
|
||||
result.append(read_one_thermo(filename))
|
||||
return result
|
||||
Reference in New Issue
Block a user