Konfiguration über http
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 년 전
4 년 전
4 년 전
4 년 전
4 년 전
4 년 전
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include "Arduino.h"
  2. #include "System.h"
  3. char* System::uptime()
  4. {
  5. char buffer[65];
  6. long days=0;
  7. long hours=0;
  8. long mins=0;
  9. long secs=0;
  10. secs = millis()/1000; //convect milliseconds to seconds
  11. mins=secs/60; //convert seconds to minutes
  12. hours=mins/60; //convert minutes to hours
  13. days=hours/24; //convert hours to days
  14. secs=secs-(mins*60); //subtract the coverted seconds to minutes in order to display 59 secs max
  15. mins=mins-(hours*60); //subtract the coverted minutes to hours in order to display 59 minutes max
  16. hours=hours-(days*24); //subtract the coverted hours to days in order to display 23 hours max
  17. if (days > 0) {
  18. ltoa(days,buffer,10);
  19. strcpy(retval,buffer);
  20. }
  21. else {
  22. strcpy(retval,"0");
  23. }
  24. strcat(retval,":");
  25. ltoa(hours,buffer,10);
  26. strcat(retval,buffer);
  27. strcat(retval,":");
  28. ltoa(mins,buffer,10);
  29. strcat(retval,buffer);
  30. strcat(retval,":");
  31. ltoa(secs,buffer,10);
  32. strcat(retval,buffer);
  33. strcat(retval,'\0');
  34. return retval;
  35. }
  36. int System::ramFree () {
  37. extern int __heap_start, *__brkval;
  38. int v;
  39. int a = (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
  40. return a;
  41. }
  42. int System::ramSize() {
  43. int v;
  44. int a = (int) &v;
  45. return a;
  46. }