From 06b81d5242c69cf6cbc2b5a1dc73d137cd88106e Mon Sep 17 00:00:00 2001 From: Drath Date: Sun, 14 Sep 2025 21:34:05 +0200 Subject: [PATCH] refactor --- main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.cpp b/main.cpp index b91780b..ceb3a29 100644 --- a/main.cpp +++ b/main.cpp @@ -35,8 +35,8 @@ struct Sensors { std::string loadavg; mem_usage_t ram; mem_usage_t home; - gpu_t gpu; - cpu_t cpu; + cpu::sensors cpu; + gpu::sensors gpu; float hass_state = 0.0f; std::mutex mtx; // making sure the struct isnt accessed by multiple threads at once }; @@ -65,8 +65,8 @@ void hassThread(std::stop_token st, Sensors* s) { void sensorsThread(std::stop_token st, Sensors* s) { // std::println("[Thread] Starting sensors_thread, pid {}, poll interval {} ms", gettid(), LCD_INTERVAL_MS); - cpu_hwmon_t cpu_hwmon = detectCpuHwmon("0000:00:18.3"); - std::string gpu_hwmon = detectGpuHwmon("0000:08:00.0"); + cpu::detectHwmon(&s->cpu, "0000:00:18.3"); + gpu::detectHwmon(&s->gpu, "0000:08:00.0"); while (!st.stop_requested()) { auto start = std::chrono::steady_clock::now(); @@ -76,8 +76,8 @@ void sensorsThread(std::stop_token st, Sensors* s) { s->loadavg = getAvgs(); s->ram = getRam(); s->home = getDisk("/home/drath"); - s->cpu = getCpu(cpu_hwmon); - s->gpu = getGpu(gpu_hwmon, false); + cpu::update(&s->cpu); + gpu::update(&s->gpu); } // std::println("[Sensors] took {} microseconds", std::chrono::duration_cast(std::chrono::steady_clock::now() - start).count());