diff options
Diffstat (limited to 'Temperature.cpp')
-rw-r--r-- | Temperature.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Temperature.cpp b/Temperature.cpp new file mode 100644 index 0000000..dece26a --- /dev/null +++ b/Temperature.cpp @@ -0,0 +1,22 @@ +#include "Temperature.h" + +#include <libreichwein/file.h> + +#include <filesystem> + +namespace fs = std::filesystem; + +namespace { + // e.g. 46000 for 46C + fs::path temp_path{"/sys/class/thermal/thermal_zone0/temp"}; +} + +Temperature::Temperature() +{ +} + +int Temperature::read_degree() const +{ + std::string contents {Reichwein::File::getFile(temp_path)}; + return std::stoul(contents) / 1000; +} |