Skip to content

Commit 8effa45

Browse files
committed
White space cleanup
1 parent ebee935 commit 8effa45

File tree

2 files changed

+61
-61
lines changed

2 files changed

+61
-61
lines changed

src/SparkFunMLX90614.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ IRTherm::IRTherm()
3131
uint8_t IRTherm::begin(uint8_t address)
3232
{
3333
_deviceAddress = address; // Store the address in a private member
34-
34+
3535
Wire.begin(); // Initialize I2C
3636
//! TODO: read a register, return success only if the register
3737
//! produced a known-good value.
@@ -104,7 +104,7 @@ uint8_t IRTherm::readObject()
104104
_rawObject = rawObj;
105105
return 1;
106106
}
107-
return 0;
107+
return 0;
108108
}
109109

110110
uint8_t IRTherm::readObject2()
@@ -122,7 +122,7 @@ uint8_t IRTherm::readObject2()
122122
_rawObject2 = rawObj;
123123
return 1;
124124
}
125-
return 0;
125+
return 0;
126126
}
127127

128128
uint8_t IRTherm::readAmbient()
@@ -174,7 +174,7 @@ uint8_t IRTherm::setMin(float minTemp)
174174
{
175175
// Convert the unit-ed value to a raw ADC value:
176176
int16_t rawMin = calcRawTemp(minTemp);
177-
// Write that value to the TOMIN EEPROM address:
177+
// Write that value to the TOMIN EEPROM address:
178178
return writeEEPROM(MLX90614_REGISTER_TOMIN, rawMin);
179179
}
180180

@@ -226,15 +226,15 @@ uint8_t IRTherm::setAddress(uint8_t newAdd)
226226
{
227227
tempAdd &= 0xFF00; // Mask out the address (MSB is junk?)
228228
tempAdd |= newAdd; // Add the new address
229-
229+
230230
// Write the new addres back to EEPROM:
231231
return writeEEPROM(MLX90614_REGISTER_ADDRESS, tempAdd);
232-
}
232+
}
233233
return 0;
234234
}
235235

