Skip to content

Commit

Permalink
Merge pull request #9 from narugit/feature/use_tc0abxz
Browse files Browse the repository at this point in the history
feat: Use other sensors when the temperature gets 0.0
  • Loading branch information
narugit authored Jun 12, 2023
2 parents 9b9f73b + 7756490 commit 74b5210
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion smctemp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <string>
#include <vector>

Expand Down Expand Up @@ -403,9 +404,19 @@ double SmcTemp::GetCpuTemp() {
temp += smc_accessor_.ReadValue(sensor.c_str());
}
temp /= sensors.size();
if (temp < 110.0) {
if (temp > std::numeric_limits<double>::epsilon()) {
return temp;
}
std::vector<std::string> aux_sensors{
static_cast<std::string>(kSensorTc0a),
static_cast<std::string>(kSensorTc0b),
static_cast<std::string>(kSensorTc0x),
static_cast<std::string>(kSensorTc0z),
};
for (auto sensor : aux_sensors) {
temp += smc_accessor_.ReadValue(sensor.c_str());
}
temp /= aux_sensors.size();
#endif
return temp;
}
Expand Down
4 changes: 4 additions & 0 deletions smctemp.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ constexpr UInt32Char_t kSensorTc0e = "TC0E"; // CPU PECI die filtered temperatur
constexpr UInt32Char_t kSensorTc0f = "TC0F"; // CPU PECI die temperature filtered then adjusted
constexpr UInt32Char_t kSensorTc0p = "TC0P"; // CPU proximity temperature
#elif defined(ARCH_TYPE_ARM64)
constexpr UInt32Char_t kSensorTc0a = "Tc0a";
constexpr UInt32Char_t kSensorTc0b = "Tc0b";
constexpr UInt32Char_t kSensorTc0x = "Tc0x";
constexpr UInt32Char_t kSensorTc0z = "Tc0z";
constexpr UInt32Char_t kSensorTp01 = "Tp01"; // CPU performance core 1 temperature
constexpr UInt32Char_t kSensorTp05 = "Tp05"; // CPU performance core 2 temperature
constexpr UInt32Char_t kSensorTp0d = "Tp0D"; // CPU performance core 3 temperature
Expand Down

0 comments on commit 74b5210

Please sign in to comment.