def set_countdown_pin_mode(): # cd_mode = various harm levels s = SettingsObject() which = s.get('cd_mode', 0) # default is brick del s ch = ['Brick', 'Final PIN', 'Test Mode'] def set(idx, text): # save it, but "outside" of login PIN s = SettingsObject() s.set('cd_mode', idx) s.save() del s return which, ch, set
def scramble_keypad_chooser(): # rngk = randomize keypad for PIN entry s = SettingsObject() which = s.get('rngk', 0) del s ch = ['Normal', 'Scramble Keys'] def set(idx, text): # save it, but "outside" of login PIN s = SettingsObject() s.set('rngk', idx) s.save() del s return which, ch, set
def real_countdown_chooser(tag, offset, def_to): # Login countdown length, stored in minutes # lgto_ch = [ 'Disabled', ' 5 minutes', '15 minutes', '30 minutes', ' 1 hour', ' 2 hours', ' 4 hours', ' 8 hours', '12 hours', '24 hours', '48 hours', ' 3 days', ' 1 week', '28 days later', ] lgto_va = [ 0, 5, 15, 30, 60, 2 * 60, 4 * 60, 8 * 60, 12 * 60, 24 * 60, 48 * 60, 72 * 60, 7 * 24 * 60, 28 * 24 * 60 ] # 'disabled' choice not appropriate for cd_lgto case ch = lgto_ch[offset:] va = lgto_va[offset:] s = SettingsObject() timeout = s.get(tag, def_to) # in minutes try: which = va.index(timeout) except ValueError: which = 0 def set_it(idx, text): # save on key0, not normal settings s = SettingsObject() s.set(tag, va[idx]) s.save() del s return which, ch, set_it
def set_it(idx, text): value = ch[idx][0] settings.set('sens', value) numpad.sensitivity = value # save also for next login time. from main import pa from nvstore import SettingsObject if not pa.is_secondary: tmp = SettingsObject() tmp.set('sens', value) tmp.save() del tmp
async def pick_nickname(*a): # from settings menu, enter a nickname from nvstore import SettingsObject # Value is not stored with normal settings, it's part of "prelogin" settings # which are encrypted with zero-key. s = SettingsObject() nick = s.get('nick', '') if not nick: ch = await ux_show_story('''\ You can give this Coldcard a nickname and it will be shown before login.''') if ch != 'y': return from seed import spinner_edit nn = await spinner_edit(nick, confirm_exit=False) nn = nn.strip() if nn else None s.set('nick', nn) s.save() del s
# Setup OLED and get something onto it. from display import Display dis = Display() dis.splash() # Setup membrane numpad (mark 2+) from mempad import MembraneNumpad numpad = MembraneNumpad(loop) # Serial Flash memory from sflash import SPIFlash sf = SPIFlash() # NV settings from nvstore import SettingsObject settings = SettingsObject(loop) # global ptr to HSM policy, if any (supported on Mk3 only) hsm_active = None async def done_splash2(): # Boot up code; after splash screen is done. # MAYBE: check if we're a brick and die again? Or show msg? if version.is_factory_mode: # in factory mode, turn on USB early to allow debug/setup from usb import enable_usb enable_usb(loop, True)
def set(idx, text): # save it, but "outside" of login PIN s = SettingsObject() s.set('rngk', idx) s.save() del s
def set_it(idx, text): # save on key0, not normal settings s = SettingsObject() s.set(tag, va[idx]) s.save() del s
if version.has_membrane: # Setup membrane numpad (mark 2+) from mempad import MembraneNumpad numpad = MembraneNumpad(loop) else: # Setup touch numpad (mark 1 hardware) from touchpad import TouchNumpad numpad = TouchNumpad(loop) # Serial Flash memory from sflash import SPIFlash sf = SPIFlash() # NV settings from nvstore import SettingsObject settings = SettingsObject(loop) # important default/restore preference numpad.sensitivity = settings.get('sens', numpad.sensitivity) async def done_splash2(): # Boot up code; after splash screen is done. # MAYBE: check if we're a brick and die again? Or show msg? if version.is_factory_mode(): # in factory mode, turn on USB early to allow debug/setup from usb import enable_usb enable_usb(loop, True)