diff --git a/include/sys.hpp b/include/sys.hpp index 77a532f..6b1d536 100644 --- a/include/sys.hpp +++ b/include/sys.hpp @@ -13,6 +13,12 @@ namespace sys { const char months[][4] = {"sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paz", "lis", "gru"}; const 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 +}; + struct Memory { uint64_t free = 0; uint64_t used = 0; @@ -27,6 +33,8 @@ struct TimeDate { void getTimeDate(TimeDate* td); void getDisk(Memory* disk, std::string mount); void getRam(Memory* mem); +void detectHwmon(sysSensors* s); +void updateSensors(sysSensors* s); } // namespace sys diff --git a/src/sys.cpp b/src/sys.cpp index 5605656..797969d 100644 --- a/src/sys.cpp +++ b/src/sys.cpp @@ -20,4 +20,14 @@ void sys::getDisk(Memory* disk, std::string mount) { disk->free = diskData.f_bfree * diskData.f_frsize; disk->used = (diskData.f_blocks - diskData.f_bfree) * diskData.f_frsize; disk->total = diskData.f_blocks * diskData.f_frsize; +} + +void sys::detectHwmon(sysSensors* s) { + s->hwmon = getFirstDir("/sys/devices/platform/nct6775.656/hwmon"); // we hardcode the chip path, should be sane +} + +void sys::updateSensors(sysSensors* s) { + s->fan_speed[0] = std::stol(readFile(s->hwmon + "/fan2_input", 4)); + s->fan_speed[1] = std::stol(readFile(s->hwmon + "/fan7_input", 4));; + s->t_sensor = std::stol(readFile(s->hwmon + "/temp5_input", 2)); } \ No newline at end of file