get rid of macro, use inline func

This commit is contained in:
2025-12-28 19:06:23 +01:00
parent 12d7ab9b0f
commit 2d3a481638
5 changed files with 44 additions and 38 deletions

View File

@@ -17,13 +17,16 @@ void detectHwmon(cpuSensors* target, const std::string& pci) {
return;
}
target->zenpower = false; // we were using readFileToStr to figure this out, we dont f/w it anymore, find another way (see if hwmon/in1_input exists?)
target->zenpower = false; // we were using readFileToStr to figure this out, we dont f/w it anymore, find another way (see if hwmon/in1_input exists?)
applog(LOG::INF, "Detected module \"{}\" in path \"{}\"", target->zenpower ? "zenpower" : "k10temp", target->hwmon);
}
void update(cpuSensors* c) {
static char buf[32];
struct EnergyTs { uint64_t energy = 0; std::chrono::time_point<std::chrono::steady_clock> ts; };
struct EnergyTs {
uint64_t energy = 0;
std::chrono::time_point<std::chrono::steady_clock> ts;
};
static EnergyTs prev;
EnergyTs curr;
@@ -31,7 +34,8 @@ void update(cpuSensors* c) {
// read power from intel-rapl? works on amd too, btop uses this trick, seems accurate
// it tracks with "socket power" in hwinfo on windows, its actually the same thing i had in lcdsmartie
curr.ts = std::chrono::steady_clock::now();
fastReadNum("/sys/class/powercap/intel-rapl:0/energy_uj", curr.energy);
// fastReadNum("/sys/class/powercap/intel-rapl:0/energy_uj", curr.energy);
curr.energy = fastReadNum("/sys/class/powercap/intel-rapl:0/energy_uj", buf);
c->ptotal = (float)(curr.energy - prev.energy) / (float)(std::chrono::duration_cast<std::chrono::microseconds>(curr.ts - prev.ts).count());
prev = curr;
@@ -47,14 +51,14 @@ void update(cpuSensors* c) {
// commented out unused values so its faster
if (c->zenpower) {
fastReadNum(c->hwmon + "/temp1_input", c->tdie) / 1000;
fastReadNum(c->hwmon + "/temp2_input", c->tctl) / 1000;
fastReadNum(c->hwmon + "/temp3_input", c->tccd1) / 1000;
fastReadNum(c->hwmon + "/in1_input", c->vcore) / 1000.0;
fastReadNum(c->hwmon + "/in2_input", c->vsoc) / 1000.0;
c->tdie = fastReadNum(c->hwmon + "/temp1_input", buf) / 1000;
c->tctl = fastReadNum(c->hwmon + "/temp2_input", buf) / 1000;
c->tccd1 = fastReadNum(c->hwmon + "/temp3_input", buf) / 1000;
c->vcore = fastReadNum(c->hwmon + "/in1_input", buf) / 1000.0;
c->vsoc = fastReadNum(c->hwmon + "/in2_input", buf) / 1000.0;
} else {
fastReadNum(c->hwmon + "/temp1_input", c->tctl) / 1000;
fastReadNum(c->hwmon + "/temp3_input", c->tccd1) / 1000;
c->tctl = fastReadNum(c->hwmon + "/temp1_input", buf) / 1000;
c->tccd1 = fastReadNum(c->hwmon + "/temp3_input", buf) / 1000;
}
}