Skip to content

Commit ec07ae5

Browse files
authored
Merge pull request #35 from resterampeberlin/master
Added threshold handling
2 parents c23a980 + 89afc45 commit ec07ae5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Adafruit_MAX31865.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bool Adafruit_MAX31865::begin(max31865_numwires_t wires) {
6161
setWires(wires);
6262
enableBias(false);
6363
autoConvert(false);
64+
setThresholds(0, 0xFFFF);
6465
clearFault();
6566

6667
// Serial.print("config: ");
@@ -139,6 +140,41 @@ void Adafruit_MAX31865::enable50Hz(bool b) {
139140
writeRegister8(MAX31865_CONFIG_REG, t);
140141
}
141142

143+
/**************************************************************************/
144+
/*!
145+
@brief Write the lower and upper values into the threshold fault
146+
register to values as returned by readRTD()
147+
@param lower raw lower threshold
148+
@param upper raw upper threshold
149+
*/
150+
/**************************************************************************/
151+
void Adafruit_MAX31865::setThresholds(uint16_t lower, uint16_t upper) {
152+
writeRegister8(MAX31865_LFAULTLSB_REG, lower & 0xFF);
153+
writeRegister8(MAX31865_LFAULTMSB_REG, lower >> 8);
154+
writeRegister8(MAX31865_HFAULTLSB_REG, upper & 0xFF);
155+
writeRegister8(MAX31865_HFAULTMSB_REG, upper >> 8);
156+
}
157+
158+
/**************************************************************************/
159+
/*!
160+
@brief Read the raw 16-bit lower threshold value
161+
@return The raw unsigned 16-bit value, NOT temperature!
162+
*/
163+
/**************************************************************************/
164+
uint16_t Adafruit_MAX31865::getLowerThreshold(void) {
165+
return readRegister16(MAX31865_LFAULTMSB_REG);
166+
}
167+
168+
/**************************************************************************/
169+
/*!
170+
@brief Read the raw 16-bit lower threshold value
171+
@return The raw unsigned 16-bit value, NOT temperature!
172+
*/
173+
/**************************************************************************/
174+
uint16_t Adafruit_MAX31865::getUpperThreshold(void) {
175+
return readRegister16(MAX31865_HFAULTMSB_REG);
176+
}
177+
142178
/**************************************************************************/
143179
/*!
144180
@brief How many wires we have in our RTD setup, can be MAX31865_2WIRE,

Adafruit_MAX31865.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class Adafruit_MAX31865 {
7373
void clearFault(void);
7474
uint16_t readRTD();
7575

76+
void setThresholds(uint16_t lower, uint16_t upper);
77+
uint16_t getLowerThreshold(void);
78+
uint16_t getUpperThreshold(void);
79+
7680
void setWires(max31865_numwires_t wires);
7781
void autoConvert(bool b);
7882
void enable50Hz(bool b);

0 commit comments

Comments
 (0)