mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-13 02:58:57 +00:00
refactor(core): expose USE_TOUCH and USE_BUTTON to uPy
[no changelog]
This commit is contained in:
parent
4b68431f7c
commit
c30f1231d5
@ -760,6 +760,8 @@ if FROZEN:
|
||||
bitcoin_only=BITCOIN_ONLY,
|
||||
backlight='backlight' in FEATURES_AVAILABLE,
|
||||
optiga='optiga' in FEATURES_AVAILABLE,
|
||||
use_button='button' in FEATURES_AVAILABLE,
|
||||
use_touch='touch' in FEATURES_AVAILABLE,
|
||||
ui_layout=UI_LAYOUT,
|
||||
thp=THP,
|
||||
)
|
||||
|
@ -485,18 +485,6 @@ elif TREZOR_MODEL in ('T3T1',):
|
||||
else:
|
||||
raise ValueError('Unknown Trezor model')
|
||||
|
||||
|
||||
if 'sd_card' in FEATURES_AVAILABLE:
|
||||
SDCARD = True
|
||||
else:
|
||||
SDCARD = False
|
||||
|
||||
if 'optiga' in FEATURES_AVAILABLE:
|
||||
OPTIGA = True
|
||||
else:
|
||||
OPTIGA = False
|
||||
|
||||
|
||||
env.Tool('micropython')
|
||||
|
||||
env.Replace(
|
||||
@ -664,7 +652,7 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/*.py',
|
||||
exclude=[
|
||||
SOURCE_PY_DIR + 'trezor/sdcard.py',
|
||||
] if not SDCARD else []
|
||||
] if 'sd_card' not in FEATURES_AVAILABLE else []
|
||||
))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/crypto/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/ui/*.py'))
|
||||
@ -701,7 +689,7 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py',
|
||||
exclude=[
|
||||
SOURCE_PY_DIR + 'storage/sd_salt.py',
|
||||
] if not SDCARD else []
|
||||
] if 'sd_card' not in FEATURES_AVAILABLE else []
|
||||
))
|
||||
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/__init__.py'))
|
||||
@ -726,16 +714,16 @@ if FROZEN:
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/common/*.py',
|
||||
exclude=[
|
||||
SOURCE_PY_DIR + 'apps/common/sdcard.py',
|
||||
] if not SDCARD else []
|
||||
] if "sd_card" not in FEATURES_AVAILABLE else []
|
||||
))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py',
|
||||
exclude=[
|
||||
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
||||
] if not SDCARD else [] + [
|
||||
] if "sd_card" not in FEATURES_AVAILABLE else [] + [
|
||||
SOURCE_PY_DIR + 'apps/management/authenticate_device.py',
|
||||
] if not OPTIGA else [])
|
||||
] if "optiga" not in FEATURES_AVAILABLE else [])
|
||||
)
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*/*.py'))
|
||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/misc/*.py'))
|
||||
@ -804,7 +792,9 @@ if FROZEN:
|
||||
source_dir=SOURCE_PY_DIR,
|
||||
bitcoin_only=BITCOIN_ONLY,
|
||||
backlight='backlight' in FEATURES_AVAILABLE,
|
||||
optiga=OPTIGA,
|
||||
optiga='optiga' in FEATURES_AVAILABLE,
|
||||
use_button='button' in FEATURES_AVAILABLE,
|
||||
use_touch='touch' in FEATURES_AVAILABLE,
|
||||
ui_layout=UI_LAYOUT,
|
||||
thp=THP,
|
||||
)
|
||||
|
@ -420,6 +420,10 @@ STATIC mp_obj_tuple_t mod_trezorutils_version_obj = {
|
||||
/// """Whether the hardware supports haptic feedback."""
|
||||
/// USE_OPTIGA: bool
|
||||
/// """Whether the hardware supports Optiga secure element."""
|
||||
/// USE_TOUCH: bool
|
||||
/// """Whether the hardware supports touch screen."""
|
||||
/// USE_BUTTON: bool
|
||||
/// """Whether the hardware supports two-button input."""
|
||||
/// MODEL: str
|
||||
/// """Model name."""
|
||||
/// MODEL_FULL_NAME: str
|
||||
@ -485,6 +489,16 @@ STATIC const mp_rom_map_elem_t mp_module_trezorutils_globals_table[] = {
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_OPTIGA), mp_const_true},
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_OPTIGA), mp_const_false},
|
||||
#endif
|
||||
#ifdef USE_TOUCH
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_TOUCH), mp_const_true},
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_TOUCH), mp_const_false},
|
||||
#endif
|
||||
#ifdef USE_BUTTON
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_BUTTON), mp_const_true},
|
||||
#else
|
||||
{MP_ROM_QSTR(MP_QSTR_USE_BUTTON), mp_const_false},
|
||||
#endif
|
||||
{MP_ROM_QSTR(MP_QSTR_MODEL), MP_ROM_PTR(&mod_trezorutils_model_name_obj)},
|
||||
{MP_ROM_QSTR(MP_QSTR_MODEL_FULL_NAME),
|
||||
|
@ -130,6 +130,10 @@ USE_HAPTIC: bool
|
||||
"""Whether the hardware supports haptic feedback."""
|
||||
USE_OPTIGA: bool
|
||||
"""Whether the hardware supports Optiga secure element."""
|
||||
USE_TOUCH: bool
|
||||
"""Whether the hardware supports touch screen."""
|
||||
USE_BUTTON: bool
|
||||
"""Whether the hardware supports two-button input."""
|
||||
MODEL: str
|
||||
"""Model name."""
|
||||
MODEL_FULL_NAME: str
|
||||
|
@ -46,6 +46,8 @@ def generate(env):
|
||||
optiga = env["optiga"]
|
||||
layout_tt = env["ui_layout"] == "UI_LAYOUT_TT"
|
||||
layout_tr = env["ui_layout"] == "UI_LAYOUT_TR"
|
||||
touch = env["use_touch"]
|
||||
button = env["use_button"]
|
||||
layout_mercury = env["ui_layout"] == "UI_LAYOUT_MERCURY"
|
||||
thp = env["thp"]
|
||||
interim = f"{target[:-4]}.i" # replace .mpy with .i
|
||||
@ -56,6 +58,8 @@ def generate(env):
|
||||
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'",
|
||||
rf"-e 's/utils\.USE_BUTTON/{button}/g'",
|
||||
rf"-e 's/utils\.USE_TOUCH/{touch}/g'",
|
||||
rf"-e 's/utils\.USE_THP/{thp}/g'",
|
||||
r"-e 's/if TYPE_CHECKING/if False/'",
|
||||
r"-e 's/import typing/# \0/'",
|
||||
|
@ -11,10 +11,12 @@ from trezorutils import ( # noqa: F401
|
||||
SCM_REVISION,
|
||||
UI_LAYOUT,
|
||||
USE_BACKLIGHT,
|
||||
USE_BUTTON,
|
||||
USE_HAPTIC,
|
||||
USE_OPTIGA,
|
||||
USE_SD_CARD,
|
||||
USE_THP,
|
||||
USE_TOUCH,
|
||||
VERSION,
|
||||
bootloader_locked,
|
||||
check_firmware_header,
|
||||
|
Loading…
Reference in New Issue
Block a user