add motherboard sensors
This commit is contained in:
22
main.cpp
22
main.cpp
@@ -33,6 +33,7 @@ struct Sensors {
|
||||
double avg[3] = {0.0f};
|
||||
sys::Memory ram;
|
||||
sys::Memory home;
|
||||
sys::sysSensors sys;
|
||||
cpu::cpuSensors cpu;
|
||||
gpu::gpuSensors gpu;
|
||||
float hass_state = 0.0f;
|
||||
@@ -65,6 +66,7 @@ void sensorsThread(std::stop_token st, Sensors* s) {
|
||||
log(LOG::INF, "Thread", "Starting sensors_thread, pid {}, poll interval {} ms", gettid(), LCD_INTERVAL_MS);
|
||||
cpu::detectHwmon(&s->cpu, "0000:00:18.3");
|
||||
gpu::detectHwmon(&s->gpu, "0000:0a:00.0");
|
||||
sys::detectHwmon(&s->sys, "nct6775.656");
|
||||
|
||||
while (!st.stop_requested()) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
@@ -75,6 +77,7 @@ void sensorsThread(std::stop_token st, Sensors* s) {
|
||||
getloadavg(s->avg, 3);
|
||||
sys::getRam(&s->ram);
|
||||
sys::getDisk(&s->home, "/home/drath");
|
||||
sys::updateSensors(&s->sys);
|
||||
cpu::update(&s->cpu);
|
||||
gpu::update(&s->gpu);
|
||||
}
|
||||
@@ -102,11 +105,18 @@ void displayThread(std::stop_token st, Sensors* s) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(s->mtx);
|
||||
|
||||
// prepare some tricky sensors
|
||||
std::string gpu_temps = std::to_string(s->gpu.temp_edge);
|
||||
if (s->gpu.temp_hotspot)
|
||||
gpu_temps = pad(lcd.cc(1) + std::to_string(s->gpu.temp_hotspot - s->gpu.temp_edge) + lcd.cc(0), 4) + pad(gpu_temps + "/" + std::to_string(s->gpu.temp_hotspot), 6);
|
||||
|
||||
lcd.writeBuf(0, 0, pad(s->td.date, 11, true) + " " + s->td.time + lcd.bar(7, s->gpu.usage_core / 100.0) /* + pad(s->loadavg, 17)*/);
|
||||
uint16_t cpu_fan = 0;
|
||||
for (auto &fan : s->sys.fan_speed)
|
||||
cpu_fan += fan;
|
||||
cpu_fan = cpu_fan >> 1; // fast divide by 2
|
||||
|
||||
// write to display buffer
|
||||
lcd.writeBuf(0, 0, pad(s->td.date, 11, true) + " " + s->td.time + lcd.bar(7, s->gpu.usage_core / 100.0));
|
||||
lcd.writeBuf(0, 26, pNum(s->avg[0], s->avg[0] > 10 ? 1 : 2));
|
||||
lcd.writeBuf(0, 31, pNum(s->avg[1], s->avg[1] > 10 ? 1 : 2));
|
||||
lcd.writeBuf(0, 36, pNum(s->avg[2], s->avg[2] > 10 ? 1 : 2));
|
||||
@@ -115,16 +125,18 @@ void displayThread(std::stop_token st, Sensors* s) {
|
||||
lcd.writeBuf(1, 8, pad(pBytes(s->ram.used, true) + "B", 7, true));
|
||||
lcd.writeBuf(1, 30 - gpu_temps.size(), pad(pBytes(s->gpu.vram_used) + "B", 7));
|
||||
lcd.writeBuf(1, 39 - gpu_temps.size(), gpu_temps + lcd.cc(0));
|
||||
lcd.writeBuf(1, 15, std::to_string(s->sys.t_sensor) + lcd.cc(0)); // t_sensor temp
|
||||
|
||||
lcd.writeBuf(2, 0, pad(pNum(s->cpu.ptotal, 1) + "W", 8, true));
|
||||
lcd.writeBuf(2, 7, lcd.cc(2) + pad(pBytes(s->home.free) + "B", 6));
|
||||
lcd.writeBuf(2, 5, pad(std::to_string(cpu_fan) + "R", 5)); // avg fan speed
|
||||
lcd.writeBuf(2, 16, pad(pNum(s->hass_state) + "W", 4));
|
||||
lcd.writeBuf(2, 21, pad(std::to_string(s->gpu.fan_pwm) + "%", 4));
|
||||
// lcd.writeBuf(2, 21, pad(std::to_string(s->gpu.fan_pwm) + "%", 4));
|
||||
lcd.writeBuf(2, 26, pad(std::to_string(s->gpu.fan_speed) + "R", 5));
|
||||
lcd.writeBuf(2, 31, pad(std::to_string(s->gpu.power_avg) + "/" + std::to_string(s->gpu.power_cap) + "W", 9));
|
||||
|
||||
lcd.writeBuf(3, 0, pad(pNum(s->cpu.vcore, 3) + "V", 7, true));
|
||||
lcd.writeBuf(3, 7, std::to_string(s->cpu.avg_freq) + "MHz");
|
||||
lcd.writeBuf(3, 0, pad(pNum(s->cpu.vcore, 2) + "V", 7, true));
|
||||
lcd.writeBuf(3, 6, std::to_string(s->cpu.avg_freq) + "MHz");
|
||||
lcd.writeBuf(3, 14, lcd.cc(2) + pad(pBytes(s->home.free), 5));
|
||||
lcd.writeBuf(3, 21, pad(std::to_string(s->gpu.clock_core) + "/" + std::to_string(s->gpu.clock_mem) + "MHz ", 13));
|
||||
lcd.writeBuf(3, 34, pad(pNum(s->gpu.vcore, 3) + "V", 5));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user