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
97cb5b5b
Commit
97cb5b5b
authored
Aug 29, 2023
by
pippin
Browse files
Options
Downloads
Patches
Plain Diff
py: add fps overlay mode
parent
eec9a27d
Branches
Branches containing commit
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/settings.py
+5
-2
5 additions, 2 deletions
python_payload/st3m/settings.py
python_payload/st3m/ui/elements/overlays.py
+49
-17
49 additions, 17 deletions
python_payload/st3m/ui/elements/overlays.py
with
54 additions
and
19 deletions
python_payload/st3m/settings.py
+
5
−
2
View file @
97cb5b5b
...
@@ -376,6 +376,7 @@ class SettingsMenu(SimpleMenu):
...
@@ -376,6 +376,7 @@ class SettingsMenu(SimpleMenu):
# Actual tunables / settings.
# Actual tunables / settings.
onoff_button_swap
=
OnOffTunable
(
"
Swap Buttons
"
,
"
system.swap_buttons
"
,
False
)
onoff_button_swap
=
OnOffTunable
(
"
Swap Buttons
"
,
"
system.swap_buttons
"
,
False
)
onoff_show_fps
=
OnOffTunable
(
"
Show FPS
"
,
"
system.show_fps
"
,
False
)
onoff_debug
=
OnOffTunable
(
"
Debug Overlay
"
,
"
system.debug
"
,
False
)
onoff_debug
=
OnOffTunable
(
"
Debug Overlay
"
,
"
system.debug
"
,
False
)
onoff_debug_touch
=
OnOffTunable
(
"
Touch Overlay
"
,
"
system.debug_touch
"
,
False
)
onoff_debug_touch
=
OnOffTunable
(
"
Touch Overlay
"
,
"
system.debug_touch
"
,
False
)
onoff_show_tray
=
OnOffTunable
(
"
Show Icons
"
,
"
system.show_icons
"
,
True
)
onoff_show_tray
=
OnOffTunable
(
"
Show Icons
"
,
"
system.show_icons
"
,
True
)
...
@@ -395,6 +396,7 @@ load_save_settings: List[UnaryTunable] = [
...
@@ -395,6 +396,7 @@ load_save_settings: List[UnaryTunable] = [
onoff_debug_touch
,
onoff_debug_touch
,
onoff_wifi
,
onoff_wifi
,
onoff_wifi_preference
,
onoff_wifi_preference
,
onoff_show_fps
,
str_wifi_ssid
,
str_wifi_ssid
,
str_wifi_psk
,
str_wifi_psk
,
str_hostname
,
str_hostname
,
...
@@ -408,8 +410,9 @@ if TYPE_CHECKING:
...
@@ -408,8 +410,9 @@ if TYPE_CHECKING:
settings_menu_structure
:
"
MenuStructure
"
=
[
settings_menu_structure
:
"
MenuStructure
"
=
[
onoff_show_tray
,
onoff_show_tray
,
onoff_button_swap
,
onoff_button_swap
,
onoff_debug
,
onoff_show_fps
,
onoff_debug_touch
,
# onoff_debug,
# onoff_debug_touch,
onoff_wifi
,
onoff_wifi
,
onoff_wifi_preference
,
onoff_wifi_preference
,
MenuItemAppLaunch
(
BundleMetadata
(
"
/flash/sys/apps/w1f1
"
)),
MenuItemAppLaunch
(
BundleMetadata
(
"
/flash/sys/apps/w1f1
"
)),
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/ui/elements/overlays.py
+
49
−
17
View file @
97cb5b5b
...
@@ -6,7 +6,7 @@ for persistent, anchored symbols like charging symbols, toasts, debug overlays,
...
@@ -6,7 +6,7 @@ for persistent, anchored symbols like charging symbols, toasts, debug overlays,
etc.
etc.
"""
"""
from
st3m
import
Responder
,
InputState
,
Reactor
from
st3m
import
Responder
,
InputState
,
Reactor
,
settings
from
st3m.goose
import
Dict
,
Enum
,
List
,
ABCBase
,
abstractmethod
,
Optional
from
st3m.goose
import
Dict
,
Enum
,
List
,
ABCBase
,
abstractmethod
,
Optional
from
st3m.utils
import
tau
from
st3m.utils
import
tau
from
st3m.ui.view
import
ViewManager
from
st3m.ui.view
import
ViewManager
...
@@ -38,7 +38,10 @@ _all_kinds = [
...
@@ -38,7 +38,10 @@ _all_kinds = [
OverlayKind
.
Toast
,
OverlayKind
.
Toast
,
]
]
_max_y
=
0
_clip_x0
=
120
_clip_x1
=
120
_clip_y0
=
0
_clip_y1
=
0
class
Overlay
(
Responder
):
class
Overlay
(
Responder
):
...
@@ -79,15 +82,44 @@ class Compositor(Responder):
...
@@ -79,15 +82,44 @@ class Compositor(Responder):
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
self
.
main
.
think
(
ins
,
delta_ms
)
self
.
main
.
think
(
ins
,
delta_ms
)
if
self
.
_frame_skip
<=
0
:
if
self
.
_frame_skip
<=
0
:
if
not
settings
.
onoff_show_fps
.
value
:
for
overlay
in
self
.
_enabled_overlays
():
for
overlay
in
self
.
_enabled_overlays
():
overlay
.
think
(
ins
,
delta_ms
)
overlay
.
think
(
ins
,
delta_ms
)
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
global
_max_y
global
_clip_x0
global
_clip_y0
global
_clip_x1
global
_clip_y1
self
.
main
.
draw
(
ctx
)
self
.
main
.
draw
(
ctx
)
if
self
.
_frame_skip
<=
0
:
if
self
.
_frame_skip
<=
0
:
_max_y
=
0
octx
=
sys_display
.
get_overlay_ctx
()
octx
=
sys_display
.
get_overlay_ctx
()
if
settings
.
onoff_show_fps
.
value
:
_clip_x0
=
110
_clip_y1
=
0
_clip_x1
=
130
_clip_y1
=
7
octx
.
save
()
octx
.
compositing_mode
=
octx
.
CLEAR
octx
.
rectangle
(
_clip_x0
-
120
,
_clip_y0
-
120
,
_clip_x1
-
_clip_x0
+
1
,
_clip_y1
-
_clip_y0
+
1
,
).
fill
()
octx
.
restore
()
octx
.
gray
(
1
)
octx
.
font_size
=
11
octx
.
font
=
"
Bold
"
octx
.
move_to
(
0
,
-
113
)
octx
.
text_align
=
octx
.
CENTER
octx
.
text
(
"
{0:.1f}
"
.
format
(
sys_display
.
fps
()))
else
:
_clip_x0
=
80
_clip_y0
=
0
_clip_x1
=
160
_clip_y1
=
0
octx
.
save
()
octx
.
save
()
octx
.
compositing_mode
=
octx
.
CLEAR
octx
.
compositing_mode
=
octx
.
CLEAR
octx
.
rectangle
(
-
120
,
-
120
,
240
,
240
).
fill
()
octx
.
rectangle
(
-
120
,
-
120
,
240
,
240
).
fill
()
...
@@ -95,7 +127,7 @@ class Compositor(Responder):
...
@@ -95,7 +127,7 @@ class Compositor(Responder):
for
overlay
in
self
.
_enabled_overlays
():
for
overlay
in
self
.
_enabled_overlays
():
overlay
.
draw
(
octx
)
overlay
.
draw
(
octx
)
self
.
_frame_skip
=
8
self
.
_frame_skip
=
8
sys_display
.
set_
overlay_
height
(
_max_y
)
sys_display
.
overlay_
clip
(
_clip_x0
,
_clip_y0
,
_clip_x1
,
_clip_y1
)
self
.
_frame_skip
-=
1
self
.
_frame_skip
-=
1
def
add_overlay
(
self
,
ov
:
Overlay
)
->
None
:
def
add_overlay
(
self
,
ov
:
Overlay
)
->
None
:
...
@@ -293,10 +325,10 @@ class OverlayVolume(Overlay):
...
@@ -293,10 +325,10 @@ class OverlayVolume(Overlay):
self
.
_showing
=
None
self
.
_showing
=
None
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
global
_
max
_y
global
_
clip
_y
1
if
self
.
_showing
is
None
:
if
self
.
_showing
is
None
:
return
return
_
max
_y
=
max
(
_
max
_y
,
16
0
)
_
clip
_y
1
=
max
(
_
clip
_y
1
,
16
1
)
opacity
=
self
.
_showing
/
200
opacity
=
self
.
_showing
/
200
opacity
=
min
(
opacity
,
0.8
)
opacity
=
min
(
opacity
,
0.8
)
...
@@ -485,10 +517,10 @@ class IconTray(Overlay):
...
@@ -485,10 +517,10 @@ class IconTray(Overlay):
v
.
think
(
ins
,
delta_ms
)
v
.
think
(
ins
,
delta_ms
)
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
global
_
max
_y
global
_
clip
_y
1
if
len
(
self
.
visible
)
<
1
:
if
len
(
self
.
visible
)
<
1
:
return
return
_
max
_y
=
max
(
_
max
_y
,
32
)
_
clip
_y
1
=
max
(
_
clip
_y
1
,
32
)
width
=
0
width
=
0
for
icon
in
self
.
visible
:
for
icon
in
self
.
visible
:
width
+=
icon
.
WIDTH
width
+=
icon
.
WIDTH
...
...
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