yuge overhaul, threads, hass, rewrote display, hwmons, bunc of shit

This commit is contained in:
Drath
2025-09-11 17:56:40 +02:00
parent 3153b1dc1b
commit 7b4791395e
12 changed files with 411 additions and 255 deletions

26
src/sys.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <sys.hpp>
std::string getAvgs() {
std::string ret;
double avgs[3];
getloadavg(avgs, 3);
for (uint8_t i = 0; i < 3; i++)
ret += pNum(avgs[i], avgs[i] > 10 ? 1 : 2) + " ";
ret.pop_back(); // remove trailing space
return ret;
}
std::array<std::string, 2> getTimeDate() {
std::array months = {"sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paz", "lis", "gru"};
std::array wdays = {"Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob"};
// std::array wdays = {"Ni", "Pn", "Wt", "Sr", "Cz", "Pi", "So"};
auto now = std::time(nullptr);
auto tm = *std::localtime(&now);
std::stringstream time, date;
time << std::setfill('0');
time << std::setw(2) << tm.tm_hour << ":";
time << std::setw(2) << tm.tm_min << ":";
time << std::setw(2) << tm.tm_sec;
date << wdays[tm.tm_wday] << ", " << tm.tm_mday << " " << months[tm.tm_mon];
return {time.str(), date.str()};
}