Move all floats to doubles
The code was developed initially around a pid loop implemented using
floats. Therefore, the code was converting back and forth between
double for sensor values as inputs and outputs from this PID loop.
Change-Id: I2d2919e1165103040729c9f16bb84fde3dd6b81b
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp
index ce08185..4a61def 100644
--- a/pid/fancontroller.cpp
+++ b/pid/fancontroller.cpp
@@ -39,7 +39,7 @@
return fan;
}
-float FanController::inputProc(void)
+double FanController::inputProc(void)
{
double value = 0;
std::vector<int64_t> values;
@@ -82,15 +82,15 @@
value = *result;
}
- return static_cast<float>(value);
+ return value;
}
-float FanController::setptProc(void)
+double FanController::setptProc(void)
{
- float maxRPM = _owner->getMaxRPMRequest();
+ double maxRPM = _owner->getMaxRPMRequest();
// store for reference, and check if more or less.
- float prev = getSetpoint();
+ double prev = getSetpoint();
if (maxRPM > prev)
{
@@ -110,9 +110,9 @@
return (maxRPM);
}
-void FanController::outputProc(float value)
+void FanController::outputProc(double value)
{
- float percent = value;
+ double percent = value;
/* If doing tuning logging, don't go into failsafe mode. */
#ifndef __TUNING_LOGGING__
@@ -133,7 +133,7 @@
for (const auto& it : _inputs)
{
auto sensor = _owner->getSensor(it);
- sensor->write(static_cast<double>(percent));
+ sensor->write(percent);
}
return;