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
30a915b6
Commit
30a915b6
authored
2 years ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
st3m: add delta to input events
parent
a83742a4
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/event.py
+15
-8
15 additions, 8 deletions
python_payload/st3m/event.py
python_payload/st3m/menu.py
+2
-2
2 additions, 2 deletions
python_payload/st3m/menu.py
with
17 additions
and
10 deletions
python_payload/st3m/event.py
+
15
−
8
View file @
30a915b6
...
@@ -73,7 +73,7 @@ class Engine:
...
@@ -73,7 +73,7 @@ class Engine:
self
.
next_timed
.
trigger
({
"
ticks_ms
"
:
now
,
"
ticks_delay
"
:
-
diff
})
self
.
next_timed
.
trigger
({
"
ticks_ms
"
:
now
,
"
ticks_delay
"
:
-
diff
})
self
.
next_timed
=
None
self
.
next_timed
=
None
def
_handle_input
(
self
):
def
_handle_input
(
self
,
delta
):
input_state
=
[]
input_state
=
[]
# buttons
# buttons
...
@@ -108,6 +108,7 @@ class Engine:
...
@@ -108,6 +108,7 @@ class Engine:
# update for all
# update for all
entry
[
"
ticks_ms
"
]
=
time
.
ticks_ms
()
entry
[
"
ticks_ms
"
]
=
time
.
ticks_ms
()
entry
[
"
delta
"
]
=
delta
if
entry
[
"
value
"
]
!=
last_entry
[
"
value
"
]:
if
entry
[
"
value
"
]
!=
last_entry
[
"
value
"
]:
# update only when value changed
# update only when value changed
...
@@ -132,16 +133,16 @@ class Engine:
...
@@ -132,16 +133,16 @@ class Engine:
if
self
.
foreground_app
:
if
self
.
foreground_app
:
self
.
foreground_app
.
tick
()
self
.
foreground_app
.
tick
()
def
_handle_draw
(
self
):
def
_handle_draw
(
self
,
ctx
):
if
self
.
foreground_app
:
if
self
.
foreground_app
:
self
.
foreground_app
.
draw
()
self
.
foreground_app
.
draw
(
ctx
)
if
self
.
active_menu
:
if
self
.
active_menu
:
self
.
active_menu
.
draw
()
self
.
active_menu
.
draw
(
ctx
)
hardware
.
display_update
()
hardware
.
display_update
()
def
_eventloop_single
(
self
):
def
_eventloop_single
(
self
,
delta
):
self
.
_handle_timed
()
self
.
_handle_timed
()
self
.
_handle_input
()
self
.
_handle_input
(
delta
)
self
.
_handle_userloop
()
self
.
_handle_userloop
()
def
eventloop
(
self
):
def
eventloop
(
self
):
...
@@ -150,15 +151,21 @@ class Engine:
...
@@ -150,15 +151,21 @@ class Engine:
log
.
warning
(
"
eventloop already running, doing nothing
"
)
log
.
warning
(
"
eventloop already running, doing nothing
"
)
return
return
self
.
is_running
=
True
self
.
is_running
=
True
ctx
=
hardware
.
get_ctx
()
last_draw
=
0
last_draw
=
0
last_eventloop
=
None
while
self
.
is_running
:
while
self
.
is_running
:
self
.
_eventloop_single
()
now
=
time
.
ticks_ms
()
now
=
time
.
ticks_ms
()
if
last_eventloop
is
not
None
:
delta
=
now
-
last_eventloop
self
.
_eventloop_single
(
delta
/
1000.0
)
last_eventloop
=
now
diff
=
time
.
ticks_diff
(
now
,
last_draw
)
diff
=
time
.
ticks_diff
(
now
,
last_draw
)
# print("diff:",diff)
# print("diff:",diff)
if
diff
>
10
:
if
diff
>
10
:
# print("eventloop draw")
# print("eventloop draw")
self
.
_handle_draw
()
self
.
_handle_draw
(
ctx
)
last_draw
=
time
.
ticks_ms
()
last_draw
=
time
.
ticks_ms
()
# self.deadline = time.ticks_add(time.ticks_ms(),ms)
# self.deadline = time.ticks_add(time.ticks_ms(),ms)
...
...
This diff is collapsed.
Click to expand it.
python_payload/st3m/menu.py
+
2
−
2
View file @
30a915b6
...
@@ -230,10 +230,10 @@ def on_scroll(d):
...
@@ -230,10 +230,10 @@ def on_scroll(d):
return
return
if
d
[
"
index
"
]
==
0
:
# right button
if
d
[
"
index
"
]
==
0
:
# right button
active_menu
.
scroll_app
(
d
[
"
value
"
])
active_menu
.
scroll_app
(
d
[
"
value
"
]
*
10.0
*
d
[
"
delta
"
]
)
else
:
# index=1, #left button
else
:
# index=1, #left button
active_menu
.
scroll_menu
(
d
[
"
value
"
])
active_menu
.
scroll_menu
(
d
[
"
value
"
]
*
10.0
*
d
[
"
delta
"
]
)
def
on_scroll_captouch
(
d
):
def
on_scroll_captouch
(
d
):
...
...
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