Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fleur
firmware
Commits
f34b58ca
Commit
f34b58ca
authored
5 years ago
by
Philip Stewart
Committed by
rahix
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(simple-menu): Add option to use right buttons for scrolling
parent
db14781c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pycardium/modules/py/simple_menu.py
+14
-2
14 additions, 2 deletions
pycardium/modules/py/simple_menu.py
with
14 additions
and
2 deletions
pycardium/modules/py/simple_menu.py
+
14
−
2
View file @
f34b58ca
...
...
@@ -120,6 +120,12 @@ class Menu:
.. versionadded:: 1.9
"""
right_buttons_scroll
=
False
"""
Use top right and bottom right buttons to move in the list
instead of bottom left and bottom right buttons.
"""
def
on_scroll
(
self
,
item
,
index
):
"""
Hook when the selector scrolls to a new item.
...
...
@@ -173,6 +179,12 @@ class Menu:
self
.
idx
=
0
self
.
select_time
=
utime
.
time_ms
()
self
.
disp
=
display
.
open
()
self
.
button_scroll_up
=
(
buttons
.
TOP_RIGHT
if
self
.
right_buttons_scroll
else
buttons
.
BOTTOM_LEFT
)
self
.
button_select
=
(
buttons
.
BOTTOM_LEFT
if
self
.
right_buttons_scroll
else
buttons
.
TOP_RIGHT
)
def
entry2name
(
self
,
value
):
"""
...
...
@@ -290,7 +302,7 @@ class Menu:
except
Exception
as
e
:
print
(
"
Exception during menu.on_scroll():
"
)
sys
.
print_exception
(
e
)
elif
ev
==
button
s
.
BOTTOM_LEFT
:
elif
ev
==
self
.
button
_scroll_up
:
self
.
select_time
=
utime
.
time_ms
()
self
.
draw_menu
(
8
)
self
.
idx
=
(
self
.
idx
+
len
(
self
.
entries
)
-
1
)
%
len
(
self
.
entries
)
...
...
@@ -301,7 +313,7 @@ class Menu:
except
Exception
as
e
:
print
(
"
Exception during menu.on_scroll():
"
)
sys
.
print_exception
(
e
)
elif
ev
==
button
s
.
TOP_RIGHT
:
elif
ev
==
self
.
button
_select
:
try
:
self
.
on_select
(
self
.
entries
[
self
.
idx
],
self
.
idx
)
self
.
select_time
=
utime
.
time_ms
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment