align structs, idk if it does anything
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
15
src/cpu.cpp
15
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user