What changed, and why it matters
This commit fixes a timing issue in how Krux detects whether the device has a battery. Previously, the battery check ran too early during power manager setup, before the analog-to-digital converter (ADC) had stabilized, which could cause the device to incorrectly decide it had no battery. The fix moves the check later, to the login screen, giving the ADC time to read the battery voltage correctly. The only visible effect is whether a 'Shutdown' menu item appears. There is no direct security vulnerability here; it is a reliability/usability bug fix.
No security action required. Treat as a normal reliability/bug-fix commit. If reviewing for release notes, note it as a battery-detection accuracy improvement.
Security signals we found
No security-relevant code paths altered
Change is a timing/reliability fix for hardware ADC initialization
No input validation, cryptography, authentication, or privilege changes
No references to vulnerabilities, CVEs, or security researchers
Evidence from the diff
The patch relocates the battery detection call from PowerManager.init to Login.init. In power.py, kboard.has_battery = self.has_battery() is removed from the PMU initialization block. In login.py, the Login page now calls ctx.power_manager.has_battery() after the power manager has had time to enable ADCs and settle, then conditionally appends the Shutdown menu item. A comment in kboard.py is also corrected. The change addresses an ADC settling-time issue that could lead to a false negative for battery presence.
Changed components
src/krux/power.pysrc/krux/pages/login.pysrc/krux/kboard.pyInspect captured patch +4 / −3
diff --git a/src/krux/kboard.py b/src/krux/kboard.py
index 8393912..ebe4789 100644
--- a/src/krux/kboard.py
+++ b/src/krux/kboard.py
@@ -35,7 +35,7 @@ class KBoard:
self.is_tzt = board.config["type"] == "tzt"
self.is_wonder_k = board.config["type"] == "wonder_k"
self.is_m5stickv = board.config["type"] == "m5stickv"
- self.has_battery = False # Varible to be set by PowerManager
+ self.has_battery = False # Variable to be set in Login Page
self.has_touchscreen = board.config["krux"]["display"].get("touch", False)
self.has_minimal_display = self.is_m5stickv or self.is_cube
self.can_control_brightness = any(
diff --git a/src/krux/pages/login.py b/src/krux/pages/login.py
index e1a0b54..e0dfde6 100644
--- a/src/krux/pages/login.py
+++ b/src/krux/pages/login.py
@@ -81,8 +81,10 @@ class Login(Page):
(t("Tools"), self.tools),
(t("About"), self.about),
]
+ if ctx.power_manager is not None:
+ kboard.has_battery = ctx.power_manager.has_battery()
if kboard.has_battery:
- login_menu_items.append((t("Shutdown"), ctx.power_manager.shutdown))
+ login_menu_items.append((t("Shutdown"), self.shutdown))
super().__init__(
ctx,
diff --git a/src/krux/power.py b/src/krux/power.py
index 6de6b9b..ea21cec 100644
--- a/src/krux/power.py
+++ b/src/krux/power.py
@@ -42,7 +42,6 @@ class PowerManager:
self.pmu.enable_adcs(True)
if kboard.is_m5stickv:
self.pmu.enable_pek_button_monitor()
- kboard.has_battery = self.has_battery()
except Exception as e:
print(e)
Why this scored 19/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.