as

Dependencies:   CommonTypes ESC Matrix PID Servo kalman mbed-rtos mbed

Fork of Nucleo_MPU_9250_ by Alan Huchin Herrera

Revision:
0:89cf0851969b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MathFuncs.h	Tue Jun 26 18:24:45 2018 +0000
@@ -0,0 +1,43 @@
+/*
+ * SOURCE FILE : MathFuncs.h
+ *
+ * Definition of class MathFuncs.
+ *
+ */
+
+#ifndef MathFuncsDefined
+
+    #define MathFuncsDefined
+    
+    #include "Types.h"
+    
+    /** Various useful maths related functions. */
+    class MathFuncs {
+    
+    public :
+
+        /** Constrain a number to be between 2 values.
+         *
+         * @param x Number to constrain.
+         * @param min Minimum value.
+         * @param max Maximum value.
+         * @returns A number between min and max.
+         */
+        static Int16 Constrain( Int16 x, Int16 min, Int16 max ) {
+            if( x < min ) {
+                return min;
+            }
+            else if( x > max ) {
+                return max;
+            }
+            else {
+                return x;
+            }
+        }
+            
+    };
+
+#endif
+
+/* END of MathFuncs.h */
+