forked from AxisCommunications/door-controller-test-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.cpp
More file actions
59 lines (46 loc) · 1.22 KB
/
System.cpp
File metadata and controls
59 lines (46 loc) · 1.22 KB
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
#include "Arduino.h"
#include "System.h"
char* System::uptime()
{
char buffer[65];
long days=0;
long hours=0;
long mins=0;
long secs=0;
secs = millis()/1000; //convect milliseconds to seconds
mins=secs/60; //convert seconds to minutes
hours=mins/60; //convert minutes to hours
days=hours/24; //convert hours to days
secs=secs-(mins*60); //subtract the coverted seconds to minutes in order to display 59 secs max
mins=mins-(hours*60); //subtract the coverted minutes to hours in order to display 59 minutes max
hours=hours-(days*24); //subtract the coverted hours to days in order to display 23 hours max
if (days > 0) {
ltoa(days,buffer,10);
strcpy(retval,buffer);
}
else {
strcpy(retval,"0");
}
strcat(retval,":");
ltoa(hours,buffer,10);
strcat(retval,buffer);
strcat(retval,":");
ltoa(mins,buffer,10);
strcat(retval,buffer);
strcat(retval,":");
ltoa(secs,buffer,10);
strcat(retval,buffer);
strcat(retval,'\0');
return retval;
}
int System::ramFree () {
extern int __heap_start, *__brkval;
int v;
int a = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
return a;
}
int System::ramSize() {
int v;
int a = (int) &v;
return a;
}