diff --git a/main.py b/main.py index f4ad02b..8fcb38e 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,8 @@ class Plugin: FAN_VOLTAGES = [0, 1000, 2000, 3000, 4000, 5000, 6000] set_fan_voltage = None + + # CPU stuff # call from main_view.html with setCPUs(count, smt) async def set_cpus(self, count, smt=True) -> int: @@ -69,6 +71,8 @@ class Plugin: freq = int(freq_maybe) return self.SCALING_FREQUENCIES.index(freq) + # Fan stuff + async def set_fan_tick(self, tick: int): self.set_fan_voltage = tick # cache voltage set to echo back in get_fan_tick() if tick >= len(self.FAN_VOLTAGES): @@ -101,6 +105,17 @@ class Plugin: return i return len(self.FAN_VOLTAGES)-1 # any higher value is considered as highest manual setting + # Battery stuff + + async def get_charge_now(self) -> int: + return int(read_from_sys("/sys/class/hwmon/hwmon2/device/charge_now", amount=-1).strip()) + + async def get_charge_full(self) -> int: + return int(read_from_sys("/sys/class/hwmon/hwmon2/device/charge_full", amount=-1).strip()) + + async def get_charge_design(self) -> int: + return int(read_from_sys("/sys/class/hwmon/hwmon2/device/charge_full_design", amount=-1).strip()) + # Asyncio-compatible long-running code, executed in a task when the plugin is loaded async def _main(self): pass diff --git a/main_view.html b/main_view.html index d4351c3..a5626f9 100644 --- a/main_view.html +++ b/main_view.html @@ -41,6 +41,18 @@ function getFanTick() { return call_plugin_method("get_fan_tick", {}); } + + function getChargeNow() { + return call_plugin_method("get_charge_now", {}); + } + + function getChargeFull() { + return call_plugin_method("get_charge_full", {}); + } + + function getChargeDesign() { + return call_plugin_method("get_charge_design", {}); + } // other logic @@ -51,6 +63,7 @@ selectNotch("cpuThreadsNotch", await getCPUs() - 1, 8); selectNotch("frequencyNotch", await getMaxBoost(), 3); selectNotch("fanNotch", await getFanTick(), 8); + await updateBatteryStats(); } async function setCPUNotch(index) { @@ -123,14 +136,24 @@ } } } + + async function updateBatteryStats() { + let batCapacityNow = document.getElementById("batCapacityNow"); + let batCapacityFull = document.getElementById("batCapacityFull"); + let chargeNow = await getChargeNow(); + let chargeFull = await getChargeFull(); + let chargeDesign = await getChargeDesign(); + batCapacityNow.innerText = (7.7 * chargeNow / 1000000).toFixed(2).toString() + " Wh (" + (100 * chargeNow / chargeFull).toFixed(0).toString() + "%)"; + batCapacityFull.innerText = (7.7 * chargeFull / 1000000).toFixed(2).toString() + " Wh (" + (100 * chargeFull / chargeDesign).toFixed(0).toString() + "%)"; + } - + - +
@@ -214,10 +239,12 @@
+
Allows the CPU to go above max frequency
+
@@ -253,7 +280,7 @@
- +
Fan RPM
@@ -303,5 +330,34 @@
+ + +
+
+
Battery
+
+
+
+
+
+
Now
+
+
??? (??%)
+
+
+
+
+
+
+
+
Max
+
+
??? (??%)
+
+
+
+
+
+