Skip to content

Commit 74b5210

Browse files
authored
Merge pull request #9 from narugit/feature/use_tc0abxz
feat: Use other sensors when the temperature gets 0.0
2 parents 9b9f73b + 7756490 commit 74b5210

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

smctemp.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <cmath>
2828
#include <iomanip>
2929
#include <iostream>
30+
#include <limits>
3031
#include <string>
3132
#include <vector>
3233

@@ -403,9 +404,19 @@ double SmcTemp::GetCpuTemp() {
403404
temp += smc_accessor_.ReadValue(sensor.c_str());
404405
}
405406
temp /= sensors.size();
406-
if (temp < 110.0) {
407+
if (temp > std::numeric_limits<double>::epsilon()) {
407408
return temp;
408409
}
410+
std::vector<std::string> aux_sensors{
411+
static_cast<std::string>(kSensorTc0a),
412+
static_cast<std::string>(kSensorTc0b),
413+
static_cast<std::string>(kSensorTc0x),
414+
static_cast<std::string>(kSensorTc0z),
415+
};
416+
for (auto sensor : aux_sensors) {
417+
temp += smc_accessor_.ReadValue(sensor.c_str());
418+
}
419+
temp /= aux_sensors.size();
409420
#endif
410421
return temp;
411422
}

smctemp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ constexpr UInt32Char_t kSensorTc0e = "TC0E"; // CPU PECI die filtered temperatur
5050
constexpr UInt32Char_t kSensorTc0f = "TC0F"; // CPU PECI die temperature filtered then adjusted
5151
constexpr UInt32Char_t kSensorTc0p = "TC0P"; // CPU proximity temperature
5252
#elif defined(ARCH_TYPE_ARM64)
53+
constexpr UInt32Char_t kSensorTc0a = "Tc0a";
54+
constexpr UInt32Char_t kSensorTc0b = "Tc0b";
55+
constexpr UInt32Char_t kSensorTc0x = "Tc0x";
56+
constexpr UInt32Char_t kSensorTc0z = "Tc0z";
5357
constexpr UInt32Char_t kSensorTp01 = "Tp01"; // CPU performance core 1 temperature
5458
constexpr UInt32Char_t kSensorTp05 = "Tp05"; // CPU performance core 2 temperature
5559
constexpr UInt32Char_t kSensorTp0d = "Tp0D"; // CPU performance core 3 temperature

0 commit comments

Comments
 (0)