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
No related branches found
No related tags found
1 merge request!125[max31855] Fixed temperature sampling using 2 complement
Pipeline #5091 passed
...@@ -68,18 +68,19 @@ bool MAX31855::checkConnection() ...@@ -68,18 +68,19 @@ bool MAX31855::checkConnection()
TemperatureData MAX31855::sampleImpl() TemperatureData MAX31855::sampleImpl()
{ {
uint16_t sample; int16_t sample;
{ {
SPITransaction spi{slave}; SPITransaction spi{slave};
sample = spi.read16(); sample = spi.read16();
sample = sample >> 2;
} }
TemperatureData result{}; TemperatureData result{};
result.temperatureTimestamp = TimestampTimer::getTimestamp(); result.temperatureTimestamp = TimestampTimer::getTimestamp();
// Convert the integer and decimal part separately // 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; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment