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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
0022b633
Commit
0022b633
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
py: implement USB icon
parent
f8c0cb9b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/st3m/run.py
+3
-0
3 additions, 0 deletions
python_payload/st3m/run.py
python_payload/st3m/ui/elements/overlays.py
+71
-0
71 additions, 0 deletions
python_payload/st3m/ui/elements/overlays.py
with
74 additions
and
0 deletions
python_payload/st3m/run.py
+
3
−
0
View file @
0022b633
...
...
@@ -85,6 +85,9 @@ def _make_compositor(reactor: Reactor, r: Responder) -> overlays.Compositor:
_onoff_debug_touch_update
()
settings
.
onoff_debug_touch
.
subscribe
(
_onoff_debug_touch_update
)
compositor
.
add_overlay
(
debug_touch
)
# Add icon tray.
compositor
.
add_overlay
(
overlays
.
IconTray
())
return
compositor
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/ui/elements/overlays.py
+
71
−
0
View file @
0022b633
...
...
@@ -13,6 +13,7 @@ from ctx import Context
import
math
import
audio
import
hardware
class
OverlayKind
(
Enum
):
...
...
@@ -319,3 +320,73 @@ class OverlayVolume(Overlay):
ctx
.
fill
()
ctx
.
end_group
()
class
Icon
(
Responder
):
"""
A tray icon that might or might not be shown in the top icon tray.
Should render into a 240x240 viewport. Will be scaled down by the IconTray
that contains it.
"""
@abstractmethod
def
visible
(
self
)
->
bool
:
...
class
USBIcon
(
Icon
):
"""
Found in the bargain bin at an Aldi Süd.
Might or might not be related to a certain serial bus.
"""
def
visible
(
self
)
->
bool
:
return
hardware
.
usb_connected
()
def
draw
(
self
,
ctx
:
Context
)
->
None
:
ctx
.
gray
(
1.0
)
ctx
.
arc
(
-
90
,
0
,
20
,
0
,
6.28
,
0
).
fill
()
ctx
.
line_width
=
10.0
ctx
.
move_to
(
-
90
,
0
).
line_to
(
90
,
0
).
stroke
()
ctx
.
move_to
(
100
,
0
).
line_to
(
70
,
15
).
line_to
(
70
,
-
15
).
line_to
(
100
,
0
).
fill
()
ctx
.
move_to
(
-
50
,
0
).
line_to
(
-
10
,
-
40
).
line_to
(
20
,
-
40
).
stroke
()
ctx
.
arc
(
20
,
-
40
,
15
,
0
,
6.28
,
0
).
fill
()
ctx
.
move_to
(
-
30
,
0
).
line_to
(
10
,
40
).
line_to
(
40
,
40
).
stroke
()
ctx
.
rectangle
(
40
-
15
,
40
-
15
,
30
,
30
).
fill
()
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
pass
class
IconTray
(
Overlay
):
"""
An overlay which renders Icons.
"""
kind
=
OverlayKind
.
Indicators
def
__init__
(
self
)
->
None
:
self
.
icons
=
[
USBIcon
(),
]
self
.
visible
:
List
[
Icon
]
=
[]
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
self
.
visible
=
[
i
for
i
in
self
.
icons
if
i
.
visible
()]
for
v
in
self
.
visible
:
v
.
think
(
ins
,
delta_ms
)
def
draw
(
self
,
ctx
:
Context
)
->
None
:
nicons
=
len
(
self
.
visible
)
dist
=
20
width
=
(
nicons
-
1
)
*
dist
x0
=
width
/
-
2
for
i
,
v
in
enumerate
(
self
.
visible
):
x
=
x0
+
i
*
dist
ctx
.
save
()
ctx
.
translate
(
x
,
-
100
)
ctx
.
scale
(
0.1
,
0.1
)
v
.
draw
(
ctx
)
ctx
.
restore
()
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