mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-30 03:18:20 +00:00
refactor(core): expose USE_TOUCH and USE_BUTTON to uPy
[no changelog]
This commit is contained in:
parent
e9bb598d2f
commit
0f84d51051
@ -685,6 +685,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.get_ui_layout(TREZOR_MODEL),
|
||||
thp=THP,
|
||||
)
|
||||
|
@ -444,18 +444,6 @@ env = Environment(ENV=os.environ, CFLAGS='%s -DCONFIDENTIAL= -DPYOPT=%s -DBITCOI
|
||||
|
||||
FEATURES_AVAILABLE = models.configure_board(TREZOR_MODEL, HW_REVISION, FEATURES_WANTED, env, CPPDEFINES_HAL, SOURCE_UNIX, PATH_HAL)
|
||||
|
||||
|
||||
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(
|
||||
@ -629,7 +617,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'))
|
||||
@ -654,7 +642,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'))
|
||||
@ -679,16 +667,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'))
|
||||
@ -763,7 +751,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.get_ui_layout(TREZOR_MODEL),
|
||||
thp=THP,
|
||||
)
|
||||
|
@ -389,6 +389,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
|
||||
@ -454,6 +458,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