Utility library for MTS Socket Modem Arduino Shield devices from Multi-Tech Systems

Dependents:   mtsas mtsas thermostat_fan_demo--fan mtsas ... more

NOTE: MTS-Utils has moved to GitHub. This version will not be updated. For updates, go to the GitHub version.

Files at this revision

API Documentation at this revision

Comitter:
Mike Fiore
Date:
Mon May 19 14:39:33 2014 -0500
Parent:
4:f4d3bafc71dd
Child:
6:fca9bc67b15f
Commit message:
add Utils.h, replace inclusion of Vars.h with Utils.h

Changed in this revision

MTSCircularBuffer.h Show annotated file Show diff for this revision Revisions of this file
Test/TestMTSCircularBuffer.h Show annotated file Show diff for this revision Revisions of this file
Utils.h Show annotated file Show diff for this revision Revisions of this file
--- a/MTSCircularBuffer.h	Mon May 19 12:37:38 2014 -0500
+++ b/MTSCircularBuffer.h	Mon May 19 14:39:33 2014 -0500
@@ -2,7 +2,7 @@
 #define MTSCIRCULARBUFFER_H
 
 #include "mbed.h"
-#include "Vars.h"
+#include "Utils.h"
 
 namespace mts
 {
--- a/Test/TestMTSCircularBuffer.h	Mon May 19 12:37:38 2014 -0500
+++ b/Test/TestMTSCircularBuffer.h	Mon May 19 14:39:33 2014 -0500
@@ -2,7 +2,6 @@
 #define TESTMTSCIRCULARBUFFER_H
 
 #include "MTSCircularBuffer.h"
-#include "Vars.h"
 
 
 /* unit tests for the circular buffer class */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Utils.h	Mon May 19 14:39:33 2014 -0500
@@ -0,0 +1,45 @@
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <string>
+
+//Defines a max function that can be used.
+#ifndef MAX
+#define MAX(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
+#endif
+
+//Defines a min function that can be used.
+#ifndef MIN
+#define MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
+#endif
+
+///An enumeration for relational operators
+enum RelationalOperator {
+    GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL
+};
+
+/** A static method for getting a string representation for the RelationalOperator
+* enumeration.
+*
+* @param relationalOperator a RelationalOperator enumeration.
+* @returns the enumeration name as a string.
+*/
+static std::string getRelationalOperatorNames(RelationalOperator relationalOperator)
+{
+    switch(relationalOperator) {
+        case GREATER:
+            return "GREATER";
+        case LESS:
+            return "LESS";
+        case EQUAL:
+            return "EQUAL";
+        case GREATER_EQUAL:
+            return "GREATER_EQUAL";
+        case LESS_EQUAL:
+            return "LESS_EQUAL";
+        default:
+            return "UNKNOWN ENUM";
+    }
+}
+
+#endif