diff --git a/include/app.hpp b/include/app.hpp index 6086d97..6d63354 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -17,7 +17,7 @@ struct sensors { sys::sysSensors sys; cpu::cpuSensors cpu; gpu::gpuSensors gpu; - float hass_state = 0.0f; + double hass_state = 0.0f; std::mutex mtx; // making sure the struct isnt accessed by multiple threads at once }; diff --git a/include/cpu.hpp b/include/cpu.hpp index d0ae51e..9641c6f 100644 --- a/include/cpu.hpp +++ b/include/cpu.hpp @@ -8,19 +8,21 @@ namespace cpu { -struct cpuSensors { - std::string hwmon; - bool zenpower = false; +enum Module : uint8_t { unknown, k10temp, zenpower }; - int tdie = 0; - int tctl = 0; - int tccd1 = 0; - double pcore = 0.0; - double psoc = 0.0; - double ptotal = 0.0; - double vcore = 0.0; - double vsoc = 0.0; +struct cpuSensors { + Module module = unknown; + std::byte _pad[1]; + int16_t tdie = 0; + int16_t tctl = 0; + int16_t tccd1 = 0; + // double pcore = 0.0; + // double psoc = 0.0; + float ptotal = 0.0; + // double vcore = 0.0; + // double vsoc = 0.0; uint32_t avg_freq = 0; + std::string hwmon; }; void detectHwmon(cpuSensors* target, const std::string& pci); diff --git a/include/gpu.hpp b/include/gpu.hpp index 0d29e1e..a5a3543 100644 --- a/include/gpu.hpp +++ b/include/gpu.hpp @@ -9,10 +9,10 @@ namespace gpu { struct gpuSensors { - std::string hwmon; - bool hasGpuMetrics = false; + uint64_t vram_used = 0; + // uint64_t vram_total = 0; - double vcore = 0.0f; + float vcore = 0.0f; uint16_t clock_core = 0; uint16_t clock_mem = 0; @@ -31,12 +31,13 @@ struct gpuSensors { uint8_t temp_vrm_soc = 0; uint8_t temp_vrm_mem = 0; + bool hasGpuMetrics = false; + uint8_t usage_core = 0; uint8_t usage_media = 0; uint8_t usage_umc = 0; - uint64_t vram_used = 0; - // uint64_t vram_total = 0; + std::string hwmon; }; void detectHwmon(gpuSensors* target, const std::string& pci); diff --git a/include/sys.hpp b/include/sys.hpp index fb38284..525d712 100644 --- a/include/sys.hpp +++ b/include/sys.hpp @@ -12,7 +12,8 @@ constexpr char wdays[][4] = {"Nie", "Pon", "Wto", "Sro", "Czw", "Pia", "Sob"}; struct sysSensors { std::string hwmon; uint16_t fan_speed[2] = {0}; // left and right cpu fans - uint8_t t_sensor = 0; // ntc temp sensor + int16_t t_sensor = 0; // ntc temp sensor + std::byte _pad[2]; }; struct Memory { diff --git a/src/cpu.cpp b/src/cpu.cpp index 7c735bd..2ee4d9e 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -18,8 +18,9 @@ void detectHwmon(cpuSensors* target, const std::string& pci) { return; } - target->zenpower = utils::fileExists(target->hwmon+ "/in1_input"); // idk if this is reliable, we're trying to avoid just reading the name - applog(LOG::INF, "Detected module \"{}\" in path \"{}\"", target->zenpower ? "zenpower" : "k10temp", target->hwmon); + if (utils::fileExists(target->hwmon+ "/in1_input")) // idk if this is reliable, we're trying to avoid just reading the name + target->module = k10temp; + applog(LOG::INF, "Detected module \"{}\" in path \"{}\"", target->module ? "zenpower" : "k10temp", target->hwmon); } void update(cpuSensors* c) { @@ -51,13 +52,15 @@ void update(cpuSensors* c) { if (c->hwmon.empty()) return; // break if no module // commented out unused values so its faster - if (c->zenpower) { + if (c->module == zenpower) { utils::fastReadNum<1000>(c->hwmon + "/temp1_input", buf, c->tdie); utils::fastReadNum<1000>(c->hwmon + "/temp2_input", buf, c->tctl); utils::fastReadNum<1000>(c->hwmon + "/temp3_input", buf, c->tccd1); - utils::fastReadNum<1000>(c->hwmon + "/in1_input", buf, c->vcore); - utils::fastReadNum<1000>(c->hwmon + "/in2_input", buf, c->vsoc); - } else { + // utils::fastReadNum<1000>(c->hwmon + "/in1_input", buf, c->vcore); + // utils::fastReadNum<1000>(c->hwmon + "/in2_input", buf, c->vsoc); + } + + if (c->module == k10temp) { utils::fastReadNum<1000>(c->hwmon + "/temp1_input", buf, c->tctl); utils::fastReadNum<1000>(c->hwmon + "/temp3_input", buf, c->tccd1); }