Skip to content
Snippets Groups Projects
Commit a20ac427 authored by Matteo Pignataro's avatar Matteo Pignataro
Browse files

[max31855] Fixed temperature sampling using 2 complement

parent 974b8309
Branches
No related tags found
No related merge requests found
......@@ -68,18 +68,19 @@ bool MAX31855::checkConnection()
TemperatureData MAX31855::sampleImpl()
{
uint16_t sample;
int16_t sample;
{
SPITransaction spi{slave};
sample = spi.read16();
sample = sample >> 2;
}
TemperatureData result{};
result.temperatureTimestamp = TimestampTimer::getTimestamp();
// Convert the integer and decimal part separately
result.temperature = static_cast<float>(sample >> 2) * 0.25;
result.temperature = static_cast<float>(sample) * 0.25;
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment