Library to add minimum/maximum functions for analog values

Files at this revision

API Documentation at this revision

Comitter:
masterkookus
Date:
Mon Oct 07 12:44:34 2019 +0000
Parent:
0:cdaabb616422
Commit message:
Added percent or value option

Changed in this revision

analogMinMax.cpp Show annotated file Show diff for this revision Revisions of this file
analogMinMax.h Show annotated file Show diff for this revision Revisions of this file
--- a/analogMinMax.cpp	Wed Oct 02 19:14:53 2019 +0000
+++ b/analogMinMax.cpp	Mon Oct 07 12:44:34 2019 +0000
@@ -1,12 +1,26 @@
 #include "analogMinMax.h"
 
-analogMinMax::analogMinMax(float nominalVal, bool useMinLimit, float minPercent, bool useMaxLimit, float maxPercent)
+analogMinMax::analogMinMax(float nominalVal, bool useMinLimit, bool minIsPercent, float minSetVal, bool useMaxLimit, bool maxIsPercent, float maxSetVal)
 {
     nomVal = nominalVal;
     maxLim=useMinLimit;
     minLim=useMaxLimit;
-    minLimVal = nominalVal*minPercent;
-    maxLimVal = nominalVal*maxPercent;
+    if (minIsPercent)
+    {
+        minLimVal = nominalVal*minSetVal;
+    }
+    else
+    {
+        minLimVal = minSetVal;
+    }
+    if (maxIsPercent)
+    {
+        maxLimVal = nominalVal*maxSetVal;
+    }
+    else
+    {
+        maxLimVal = maxSetVal;
+    }
 }
 
 void analogMinMax::putVal(float newval)
--- a/analogMinMax.h	Wed Oct 02 19:14:53 2019 +0000
+++ b/analogMinMax.h	Mon Oct 07 12:44:34 2019 +0000
@@ -14,7 +14,7 @@
         float nomVal;
         
     public:
-        analogMinMax(float, bool, float, bool, float);
+        analogMinMax(float, bool, bool, float, bool, bool, float);
         void putVal(float);
         float getMin(void);
         float getMax(void);