Skip to content
Snippets Groups Projects
Commit b5c2497e authored by Alberto Nidasio's avatar Alberto Nidasio
Browse files

[MAX] Changed conversion function

parent 99e5fb3d
Branches
No related tags found
No related merge requests found
...@@ -78,12 +78,8 @@ TemperatureData MAX31855::sampleImpl() ...@@ -78,12 +78,8 @@ TemperatureData MAX31855::sampleImpl()
TemperatureData result{}; TemperatureData result{};
result.temperatureTimestamp = TimestampTimer::getInstance().getTimestamp(); result.temperatureTimestamp = TimestampTimer::getInstance().getTimestamp();
// Extract data bits
sample = sample >> 2;
// Convert the integer and decimal part separately // Convert the integer and decimal part separately
result.temperature = static_cast<float>(sample >> 2); result.temperature = static_cast<float>(sample >> 2) * 0.25;
result.temperature += static_cast<float>(sample & 0x3) * 0.25;
return result; return result;
} }
......
...@@ -79,11 +79,9 @@ TemperatureData MAX6675::sampleImpl() ...@@ -79,11 +79,9 @@ TemperatureData MAX6675::sampleImpl()
// Extract bits 14-3 // Extract bits 14-3
sample &= 0x7FF8; sample &= 0x7FF8;
sample >>= 3;
// Convert the integer and decimal part separately // Convert the integer and decimal part separately
result.temperature = static_cast<float>(sample >> 2); result.temperature += static_cast<float>(sample >> 3) * 0.25;
result.temperature += static_cast<float>(sample & 0x3) * 0.25;
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment