mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.1.05 2015-07-12 refactor robust constructor
This commit is contained in:
parent
1f3495a4b2
commit
7993100516
@ -1,12 +1,13 @@
|
||||
//
|
||||
// FILE: MAX31855.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.04
|
||||
// VERSION: 0.1.05
|
||||
// PURPOSE: MAX31855 - Thermocouple
|
||||
// DATE: 2014-01-01
|
||||
// URL:
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.05 2015-07-12 refactor robust constructor
|
||||
// 0.1.04 2015-03-09 replaced float -> double (ARM support)
|
||||
// 0.1.03 fixed negative temperature
|
||||
// 0.1.02 added offset
|
||||
@ -24,6 +25,9 @@ MAX31855::MAX31855(uint8_t sclk, uint8_t cs, uint8_t miso)
|
||||
_cs = cs;
|
||||
_miso = miso;
|
||||
_offset = 0;
|
||||
_status = STATUS_NOREAD;
|
||||
_temperature = -999;
|
||||
_internal = -999;
|
||||
}
|
||||
|
||||
void MAX31855::begin()
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FILE: MAX31855.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.04
|
||||
// VERSION: 0.1.05
|
||||
// PURPOSE: MAX31855 - Thermocouple
|
||||
// DATE: 2014-01-01
|
||||
// URL:
|
||||
@ -17,12 +17,14 @@
|
||||
#include "Arduino.h"
|
||||
#endif
|
||||
|
||||
#define MAX31855_VERSION "0.1.04"
|
||||
#define MAX31855_VERSION "0.1.05"
|
||||
|
||||
#define STATUS_OK 0x00
|
||||
#define STATUS_OPEN_CIRCUIT 0x01
|
||||
#define STATUS_SHORT_TO_GND 0x02
|
||||
#define STATUS_SHORT_TO_VCC 0x04
|
||||
#define STATUS_NOREAD 0x80
|
||||
|
||||
|
||||
class MAX31855
|
||||
{
|
||||
@ -32,12 +34,13 @@ public:
|
||||
|
||||
uint8_t read();
|
||||
|
||||
double getInternal(void) { return _internal; };
|
||||
double getTemperature(void) { return _temperature; };
|
||||
uint8_t getStatus(void) { return _status; };
|
||||
double getInternal(void) const { return _internal; };
|
||||
double getTemperature(void) const { return _temperature; };
|
||||
|
||||
void setOffset(double t) { _offset = t; };
|
||||
double getOffset() { return _offset; };
|
||||
uint8_t getStatus(void) const { return _status; };
|
||||
|
||||
void setOffset(const double t) { _offset = t; };
|
||||
double getOffset() const { return _offset; };
|
||||
|
||||
private:
|
||||
uint32_t _read();
|
||||
|
@ -20,11 +20,10 @@ bit 0 set = thermocouple open circuit
|
||||
bit 1 set = thermocouple short to GND
|
||||
bit 2 set = thermocouple short to VCC
|
||||
|
||||
|
||||
After a tc.read() you can do tc.getTemperature() and tc.getInternal().
|
||||
repeated getTemperature() will give the same value until a new tc.read();
|
||||
|
||||
The reason for this is that it allows the object holds its last known temperature.
|
||||
The reason for this is that it allows the object to hold its last known temperature.
|
||||
Now one can do:
|
||||
|
||||
float last = tc.getTemperature();
|
||||
|
Loading…
Reference in New Issue
Block a user