mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: added m2 and m3 sensors to the CPU temperature reader (#1698)
This commit is contained in:
@@ -248,6 +248,20 @@ public class ProcessReader: Reader<[TopProcess]> {
|
||||
}
|
||||
|
||||
public class TemperatureReader: Reader<Double> {
|
||||
var list: [String] = []
|
||||
|
||||
public override func setup() {
|
||||
switch SystemKit.shared.device.platform {
|
||||
case .m1, .m1Pro, .m1Max, .m1Ultra:
|
||||
self.list = ["Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D", "Tp0H", "Tp0L", "Tp0P", "Tp0X", "Tp0b"]
|
||||
case .m2, .m2Pro, .m2Max, .m2Ultra:
|
||||
self.list = ["Tp0A", "Tp0D", "Tp0E", "Tp01", "Tp02", "Tp05", "Tp06", "Tp09"]
|
||||
case .m3, .m3Pro, .m3Max, .m3Ultra:
|
||||
self.list = ["Te05", "Te0L", "Te0P", "Te0S", "Tf04", "Tf09", "Tf0A", "Tf0B", "Tf0D", "Tf0E", "Tf44", "Tf49", "Tf4A", "Tf4B", "Tf4D", "Tf4E"]
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
||||
public override func read() {
|
||||
var temperature: Double? = nil
|
||||
|
||||
@@ -262,10 +276,9 @@ public class TemperatureReader: Reader<Double> {
|
||||
} else if let value = SMC.shared.getValue("TC0H"), value < 110 {
|
||||
temperature = value
|
||||
} else {
|
||||
#if arch(arm64)
|
||||
var total: Double = 0
|
||||
var counter: Double = 0
|
||||
["Tp09", "Tp0T", "Tp01", "Tp05", "Tp0D", "Tp0H", "Tp0L", "Tp0P", "Tp0X", "Tp0b"].forEach { (key: String) in
|
||||
self.list.forEach { (key: String) in
|
||||
if let value = SMC.shared.getValue(key) {
|
||||
total += value
|
||||
counter += 1
|
||||
@@ -274,7 +287,6 @@ public class TemperatureReader: Reader<Double> {
|
||||
if total != 0 && counter != 0 {
|
||||
temperature = total / counter
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
self.callback(temperature)
|
||||
|
||||
Reference in New Issue
Block a user