mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: changed RPM to the percentage for the hottest fan (#1335)
This commit is contained in:
@@ -134,7 +134,7 @@ internal class SensorsReader: Reader<[Sensor_p]> {
|
||||
|
||||
var cpuSensors = self.list.filter({ $0.group == .CPU && $0.type == .temperature && $0.average }).map{ $0.value }
|
||||
var gpuSensors = self.list.filter({ $0.group == .GPU && $0.type == .temperature && $0.average }).map{ $0.value }
|
||||
let fanSensors = self.list.filter({ $0.type == .fan && !$0.isComputed }).map{ $0.value }
|
||||
let fanSensors = self.list.filter({ $0.type == .fan && !$0.isComputed })
|
||||
|
||||
#if arch(arm64)
|
||||
if self.HIDState {
|
||||
@@ -189,9 +189,9 @@ internal class SensorsReader: Reader<[Sensor_p]> {
|
||||
}
|
||||
}
|
||||
if !fanSensors.isEmpty && fanSensors.count > 1 {
|
||||
if let max = fanSensors.max() {
|
||||
if let f = fanSensors.max(by: { $0.value < $1.value }) as? Fan {
|
||||
if let idx = self.list.firstIndex(where: { $0.key == "Fastest Fan" }) {
|
||||
self.list[idx].value = max
|
||||
self.list[idx].value = (f.value*100)/f.maxSpeed
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,8 +213,8 @@ internal class SensorsReader: Reader<[Sensor_p]> {
|
||||
self.callback(self.list)
|
||||
}
|
||||
|
||||
private func initCalculatedSensors(_ sensors: [Sensor_p]) -> [Sensor] {
|
||||
var list: [Sensor] = []
|
||||
private func initCalculatedSensors(_ sensors: [Sensor_p]) -> [Sensor_p] {
|
||||
var list: [Sensor_p] = []
|
||||
|
||||
var cpuSensors = sensors.filter({ $0.group == .CPU && $0.type == .temperature && $0.average }).map{ $0.value }
|
||||
var gpuSensors = sensors.filter({ $0.group == .GPU && $0.type == .temperature && $0.average }).map{ $0.value }
|
||||
@@ -226,7 +226,7 @@ internal class SensorsReader: Reader<[Sensor_p]> {
|
||||
}
|
||||
#endif
|
||||
|
||||
let fanSensors = sensors.filter({ $0.type == .fan && !$0.isComputed }).map{ $0.value}
|
||||
let fanSensors = sensors.filter({ $0.type == .fan && !$0.isComputed })
|
||||
|
||||
if !cpuSensors.isEmpty {
|
||||
let value = cpuSensors.reduce(0, +) / Double(cpuSensors.count)
|
||||
@@ -243,8 +243,8 @@ internal class SensorsReader: Reader<[Sensor_p]> {
|
||||
}
|
||||
}
|
||||
if !fanSensors.isEmpty && fanSensors.count > 1 {
|
||||
if let max = fanSensors.max() {
|
||||
list.append(Sensor(key: "Fastest Fan", name: "Fastest Fan", value: max, group: .sensor, type: .fan, platforms: Platform.all, isComputed: true))
|
||||
if let f = fanSensors.max(by: { $0.value < $1.value }) as? Fan {
|
||||
list.append(Sensor(key: "Fastest Fan", name: "Fastest Fan", value: (f.value*100)/f.maxSpeed, group: .sensor, type: .fan, platforms: Platform.all, isComputed: true))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ internal struct Sensor: Sensor_p {
|
||||
case .current:
|
||||
return "A"
|
||||
case .fan:
|
||||
return "RPM"
|
||||
return "%"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ internal struct Sensor: Sensor_p {
|
||||
let val = value >= 9.95 ? "\(Int(round(value)))" : String(format: "%.1f", value)
|
||||
return "\(val)\(unit)"
|
||||
case .fan:
|
||||
return "\(Int(value))"
|
||||
return "\(Int(value))\(unit)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user