This commit is contained in:
2025-12-22 11:02:32 +01:00
parent 80635a4a03
commit 8996970cdc

View File

@@ -103,8 +103,8 @@ void displayThread(std::stop_token st, Sensors* s) {
lcd.setCustomChar(0, {16, 6, 9, 8, 8, 9, 6, 0}); // celcius
lcd.setCustomChar(1, {0, 0, 4, 10, 10, 17, 31, 0}); // delta
lcd.setCustomChar(2, {0, 0, 8, 21, 21, 2, 0, 0}); // home (tilde)
lcd.setCustomChar(3, {4, 14, 21, 4, 4, 4 , 0}); // up arrow
lcd.setCustomChar(4, {4, 4, 4, 21, 14, 4 , 0}); // down arrow
lcd.setCustomChar(3, {4, 14, 21, 4, 4, 4, 0}); // up arrow
lcd.setCustomChar(4, {4, 4, 4, 21, 14, 4, 0}); // down arrow
// welcome msg
lcd.writeBuf(2, 0, center("Waiting for sensors...", 40));
@@ -123,10 +123,10 @@ void displayThread(std::stop_token st, Sensors* s) {
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), 5);
uint16_t cpu_fan = 0;
for (auto &fan : s->sys.fan_speed)
for (auto& fan : s->sys.fan_speed)
cpu_fan += fan;
cpu_fan /= 2;
// write to display buffer
lcd.writeBuf(0, 0, pad(s->td.date, 11, JUST::LEFT) + " " + 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));
@@ -136,12 +136,12 @@ void displayThread(std::stop_token st, Sensors* s) {
lcd.writeBuf(1, 0, pad(std::to_string(s->cpu.tctl) + "/" + std::to_string(s->cpu.tccd1) + lcd.cc(0), 8, JUST::LEFT));
lcd.writeBuf(1, 7, pad(pBytes(s->ram.used, true), 6, JUST::LEFT));
lcd.writeBuf(1, 13, pad(pNum(s->hass_state) + "W", 4));
lcd.writeBuf(1, 19, std::to_string(s->sys.t_sensor) + lcd.cc(0)); // t_sensor temp
lcd.writeBuf(1, 19, std::to_string(s->sys.t_sensor) + lcd.cc(0)); // t_sensor temp
lcd.writeBuf(1, 32 - gpu_temps.size(), pad(pBytes(s->gpu.vram_used), 6));
lcd.writeBuf(1, 39 - gpu_temps.size(), gpu_temps + lcd.cc(0));
lcd.writeBuf(2, 0, pad(std::to_string((int)s->cpu.ptotal) + "W", 8, JUST::LEFT));
lcd.writeBuf(2, s->cpu.ptotal < 100 ? 4 : 5, std::to_string(cpu_fan) + "R"); // avg fan speed
lcd.writeBuf(2, s->cpu.ptotal < 100 ? 4 : 5, std::to_string(cpu_fan) + "R"); // avg fan speed
lcd.writeBuf(2, 12, lcd.cc(3) + pBytes(s->net.upload));
lcd.writeBuf(2, 19, lcd.cc(4) + pBytes(s->net.download));
lcd.writeBuf(2, 26, pad(std::to_string(s->gpu.fan_speed) + "R", 5));
@@ -164,12 +164,12 @@ void displayThread(std::stop_token st, Sensors* s) {
}
int main() {
log(LOG::START, "LINUXSMARTIE", "============================= PROGRAM START ============================="); // to make logs clearer
log(LOG::START, "LINUXSMARTIE", "============================= PROGRAM START ============================="); // to make logs clearer
std::signal(SIGINT, sighandler);
std::signal(SIGTERM, sighandler);
Sensors* pSensors = new Sensors;
log(LOG::DBG, "main", "main thread pid is {}, size of sensor struct is {} bytes", gettid(),sizeof(Sensors));
log(LOG::DBG, "main", "main thread pid is {}, size of sensor struct is {} bytes", gettid(), sizeof(Sensors));
std::function<void(std::stop_token st, Sensors * s)> funcs[] = {displayThread, hassThread, sensorsThread}; // array of functions