Skip to content

Commit

Permalink
mpflash: Lower update frequency of display for accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Josverl committed May 2, 2024
1 parent 5ef40ac commit 7f35f49
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/mpflash/mpflash/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def get_boards(ports: List[str], boards: List[str], clean: bool) -> List[Firmwar
for board in _urls:
board["port"] = port

for board in track(_urls, description=f"Checking {port} download pages", transient=True):
for board in track(_urls, description=f"Checking {port} download pages", transient=True,refresh_per_second=2):
# add a board to the list for each firmware found
firmwares = []
for ext in PORT_FWTYPES[port]:
Expand Down
2 changes: 1 addition & 1 deletion src/mpflash/mpflash/flash_uf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ def flash_uf2(mcu: MPRemoteBoard, fw_file: Path, erase: bool) -> Optional[MPRemo
log.success("Done copying, resetting the board and wait for it to restart")
if sys.platform in ["linux", "darwin"]:
dismount_uf2()
for _ in track(range(5 + 2), description="Waiting for the board to restart", transient=True):
for _ in track(range(5 + 2), description="Waiting for the board to restart", transient=True, refresh_per_second=2):
time.sleep(1) # 5 secs to short on linux
return mcu
2 changes: 1 addition & 1 deletion src/mpflash/mpflash/flash_uf2_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def wait_for_UF2_linux(s_max: int = 10):
wait = 10
uf2_drives = []
# while not destination and wait > 0:
for _ in track(range(s_max), description="Waiting for mcu to mount as a drive", transient=True):
for _ in track(range(s_max), description="Waiting for mcu to mount as a drive", transient=True,refresh_per_second=2):
# log.info(f"Waiting for mcu to mount as a drive : {wait} seconds left")
uf2_drives += list(get_uf2_drives())
for drive in get_uf2_drives():
Expand Down
2 changes: 1 addition & 1 deletion src/mpflash/mpflash/flash_uf2_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def wait_for_UF2_windows(s_max: int = 10):
if s_max < 1:
s_max = 10
destination = ""
for _ in track(range(s_max), description="Waiting for mcu to mount as a drive", transient=True):
for _ in track(range(s_max), description="Waiting for mcu to mount as a drive", transient=True,refresh_per_second=2):
# log.info(f"Waiting for mcu to mount as a drive : {n} seconds left")
drives = [drive.device for drive in psutil.disk_partitions()]
for drive in drives:
Expand Down
7 changes: 4 additions & 3 deletions src/mpflash/mpflash/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ def list_mcus(bluetooth: bool = False):
"""
conn_mcus = [MPRemoteBoard(sp) for sp in MPRemoteBoard.connected_boards(bluetooth) if sp not in config.ignore_ports]

# a lot of boilerplate to show a progress bar with the comport currenlty scanned
with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn()) as progress:
# a lot of boilerplate to show a progress bar with the comport currently scanned
# low update rate to facilitate screen readers/narration
with Progress(rp_spinner, rp_text, rp_bar, TimeElapsedColumn(), refresh_per_second=2) as progress:
tsk_scan = progress.add_task("[green]Scanning", visible=False, total=None)
progress.tasks[tsk_scan].fields["device"] = "..."
progress.tasks[tsk_scan].visible = True
Expand Down Expand Up @@ -105,7 +106,7 @@ def mcu_table(
if needs_build:
table.add_column("Build" if is_wide else "Bld", justify="right")

for mcu in track(conn_mcus, description="Updating board info", transient=True, update_period=0.1):
for mcu in track(conn_mcus, description="Updating board info", transient=True, refresh_per_second=2):
if refresh:
try:
mcu.get_mcu_info()
Expand Down
1 change: 1 addition & 0 deletions src/mpflash/mpflash/mpremoteboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def wait_for_restart(self, timeout: int = 10):
transient=True,
get_time=lambda: time.time(),
show_speed=False,
refresh_per_second=1,
):
time.sleep(1)
try:
Expand Down

0 comments on commit 7f35f49

Please sign in to comment.