-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for kernel spi (not bitbang) MAX38155 interface
- Loading branch information
1 parent
c6b5ca1
commit 87778d8
Showing
5 changed files
with
65 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
thumbs.db | ||
storage/profiles | ||
config.py | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python | ||
from Adafruit_MAX31855 import MAX31855 | ||
|
||
class MAX31855SPI(object): | ||
'''Python driver for [MAX38155 Cold-Junction Compensated Thermocouple-to-Digital Converter](http://www.maximintegrated.com/datasheet/index.mvp/id/7273) | ||
Requires: | ||
- adafruit's MAX31855 SPI-only device library | ||
''' | ||
def __init__(self, spi_dev): | ||
self.max31855 = MAX31855.MAX31855(spi=spi_dev) | ||
|
||
def get(self): | ||
'''Reads SPI bus and returns current value of thermocouple.''' | ||
state = self.max31855.readState() | ||
if state['openCircuit']: | ||
raise MAX31855Error('Not Connected') | ||
elif state['shortGND']: | ||
raise MAX31855Error('Short to Ground') | ||
elif state['shortVCC']: | ||
raise MAX31855Error('Short to VCC') | ||
elif state['fault']: | ||
raise MAX31855Error('Unknown Error') | ||
return self.max31855.readLinearizedTempC() | ||
|
||
|
||
class MAX31855SPIError(Exception): | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
def __str__(self): | ||
return repr(self.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adafruit-MAX31855>=1.6.1 |