1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-06-25 17:32:34 +00:00

chore(core): remove battery from show_device_menu

- the battery status changes are now propagated into Components by
Event::PM

[no changelog]
This commit is contained in:
obrusvit 2025-06-03 13:10:53 +02:00 committed by Vít Obrusník
parent f04edf3a28
commit 17d6dd4a55
10 changed files with 1 additions and 37 deletions

View File

@ -123,7 +123,6 @@ static void _librust_qstrs(void) {
MP_QSTR_backup__title_create_wallet_backup; MP_QSTR_backup__title_create_wallet_backup;
MP_QSTR_backup__title_skip; MP_QSTR_backup__title_skip;
MP_QSTR_backup__want_to_skip; MP_QSTR_backup__want_to_skip;
MP_QSTR_battery_percentage;
MP_QSTR_bitcoin__commitment_data; MP_QSTR_bitcoin__commitment_data;
MP_QSTR_bitcoin__confirm_locktime; MP_QSTR_bitcoin__confirm_locktime;
MP_QSTR_bitcoin__create_proof_of_ownership; MP_QSTR_bitcoin__create_proof_of_ownership;

View File

@ -841,7 +841,6 @@ extern "C" fn new_show_homescreen(n_args: usize, args: *const Obj, kwargs: *mut
extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj {
let block = move |_args: &[Obj], kwargs: &Map| { let block = move |_args: &[Obj], kwargs: &Map| {
let failed_backup: bool = kwargs.get(Qstr::MP_QSTR_failed_backup)?.try_into()?; let failed_backup: bool = kwargs.get(Qstr::MP_QSTR_failed_backup)?.try_into()?;
let battery_percentage: u8 = kwargs.get_or(Qstr::MP_QSTR_battery_percentage, 0)?;
let firmware_version: TString = kwargs.get(Qstr::MP_QSTR_firmware_version)?.try_into()?; let firmware_version: TString = kwargs.get(Qstr::MP_QSTR_firmware_version)?.try_into()?;
let device_name: TString = kwargs.get(Qstr::MP_QSTR_device_name)?.try_into()?; let device_name: TString = kwargs.get(Qstr::MP_QSTR_device_name)?.try_into()?;
let paired_devices: Obj = kwargs.get(Qstr::MP_QSTR_paired_devices)?; let paired_devices: Obj = kwargs.get(Qstr::MP_QSTR_paired_devices)?;
@ -850,7 +849,6 @@ extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut
kwargs.get(Qstr::MP_QSTR_auto_lock_delay)?.try_into()?; kwargs.get(Qstr::MP_QSTR_auto_lock_delay)?.try_into()?;
let layout = ModelUI::show_device_menu( let layout = ModelUI::show_device_menu(
failed_backup, failed_backup,
battery_percentage,
firmware_version, firmware_version,
device_name, device_name,
paired_devices, paired_devices,
@ -1675,7 +1673,6 @@ pub static mp_module_trezorui_api: Module = obj_module! {
/// def show_device_menu( /// def show_device_menu(
/// *, /// *,
/// failed_backup: bool, /// failed_backup: bool,
/// battery_percentage: int,
/// firmware_version: str, /// firmware_version: str,
/// device_name: str, /// device_name: str,
/// paired_devices: Iterable[str], /// paired_devices: Iterable[str],

View File

@ -880,7 +880,6 @@ impl FirmwareUI for UIBolt {
fn show_device_menu( fn show_device_menu(
_failed_backup: bool, _failed_backup: bool,
_battery_percentage: u8,
_firmware_version: TString<'static>, _firmware_version: TString<'static>,
_device_name: TString<'static>, _device_name: TString<'static>,
_paired_devices: heapless::Vec<TString<'static>, 1>, _paired_devices: heapless::Vec<TString<'static>, 1>,

View File

@ -1073,7 +1073,6 @@ impl FirmwareUI for UICaesar {
fn show_device_menu( fn show_device_menu(
_failed_backup: bool, _failed_backup: bool,
_battery_percentage: u8,
_firmware_version: TString<'static>, _firmware_version: TString<'static>,
_device_name: TString<'static>, _device_name: TString<'static>,
_paired_devices: Vec<TString<'static>, 1>, _paired_devices: Vec<TString<'static>, 1>,

View File

@ -900,7 +900,6 @@ impl FirmwareUI for UIDelizia {
fn show_device_menu( fn show_device_menu(
_failed_backup: bool, _failed_backup: bool,
_battery_percentage: u8,
_firmware_version: TString<'static>, _firmware_version: TString<'static>,
_device_name: TString<'static>, _device_name: TString<'static>,
_paired_devices: heapless::Vec<TString<'static>, 1>, _paired_devices: heapless::Vec<TString<'static>, 1>,

View File

@ -147,23 +147,17 @@ enum ActiveScreen<'a> {
pub struct DeviceMenuScreen<'a> { pub struct DeviceMenuScreen<'a> {
bounds: Rect, bounds: Rect,
battery_percentage: u8,
firmware_version: TString<'static>, firmware_version: TString<'static>,
// These correspond to the currently active subscreen, // These correspond to the currently active subscreen,
// which is one of the possible kinds of subscreens // which is one of the possible kinds of subscreens
// as defined by `enum Subscreen` (DeviceScreen is still a VerticalMenuScreen!) // as defined by `enum Subscreen` (DeviceScreen is still a VerticalMenuScreen!)
// This way we only need to keep one screen at any time in memory. // This way we only need to keep one screen at any time in memory.
active_screen: GcBox<ActiveScreen<'a>>, active_screen: GcBox<ActiveScreen<'a>>,
// Information needed to construct any subscreen on demand // Information needed to construct any subscreen on demand
submenus: GcBox<Vec<Submenu, MAX_SUBMENUS>>, submenus: GcBox<Vec<Submenu, MAX_SUBMENUS>>,
subscreens: Vec<Subscreen, MAX_SUBSCREENS>, subscreens: Vec<Subscreen, MAX_SUBSCREENS>,
// index of the current subscreen in the list of subscreens // index of the current subscreen in the list of subscreens
active_subscreen: usize, active_subscreen: usize,
// stack of parents that led to the current subscreen // stack of parents that led to the current subscreen
parent_subscreens: Vec<usize, MAX_DEPTH>, parent_subscreens: Vec<usize, MAX_DEPTH>,
} }
@ -171,20 +165,14 @@ pub struct DeviceMenuScreen<'a> {
impl<'a> DeviceMenuScreen<'a> { impl<'a> DeviceMenuScreen<'a> {
pub fn new( pub fn new(
failed_backup: bool, failed_backup: bool,
battery_percentage: u8,
firmware_version: TString<'static>, firmware_version: TString<'static>,
device_name: TString<'static>, device_name: TString<'static>,
// NB: we currently only support one device at a time. // NB: we currently only support one device at a time.
// if we ever increase this size, we will need a way to return the correct
// device index on Disconnect back to uPy
// (see component_msg_obj.rs, which currently just returns "DeviceDisconnect" with no
// index!)
paired_devices: Vec<TString<'static>, 1>, paired_devices: Vec<TString<'static>, 1>,
auto_lock_delay: TString<'static>, auto_lock_delay: TString<'static>,
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let mut screen = Self { let mut screen = Self {
bounds: Rect::zero(), bounds: Rect::zero(),
battery_percentage,
firmware_version, firmware_version,
active_screen: GcBox::new(ActiveScreen::Empty)?, active_screen: GcBox::new(ActiveScreen::Empty)?,
active_subscreen: 0, active_subscreen: 0,
@ -219,10 +207,6 @@ impl<'a> DeviceMenuScreen<'a> {
Ok(screen) Ok(screen)
} }
fn is_low_battery(&self) -> bool {
self.battery_percentage < 20
}
fn add_paired_devices_menu( fn add_paired_devices_menu(
&mut self, &mut self,
paired_devices: Vec<TString<'static>, 1>, paired_devices: Vec<TString<'static>, 1>,
@ -397,14 +381,7 @@ impl<'a> DeviceMenuScreen<'a> {
} }
let mut header = Header::new(submenu.header_text).with_close_button(); let mut header = Header::new(submenu.header_text).with_close_button();
if submenu.show_battery { if submenu.show_battery {
header = header.with_icon( // TODO: add battery
theme::ICON_BATTERY_ZAP,
if self.is_low_battery() {
theme::YELLOW
} else {
theme::GREEN_LIME
},
);
} else { } else {
header = header.with_left_button( header = header.with_left_button(
Button::with_icon(theme::ICON_CHEVRON_LEFT), Button::with_icon(theme::ICON_CHEVRON_LEFT),

View File

@ -1018,7 +1018,6 @@ impl FirmwareUI for UIEckhart {
fn show_device_menu( fn show_device_menu(
failed_backup: bool, failed_backup: bool,
battery_percentage: u8,
firmware_version: TString<'static>, firmware_version: TString<'static>,
device_name: TString<'static>, device_name: TString<'static>,
paired_devices: Vec<TString<'static>, 1>, paired_devices: Vec<TString<'static>, 1>,
@ -1026,7 +1025,6 @@ impl FirmwareUI for UIEckhart {
) -> Result<impl LayoutMaybeTrace, Error> { ) -> Result<impl LayoutMaybeTrace, Error> {
let layout = RootComponent::new(DeviceMenuScreen::new( let layout = RootComponent::new(DeviceMenuScreen::new(
failed_backup, failed_backup,
battery_percentage,
firmware_version, firmware_version,
device_name, device_name,
paired_devices, paired_devices,

View File

@ -315,7 +315,6 @@ pub trait FirmwareUI {
fn show_device_menu( fn show_device_menu(
failed_backup: bool, failed_backup: bool,
battery_percentage: u8,
firmware_version: TString<'static>, firmware_version: TString<'static>,
device_name: TString<'static>, device_name: TString<'static>,
paired_devices: Vec<TString<'static>, 1>, paired_devices: Vec<TString<'static>, 1>,

View File

@ -553,7 +553,6 @@ def show_homescreen(
def show_device_menu( def show_device_menu(
*, *,
failed_backup: bool, failed_backup: bool,
battery_percentage: int,
firmware_version: str, firmware_version: str,
device_name: str, device_name: str,
paired_devices: Iterable[str], paired_devices: Iterable[str],

View File

@ -36,7 +36,6 @@ async def handle_device_menu() -> None:
storage.device.is_initialized() and storage.device.unfinished_backup() storage.device.is_initialized() and storage.device.unfinished_backup()
) )
# MOCK DATA # MOCK DATA
battery_percentage = 22
paired_devices = ["Trezor Suite"] if ble.is_connected() else [] paired_devices = ["Trezor Suite"] if ble.is_connected() else []
# ### # ###
firmware_version = ".".join(map(str, utils.VERSION)) firmware_version = ".".join(map(str, utils.VERSION))
@ -53,7 +52,6 @@ async def handle_device_menu() -> None:
menu_result = await interact( menu_result = await interact(
trezorui_api.show_device_menu( trezorui_api.show_device_menu(
failed_backup=failed_backup, failed_backup=failed_backup,
battery_percentage=battery_percentage,
paired_devices=paired_devices, paired_devices=paired_devices,
firmware_version=firmware_version, firmware_version=firmware_version,
device_name=device_name, device_name=device_name,