This commit is contained in:
Drath
2025-09-14 21:34:05 +02:00
parent 329837f92d
commit 06b81d5242

View File

@@ -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::microseconds>(std::chrono::steady_clock::now() - start).count());