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
aaffd4bc
Commit
aaffd4bc
authored
1 year ago
by
iggy
Committed by
q3k
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
py: st4m: inertia scroll wip
parent
4f981d3c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!35
py: grand st3m unification
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/st4m/ui/elements/menus.py
+1
-1
1 addition, 1 deletion
python_payload/st4m/ui/elements/menus.py
python_payload/st4m/ui/interactions.py
+68
-19
68 additions, 19 deletions
python_payload/st4m/ui/interactions.py
with
69 additions
and
20 deletions
python_payload/st4m/ui/elements/menus.py
+
1
−
1
View file @
aaffd4bc
...
...
@@ -124,7 +124,7 @@ class FlowerMenu(MenuController):
item
.
rotation_time
=
10000
current
=
self
.
_scroll_controller
.
current_position
()
current_int
=
round
(
current
)
%
len
(
self
.
_items
)
print
(
"
current
"
,
current
,
current_int
)
#
print("current", current, current_int)
self
.
ui
.
items_ring
[
current_int
].
highlighted
=
True
self
.
ui
.
items_ring
[
current_int
].
rotation_time
=
3000
self
.
ui
.
angle_offset
=
math
.
pi
-
(
tau
*
current
/
len
(
self
.
ui
.
items_ring
))
...
...
This diff is collapsed.
Click to expand it.
python_payload/st4m/ui/interactions.py
+
68
−
19
View file @
aaffd4bc
...
...
@@ -131,7 +131,7 @@ class ScrollController(st4m.Responder):
diff
=
d
# diff =
# print(diff)
max_velocity
=
500
max_velocity
=
0.2
velocity
=
self
.
_velocity
if
abs
(
velocity
)
<
1
:
...
...
@@ -189,16 +189,29 @@ class GestureScrollController(ScrollController):
dphi
=
self
.
_petal
.
_input
.
_dphi
phase
=
self
.
_petal
.
_input
.
phase
()
self
.
_speedbuffer
.
append
(
self
.
_velocity
)
if
len
(
self
.
_speedbuffer
)
>
10
:
if
self
.
_velocity
==
30
:
print
(
"
here
"
)
# raise ValueError
self
.
_speedbuffer
=
[
1
]
self
.
_current_position
+=
0.3
elif
self
.
_velocity
==
-
30
:
self
.
_speedbuffer
=
[
-
1
]
self
.
_current_position
-=
0.3
else
:
self
.
_speedbuffer
.
append
(
self
.
_velocity
)
# print(self._speedbuffer)
while
len
(
self
.
_speedbuffer
)
>
5
:
self
.
_speedbuffer
.
pop
(
0
)
speed
=
sum
(
self
.
_speedbuffer
)
/
len
(
self
.
_speedbuffer
)
speed
=
min
(
speed
,
0.008
)
speed
=
max
(
speed
,
-
0.008
)
if
phase
==
self
.
_petal
.
_input
.
ENDED
:
self
.
_speedbuffer
=
[
0
if
abs
(
speed
)
<
0.00
1
else
speed
]
self
.
_speedbuffer
=
[
0
if
abs
(
speed
)
<
0.00
5
else
speed
]
elif
phase
==
self
.
_petal
.
_input
.
UP
:
#
pass
self
.
_speedbuffer
.
append
(
speed
*
0.85
)
pass
#
self._speedbuffer.append(speed * 0.85)
elif
phase
==
self
.
_petal
.
_input
.
BEGIN
:
self
.
_ignore
=
5
self
.
_speedbuffer
=
[
0.0
]
...
...
@@ -212,7 +225,7 @@ class GestureScrollController(ScrollController):
# self._target_position += 1
self
.
_speedbuffer
.
append
(
impulse
)
if
abs
(
speed
)
<
0.000
00
1
:
if
abs
(
speed
)
<
0.0001
:
speed
=
0
self
.
_velocity
=
speed
...
...
@@ -221,23 +234,59 @@ class GestureScrollController(ScrollController):
self
.
_current_position
+
self
.
_velocity
*
delta_ms
)
%
self
.
_nitems
if
phase
!=
self
.
_petal
.
_input
.
UP
:
return
microstep
=
round
(
self
.
_current_position
)
-
self
.
_current_position
print
(
"
micro:
"
,
microstep
)
print
(
"
v
"
,
self
.
_velocity
)
# print("micro:", microstep)
# print("v", self._velocity)
# print("pos", self._current_position)
if
(
abs
(
microstep
)
<
0.1
and
abs
(
self
.
_velocity
)
<
0.001
# and abs(self._velocity)
):
self
.
_velocity
=
0
# self._speedbuffer = []
self
.
_speedbuffer
.
append
(
0
)
self
.
_current_position
=
round
(
self
.
_current_position
)
# print("LOCK")
return
# if abs(self._velocity) <= 0.0001:
# self._velocity = 0
if
abs
(
self
.
_velocity
)
>
0.001
:
# self._velocity *= 0.7
self
.
_speedbuffer
.
append
(
-
self
.
_velocity
)
# print("BREAKING")
return
if
self
.
_velocity
>=
0
and
microstep
>
0
:
self
.
_velocity
-=
microstep
/
100
print
(
"
1
"
)
elif
self
.
_velocity
<=
0
and
microstep
>
0
:
self
.
_velocity
+=
microstep
/
100
print
(
"
2
"
)
elif
self
.
_velocity
>=
0
and
microstep
<
0
:
self
.
_velocity
-=
microstep
/
50
print
(
"
3
"
)
# self._velocity += microstep / 5
# self._speedbuffer.append(microstep / 10)
self
.
_speedbuffer
.
append
(
max
(
self
.
_velocity
,
0.01
)
*
microstep
*
10
)
# print("1")
elif
self
.
_velocity
<
0
and
microstep
>
0
:
# self._velocity += microstep / 100
# self._speedbuffer.append(microstep / 5)
self
.
_speedbuffer
.
append
(
-
self
.
_velocity
)
# print("2")
elif
self
.
_velocity
>
0
and
microstep
<
0
:
# self._speedbuffer.append(microstep / 5)
self
.
_speedbuffer
.
append
(
-
self
.
_velocity
*
0.5
)
# self._velocity = max(self._velocity + microstep, 0)
# if self._velocity == 0:
# self._speedbuffer = []
# print("3")
elif
self
.
_velocity
<=
0
and
microstep
<
0
:
self
.
_velocity
+=
microstep
/
50
print
(
"
4
"
)
# self._velocity += microstep / 20
# self._speedbuffer.append(microstep / 10)
self
.
_speedbuffer
.
append
(
min
(
self
.
_velocity
,
-
0.01
)
*
abs
(
microstep
)
*
10
)
# print("4")
# self._speedbuffer.append(self._velocity)
# if self._velocity > 0:
# self._velocity -= microstep / 100
# else:
...
...
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