Skip to content

Commit

Permalink
python: update symbol browser experiment
Browse files Browse the repository at this point in the history
Add arrows to show which buttons to use.
  • Loading branch information
vpayno committed May 15, 2024
1 parent 992a533 commit 20620df
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions python/src/browse-all-symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,36 @@
index: int = -1
COUNT: int = len(images)


def browse_left(index: int) -> int:
"""Scroll carousel to the left.
:param index: the current position
:return: the new position
"""
return (index - 1) % COUNT


def browse_right(index: int) -> int:
"""Scroll carousel to the right.
:param index: the current position
:return: the new position
"""
return (index + 1) % COUNT


# Code in a 'while True:' loop repeats forever
while True:
display.show(Image.ARROW_E)
sleep(500)
display.show(Image.ARROW_W)
sleep(500)

if button_a.was_pressed():
index = browse_left(index)
elif button_b.was_pressed():
index = browse_right(index)
elif pin_logo.is_touched():
print("INFO: not doing anything since the last image is already in a loop")

image: str

Expand Down

0 comments on commit 20620df

Please sign in to comment.