fixup! feat(core): add settings to turn haptic on/off

mmilata/ui-t3t1-preview
tychovrahe 4 weeks ago
parent e65f540545
commit 4f700c68cd

@ -21,20 +21,21 @@
/// package: trezorio.haptic
/// def haptic_set(enable: bool) -> None:
/// def haptic_set_enabled(enable: bool) -> None:
/// """
/// Enable/Disable the haptic feedback.
/// """
STATIC mp_obj_t mod_trezorio_haptic_set(mp_obj_t enable) {
STATIC mp_obj_t mod_trezorio_haptic_set_enabled(mp_obj_t enable) {
haptic_set_enabled(mp_obj_is_true(enable));
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorio_haptic_set_obj,
mod_trezorio_haptic_set);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_trezorio_haptic_set_enabled_obj,
mod_trezorio_haptic_set_enabled);
STATIC const mp_rom_map_elem_t mod_trezorio_haptic_globals_table[] = {
{MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_haptic)},
{MP_ROM_QSTR(MP_QSTR_haptic_set), MP_ROM_PTR(&mod_trezorio_haptic_set_obj)},
{MP_ROM_QSTR(MP_QSTR_haptic_set_enabled),
MP_ROM_PTR(&mod_trezorio_haptic_set_enabled_obj)},
};
STATIC MP_DEFINE_CONST_DICT(mod_trezorio_haptic_globals,

@ -60,7 +60,7 @@ bool usb_connected_previously = true;
#endif
/// package: trezorio.__init__
/// from . import fatfs, sdcard, haptic
/// from . import fatfs, haptic, sdcard
/// POLL_READ: int # wait until interface is readable and return read data
/// POLL_WRITE: int # wait until interface is writable

@ -190,7 +190,7 @@ class WebUSB:
"""
Sends message using USB WebUSB (device) or UDP (emulator).
"""
from . import fatfs, sdcard, haptic
from . import fatfs, haptic, sdcard
POLL_READ: int # wait until interface is readable and return read data
POLL_WRITE: int # wait until interface is writable
TOUCH: int # interface id of the touch events

@ -2,7 +2,7 @@ from typing import *
# extmod/modtrezorio/modtrezorio-haptic.h
def haptic_set(enable: bool) -> None:
def haptic_set_enabled(enable: bool) -> None:
"""
Enable/Disable the haptic feedback.
"""

@ -127,7 +127,7 @@ async def apply_settings(msg: ApplySettings) -> Success:
from trezor import io
await _require_confirm_haptic_feedback(haptic_feedback)
io.haptic.haptic_set(haptic_feedback)
io.haptic.haptic_set_enabled(haptic_feedback)
storage_device.set_haptic_feedback(haptic_feedback)
reload_settings_from_storage()
@ -292,17 +292,9 @@ if utils.USE_BACKLIGHT:
if utils.USE_HAPTIC:
async def _require_confirm_haptic_feedback(enable: bool) -> None:
if enable:
await confirm_action(
"haptic_feedback__enable",
TR.haptic_feedback__title,
TR.haptic_feedback__enable,
br_code=BRT_PROTECT_CALL,
)
else:
await confirm_action(
"haptic_feedback__disable",
TR.haptic_feedback__title,
TR.haptic_feedback__disable,
br_code=BRT_PROTECT_CALL,
)
await confirm_action(
"haptic_feedback__settings",
TR.haptic_feedback__title,
TR.haptic_feedback__enable if enable else TR.haptic_feedback__disable,
br_code=BRT_PROTECT_CALL,
)

@ -10,7 +10,7 @@ welcome_screen_start_ms = utime.ticks_ms()
import storage
import storage.device
from trezor import config, log, loop, ui, io, utils, wire, translations
from trezor import config, io, log, loop, ui, utils, wire, translations
from trezor.pin import (
allow_all_loader_messages,
ignore_nonpin_loader_messages,
@ -52,7 +52,7 @@ async def bootscreen() -> None:
ui.backlight_fade(ui.style.get_backlight_dim())
ui.display.orientation(storage.device.get_rotation())
if utils.USE_HAPTIC:
io.haptic.haptic_set(storage.device.get_haptic_feedback())
io.haptic.haptic_set_enabled(storage.device.get_haptic_feedback())
await lockscreen
await verify_user_pin()
@ -65,7 +65,7 @@ async def bootscreen() -> None:
enforce_welcome_screen_duration()
rotation = storage.device.get_rotation()
if utils.USE_HAPTIC:
io.haptic.haptic_set(storage.device.get_haptic_feedback())
io.haptic.haptic_set_enabled(storage.device.get_haptic_feedback())
if rotation != ui.display.orientation():
# there is a slight delay before next screen is shown,

Loading…
Cancel
Save