Krolyxon
Commit 278646b

Branches

Tags

Refs →

orion-rfsrcsysinfo.cpp

87 lines · 2.3 KB · C++

1#include <Arduino.h>
2#include "ui/display.h"
3#include "buttons.h"
4#include <esp_chip_info.h>
5#include <esp_heap_caps.h>
6
7void runSystemInfoFeature()
8{
9 esp_chip_info_t chip_info;
10
11 esp_chip_info(&chip_info);
12
13 while (true)
14 {
15 //u8g2.clearBuffer();
16
17 //char buf[32];
18
19 //sprintf(buf, "Cores: %d", chip_info.cores);
20 //u8g2.drawStr(0, 14, buf);
21
22 //sprintf(buf, "Heap: %d",
23 // heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
24 //u8g2.drawStr(0, 28, buf);
25
26
27 //u8g2.drawStr(0, 60, "BACK to exit");
28
29 // Get RAM info
30 size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT);
31 size_t totalHeap = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
32 int ramUsage = 100 - ((freeHeap * 100) / totalHeap);
33
34 // Get Flash info
35 //uint32_t flashSize = spi_flash_get_chip_size();
36 uint32_t flashSize = ESP.getFlashChipSize();
37 uint32_t flashUsed = ESP.getSketchSize();
38 int flashUsage = (flashUsed * 100) / flashSize;
39
40 // Temperature (approx)
41 uint8_t temperature = temperatureRead();
42
43 // Chip info
44 esp_chip_info_t chip_info;
45 esp_chip_info(&chip_info);
46
47 u8g2.clearBuffer();
48 u8g2.setFont(u8g2_font_6x12_tr);
49
50 char buf[32];
51
52 // Box 1 - RAM
53 u8g2.drawFrame(0, 0, 128, 12);
54 sprintf(buf, "RAM: %d%% used", ramUsage);
55 u8g2.drawStr(4, 9, buf);
56
57 // Box 2 - Flash
58 u8g2.drawFrame(0, 12, 128, 12);
59 sprintf(buf, "Flash: %d%% used", flashUsage);
60 u8g2.drawStr(4, 21, buf);
61
62 // Box 3 - Temp (FULL WIDTH now)
63 u8g2.drawFrame(0, 24, 128, 12);
64 sprintf(buf, "Temp: %d C", temperature);
65 u8g2.drawStr(4, 33, buf);
66
67 // Box 4 - Chip info (FULL WIDTH)
68 u8g2.drawFrame(0, 36, 128, 12);
69 sprintf(buf, "Cores: %d Rev: %d", chip_info.cores, chip_info.revision);
70 u8g2.drawStr(4, 45, buf);
71
72 // Box 5 - PSRAM (KB)
73 u8g2.drawFrame(0, 48, 128, 12);
74 sprintf(buf, "PSRAM: %lu KB", heap_caps_get_free_size(MALLOC_CAP_SPIRAM) / 1024);
75 u8g2.drawStr(4, 57, buf);
76
77 u8g2.sendBuffer();
78
79 if (btnBack())
80 {
81 delay(200);
82 return;
83 }
84
85 delay(100);
86 }
87}