-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #208 from Foundation-Devices/PASS1-590-developer-p…
…atch PASS1-590: developer patch
- Loading branch information
Showing
18 changed files
with
266 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
# Keep lists below sorted for easier reference | ||
|
||
freeze('$(MPY_DIR)/ports/stm32/boards/Passport/modules', | ||
('developer/__init__.py', | ||
'developer/battery_page.py', | ||
'developer/delete_derived_keys_flow.py', | ||
'developer/developer_functions_flow.py', | ||
'developer/spin_delay_flow.py', | ||
)) | ||
|
||
include("$(MPY_DIR)/ports/stm32/boards/Passport/manifest.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# __init__.py | ||
|
||
from .developer_functions_flow import * | ||
from .spin_delay_flow import * | ||
from .delete_derived_keys_flow import * | ||
from .battery_page import * |
42 changes: 42 additions & 0 deletions
42
ports/stm32/boards/Passport/modules/developer/battery_page.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# SPDX-FileCopyrightText: © 2022 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# info_page.py | ||
|
||
import lvgl as lv | ||
from pages import StatusPage | ||
import microns | ||
|
||
|
||
class BatteryPage(StatusPage): | ||
def __init__(self, text=None, card_header={'title': 'Battery'}, | ||
statusbar=None, left_micron=None, right_micron=microns.Checkmark): | ||
from common import ui | ||
|
||
super().__init__( | ||
show_progress=True, | ||
percent=ui.battery_level, | ||
card_header=card_header, | ||
statusbar=statusbar, | ||
left_micron=left_micron, | ||
right_micron=right_micron) | ||
|
||
def update_battery(self): | ||
from common import ui | ||
self.set_progress(ui.battery_level) | ||
|
||
def on_timer(self, _t): | ||
self.update_battery() | ||
|
||
def attach(self, group): | ||
super().attach(group) | ||
|
||
# Create a timer to update the battery | ||
self.timer = lv.timer_create(self.on_timer, 5000, None) | ||
|
||
def detach(self): | ||
super().detach() | ||
|
||
if self.timer is not None: | ||
self.timer._del() | ||
self.timer = None |
29 changes: 29 additions & 0 deletions
29
ports/stm32/boards/Passport/modules/developer/delete_derived_keys_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# delete_deriveds_key_flow.py - Delete derived keys | ||
|
||
from flows import Flow | ||
|
||
|
||
class DeleteDerivedKeysFlow(Flow): | ||
def __init__(self): | ||
super().__init__(initial_state=self.confirm_delete, name='DeleteDerivedKeysFlow') | ||
|
||
async def confirm_delete(self): | ||
from pages import QuestionPage | ||
|
||
result = await QuestionPage(text='Delete all Child Keys?').show() | ||
|
||
if result: | ||
self.goto(self.do_delete) | ||
else: | ||
self.set_result(False) | ||
|
||
async def do_delete(self): | ||
from common import settings | ||
from pages import SuccessPage | ||
settings.remove('derived_keys') | ||
settings.save() | ||
await SuccessPage(text='Keys Deleted').show() | ||
self.set_result(True) |
41 changes: 41 additions & 0 deletions
41
ports/stm32/boards/Passport/modules/developer/developer_functions_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# SPDX-FileCopyrightText: © 2022 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# developer_functions_flow.py - Run a named developer function | ||
|
||
from flows import Flow | ||
|
||
|
||
class DeveloperFunctionsFlow(Flow): | ||
def __init__(self, fn_name=None): | ||
super().__init__(initial_state=self.run_function, name='DeveloperFunctionsFlow') | ||
self.fn_name = fn_name | ||
print('DeveloperFunctionsFlow: fn_name={}'.format(self.fn_name)) | ||
|
||
async def run_function(self): | ||
if self.fn_name == 'dump_settings': | ||
from common import settings | ||
from utils import to_str | ||
print('Current Settings:\n{}'.format(to_str(settings.current))) | ||
self.set_result(True) | ||
|
||
elif self.fn_name == 'factory_reset': | ||
from flows import ChangePINFlow | ||
from tasks import erase_passport_task | ||
from utils import spinner_task | ||
from pages import ErrorPage | ||
import common | ||
from common import system | ||
|
||
print('Factory Reset!') | ||
|
||
result = await ChangePINFlow().run() | ||
if result: | ||
await spinner_task('Factory Reset Passport...', erase_passport_task, args=[True]) | ||
common.settings.remove('setup_mode') | ||
system.reset() | ||
|
||
self.set_result(True) | ||
else: | ||
await ErrorPage(text='Unable to reset PIN, so not erasing Passport.').show() | ||
self.set_result(False) |
29 changes: 29 additions & 0 deletions
29
ports/stm32/boards/Passport/modules/developer/spin_delay_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: © 2022 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# spin_delay_flow.py - Show a spinner that will display until the given delay has expired. | ||
|
||
|
||
from flows import Flow | ||
|
||
|
||
class SpinDelayFlow(Flow): | ||
def __init__(self, delay_ms=5000): | ||
super().__init__(initial_state=self.spin, name='SpinDelayFlow') | ||
self.delay_ms = delay_ms | ||
|
||
async def spin(self): | ||
from utils import spinner_task | ||
from tasks import delay_task | ||
|
||
(error,) = await spinner_task( | ||
'Delaying for {}ms...'.format(self.delay_ms), | ||
delay_task, | ||
args=[self.delay_ms, True]) | ||
|
||
self.goto(self.show_success) | ||
|
||
async def show_success(self): | ||
from pages import SuccessPage | ||
await SuccessPage(text='Delay Complete').show() | ||
self.set_result(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
ports/stm32/boards/Passport/modules/flows/delete_derived_keys_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <hello@foundationdevices.com> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# delete_deriveds_key_flow.py - Delete derived keys | ||
|
||
from flows import Flow | ||
|
||
|
||
class DeleteDerivedKeysFlow(Flow): | ||
def __init__(self): | ||
super().__init__(initial_state=self.confirm_delete, name='DeleteDerivedKeysFlow') | ||
|
||
async def confirm_delete(self): | ||
from pages import QuestionPage | ||
|
||
result = await QuestionPage(text='Delete all Child Keys?').show() | ||
|
||
if result: | ||
self.goto(self.do_delete) | ||
else: | ||
self.set_result(False) | ||
|
||
async def do_delete(self): | ||
from common import settings | ||
from pages import SuccessPage | ||
settings.remove('derived_keys') | ||
settings.save() | ||
await SuccessPage(text='Keys Deleted').show() | ||
self.set_result(True) |
42 changes: 0 additions & 42 deletions
42
ports/stm32/boards/Passport/modules/flows/developer_functions_flow.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.