- enhancement: battery cycle (#245)

* - fix battery cycles not showing up in the popup.

* - resolve conflicts with the newest version

* fix: show correct GPU temperature on MBP16" built-in with Radeon Pro 5300M
This commit is contained in:
Junyi
2020-12-25 19:56:19 +08:00
committed by GitHub
parent f26f3e4691
commit 88162a703a
3 changed files with 23 additions and 8 deletions

View File

@@ -20,10 +20,11 @@ internal class Popup: NSView, Popup_p {
private var grid: NSGridView? = nil
private let dashboardHeight: CGFloat = 90
private let detailsHeight: CGFloat = 88 + Constants.Popup.separatorHeight
private let detailsHeight: CGFloat = (22 * 5) + Constants.Popup.separatorHeight
private let batteryHeight: CGFloat = (22 * 4) + Constants.Popup.separatorHeight
private let adapterHeight: CGFloat = 44 + Constants.Popup.separatorHeight
private let processHeight: CGFloat = 22
private let adapterHeight: CGFloat = (22 * 2) + Constants.Popup.separatorHeight
private let processHeight: CGFloat = (22 * 1)
private var dashboardView: NSView? = nil
private var dashboardBatteryView: BatteryView? = nil
@@ -36,6 +37,7 @@ internal class Popup: NSView, Popup_p {
private var timeLabelField: NSTextField? = nil
private var timeField: NSTextField? = nil
private var healthField: NSTextField? = nil
private var cyclesField: NSTextField? = nil
private var amperageField: NSTextField? = nil
private var voltageField: NSTextField? = nil
@@ -139,13 +141,14 @@ internal class Popup: NSView, Popup_p {
let view: NSView = NSView(frame: NSRect(x: 0, y: 0, width: self.frame.width, height: self.detailsHeight))
let separator = SeparatorView(LocalizedString("Details"), origin: NSPoint(x: 0, y: self.detailsHeight-Constants.Popup.separatorHeight), width: self.frame.width)
let container: NSView = NSView(frame: NSRect(x: 0, y: 0, width: self.frame.width, height: separator.frame.origin.y))
self.levelField = PopupRow(container, n: 3, title: "\(LocalizedString("Level")):", value: "").1
self.sourceField = PopupRow(container, n: 2, title: "\(LocalizedString("Source")):", value: "").1
let t = self.labelValue(container, n: 1, title: "\(LocalizedString("Time")):", value: "")
self.levelField = PopupRow(container, n: 4, title: "\(LocalizedString("Level")):", value: "").1
self.sourceField = PopupRow(container, n: 3, title: "\(LocalizedString("Source")):", value: "").1
let t = self.labelValue(container, n: 2, title: "\(LocalizedString("Time")):", value: "")
self.timeLabelField = t.0
self.timeField = t.1
self.healthField = PopupRow(container, n: 0, title: "\(LocalizedString("Health")):", value: "").1
self.healthField = PopupRow(container, n: 1, title: "\(LocalizedString("Health")):", value: "").1
self.cyclesField = PopupRow(container, n: 0, title: "\(LocalizedString("Cycles")):", value: "").1
view.addSubview(separator)
view.addSubview(container)
@@ -244,6 +247,7 @@ internal class Popup: NSView, Popup_p {
}
self.healthField?.stringValue = "\(value.health) % (\(value.state))"
self.cyclesField?.stringValue = "\(value.cycles)"
self.amperageField?.stringValue = "\(abs(value.amperage)) mA"
self.voltageField?.stringValue = "\(value.voltage.roundTo(decimalPlaces: 2)) V"

View File

@@ -117,6 +117,16 @@ internal class InfoReader: Reader<GPUs> {
}
}
if IOClass.starts(with: "AMDRadeon") && temperature == 0{
if let tmp = self.smc?.pointee.getValue("TGDD") { // AMD Radeon 5300M works
temperature = Int(tmp)
} else if let tmp = self.smc?.pointee.getValue("TG0P") { // GPU 0 Proximity
temperature = Int(tmp)
} else if let tmp = self.smc?.pointee.getValue("TG0D") {
temperature = Int(tmp)
}
}
if let agcInfo = accelerator["AGCInfo"] as? [String:Int] {
self.gpus.list[idx].state = agcInfo["poweredOffByAGC"] == 0
}

View File

@@ -116,6 +116,7 @@ let SensorsList: [Sensor_t] = [
Sensor_t(key: "TCGC", name: "GPU Intel Graphics", group: SensorGroup.GPU.rawValue, type: SensorType.Temperature.rawValue),
Sensor_t(key: "TG0D", name: "GPU diode", group: SensorGroup.GPU.rawValue, type: SensorType.Temperature.rawValue),
Sensor_t(key: "TGDD", name: "GPU AMD Radeon", group: SensorGroup.GPU.rawValue, type: SensorType.Temperature.rawValue),
Sensor_t(key: "TG0H", name: "GPU heatsink", group: SensorGroup.GPU.rawValue, type: SensorType.Temperature.rawValue),
Sensor_t(key: "TG0P", name: "GPU proximity", group: SensorGroup.GPU.rawValue, type: SensorType.Temperature.rawValue),