|
1 |
| -/****************************************************************************** |
| 1 | +/****************************************************************************** |
2 | 2 | SparkFunMLX90614.h
|
3 | 3 | Header file for the SparkFun IR Thermometer Library
|
4 | 4 |
|
@@ -53,134 +53,134 @@ typedef enum {
|
53 | 53 | TEMP_F
|
54 | 54 | } temperature_units;
|
55 | 55 |
|
56 |
| -class IRTherm |
| 56 | +class IRTherm |
57 | 57 | {
|
58 | 58 | public:
|
59 | 59 | // Default constructor, does very little besides setting class variable
|
60 | 60 | // initial values.
|
61 | 61 | IRTherm();
|
62 |
| - |
63 |
| - // begin(<address>) initializes the Wire library, and prepares |
64 |
| - // communication with an MLX90614 device at the specified 7-bit I2C |
| 62 | + |
| 63 | + // begin(<address>) initializes the Wire library, and prepares |
| 64 | + // communication with an MLX90614 device at the specified 7-bit I2C |
65 | 65 | // address.
|
66 | 66 | // If no parameter is supplied, the default MLX90614 address is used.
|
67 | 67 | uint8_t begin(uint8_t address = MLX90614_DEFAULT_ADDRESS);
|
68 |
| - |
69 |
| - // setUnit(<unit>) configures the units returned by the ambient(), |
70 |
| - // object(), minimum() and maximum() functions, and it determines what |
| 68 | + |
| 69 | + // setUnit(<unit>) configures the units returned by the ambient(), |
| 70 | + // object(), minimum() and maximum() functions, and it determines what |
71 | 71 | // units the setMin() and setMax() functions should expect.
|
72 | 72 | // <unit> can be either:
|
73 | 73 | // - TEMP_RAW: No conversion, just the raw 12-bit ADC reading
|
74 | 74 | // - TEMP_K: Kelvin
|
75 | 75 | // - TEMP_C: Celsius
|
76 | 76 | // - TEMP_F: Farenheit
|
77 | 77 | void setUnit(temperature_units unit);
|
78 |
| - |
79 |
| - // read() pulls the latest ambient and object temperatures from the |
80 |
| - // MLX90614. It will return either 1 on success or 0 on failure. (Failure |
| 78 | + |
| 79 | + // read() pulls the latest ambient and object temperatures from the |
| 80 | + // MLX90614. It will return either 1 on success or 0 on failure. (Failure |
81 | 81 | // can result from either a timed out I2C transmission, or an incorrect
|
82 | 82 | // checksum value).
|
83 | 83 | uint8_t read(void);
|
84 |
| - |
85 |
| - // object() returns the MLX90614's most recently read object temperature |
| 84 | + |
| 85 | + // object() returns the MLX90614's most recently read object temperature |
86 | 86 | // after the read() function has returned successfully. The float value
|
87 | 87 | // returned will be in the units specified by setUnit().
|
88 | 88 | float object(void);
|
89 |
| - |
90 |
| - // ambient() returns the MLX90614's most recently read ambient temperature |
| 89 | + |
| 90 | + // ambient() returns the MLX90614's most recently read ambient temperature |
91 | 91 | // after the read() function has returned successfully. The float value
|
92 | 92 | // returned will be in the units specified by setUnit().
|
93 | 93 | float ambient(void);
|
94 |
| - |
95 |
| - // readEmissivity() reads the MLX90614's emissivity setting. It will |
| 94 | + |
| 95 | + // readEmissivity() reads the MLX90614's emissivity setting. It will |
96 | 96 | // return a value between 0.1 and 1.0.
|
97 | 97 | float readEmissivity(void);
|
98 |
| - |
99 |
| - // setEmissivity(<emis>) can set the MLX90614's configured emissivity |
| 98 | + |
| 99 | + // setEmissivity(<emis>) can set the MLX90614's configured emissivity |
100 | 100 | // EEPROM value.
|
101 | 101 | // The <emis> parameter should be a value between 0.1 and 1.0.
|
102 | 102 | // The function will return either 1 on success or 0 on failure.
|
103 | 103 | uint8_t setEmissivity(float emis);
|
104 |
| - |
| 104 | + |
105 | 105 | // readAddress() returns the MLX90614's configured 7-bit I2C bus address.
|
106 | 106 | // A value between 0x01 and 0x7F should be returned.
|
107 | 107 | uint8_t readAddress(void);
|
108 |
| - |
| 108 | + |
109 | 109 | // setAddress(<newAdd>) can set the MLX90614's 7-bit I2C bus address.
|
110 | 110 | // The <newAdd> parameter should be a value between 0x01 and 0x7F.
|
111 | 111 | // The function returns 1 on success and 0 on failure.
|
112 | 112 | // The new address won't take effect until the device is reset.
|
113 | 113 | uint8_t setAddress(uint8_t newAdd);
|
114 |
| - |
| 114 | + |
115 | 115 | // readID() reads the 64-bit ID of the MLX90614.
|
116 | 116 | // Return value is either 1 on success or 0 on failure.
|
117 | 117 | uint8_t readID(void);
|
118 |
| - |
| 118 | + |
119 | 119 | // After calling readID() getIDH() and getIDL() can be called to read
|
120 | 120 | // the upper 4 bytes and lower 4-bytes, respectively, of the MLX90614's
|
121 | 121 | // identification registers.
|
122 | 122 | uint32_t getIDH(void);
|
123 | 123 | uint32_t getIDL(void);
|
124 |
| - |
| 124 | + |
125 | 125 | // readRange() pulls the object maximum and minimum values stored in the
|
126 | 126 | // MLX90614's EEPROM.
|
127 | 127 | // It will return either 1 on success or 0 on failure.
|
128 | 128 | uint8_t readRange(void);
|
129 |
| - |
| 129 | + |
130 | 130 | // minimum() and maximum() return the MLX90614's minimum and maximum object
|
131 | 131 | // sensor readings.
|
132 | 132 | // The float values returned will be in the units specified by setUnit().
|
133 | 133 | float minimum(void);
|
134 | 134 | float maximum(void);
|
135 |
| - |
136 |
| - // setMax(<maxTemp>) and setMin(<minTemp>) configure the MLX90614's |
| 135 | + |
| 136 | + // setMax(<maxTemp>) and setMin(<minTemp>) configure the MLX90614's |
137 | 137 | // maximum and minimum object sensor temperatures.
|
138 | 138 | uint8_t setMax(float maxTemp);
|
139 | 139 | uint8_t setMin(float minTemp);
|
140 |
| - |
| 140 | + |
141 | 141 | // sleep() sets the MLX90614 into a low-power sleep mode.
|
142 | 142 | uint8_t sleep(void);
|
143 |
| - |
| 143 | + |
144 | 144 | // wake() should revive the MLX90614 from low-power sleep mode.
|
145 | 145 | uint8_t wake(void);
|
146 |
| - |
| 146 | + |
147 | 147 | private:
|
148 | 148 | uint8_t _deviceAddress; // MLX90614's 7-bit I2C address
|
149 | 149 | temperature_units _defaultUnit; // Keeps track of configured temperature unit
|
150 |
| - |
| 150 | + |
151 | 151 | // These keep track of the raw temperature values read from the sensor:
|
152 | 152 | int16_t _rawAmbient, _rawObject, _rawObject2, _rawMax, _rawMin;
|
153 |
| - |
| 153 | + |
154 | 154 | uint16_t id[4]; // Keeps track of the 64-bit ID value
|
155 |
| - |
| 155 | + |
156 | 156 | // These functions individually read the object, object2, and ambient
|
157 | 157 | // temperature values from the MLX90614's RAM:
|
158 | 158 | uint8_t readObject(void);
|
159 | 159 | uint8_t readObject2(void);
|
160 | 160 | uint8_t readAmbient(void);
|
161 |
| - |
| 161 | + |
162 | 162 | // These functions individually read the min and mx temperatures in
|
163 | 163 | // the MLX90614's EEPROM:
|
164 | 164 | uint8_t readMax(void);
|
165 | 165 | uint8_t readMin(void);
|
166 |
| - |
| 166 | + |
167 | 167 | // calcTemperature converts a raw ADC temperature reading to the
|
168 | 168 | // set unit.
|
169 | 169 | float calcTemperature(int16_t rawTemp);
|
170 |
| - |
| 170 | + |
171 | 171 | // calcRawTemperature converts a set unit temperature to a
|
172 | 172 | // raw ADC value:
|
173 | 173 | int16_t calcRawTemp(float calcTemp);
|
174 |
| - |
| 174 | + |
175 | 175 | // Abstract function to write 16-bits to an address in the MLX90614's
|
176 | 176 | // EEPROM
|
177 | 177 | uint8_t writeEEPROM(byte reg, int16_t data);
|
178 |
| - |
| 178 | + |
179 | 179 | // Abstract functions to read and write 16-bit values from a RAM
|
180 | 180 | // or EEPROM address in the MLX90614
|
181 | 181 | uint8_t I2CReadWord(byte reg, int16_t * dest);
|
182 | 182 | uint8_t I2CWriteWord(byte reg, int16_t data);
|
183 |
| - |
| 183 | + |
184 | 184 | // crc8 returns a calculated crc value given an initial value and
|
185 | 185 | // input data.
|
186 | 186 | // It's configured to calculate the CRC using a x^8+x^2+x^1+1 poly
|
|
0 commit comments