diff --git a/include/gpu.hpp b/include/gpu.hpp index 8f1fc01..b689b49 100644 --- a/include/gpu.hpp +++ b/include/gpu.hpp @@ -16,7 +16,7 @@ namespace gpu { -struct sensors { +struct gpuSensors { std::string hwmon = ""; bool hasGpuMetrics = false; @@ -47,8 +47,8 @@ struct sensors { uint64_t vram_total = 0; }; -void detectHwmon(sensors* target, std::string pci); -void update(sensors* g); +void detectHwmon(gpuSensors* target, std::string pci); +void update(gpuSensors* g); } // namespace gpu diff --git a/main.cpp b/main.cpp index e82b0bf..c1da356 100644 --- a/main.cpp +++ b/main.cpp @@ -36,7 +36,7 @@ struct Sensors { sys::Memory ram; sys::Memory home; cpu::cpuSensors cpu; - gpu::sensors gpu; + gpu::gpuSensors gpu; float hass_state = 0.0f; std::mutex mtx; // making sure the struct isnt accessed by multiple threads at once }; diff --git a/src/gpu.cpp b/src/gpu.cpp index 99f9c9e..e9bce41 100644 --- a/src/gpu.cpp +++ b/src/gpu.cpp @@ -6,7 +6,7 @@ namespace gpu { /* takes pointer to a target gpu::sensors struct and updates its hwmon path and detects gpu_metrics */ -void detectHwmon(sensors* target, std::string pci) { +void detectHwmon(gpuSensors* target, std::string pci) { target->hwmon = getFirstDir("/sys/bus/pci/devices/" + pci + "/hwmon"); std::println("[gpu::detectHwmon] Detected path \"{}\"", target->hwmon); @@ -18,7 +18,7 @@ void detectHwmon(sensors* target, std::string pci) { } /* some metrics are missing in gpu_metrics, we always fill them from fs */ -void fillMissingMetrics(sensors* g) { +void fillMissingMetrics(gpuSensors* g) { g->vcore = std::stol(readFile(g->hwmon + "/in0_input", 4)) / 1000.0f; g->fan_pwm = std::stoi(readFile(g->hwmon + "/pwm1", 4)) * 100 / 256; g->fan_speed = std::stol(readFile(g->hwmon + "/fan1_input", 4)); @@ -29,7 +29,7 @@ void fillMissingMetrics(sensors* g) { } /* get sensors for pre-vega cards (rx480/580) */ -void updateFromFs(sensors* g) { +void updateFromFs(gpuSensors* g) { g->clock_core = std::stoll(readFile(g->hwmon + "/freq1_input", 16)) / 1000000; g->clock_mem = std::stoll(readFile(g->hwmon + "/freq2_input", 16)) / 1000000; g->power_avg = std::stol(readFile(g->hwmon + "/power1_input", 16)) / 1000000; @@ -38,7 +38,7 @@ void updateFromFs(sensors* g) { } /* get sensors for vega and newer (rx5700xt, rx7800xt [*]) */ -void updateFromMetrics(sensors* g) { +void updateFromMetrics(gpuSensors* g) { char raw_metrics[MAX_METRICS_LENGTH]; if (!readFile2(g->hwmon + REL_METRICS_PATH, raw_metrics, sizeof(raw_metrics))) return; @@ -87,7 +87,7 @@ void updateFromMetrics(sensors* g) { } /* reads values from system and updates the target gpu::sensors struct */ -void update(sensors* g) { +void update(gpuSensors* g) { fillMissingMetrics(g); if (g->hasGpuMetrics)