Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions SensorsKit/SensorHistoryData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ public class SensorHistoryData: NSObject, Synchronizable
case voltage
case current
case ambiantLight
case rpm

public var description: String
{
switch self
{
case .thermal: return "thermal"
case .rpm: return "rpm"
case .voltage: return "voltage"
case .current: return "current"
case .ambiantLight: return "ambiantLight"
Expand Down
4 changes: 4 additions & 0 deletions SensorsKit/Sensors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ public class Sensors: NSObject

private var shouldRun = true
private var completion: ( () -> Void )?
private var regexFanRPM: NSRegularExpression

@objc
public override init()
{
self.regexFanRPM = try! NSRegularExpression( pattern: "F[0-9]Ac" )

super.init()

DispatchQueue.global( qos: .background ).async
Expand Down Expand Up @@ -114,6 +117,7 @@ public class Sensors: NSObject
let all = SMC.shared.readAllKeys()

all.filter { $0.keyName.hasPrefix( "T" ) }.forEach { self.addSensorHistoryData( data: $0, kind: .thermal ) }
all.filter { self.regexFanRPM.firstMatch(in: $0.keyName, range: NSMakeRange(0, $0.keyName.count)) != nil }.forEach { self.addSensorHistoryData( data: $0, kind: .rpm ) }
all.filter { $0.keyName.hasPrefix( "V" ) }.forEach { self.addSensorHistoryData( data: $0, kind: .voltage ) }
all.filter { $0.keyName.hasPrefix( "I" ) }.forEach { self.addSensorHistoryData( data: $0, kind: .current ) }
}
Expand Down