From 171aa5502cfcac1abc5315c8792521790195e4a9 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 11 Jan 2025 11:43:58 +0100 Subject: Add notes and temperature monitor --- Temperature.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Temperature.cpp (limited to 'Temperature.cpp') 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 + +#include + +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; +} -- cgit v1.2.3