diff --git a/README.md b/README.md
index a4890ec..9b4fd24 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-SparkFun MCP9600 Arduino Library [](https://travis-ci.org/sparkfun/SparkFun_MCP9600_Arduino_Library)
+SparkFun MCP9600 Arduino Library
========================================
diff --git a/library.properties b/library.properties
index dd2487a..6224839 100644
--- a/library.properties
+++ b/library.properties
@@ -1,5 +1,5 @@
name=SparkFun MCP9600 Thermocouple Library
-version=1.0.4
+version=1.0.6
author=SparkFun Electronics
maintainer=Fischer Moseley
sentence=Driver for Microchip's MCP9600 Thermocouple Amplifier.
diff --git a/src/SparkFun_MCP9600.cpp b/src/SparkFun_MCP9600.cpp
index dbcc670..7cd1a79 100644
--- a/src/SparkFun_MCP9600.cpp
+++ b/src/SparkFun_MCP9600.cpp
@@ -83,8 +83,8 @@ bool MCP9600::checkDeviceID()
bool MCP9600::resetToDefaults()
{
bool success = writeSingleRegister(SENSOR_STATUS, 0x00);
- success |= writeSingleRegister(THERMO_SENSOR_CONFIG, 0x00);
- success |= writeSingleRegister(DEVICE_CONFIG, 0x00);
+ success |= writeSingleRegister(THERMO_SENSOR_CONFIG, 0x00); // Type-K, Filter off
+ success |= writeSingleRegister(DEVICE_CONFIG, 0x00); // 0.0625C, 18-bit, 1 sample, normal operation
success |= writeSingleRegister(ALERT1_CONFIG, 0x00);
success |= writeSingleRegister(ALERT2_CONFIG, 0x00);
success |= writeSingleRegister(ALERT3_CONFIG, 0x00);
@@ -139,7 +139,7 @@ signed long MCP9600::getRawADC()
_i2cPort->write(RAW_ADC);
_i2cPort->endTransmission();
- if (_i2cPort->requestFrom(_deviceAddress, 3) != 0)
+ if (_i2cPort->requestFrom(_deviceAddress, (uint8_t)3) != 0)
{
signed long data = _i2cPort->read() << 16;
data |= _i2cPort->read() << 8;
@@ -190,7 +190,7 @@ bool MCP9600::setThermocoupleResolution(Thermocouple_Resolution res)
Thermocouple_Resolution MCP9600::getThermocoupleResolution()
{
uint8_t config = readSingleRegister(DEVICE_CONFIG); //grab current device configuration
- uint8_t res; //define new thermocoupleResolution enum to return
+ uint8_t res = 0; //define new thermocoupleResolution enum to return
bool highResolutionBit = bitRead(config, 6);
bool lowResolutionBit = bitRead(config, 5);
bitWrite(res, 1, highResolutionBit); //set 1st bit of the enum to the 6th bit of the config register
@@ -216,7 +216,7 @@ uint8_t MCP9600::setThermocoupleType(Thermocouple_Type type)
Thermocouple_Type MCP9600::getThermocoupleType()
{
uint8_t config = readSingleRegister(THERMO_SENSOR_CONFIG);
- return static_cast(config >> 4); //clear the non-thermocouple-type bits in the config registe
+ return static_cast((config >> 4) & 0x07); //shift the thermocouple-type bits into the 3 LSB
}
uint8_t MCP9600::setFilterCoefficient(uint8_t coefficient)
@@ -226,14 +226,10 @@ uint8_t MCP9600::setFilterCoefficient(uint8_t coefficient)
uint8_t config = readSingleRegister(THERMO_SENSOR_CONFIG);
bitWrite(coefficient, 3, bitRead(config, 3));
- bitWrite(coefficient, 4, bitRead(config, 3));
- bitWrite(coefficient, 5, bitRead(config, 3));
- bitWrite(coefficient, 6, bitRead(config, 3));
- bitWrite(coefficient, 7, bitRead(config, 3));
-
- //config = config >> 3;
- //config = config << 3;
- //config |= coefficient; //set the necessary bits in the config register
+ bitWrite(coefficient, 4, bitRead(config, 4));
+ bitWrite(coefficient, 5, bitRead(config, 5));
+ bitWrite(coefficient, 6, bitRead(config, 6));
+ bitWrite(coefficient, 7, bitRead(config, 7));
return writeSingleRegister(THERMO_SENSOR_CONFIG, coefficient);
}
@@ -270,7 +266,7 @@ Burst_Sample MCP9600::getBurstSamples()
bool highResolutionBit = bitRead(config, 4);
bool midResolutionBit = bitRead(config, 3);
bool lowResolutionBit = bitRead(config, 2);
- uint8_t samples;
+ uint8_t samples = 0;
bitWrite(samples, 2, highResolutionBit); //write 4th bit of config to 2nd bit of samples
bitWrite(samples, 1, midResolutionBit); //write 3rd bit of config to 1st bit of samples
bitWrite(samples, 0, lowResolutionBit); //write 2nd bit of config to 0th bit of samples
@@ -298,7 +294,7 @@ bool MCP9600::setShutdownMode(Shutdown_Mode mode)
{
uint8_t config = readSingleRegister(DEVICE_CONFIG);
config = (config >> 2) << 2; //clear last two bits of the device config register
- config |= mode;
+ config |= mode & 0x03;
bool failed = writeSingleRegister(DEVICE_CONFIG, config); //write new config register to MCP9600
failed |= (readSingleRegister(DEVICE_CONFIG) != config); //double check that it was written properly
@@ -585,7 +581,7 @@ uint8_t MCP9600::readSingleRegister(MCP9600_Register reg)
_i2cPort->beginTransmission(_deviceAddress);
_i2cPort->write(reg);
_i2cPort->endTransmission();
- if (_i2cPort->requestFrom(_deviceAddress, 1) != 0)
+ if (_i2cPort->requestFrom(_deviceAddress, (uint8_t)1) != 0)
{
return _i2cPort->read();
}
@@ -604,7 +600,7 @@ uint16_t MCP9600::readDoubleRegister(MCP9600_Register reg)
_i2cPort->write(reg);
_i2cPort->endTransmission();
- if (_i2cPort->requestFrom(_deviceAddress, 2) != 0)
+ if (_i2cPort->requestFrom(_deviceAddress, (uint8_t)2) != 0)
{
uint16_t data = _i2cPort->read() << 8;
data |= _i2cPort->read();