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
0076f23c
Commit
0076f23c
authored
1 year ago
by
q3k
Committed by
schneider
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
py/gr33nhouse: switch to ScrollController
parent
ca335a11
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!168
Construct gr33nhouse
Pipeline
#6955
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/apps/gr33nhouse/__init__.py
+12
-12
12 additions, 12 deletions
python_payload/apps/gr33nhouse/__init__.py
python_payload/apps/gr33nhouse/applist.py
+9
-10
9 additions, 10 deletions
python_payload/apps/gr33nhouse/applist.py
with
21 additions
and
22 deletions
python_payload/apps/gr33nhouse/__init__.py
+
12
−
12
View file @
0076f23c
from
st3m.goose
import
Enum
from
st3m.application
import
Application
,
ApplicationContext
from
st3m.input
import
InputController
,
InputState
from
st3m.ui.interactions
import
ScrollController
from
st3m.ui
import
colours
from
st3m.ui.view
import
ViewManager
from
ctx
import
Context
...
...
@@ -18,7 +19,6 @@ class ViewState(Enum):
class
Gr33nhouseApp
(
Application
):
items
=
[
"
Browse apps
"
,
"
Record flow3r seed
"
,
"
Enter flow3r seed
"
]
selection
=
0
input
:
InputController
background
:
Flow3rView
...
...
@@ -29,6 +29,8 @@ class Gr33nhouseApp(Application):
self
.
input
=
InputController
()
self
.
background
=
Flow3rView
()
self
.
_sc
=
ScrollController
()
self
.
_sc
.
set_item_count
(
3
)
self
.
state
=
ViewState
.
CONTENT
...
...
@@ -76,7 +78,7 @@ class Gr33nhouseApp(Application):
30.0
,
).
fill
()
ctx
.
translate
(
0
,
-
30
*
self
.
selec
tion
)
ctx
.
translate
(
0
,
-
30
*
self
.
_sc
.
current_posi
tion
()
)
offset
=
0
...
...
@@ -86,7 +88,7 @@ class Gr33nhouseApp(Application):
ctx
.
text_baseline
=
ctx
.
MIDDLE
for
idx
,
item
in
enumerate
(
self
.
items
):
if
idx
==
self
.
selec
tion
:
if
idx
==
self
.
_sc
.
target_posi
tion
()
:
ctx
.
gray
(
0.0
)
else
:
ctx
.
gray
(
1.0
)
...
...
@@ -99,6 +101,7 @@ class Gr33nhouseApp(Application):
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
self
.
input
.
think
(
ins
,
delta_ms
)
self
.
_sc
.
think
(
ins
,
delta_ms
)
if
self
.
vm
is
None
:
raise
RuntimeError
(
"
vm is None
"
)
...
...
@@ -112,17 +115,14 @@ class Gr33nhouseApp(Application):
self
.
background
.
think
(
ins
,
delta_ms
)
if
self
.
input
.
buttons
.
app
.
left
.
pressed
:
if
self
.
selection
>
0
:
self
.
selection
-=
1
self
.
_sc
.
scroll_left
()
elif
self
.
input
.
buttons
.
app
.
right
.
pressed
:
if
self
.
selection
<
len
(
self
.
items
)
-
1
:
self
.
selection
+=
1
self
.
_sc
.
scroll_right
()
elif
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
selection
==
0
:
pos
=
self
.
_sc
.
target_position
()
if
pos
==
0
:
self
.
vm
.
push
(
AppList
())
elif
self
.
selection
==
1
:
elif
pos
==
1
:
self
.
vm
.
push
(
RecordView
())
elif
self
.
selection
==
2
:
elif
pos
==
2
:
self
.
vm
.
push
(
ManualInputView
())
This diff is collapsed.
Click to expand it.
python_payload/apps/gr33nhouse/applist.py
+
9
−
10
View file @
0076f23c
...
...
@@ -2,6 +2,7 @@ from st3m.goose import Optional, Enum, Any
from
st3m.input
import
InputController
,
InputState
from
st3m.ui
import
colours
from
st3m.ui.view
import
BaseView
,
ViewManager
from
st3m.ui.interactions
import
ScrollController
from
ctx
import
Context
import
urequests
import
time
...
...
@@ -21,7 +22,6 @@ class AppList(BaseView):
_state
:
ViewState
=
ViewState
.
INITIAL
apps
:
list
[
Any
]
=
[]
selection
:
int
=
0
input
:
InputController
background
:
Flow3rView
...
...
@@ -30,6 +30,7 @@ class AppList(BaseView):
self
.
input
=
InputController
()
self
.
vm
=
None
self
.
background
=
Flow3rView
()
self
.
_sc
=
ScrollController
()
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
self
.
vm
=
vm
...
...
@@ -89,7 +90,7 @@ class AppList(BaseView):
30.0
,
).
fill
()
ctx
.
translate
(
0
,
-
30
*
self
.
selec
tion
)
ctx
.
translate
(
0
,
-
30
*
self
.
_sc
.
current_posi
tion
()
)
offset
=
0
...
...
@@ -100,7 +101,7 @@ class AppList(BaseView):
ctx
.
move_to
(
0
,
0
)
for
idx
,
app
in
enumerate
(
self
.
apps
):
if
idx
==
self
.
selec
tion
:
if
idx
==
self
.
_sc
.
target_posi
tion
()
:
ctx
.
gray
(
0.0
)
else
:
ctx
.
gray
(
1.0
)
...
...
@@ -114,6 +115,7 @@ class AppList(BaseView):
raise
RuntimeError
(
f
"
Invalid view state
{
self
.
_state
}
"
)
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
self
.
_sc
.
think
(
ins
,
delta_ms
)
if
self
.
initial_ticks
==
0
or
time
.
ticks_ms
()
<
self
.
initial_ticks
+
300
:
return
...
...
@@ -132,6 +134,7 @@ class AppList(BaseView):
return
self
.
_state
=
ViewState
.
LOADED
self
.
_sc
.
set_item_count
(
len
(
self
.
apps
))
print
(
"
App list loaded
"
)
except
Exception
as
e
:
print
(
f
"
Load failed:
{
e
}
"
)
...
...
@@ -145,18 +148,14 @@ class AppList(BaseView):
self
.
background
.
think
(
ins
,
delta_ms
)
if
self
.
input
.
buttons
.
app
.
left
.
pressed
:
if
self
.
selection
>
0
:
self
.
selection
-=
1
self
.
_sc
.
scroll_left
()
elif
self
.
input
.
buttons
.
app
.
right
.
pressed
:
if
self
.
selection
<
len
(
self
.
apps
)
-
1
:
self
.
selection
+=
1
self
.
_sc
.
scroll_right
()
elif
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
vm
is
None
:
raise
RuntimeError
(
"
vm is None
"
)
app
=
self
.
apps
[
self
.
selec
tion
]
app
=
self
.
apps
[
self
.
_sc
.
target_posi
tion
()
]
url
=
app
[
"
tarDownloadUrl
"
]
name
=
app
[
"
name
"
]
author
=
app
[
"
author
"
]
...
...
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