-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelperfunctions.h
executable file
·79 lines (54 loc) · 1.35 KB
/
helperfunctions.h
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef HELPERFUNCTIONS_H
#define HELPERFUNCTIONS_H
#include "Arduino.h"
/*
FUNCOES DE SISTEMA
Estas funcoes sao necessarias para debug. Depois do codigo consolidado
elas serao descartadas.
Sao utilizadas para saber a quantidade de memoria disponivel.
Estamos com problemas de falta de memoria devido a geracao de json de
resposta.
*/
int get_free_memory();
void mem(void);
boolean IsNumeric(String str);
/*
FUNCAO retirada do site: http://tripsintech.com/arduino-isnumeric-function/
MODIFICADA: Acrescentei um teste para verificar se a string passada nao esta vazia
se estiver retorna false.
*/
boolean IsNumeric(String str) {
if (str.length()) {
for (char i = 0; i < str.length(); i++) {
if ( !(isDigit(str.charAt(i)) || str.charAt(i) == '.' )) {
return false;
}
}
return true;
}
else {
return false;
}
}
/*
MEMORY FUNCTIONS
Funcoes auxiliares que mostram a quantidade de memoria livre do sistema.
*/
extern unsigned int __bss_end;
extern void *__brkval;
int get_free_memory()
{
int free_memory;
if ((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end);
else
free_memory = ((int)&free_memory) - ((int)__brkval);
return free_memory;
}
void mem(void)
{
Serial.print("free_memory():");
Serial.println( get_free_memory() );
delay(10);
}
#endif