Library for LoRa communication using MultiTech MDOT.
Fork of libmDot by
Utils.h@1:9f30fbe9e9c1, 2015-06-24 (annotated)
- Committer:
- Mike Fiore
- Date:
- Wed Jun 24 17:03:08 2015 -0500
- Revision:
- 1:9f30fbe9e9c1
add README, LICENSE, headers, and library - from git tag mbed_24June2015
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:9f30fbe9e9c1 | 1 | /************************************************ |
Mike Fiore |
1:9f30fbe9e9c1 | 2 | * MultiTech MTDOT Library |
Mike Fiore |
1:9f30fbe9e9c1 | 3 | * Copyright (c) 2015 MultiTech Systems |
Mike Fiore |
1:9f30fbe9e9c1 | 4 | * |
Mike Fiore |
1:9f30fbe9e9c1 | 5 | * See LICENSE file for license information |
Mike Fiore |
1:9f30fbe9e9c1 | 6 | ***********************************************/ |
Mike Fiore |
1:9f30fbe9e9c1 | 7 | |
Mike Fiore |
1:9f30fbe9e9c1 | 8 | #ifndef UTILS_H |
Mike Fiore |
1:9f30fbe9e9c1 | 9 | #define UTILS_H |
Mike Fiore |
1:9f30fbe9e9c1 | 10 | |
Mike Fiore |
1:9f30fbe9e9c1 | 11 | #include <string> |
Mike Fiore |
1:9f30fbe9e9c1 | 12 | |
Mike Fiore |
1:9f30fbe9e9c1 | 13 | //Defines a max function that can be used. |
Mike Fiore |
1:9f30fbe9e9c1 | 14 | inline int mts_max(int a, int b) { return a > b ? a : b; } |
Mike Fiore |
1:9f30fbe9e9c1 | 15 | |
Mike Fiore |
1:9f30fbe9e9c1 | 16 | //Defines a min function that can be used. |
Mike Fiore |
1:9f30fbe9e9c1 | 17 | inline int mts_min(int a, int b) { return a < b ? a : b; } |
Mike Fiore |
1:9f30fbe9e9c1 | 18 | |
Mike Fiore |
1:9f30fbe9e9c1 | 19 | ///An enumeration for relational operators |
Mike Fiore |
1:9f30fbe9e9c1 | 20 | enum RelationalOperator { |
Mike Fiore |
1:9f30fbe9e9c1 | 21 | GREATER, LESS, EQUAL, GREATER_EQUAL, LESS_EQUAL |
Mike Fiore |
1:9f30fbe9e9c1 | 22 | }; |
Mike Fiore |
1:9f30fbe9e9c1 | 23 | |
Mike Fiore |
1:9f30fbe9e9c1 | 24 | /** A static method for getting a string representation for the RelationalOperator |
Mike Fiore |
1:9f30fbe9e9c1 | 25 | * enumeration. |
Mike Fiore |
1:9f30fbe9e9c1 | 26 | * |
Mike Fiore |
1:9f30fbe9e9c1 | 27 | * @param relationalOperator a RelationalOperator enumeration. |
Mike Fiore |
1:9f30fbe9e9c1 | 28 | * @returns the enumeration name as a string. |
Mike Fiore |
1:9f30fbe9e9c1 | 29 | */ |
Mike Fiore |
1:9f30fbe9e9c1 | 30 | static std::string getRelationalOperatorNames(RelationalOperator relationalOperator) |
Mike Fiore |
1:9f30fbe9e9c1 | 31 | { |
Mike Fiore |
1:9f30fbe9e9c1 | 32 | switch(relationalOperator) { |
Mike Fiore |
1:9f30fbe9e9c1 | 33 | case GREATER: |
Mike Fiore |
1:9f30fbe9e9c1 | 34 | return "GREATER"; |
Mike Fiore |
1:9f30fbe9e9c1 | 35 | case LESS: |
Mike Fiore |
1:9f30fbe9e9c1 | 36 | return "LESS"; |
Mike Fiore |
1:9f30fbe9e9c1 | 37 | case EQUAL: |
Mike Fiore |
1:9f30fbe9e9c1 | 38 | return "EQUAL"; |
Mike Fiore |
1:9f30fbe9e9c1 | 39 | case GREATER_EQUAL: |
Mike Fiore |
1:9f30fbe9e9c1 | 40 | return "GREATER_EQUAL"; |
Mike Fiore |
1:9f30fbe9e9c1 | 41 | case LESS_EQUAL: |
Mike Fiore |
1:9f30fbe9e9c1 | 42 | return "LESS_EQUAL"; |
Mike Fiore |
1:9f30fbe9e9c1 | 43 | default: |
Mike Fiore |
1:9f30fbe9e9c1 | 44 | return "UNKNOWN ENUM"; |
Mike Fiore |
1:9f30fbe9e9c1 | 45 | } |
Mike Fiore |
1:9f30fbe9e9c1 | 46 | } |
Mike Fiore |
1:9f30fbe9e9c1 | 47 | |
Mike Fiore |
1:9f30fbe9e9c1 | 48 | #endif |