mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
refactor(core): expose USE_TOUCH and USE_BUTTON to uPy
[no changelog]
This commit is contained in:
parent
dbe6c1c664
commit
1efb684544
@ -684,6 +684,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,
|
||||
)
|
||||
|
@ -443,18 +443,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(
|
||||
@ -628,7 +616,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'))
|
||||
@ -653,7 +641,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'))
|
||||
@ -678,16 +666,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'))
|
||||
@ -762,7 +750,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,
|
||||
)
|
||||
|
@ -388,6 +388,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
|
||||
@ -453,6 +457,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