mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: add mode to the fan (#152)
This commit is contained in:
@@ -19,6 +19,7 @@ public struct Fan {
|
||||
public let minSpeed: Double
|
||||
public let maxSpeed: Double
|
||||
public var value: Double
|
||||
public var mode: FanMode
|
||||
|
||||
var state: Bool {
|
||||
get {
|
||||
|
||||
@@ -33,7 +33,8 @@ internal class FansReader: Reader<[Fan]> {
|
||||
name: smc.pointee.getStringValue("F\(i)ID") ?? "Fan #\(i)",
|
||||
minSpeed: smc.pointee.getValue("F\(i)Mn") ?? 1,
|
||||
maxSpeed: smc.pointee.getValue("F\(i)Mx") ?? 1,
|
||||
value: smc.pointee.getValue("F\(i)Ac") ?? 0
|
||||
value: smc.pointee.getValue("F\(i)Ac") ?? 0,
|
||||
mode: self.getFanMode(i)
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -44,4 +45,21 @@ internal class FansReader: Reader<[Fan]> {
|
||||
}
|
||||
self.callback(self.list)
|
||||
}
|
||||
|
||||
private func getFanMode(_ id: Int) -> FanMode {
|
||||
let fansMode: Int = Int(self.smc.pointee.getValue("FS! ") ?? 0)
|
||||
var mode: FanMode = .automatic
|
||||
|
||||
if fansMode == 0 {
|
||||
mode = .automatic
|
||||
} else if fansMode == 3 {
|
||||
mode = .forced
|
||||
} else if fansMode == 1 && id == 0 {
|
||||
mode = .forced
|
||||
} else if fansMode == 2 && id == 1 {
|
||||
mode = .forced
|
||||
}
|
||||
|
||||
return mode
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user