Konfiguration über http
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

60 行
1.2KB

  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. }