feat(core): extend fuel gauge UI component
What changed, and why it matters
This commit adds a new display mode to the battery indicator on Trezor hardware wallets. It lets the device show only a charging icon (without the battery percentage number) when the device is plugged in. There is no security-relevant change here—only a user-interface tweak.
No security action required. Treat as a normal UI feature commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends the Rust-based FuelGauge UI component in the Eckhart layout by adding a ChargingIconOnly variant. It adds a constructor, updates should_be_shown() to return true only when ChargingState::Charging, and modifies paint logic to render only the charging icon and skip the state-of-charge percentage text in this mode. No cryptographic, memory-safety, or trust-boundary changes are present.
Changed components
core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rsInspect captured patch +37 / −13
diff --git a/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs b/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
index 0895dad38..ef6bfa6c3 100644
--- a/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
+++ b/core/embed/rust/src/ui/layout_eckhart/component/fuel_gauge.rs
@@ -45,6 +45,8 @@ pub struct FuelGauge {
pub enum FuelGaugeMode {
/// Always show the fuel gauge
Always,
+ /// Show only charging icon if the device is charging
+ ChargingIconOnly,
/// Show the fuel gauge only when charging state changes
#[cfg(feature = "micropython")]
OnChargingChange(Timer),
@@ -58,6 +60,10 @@ impl FuelGauge {
Self::new(FuelGaugeMode::Always)
}
+ pub const fn charging_icon_only() -> Self {
+ Self::new(FuelGaugeMode::ChargingIconOnly)
+ }
+
#[cfg(feature = "micropython")]
pub const fn on_charging_change() -> Self {
Self::new(FuelGaugeMode::OnChargingChange(Timer::new()))
@@ -86,6 +92,7 @@ impl FuelGauge {
pub fn should_be_shown(&self) -> bool {
match &self.mode {
FuelGaugeMode::Always => true,
+ FuelGaugeMode::ChargingIconOnly => self.charging_state == ChargingState::Charging,
#[cfg(feature = "micropython")]
FuelGaugeMode::OnChargingChange(timer)
| FuelGaugeMode::OnChargingChangeOrAttach(timer) => timer.is_running(),
@@ -158,6 +165,11 @@ impl Component for FuelGauge {
FuelGaugeMode::Always => {
ctx.request_paint();
}
+ FuelGaugeMode::ChargingIconOnly => {
+ if _e.charging_status_changed {
+ ctx.request_paint();
+ }
+ }
#[cfg(feature = "micropython")]
FuelGaugeMode::OnChargingChange(timer)
| FuelGaugeMode::OnChargingChangeOrAttach(timer) => {
@@ -215,19 +227,31 @@ impl Component for FuelGauge {
);
let text_y_coord = self.font.vert_center(area.y0, area.y1, &soc_percent_fmt);
- shape::ToifImage::new(area.left_center(), icon.toif)
- .with_fg(color_icon)
- .with_align(Alignment2D::CENTER_LEFT)
- .render(target);
-
- shape::Text::new(
- Point::new(area.x1, text_y_coord),
- &soc_percent_fmt,
- self.font,
- )
- .with_fg(color_text)
- .with_align(Alignment::End)
- .render(target);
+ match self.mode {
+ FuelGaugeMode::ChargingIconOnly => {
+ if self.charging_state == ChargingState::Charging {
+ shape::ToifImage::new(area.left_center(), icon.toif)
+ .with_fg(color_icon)
+ .with_align(Alignment2D::CENTER_LEFT)
+ .render(target);
+ }
+ }
+ _ => {
+ shape::ToifImage::new(area.left_center(), icon.toif)
+ .with_fg(color_icon)
+ .with_align(Alignment2D::CENTER_LEFT)
+ .render(target);
+
+ shape::Text::new(
+ Point::new(area.x1, text_y_coord),
+ &soc_percent_fmt,
+ self.font,
+ )
+ .with_fg(color_text)
+ .with_align(Alignment::End)
+ .render(target);
+ }
+ }
}
}
Why this scored 15/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.