diff --git a/core/SConscript.firmware b/core/SConscript.firmware index f5432749c3..9d6a2e6c8d 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -416,12 +416,15 @@ SOURCE_FIRMWARE = [ ] -if TREZOR_MODEL in ('T', 'T3T1', 'DISC1', 'DISC2'): +if TREZOR_MODEL in ('T', 'DISC1', 'DISC2'): UI_LAYOUT = 'UI_LAYOUT_TT' ui_layout_feature = 'model_tt' elif TREZOR_MODEL in ('1', 'R'): UI_LAYOUT = 'UI_LAYOUT_TR' ui_layout_feature = 'model_tr' +elif TREZOR_MODEL in ('T3T1',): + UI_LAYOUT = 'UI_LAYOUT_MERCURY' + ui_layout_feature = 'model_mercury' else: raise ValueError('Unknown Trezor model') @@ -594,6 +597,12 @@ if FROZEN: SOURCE_PY_DIR + 'trezor/ui/layouts/tr/fido.py', ] if not EVERYTHING else [] )) + elif UI_LAYOUT == 'UI_LAYOUT_MERCURY': + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/mercury/*.py', + exclude=[ + SOURCE_PY_DIR + 'trezor/ui/layouts/mercury/fido.py', + ] if not EVERYTHING else [] + )) else: raise ValueError('Unknown layout') diff --git a/core/SConscript.unix b/core/SConscript.unix index b9d54c32bf..7483db4cfb 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -454,13 +454,15 @@ else: env = Environment(ENV=os.environ, CFLAGS='%s -DPYOPT=%s -DBITCOIN_ONLY=%s %s' % (ARGUMENTS.get('CFLAGS', ''), PYOPT, BITCOIN_ONLY, STATIC)) -if TREZOR_MODEL in ('T', 'T3T1'): +if TREZOR_MODEL in ('T',): UI_LAYOUT = 'UI_LAYOUT_TT' ui_layout_feature = 'model_tt' -# XXX TODO elif TREZOR_MODEL in ('1', 'R'): UI_LAYOUT = 'UI_LAYOUT_TR' ui_layout_feature = 'model_tr' +elif TREZOR_MODEL in ('T3T1',): + UI_LAYOUT = 'UI_LAYOUT_MERCURY' + ui_layout_feature = 'model_mercury' else: raise ValueError('Unknown Trezor model') @@ -680,6 +682,12 @@ if FROZEN: SOURCE_PY_DIR + 'trezor/ui/layouts/tr/fido.py', ] if not EVERYTHING else [] )) + elif UI_LAYOUT == 'UI_LAYOUT_MERCURY': + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/layouts/mercury/*.py', + exclude=[ + SOURCE_PY_DIR + 'trezor/ui/layouts/mercury/fido.py', + ] if not EVERYTHING else [] + )) else: raise ValueError('Unknown layout') diff --git a/core/embed/extmod/modtrezorutils/modtrezorutils.c b/core/embed/extmod/modtrezorutils/modtrezorutils.c index 2cde2041aa..9c78a3e3be 100644 --- a/core/embed/extmod/modtrezorutils/modtrezorutils.c +++ b/core/embed/extmod/modtrezorutils/modtrezorutils.c @@ -466,6 +466,8 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = { {MP_ROM_QSTR(MP_QSTR_UI_LAYOUT), MP_ROM_QSTR(MP_QSTR_TT)}, #elif UI_LAYOUT_TR {MP_ROM_QSTR(MP_QSTR_UI_LAYOUT), MP_ROM_QSTR(MP_QSTR_TR)}, +#elif UI_LAYOUT_MERCURY + {MP_ROM_QSTR(MP_QSTR_UI_LAYOUT), MP_ROM_QSTR(MP_QSTR_MERCURY)}, #else #error Unknown layout #endif diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml index 2381cdfa7d..0c42100b7e 100644 --- a/core/embed/rust/Cargo.toml +++ b/core/embed/rust/Cargo.toml @@ -10,6 +10,7 @@ default = ["model_tt"] crypto = ["zeroize"] model_tt = ["jpeg"] model_tr = [] +model_mercury = ["jpeg"] micropython = [] protobuf = ["micropython"] ui = [] diff --git a/core/embed/rust/src/ui/constant.rs b/core/embed/rust/src/ui/constant.rs index 91fd83f704..5534a1e3b5 100644 --- a/core/embed/rust/src/ui/constant.rs +++ b/core/embed/rust/src/ui/constant.rs @@ -1,7 +1,13 @@ //! Reexporting the `constant` module according to the //! current feature (Trezor model) -#[cfg(all(feature = "model_tr", not(feature = "model_tt")))] +#[cfg(feature = "model_mercury")] +pub use super::model_mercury::constant::*; +#[cfg(all( + feature = "model_tr", + not(feature = "model_tt"), + not(feature = "model_mercury") +))] pub use super::model_tr::constant::*; -#[cfg(feature = "model_tt")] +#[cfg(all(feature = "model_tt", not(feature = "model_mercury")))] pub use super::model_tt::constant::*; diff --git a/core/embed/rust/src/ui/display/loader/mod.rs b/core/embed/rust/src/ui/display/loader/mod.rs index f87ff791e6..3b780a57de 100644 --- a/core/embed/rust/src/ui/display/loader/mod.rs +++ b/core/embed/rust/src/ui/display/loader/mod.rs @@ -5,16 +5,16 @@ mod starry; use crate::ui::display::{Color, Icon}; -#[cfg(feature = "model_tt")] +#[cfg(any(feature = "model_tt", feature = "model_mercury"))] use crate::ui::display::loader::circular::{ loader_circular as determinate, loader_circular_indeterminate as indeterminate, }; -#[cfg(feature = "model_tt")] +#[cfg(any(feature = "model_tt", feature = "model_mercury"))] pub use crate::ui::display::loader::circular::{loader_circular_uncompress, LoaderDimensions}; -#[cfg(not(feature = "model_tt"))] +#[cfg(all(not(feature = "model_tt"), not(feature = "model_mercury")))] use crate::ui::display::loader::rectangular::loader_rectangular as determinate; -#[cfg(not(feature = "model_tt"))] +#[cfg(all(not(feature = "model_tt"), not(feature = "model_mercury")))] use crate::ui::display::loader::starry::loader_starry_indeterminate as indeterminate; pub use small::loader_small_indeterminate; diff --git a/core/embed/rust/src/ui/mod.rs b/core/embed/rust/src/ui/mod.rs index 98891d08ee..6683baa170 100644 --- a/core/embed/rust/src/ui/mod.rs +++ b/core/embed/rust/src/ui/mod.rs @@ -17,6 +17,8 @@ pub mod util; #[cfg(feature = "micropython")] pub mod layout; +#[cfg(feature = "model_mercury")] +pub mod model_mercury; #[cfg(feature = "model_tr")] pub mod model_tr; #[cfg(feature = "model_tt")] diff --git a/core/embed/rust/src/ui/screens.rs b/core/embed/rust/src/ui/screens.rs index fa3c2cf5d8..3138ee2b73 100644 --- a/core/embed/rust/src/ui/screens.rs +++ b/core/embed/rust/src/ui/screens.rs @@ -1,6 +1,8 @@ //! Reexporting the `screens` module according to the //! current feature (Trezor model) +#[cfg(feature = "model_mercury")] +pub use super::model_mercury::screens::*; #[cfg(all(feature = "model_tr", not(feature = "model_tt")))] pub use super::model_tr::screens::*; #[cfg(feature = "model_tt")] diff --git a/core/embed/rust/src/ui/shape/model/mod.rs b/core/embed/rust/src/ui/shape/model/mod.rs index 7a041b13db..50b533237c 100644 --- a/core/embed/rust/src/ui/shape/model/mod.rs +++ b/core/embed/rust/src/ui/shape/model/mod.rs @@ -7,3 +7,8 @@ pub use model_tr::render_on_display; pub mod model_tt; #[cfg(feature = "model_tt")] pub use model_tt::render_on_display; + +#[cfg(feature = "model_mercury")] +pub mod model_mercury; +#[cfg(feature = "model_mercury")] +pub use model_mercury::render_on_display; diff --git a/core/site_scons/site_tools/micropython/__init__.py b/core/site_scons/site_tools/micropython/__init__.py index 94477ba2c9..81345798af 100644 --- a/core/site_scons/site_tools/micropython/__init__.py +++ b/core/site_scons/site_tools/micropython/__init__.py @@ -47,6 +47,7 @@ def generate(env): optiga = env["optiga"] layout_tt = env["ui_layout"] == "UI_LAYOUT_TT" layout_tr = env["ui_layout"] == "UI_LAYOUT_TR" + layout_mercury = env["ui_layout"] == "UI_LAYOUT_MERCURY" interim = f"{target[:-4]}.i" # replace .mpy with .i sed_scripts = " ".join( [ @@ -56,6 +57,7 @@ def generate(env): rf"-e 's/utils\.USE_OPTIGA/{optiga}/g'", rf"-e 's/utils\.UI_LAYOUT == \"TT\"/{layout_tt}/g'", rf"-e 's/utils\.UI_LAYOUT == \"TR\"/{layout_tr}/g'", + rf"-e 's/utils\.UI_LAYOUT == \"MERCURY\"/{layout_mercury}/g'", r"-e 's/if TYPE_CHECKING/if False/'", r"-e 's/import typing/# \0/'", r"-e '/from typing import (/,/^\s*)/ {s/^/# /; }'", diff --git a/core/src/all_modules.py b/core/src/all_modules.py index e1162a3c23..04d2ceb546 100644 --- a/core/src/all_modules.py +++ b/core/src/all_modules.py @@ -157,6 +157,18 @@ trezor.ui.layouts.fido import trezor.ui.layouts.fido trezor.ui.layouts.homescreen import trezor.ui.layouts.homescreen +trezor.ui.layouts.mercury +import trezor.ui.layouts.mercury +trezor.ui.layouts.mercury.fido +import trezor.ui.layouts.mercury.fido +trezor.ui.layouts.mercury.homescreen +import trezor.ui.layouts.mercury.homescreen +trezor.ui.layouts.mercury.progress +import trezor.ui.layouts.mercury.progress +trezor.ui.layouts.mercury.recovery +import trezor.ui.layouts.mercury.recovery +trezor.ui.layouts.mercury.reset +import trezor.ui.layouts.mercury.reset trezor.ui.layouts.progress import trezor.ui.layouts.progress trezor.ui.layouts.recovery diff --git a/core/src/trezor/ui/layouts/__init__.py b/core/src/trezor/ui/layouts/__init__.py index a29e2e2cfd..b477332f45 100644 --- a/core/src/trezor/ui/layouts/__init__.py +++ b/core/src/trezor/ui/layouts/__init__.py @@ -8,5 +8,7 @@ if utils.UI_LAYOUT == "TR": from .tr import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TT": from .tt import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury import * # noqa: F401,F403 else: raise ValueError("Unknown layout") diff --git a/core/src/trezor/ui/layouts/fido.py b/core/src/trezor/ui/layouts/fido.py index 6b3cb944e3..e7447b1a62 100644 --- a/core/src/trezor/ui/layouts/fido.py +++ b/core/src/trezor/ui/layouts/fido.py @@ -4,3 +4,5 @@ if utils.UI_LAYOUT == "TT": from .tt.fido import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TR": from .tr.fido import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury.fido import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/homescreen.py b/core/src/trezor/ui/layouts/homescreen.py index fe31124a26..ef13c57a4d 100644 --- a/core/src/trezor/ui/layouts/homescreen.py +++ b/core/src/trezor/ui/layouts/homescreen.py @@ -4,3 +4,5 @@ if utils.UI_LAYOUT == "TT": from .tt.homescreen import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TR": from .tr.homescreen import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury.homescreen import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/progress.py b/core/src/trezor/ui/layouts/progress.py index fff760ab1d..99cbfd136f 100644 --- a/core/src/trezor/ui/layouts/progress.py +++ b/core/src/trezor/ui/layouts/progress.py @@ -4,3 +4,5 @@ if utils.UI_LAYOUT == "TT": from .tt.progress import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TR": from .tr.progress import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury.progress import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/recovery.py b/core/src/trezor/ui/layouts/recovery.py index f41f1ae8b2..12a0b33540 100644 --- a/core/src/trezor/ui/layouts/recovery.py +++ b/core/src/trezor/ui/layouts/recovery.py @@ -4,3 +4,5 @@ if utils.UI_LAYOUT == "TT": from .tt.recovery import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TR": from .tr.recovery import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury.recovery import * # noqa: F401,F403 diff --git a/core/src/trezor/ui/layouts/reset.py b/core/src/trezor/ui/layouts/reset.py index d0cf6b1c9f..d180953509 100644 --- a/core/src/trezor/ui/layouts/reset.py +++ b/core/src/trezor/ui/layouts/reset.py @@ -4,3 +4,5 @@ if utils.UI_LAYOUT == "TT": from .tt.reset import * # noqa: F401,F403 elif utils.UI_LAYOUT == "TR": from .tr.reset import * # noqa: F401,F403 +elif utils.UI_LAYOUT == "MERCURY": + from .mercury.reset import * # noqa: F401,F403