z-sysInfo.ino 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. *
  3. * This is a "z-sketch". It means you can run this sketch on its own, or use it as a sub-sketch of some bigger program
  4. * See the M5ez user manual under z-sketches at https://github.com/M5ez/M5ez
  5. *
  6. */
  7. #ifndef MAIN_DECLARED
  8. #include <M5Stack.h>
  9. #include <M5ez.h>
  10. void setup() {
  11. ez.begin();
  12. sysInfo();
  13. }
  14. void loop() {
  15. }
  16. String exit_button = "";
  17. #else
  18. String exit_button = "Exit";
  19. #endif // #ifndef MAIN_DECLARED
  20. void sysInfo() {
  21. sysInfoPage1();
  22. while(true) {
  23. String btn = ez.buttons.poll();
  24. if (btn == "up") sysInfoPage1();
  25. if (btn == "down") sysInfoPage2();
  26. if (btn == "Exit") break;
  27. }
  28. }
  29. #include <SPIFFS.h>
  30. void sysInfoPage1() {
  31. const byte tab = 120;
  32. ez.screen.clear();
  33. ez.header.show("System Info (1/2)");
  34. ez.buttons.show("#" + exit_button + "#down");
  35. ez.canvas.font(&FreeSans9pt7b);
  36. ez.canvas.lmargin(10);
  37. ez.canvas.println("");
  38. ez.canvas.print("CPU freq:"); ez.canvas.x(tab); ez.canvas.println(String(ESP.getCpuFreqMHz()) + " MHz");
  39. ez.canvas.print("CPU cores:"); ez.canvas.x(tab); ez.canvas.println("2"); // :)
  40. ez.canvas.print("Chip rev.:"); ez.canvas.x(tab); ez.canvas.println(String(ESP.getChipRevision()));
  41. ez.canvas.print("Flash speed:"); ez.canvas.x(tab); ez.canvas.println(String(ESP.getFlashChipSpeed() / 1000000) + " MHz");
  42. ez.canvas.print("Flash size:"); ez.canvas.x(tab); ez.canvas.println(String(ESP.getFlashChipSize() / 1000000) + " MB");
  43. ez.canvas.print("ESP SDK:"); ez.canvas.x(tab); ez.canvas.println(String(ESP.getSdkVersion()));
  44. ez.canvas.print("M5ez:"); ez.canvas.x(tab); ez.canvas.println(String(ez.version()));
  45. }
  46. void sysInfoPage2() {
  47. const String SD_Type[5] = {"NONE", "MMC", "SD", "SDHC", "UNKNOWN"};
  48. const byte tab = 140;
  49. ez.screen.clear();
  50. ez.header.show("System Info (2/2)");
  51. ez.buttons.show("up#" + exit_button + "#");
  52. ez.canvas.font(&FreeSans9pt7b);
  53. ez.canvas.lmargin(10);
  54. ez.canvas.println("");
  55. ez.canvas.print("Free RAM:"); ez.canvas.x(tab); ez.canvas.println(String((long)ESP.getFreeHeap()) + " bytes");
  56. ez.canvas.print("Min. free seen:"); ez.canvas.x(tab); ez.canvas.println(String((long)esp_get_minimum_free_heap_size()) + " bytes");
  57. const int sd_type = SD.cardType();
  58. SPIFFS.begin();
  59. ez.canvas.print("SPIFFS size:"); ez.canvas.x(tab); ez.canvas.println(String((long)SPIFFS.totalBytes()) + " bytes");
  60. ez.canvas.print("SPIFFS used:"); ez.canvas.x(tab); ez.canvas.println(String((long)SPIFFS.usedBytes()) + " bytes");
  61. ez.canvas.print("SD type:"); ez.canvas.x(tab); ez.canvas.println(SD_Type[sd_type]);
  62. if (sd_type != 0) {
  63. ez.canvas.print("SD size:"); ez.canvas.x(tab); ez.canvas.println(String((long)SD.cardSize() / 1000000) + " MB");
  64. ez.canvas.print("SD used:"); ez.canvas.x(tab); ez.canvas.println(String((long)SD.usedBytes() / 1000000) + " MB");
  65. }
  66. }