Util.cpp
834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*****************************************
* Project : Util - Utilities
* Programmer: Joao Lopes
* Module : Util - generic utilities
* Comments : TODO: make it a library to Arduino and ESP-IDF
* Note this not is a C++ class (yet)
* Versions :
* ------- ---------- -------------------------
* 0.1.0 2018-05-09 First version
*/
///// Includes
#include <Arduino.h>
////// Routines
// Is CR or LF ?
boolean isCRLF(char character) {
return (character == '\r' || character == '\n');
}
//String is numeric ?
boolean strIsNum(String str) {
bool isNum = false;
for (uint8_t i = 0; i < str.length(); i++) {
isNum = isdigit(str[i]) || str[i] == '+' ||
str[i] == '.' || str[i] == '-';
if (!isNum)
return false;
}
return isNum;
}