Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
flow3r
flow3r firmware
Commits
94b3707a
Commit
94b3707a
authored
1 year ago
by
pippin
Committed by
pippin
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
ui: add MenuItemAction, make reboot functional, add yeet local changes
parent
f8b4081f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!74
ui: add MenuItemAction, make reboot functional, add yeet local changes
Pipeline
#6323
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
python_payload/mypystubs/machine.pyi
+3
-0
3 additions, 0 deletions
python_payload/mypystubs/machine.pyi
python_payload/st3m/run.py
+18
-2
18 additions, 2 deletions
python_payload/st3m/run.py
python_payload/st3m/ui/menu.py
+17
-2
17 additions, 2 deletions
python_payload/st3m/ui/menu.py
with
38 additions
and
4 deletions
python_payload/mypystubs/machine.pyi
+
3
−
0
View file @
94b3707a
from
typing
import
Any
from
typing
import
Any
def
reset
()
->
None
:
pass
class
Pin
:
class
Pin
:
"""
"""
See the official micropython docs for more details:
See the official micropython docs for more details:
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/run.py
+
18
−
2
View file @
94b3707a
from
st3m.reactor
import
Reactor
,
Responder
from
st3m.reactor
import
Reactor
,
Responder
from
st3m.goose
import
List
from
st3m.goose
import
List
from
st3m.ui.menu
import
MenuItem
,
MenuItemBack
,
MenuItemForeground
,
MenuItemNoop
from
st3m.ui.menu
import
(
MenuItem
,
MenuItemBack
,
MenuItemForeground
,
MenuItemNoop
,
MenuItemAction
,
)
from
st3m.ui.elements
import
overlays
from
st3m.ui.elements
import
overlays
from
st3m.ui.view
import
View
,
ViewManager
,
ViewTransitionBlend
from
st3m.ui.view
import
View
,
ViewManager
,
ViewTransitionBlend
from
st3m.ui.elements.menus
import
SimpleMenu
,
SunMenu
from
st3m.ui.elements.menus
import
SimpleMenu
,
SunMenu
...
@@ -8,6 +14,10 @@ from st3m.application import discover_bundles, BundleMetadata
...
@@ -8,6 +14,10 @@ from st3m.application import discover_bundles, BundleMetadata
from
st3m
import
settings
,
logging
,
processors
from
st3m
import
settings
,
logging
,
processors
import
captouch
,
audio
,
leds
,
gc
import
captouch
,
audio
,
leds
,
gc
import
os
import
machine
log
=
logging
.
Log
(
__name__
,
level
=
logging
.
INFO
)
log
=
logging
.
Log
(
__name__
,
level
=
logging
.
INFO
)
...
@@ -91,6 +101,11 @@ def run_view(v: View) -> None:
...
@@ -91,6 +101,11 @@ def run_view(v: View) -> None:
reactor
.
run
()
reactor
.
run
()
def
yeet_local_changes
()
->
None
:
os
.
remove
(
"
/flash/sys/.sys-installed
"
)
machine
.
reset
()
def
run_main
()
->
None
:
def
run_main
()
->
None
:
log
.
info
(
f
"
starting main
"
)
log
.
info
(
f
"
starting main
"
)
log
.
info
(
f
"
free memory:
{
gc
.
mem_free
()
}
"
)
log
.
info
(
f
"
free memory:
{
gc
.
mem_free
()
}
"
)
...
@@ -110,7 +125,8 @@ def run_main() -> None:
...
@@ -110,7 +125,8 @@ def run_main() -> None:
MenuItemForeground
(
"
Settings
"
,
menu_settings
),
MenuItemForeground
(
"
Settings
"
,
menu_settings
),
MenuItemNoop
(
"
Disk Mode
"
),
MenuItemNoop
(
"
Disk Mode
"
),
MenuItemNoop
(
"
About
"
),
MenuItemNoop
(
"
About
"
),
MenuItemNoop
(
"
Reboot
"
),
MenuItemAction
(
"
Yeet Local Changes
"
,
yeet_local_changes
),
MenuItemAction
(
"
Reboot
"
,
lambda
:
machine
.
reset
()),
],
],
)
)
menu_main
=
SunMenu
(
menu_main
=
SunMenu
(
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/ui/menu.py
+
17
−
2
View file @
94b3707a
...
@@ -2,7 +2,7 @@ import st3m
...
@@ -2,7 +2,7 @@ import st3m
from
st3m
import
Responder
from
st3m
import
Responder
from
st3m
import
logging
from
st3m
import
logging
from
st3m.goose
import
ABCBase
,
abstractmethod
,
List
,
Optional
from
st3m.goose
import
ABCBase
,
abstractmethod
,
List
,
Optional
,
Callable
from
st3m.input
import
InputState
,
InputController
from
st3m.input
import
InputState
,
InputController
from
st3m.ui.view
import
(
from
st3m.ui.view
import
(
BaseView
,
BaseView
,
...
@@ -14,7 +14,6 @@ from st3m.ui.view import (
...
@@ -14,7 +14,6 @@ from st3m.ui.view import (
from
st3m.ui.interactions
import
ScrollController
from
st3m.ui.interactions
import
ScrollController
from
ctx
import
Context
from
ctx
import
Context
log
=
logging
.
Log
(
__name__
)
log
=
logging
.
Log
(
__name__
)
...
@@ -73,6 +72,22 @@ class MenuItemForeground(MenuItem):
...
@@ -73,6 +72,22 @@ class MenuItemForeground(MenuItem):
return
self
.
_label
return
self
.
_label
class
MenuItemAction
(
MenuItem
):
"""
A MenuItem which runs the provided lambda action.
"""
def
__init__
(
self
,
label
:
str
,
action
:
Callable
[[],
None
])
->
None
:
self
.
_label
=
label
self
.
_action
=
action
def
press
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
self
.
_action
()
def
label
(
self
)
->
str
:
return
self
.
_label
class
MenuItemNoop
(
MenuItem
):
class
MenuItemNoop
(
MenuItem
):
"""
"""
A MenuItem which does nothing.
A MenuItem which does nothing.
...
...
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