forked from tfnab/Webduino
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sirleech#36 from edvler/master
Update for Web_Net_Setup
- Loading branch information
Showing
3 changed files
with
376 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#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; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef System_h | ||
#define System_h | ||
|
||
#include <Arduino.h> | ||
|
||
/** | ||
* System Class. | ||
* | ||
* @author Matthias Maderer | ||
* @version 1.1.7 | ||
*/ | ||
class System { | ||
public: | ||
/** | ||
* Returns the uptime of the arduino with a char pointer. | ||
* Format: DAYS:HOURS:MINUTES:SECONDS | ||
* Sample: 1:20:23:50 = 1 day, 20 hours, 23 minutes and 50 seconds | ||
* @return char *: pointer! | ||
*/ | ||
char * uptime(); | ||
|
||
/** | ||
* Returns the free RAM | ||
* @return int: free RAM | ||
*/ | ||
int ramFree(); | ||
|
||
/** | ||
* Returns the size of the RAM | ||
* @return int: RAM size | ||
*/ | ||
int ramSize(); | ||
|
||
private: | ||
char retval[25]; | ||
}; | ||
|
||
#endif | ||
|
Oops, something went wrong.