Test the set param mode

Dependencies:   FastPWM3

Revision:
47:e1196a851f76
Parent:
34:51647c6c500d
diff -r 2d4b1dafcfe3 -r e1196a851f76 math_ops.cpp
--- a/math_ops.cpp	Thu Jul 12 02:50:34 2018 +0000
+++ b/math_ops.cpp	Wed Dec 05 04:07:46 2018 +0000
@@ -1,5 +1,5 @@
 
-#include "math_ops.h"
+#include "../math_ops.h"
 
 
 float fmaxf(float x, float y){
@@ -36,14 +36,21 @@
         *y = *y * limit/norm;
         }
     }
+    
+void limit(float *x, float min, float max){
+    *x = fmaxf(fminf(*x, max), min);
+    }
 
 int float_to_uint(float x, float x_min, float x_max, int bits){
+    /// Converts a float to an unsigned int, given range and number of bits ///
     float span = x_max - x_min;
     float offset = x_min;
-    return (int) ((x+offset)*((float)((1<<bits)-1))/span);
+    return (int) ((x-offset)*((float)((1<<bits)-1))/span);
     }
     
+    
 float uint_to_float(int x_int, float x_min, float x_max, int bits){
+    /// converts unsigned int to float, given range and number of bits ///
     float span = x_max - x_min;
     float offset = x_min;
     return ((float)x_int)*span/((float)((1<<bits)-1)) + offset;