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
1da77e42
Commit
1da77e42
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
py: add captouch scroll demo
parent
fd955230
No related branches found
No related tags found
No related merge requests found
Pipeline
#6061
passed
1 year ago
Stage: check
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/apps/scroll_demo.py
+74
-0
74 additions, 0 deletions
python_payload/apps/scroll_demo.py
python_payload/main.py
+3
-0
3 additions, 0 deletions
python_payload/main.py
with
77 additions
and
0 deletions
python_payload/apps/scroll_demo.py
0 → 100644
+
74
−
0
View file @
1da77e42
# python imports
import
random
import
time
import
math
# flow3r imports
from
st3m
import
Ctx
,
InputState
from
st3m.application
import
Application
from
st3m.property
import
BLUE
,
WHITE
from
st3m.goose
import
Optional
from
st3m.utils
import
xy_from_polar
,
tau
from
st3m.ui.interactions
import
CapScrollController
class
ScrollDemo
(
Application
):
PETAL_NO
=
8
def
__init__
(
self
,
name
:
str
)
->
None
:
super
().
__init__
(
name
)
self
.
scroll
=
CapScrollController
()
def
draw
(
self
,
ctx
:
Ctx
)
->
None
:
ctx
.
save
()
ctx
.
move_to
(
0
,
0
)
ctx
.
gray
(
0
)
ctx
.
rectangle
(
-
120
,
-
120
,
240
,
240
)
ctx
.
fill
()
ctx
.
font
=
"
Material Icons
"
ctx
.
font_size
=
20
ctx
.
text_baseline
=
ctx
.
MIDDLE
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
rotate
((
self
.
PETAL_NO
*
-
tau
/
10
))
ctx
.
translate
(
0
,
-
90
)
ctx
.
gray
(
1
)
ctx
.
text
(
"
\ue5c4\ue5c8
"
)
ctx
.
restore
()
ctx
.
save
()
ctx
.
move_to
(
0
,
0
)
_
,
y
=
self
.
scroll
.
position
y
=
-
y
ctx
.
gray
(
0.1
)
ctx
.
rectangle
(
-
30
,
-
120
,
60
,
240
)
ctx
.
fill
()
nrects
=
10
for
i
in
range
(
nrects
):
ypos
=
y
+
i
*
240
/
nrects
ypos
+=
120
ypos
%=
240
ypos
-=
120
if
i
==
0
:
ctx
.
gray
(
1
)
elif
i
==
nrects
/
2
:
ctx
.
gray
(
0.2
)
elif
i
<
nrects
/
2
:
ctx
.
gray
(
1
-
(
i
/
nrects
*
2
))
else
:
ctx
.
gray
(
i
/
nrects
*
2
)
ctx
.
rectangle
(
-
20
,
-
5
+
ypos
,
40
,
10
)
ctx
.
fill
()
ctx
.
restore
()
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
super
().
think
(
ins
,
delta_ms
)
self
.
scroll
.
update
(
self
.
input
.
captouch
.
petals
[
self
.
PETAL_NO
].
gesture
,
delta_ms
)
app
=
ScrollDemo
(
"
scroll
"
)
This diff is collapsed.
Click to expand it.
python_payload/main.py
+
3
−
0
View file @
1da77e42
...
@@ -52,6 +52,7 @@ from apps.harmonic_demo import app as harmonic
...
@@ -52,6 +52,7 @@ from apps.harmonic_demo import app as harmonic
from
apps.melodic_demo
import
app
as
melodic
from
apps.melodic_demo
import
app
as
melodic
from
apps.nick
import
app
as
nick
from
apps.nick
import
app
as
nick
from
apps.cap_touch_demo
import
app
as
captouch_demo
from
apps.cap_touch_demo
import
app
as
captouch_demo
from
apps.scroll_demo
import
app
as
scroll_demo
# Set the view_managers for the apps, otherwise leaving the app (back) will not work
# Set the view_managers for the apps, otherwise leaving the app (back) will not work
...
@@ -60,6 +61,7 @@ harmonic._view_manager = vm
...
@@ -60,6 +61,7 @@ harmonic._view_manager = vm
melodic
.
_view_manager
=
vm
melodic
.
_view_manager
=
vm
nick
.
_view_manager
=
vm
nick
.
_view_manager
=
vm
captouch_demo
.
_view_manager
=
vm
captouch_demo
.
_view_manager
=
vm
scroll_demo
.
_view_manager
=
vm
# Build menu structure
# Build menu structure
...
@@ -82,6 +84,7 @@ menu_apps = SimpleMenu(
...
@@ -82,6 +84,7 @@ menu_apps = SimpleMenu(
MenuItemBack
(),
MenuItemBack
(),
MenuItemForeground
(
"
captouch
"
,
captouch_demo
),
MenuItemForeground
(
"
captouch
"
,
captouch_demo
),
MenuItemForeground
(
"
worms
"
,
worms
),
MenuItemForeground
(
"
worms
"
,
worms
),
MenuItemForeground
(
"
cap scroll
"
,
scroll_demo
),
],
],
vm
,
vm
,
)
)
...
...
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