overhaul of sys

This commit is contained in:
Drath
2025-09-22 22:17:51 +02:00
parent 1998fb6953
commit a9afb46c19
3 changed files with 25 additions and 41 deletions

View File

@@ -31,8 +31,8 @@ std::binary_semaphore main{0};
} // namespace sem
struct Sensors {
std::array<std::string, 2> td;
std::string loadavg;
sys::TimeDate td;
double avg[3];
sys::Memory ram;
sys::Memory home;
cpu::cpuSensors cpu;
@@ -73,9 +73,9 @@ void sensorsThread(std::stop_token st, Sensors* s) {
{
// this will unlock when program goes out of scope
std::lock_guard<std::mutex> lock(s->mtx);
// maybe make these take pointers too
s->td = getTimeDate();
s->loadavg = getAvgs();
sys::getTimeDate(&s->td);
getloadavg(s->avg, 3);
sys::getRam(&s->ram);
sys::getDisk(&s->home, "/home/drath");
cpu::update(&s->cpu);
@@ -104,7 +104,10 @@ void displayThread(std::stop_token st, Sensors* s) {
auto gpu_temps = (s->gpu.temp_hotspot) ? "/" + std::to_string(s->gpu.temp_hotspot) : "";
gpu_temps += (s->gpu.temp_mem) ? "/" + std::to_string(s->gpu.temp_mem) : "";
lcd.writeBuf(0, 0, pad(s->td[1], 11, true) + " " + s->td[0] + lcd.bar(1, s->gpu.usage_core / 100.0) + pad(s->loadavg, 17));
lcd.writeBuf(0, 0, pad(s->td.date, 11, true) + " " + s->td.time + lcd.bar(1, s->gpu.usage_core / 100.0) /* + pad(s->loadavg, 17)*/);
lcd.writeBuf(0, 26, pNum(s->avg[0], s->avg[0] > 10 ? 1 : 2));
lcd.writeBuf(0, 31, pNum(s->avg[1], s->avg[1] > 10 ? 1 : 2));
lcd.writeBuf(0, 36, pNum(s->avg[2], s->avg[2] > 10 ? 1 : 2));
lcd.writeBuf(1, 0, pad(std::to_string(s->cpu.tctl) + "/" + std::to_string(s->cpu.tccd1) + lcd.cc[0], 8, true));
lcd.writeBuf(1, 8, pad(pBytes(s->ram.used, true) + "B", 7, true));