236236
uint8_t IRTherm::readID(void)
237-
{
237+
{
238238
for (int i=0; i<4; i++)
239239
{
240240
int16_t temp = 0;
@@ -265,13 +265,13 @@ uint8_t IRTherm::sleep(void)
265265
// Bits sent: _deviceAddress (shifted left 1) + 0xFF
266266
uint8_t crc = crc8(0, (_deviceAddress << 1));
267267
crc = crc8(crc, MLX90614_REGISTER_SLEEP);
268-
268+
269269
// Manually send the sleep command:
270270
Wire.beginTransmission(_deviceAddress);
271271
Wire.write(MLX90614_REGISTER_SLEEP);
272272
Wire.write(crc);
273273
Wire.endTransmission(true);
274-
274+
275275
// Set the SCL pin LOW, and SDA pin HIGH (should be pulled up)
276276
pinMode(SCL, OUTPUT);
277277
digitalWrite(SCL, LOW);
@@ -299,7 +299,7 @@ uint8_t IRTherm::wake(void)
299299
int16_t IRTherm::calcRawTemp(float calcTemp)
300300
{
301301
int16_t rawTemp; // Value to eventually be returned
302-
302+
303303
if (_defaultUnit == TEMP_RAW)
304304
{
305305
// If unit is set to raw, just return that:
@@ -332,7 +332,7 @@ int16_t IRTherm::calcRawTemp(float calcTemp)
332332
float IRTherm::calcTemperature(int16_t rawTemp)
333333
{
334334
float retTemp;
335-
335+
336336
if (_defaultUnit == TEMP_RAW)
337337
{
338338
retTemp = (float) rawTemp;
@@ -349,28 +349,28 @@ float IRTherm::calcTemperature(int16_t rawTemp)
349349
}
350350
}
351351
}
352-
352+
353353
return retTemp;
354354
}
355355

356356
uint8_t IRTherm::I2CReadWord(byte reg, int16_t * dest)
357357
{
358358
Wire.beginTransmission(_deviceAddress);
359359
Wire.write(reg);
360-
360+
361361
Wire.endTransmission(false); // Send restart
362362
Wire.requestFrom(_deviceAddress, (uint8_t) 3);
363-
363+
364364
uint8_t lsb = Wire.read();
365365
uint8_t msb = Wire.read();
366366
uint8_t pec = Wire.read();
367-
367+
368368
uint8_t crc = crc8(0, (_deviceAddress << 1));
369369
crc = crc8(crc, reg);
370370
crc = crc8(crc, (_deviceAddress << 1) + 1);
371371
crc = crc8(crc, lsb);
372372
crc = crc8(crc, msb);
373-
373+
374374
if (crc == pec)
375375
{
376376
*dest = (msb << 8) | lsb;
@@ -383,32 +383,32 @@ uint8_t IRTherm::I2CReadWord(byte reg, int16_t * dest)
383383
}
384384

385385
uint8_t IRTherm::writeEEPROM(byte reg, int16_t data)
386-
{
386+
{
387387
// Clear out EEPROM first:
388388
if (I2CWriteWord(reg, 0) != 0)
389389
return 0; // If the write failed, return 0
390390
delay(5); // Delay tErase
391-
391+
392392
uint8_t i2cRet = I2CWriteWord(reg, data);
393393
delay(5); // Delay tWrite
394-
394+
395395
if (i2cRet == 0)
396396
return 1;
397397
else
398-
return 0;
398+
return 0;
399399
}
400400

401401
uint8_t IRTherm::I2CWriteWord(byte reg, int16_t data)
402402
{
403403
uint8_t crc;
404404
uint8_t lsb = data & 0x00FF;
405405
uint8_t msb = (data >> 8);
406-
406+
407407
crc = crc8(0, (_deviceAddress << 1));
408408
crc = crc8(crc, reg);
409409
crc = crc8(crc, lsb);
410410
crc = crc8(crc, msb);
411-
411+
412412
Wire.beginTransmission(_deviceAddress);
413413
Wire.write(reg);
414414
Wire.write(lsb);

src/SparkFunMLX90614.h

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/******************************************************************************
1+
/******************************************************************************
22
SparkFunMLX90614.h
33
Header file for the SparkFun IR Thermometer Library
44
@@ -53,134 +53,134 @@ typedef enum {
5353
TEMP_F
5454
} temperature_units;
5555

56-
class IRTherm
56+
class IRTherm
5757
{
5858
public:
5959
// Default constructor, does very little besides setting class variable
6060
// initial values.
6161
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
6565
// address.
6666
// If no parameter is supplied, the default MLX90614 address is used.
6767
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
7171
// units the setMin() and setMax() functions should expect.
7272
// <unit> can be either:
7373
// - TEMP_RAW: No conversion, just the raw 12-bit ADC reading
7474
// - TEMP_K: Kelvin
7575
// - TEMP_C: Celsius
7676
// - TEMP_F: Farenheit
7777
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
8181
// can result from either a timed out I2C transmission, or an incorrect
8282
// checksum value).
8383
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
8686
// after the read() function has returned successfully. The float value
8787
// returned will be in the units specified by setUnit().
8888
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
9191
// after the read() function has returned successfully. The float value
9292
// returned will be in the units specified by setUnit().
9393
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
9696
// return a value between 0.1 and 1.0.
9797
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
100100
// EEPROM value.
101101
// The <emis> parameter should be a value between 0.1 and 1.0.
102102
// The function will return either 1 on success or 0 on failure.
103103
uint8_t setEmissivity(float emis);
104-
104+
105105
// readAddress() returns the MLX90614's configured 7-bit I2C bus address.
106106
// A value between 0x01 and 0x7F should be returned.
107107
uint8_t readAddress(void);
108-
108+
109109
// setAddress(<newAdd>) can set the MLX90614's 7-bit I2C bus address.
110110
// The <newAdd> parameter should be a value between 0x01 and 0x7F.
111111
// The function returns 1 on success and 0 on failure.
112112
// The new address won't take effect until the device is reset.
113113
uint8_t setAddress(uint8_t newAdd);
114-
114+
115115
// readID() reads the 64-bit ID of the MLX90614.
116116
// Return value is either 1 on success or 0 on failure.
117117
uint8_t readID(void);
118-
118+
119119
// After calling readID() getIDH() and getIDL() can be called to read
120120
// the upper 4 bytes and lower 4-bytes, respectively, of the MLX90614's
121121
// identification registers.
122122
uint32_t getIDH(void);
123123
uint32_t getIDL(void);
124-
124+
125125
// readRange() pulls the object maximum and minimum values stored in the
126126
// MLX90614's EEPROM.
127127
// It will return either 1 on success or 0 on failure.
128128
uint8_t readRange(void);
129-
129+
130130
// minimum() and maximum() return the MLX90614's minimum and maximum object
131131
// sensor readings.
132132
// The float values returned will be in the units specified by setUnit().
133133
float minimum(void);
134134
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
137137
// maximum and minimum object sensor temperatures.
138138
uint8_t setMax(float maxTemp);
139139
uint8_t setMin(float minTemp);
140-
140+
141141
// sleep() sets the MLX90614 into a low-power sleep mode.
142142
uint8_t sleep(void);
143-
143+
144144
// wake() should revive the MLX90614 from low-power sleep mode.
145145
uint8_t wake(void);
146-
146+
147147
private:
148148
uint8_t _deviceAddress; // MLX90614's 7-bit I2C address
149149
temperature_units _defaultUnit; // Keeps track of configured temperature unit
150-
150+
151151
// These keep track of the raw temperature values read from the sensor:
152152
int16_t _rawAmbient, _rawObject, _rawObject2, _rawMax, _rawMin;
153-
153+
154154
uint16_t id[4]; // Keeps track of the 64-bit ID value
155-
155+
156156
// These functions individually read the object, object2, and ambient
157157
// temperature values from the MLX90614's RAM:
158158
uint8_t readObject(void);
159159
uint8_t readObject2(void);
160160
uint8_t readAmbient(void);
161-
161+
162162
// These functions individually read the min and mx temperatures in
163163
// the MLX90614's EEPROM:
164164
uint8_t readMax(void);
165165
uint8_t readMin(void);
166-
166+
167167
// calcTemperature converts a raw ADC temperature reading to the
168168
// set unit.
169169
float calcTemperature(int16_t rawTemp);
170-
170+
171171
// calcRawTemperature converts a set unit temperature to a
172172
// raw ADC value:
173173
int16_t calcRawTemp(float calcTemp);
174-
174+
175175
// Abstract function to write 16-bits to an address in the MLX90614's
176176
// EEPROM
177177
uint8_t writeEEPROM(byte reg, int16_t data);
178-
178+
179179
// Abstract functions to read and write 16-bit values from a RAM
180180
// or EEPROM address in the MLX90614
181181
uint8_t I2CReadWord(byte reg, int16_t * dest);
182182
uint8_t I2CWriteWord(byte reg, int16_t data);
183-
183+
184184
// crc8 returns a calculated crc value given an initial value and
185185
// input data.
186186
// It's configured to calculate the CRC using a x^8+x^2+x^1+1 poly

0 commit comments

Comments
 (0)