Scale ADC readings to 3 decimal places

We we're giving way too many sigfigs.

Change-Id: I2925667a94d4f86012dd076079086f3879a07859
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/ADCSensor.cpp b/src/ADCSensor.cpp
index 4ce6dda..7015d4c 100644
--- a/src/ADCSensor.cpp
+++ b/src/ADCSensor.cpp
@@ -32,6 +32,8 @@
 // scaling factor from hwmon
 static constexpr unsigned int sensorScaleFactor = 1000;
 
+static constexpr double roundFactor = 10000; // 3 decimal places
+
 ADCSensor::ADCSensor(const std::string &path,
                      sdbusplus::asio::object_server &objectServer,
                      std::shared_ptr<sdbusplus::asio::connection> &conn,
@@ -100,12 +102,16 @@
         // todo read scaling factors from configuration
         try
         {
-            float nvalue = std::stof(response);
+            double nvalue = std::stof(response);
+
             nvalue = (nvalue / sensorScaleFactor) / scaleFactor;
+            nvalue = std::round(nvalue * roundFactor) / roundFactor;
+
             if (!isnan(overriddenValue))
             {
                 nvalue = overriddenValue;
             }
+
             if (nvalue != value)
             {
                 updateValue(nvalue);
@@ -221,8 +227,9 @@
             std::cout << "trying to set uninitialized interface\n";
             continue;
         }
+
         iface->register_property(
-            level, threshold.value,
+            level, std::round(threshold.value * roundFactor) / roundFactor,
             [&](const double &request, double &oldValue) {
                 oldValue = request; // todo, just let the config do this?
                 threshold.value = request;