Skip to content

byte to uint8_t for ESP8266 3.0 compatibility #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/SparkFunMLX90614.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ int16_t IRTherm::calcRawTemp(float calcTemp)
tempFloat = calcTemp;
}
// Then multiply by 0.02 degK / bit
tempFloat *= 50;
tempFloat *= 50.0;
rawTemp = (int16_t) tempFloat;
}
return rawTemp;
Expand All @@ -351,15 +351,15 @@ float IRTherm::calcTemperature(int16_t rawTemp)
retTemp -= 273.15;
if (_defaultUnit == TEMP_F)
{
retTemp = retTemp * 9.0 / 5.0 + 32;
retTemp = retTemp * 9.0 / 5.0 + 32.0;
}
}
}

return retTemp;
}

bool IRTherm::I2CReadWord(byte reg, int16_t * dest)
bool IRTherm::I2CReadWord(uint8_t reg, int16_t * dest)
{
_i2cPort->beginTransmission(_deviceAddress);
_i2cPort->write(reg);
Expand Down Expand Up @@ -388,23 +388,23 @@ bool IRTherm::I2CReadWord(byte reg, int16_t * dest)
}
}

bool IRTherm::writeEEPROM(byte reg, int16_t data)
bool IRTherm::writeEEPROM(uint8_t reg, int16_t data)
{
// Clear out EEPROM first:
if (I2CWriteWord(reg, 0) != 0)
return 0; // If the write failed, return 0
delay(5); // Delay tErase
delay(10); // Delay tErase at least 5 ms

uint8_t i2cRet = I2CWriteWord(reg, data);
delay(5); // Delay tWrite
delay(10); // Delay tWrite at least 5 ms

if (i2cRet == 0)
return true;
else
return false;
}

uint8_t IRTherm::I2CWriteWord(byte reg, int16_t data)
uint8_t IRTherm::I2CWriteWord(uint8_t reg, int16_t data)
{
uint8_t crc;
uint8_t lsb = data & 0x00FF;
Expand Down
6 changes: 3 additions & 3 deletions src/SparkFunMLX90614.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ class IRTherm

// Abstract function to write 16-bits to an address in the MLX90614's
// EEPROM
bool writeEEPROM(byte reg, int16_t data);
bool writeEEPROM(uint8_t reg, int16_t data);

// Abstract functions to read and write 16-bit values from a RAM
// or EEPROM address in the MLX90614
bool I2CReadWord(byte reg, int16_t * dest);
uint8_t I2CWriteWord(byte reg, int16_t data);
bool I2CReadWord(uint8_t reg, int16_t * dest);
uint8_t I2CWriteWord(uint8_t reg, int16_t data);

// crc8 returns a calculated crc value given an initial value and
// input data.
Expand Down