Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Petal Hero
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
Petal Hero
Commits
9cc759b0
Verified
Commit
9cc759b0
authored
Oct 9, 2023
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
Show the artist on select screen; wrap the song list
parent
6ba60e2a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
select.py
+30
-5
30 additions, 5 deletions
select.py
song.py
+1
-1
1 addition, 1 deletion
song.py
songinfo.py
+3
-0
3 additions, 0 deletions
songinfo.py
with
34 additions
and
6 deletions
select.py
+
30
−
5
View file @
9cc759b0
...
@@ -3,9 +3,11 @@ from st3m.ui.interactions import ScrollController
...
@@ -3,9 +3,11 @@ from st3m.ui.interactions import ScrollController
import
math
import
math
import
os
,
stat
import
os
,
stat
import
time
import
time
import
leds
try
:
try
:
import
media
import
media
from
st3m.ui.view
import
ViewTransitionDirection
from
st3m.ui.view
import
ViewTransitionDirection
import
st3m.ui.led_patterns
except
ImportError
:
except
ImportError
:
pass
pass
...
@@ -53,7 +55,7 @@ def discover_songs_at(path: str, songs: list, to_process: set, dirs: set):
...
@@ -53,7 +55,7 @@ def discover_songs_at(path: str, songs: list, to_process: set, dirs: set):
dirs
.
add
(
dirpath
)
dirs
.
add
(
dirpath
)
continue
continue
s
=
LazySong
(
dirpath
)
s
=
songinfo
.
SongInfo
(
dirpath
)
s
.
load
()
s
.
load
()
songs
.
append
(
s
)
songs
.
append
(
s
)
...
@@ -83,6 +85,7 @@ class SelectView(BaseView):
...
@@ -83,6 +85,7 @@ class SelectView(BaseView):
self
.
repeat_count
=
0
self
.
repeat_count
=
0
self
.
first_scroll_think
=
False
self
.
first_scroll_think
=
False
self
.
letter_timeout
=
0
self
.
letter_timeout
=
0
self
.
show_artist
=
False
def
_discover_songs
(
self
):
def
_discover_songs
(
self
):
dirs
=
{
"
/sd/PetalHero
"
,
"
/flash/PetalHero
"
,
self
.
app
.
path
+
"
/songs
"
}
dirs
=
{
"
/sd/PetalHero
"
,
"
/flash/PetalHero
"
,
self
.
app
.
path
+
"
/songs
"
}
...
@@ -199,11 +202,12 @@ class SelectView(BaseView):
...
@@ -199,11 +202,12 @@ class SelectView(BaseView):
song
.
load
()
song
.
load
()
xpos
=
0.0
xpos
=
0.0
ctx
.
font_size
=
24
-
abs
(
distance
)
*
3
ctx
.
font_size
=
24
-
abs
(
distance
)
*
3
if
target
and
(
width
:
=
ctx
.
text_width
(
song
.
name
))
>
220
:
text
=
song
.
artist
if
self
.
show_artist
and
target
else
song
.
name
if
target
and
(
width
:
=
ctx
.
text_width
(
text
))
>
220
:
xpos
=
math
.
sin
(
self
.
_scroll_pos
)
*
(
width
-
220
)
/
2
xpos
=
math
.
sin
(
self
.
_scroll_pos
)
*
(
width
-
220
)
/
2
ctx
.
move_to
(
xpos
,
offset
+
distance
*
abs
(
distance
)
*
2
)
ctx
.
move_to
(
xpos
,
offset
+
distance
*
abs
(
distance
)
*
2
)
ctx
.
global_alpha
=
max
(
0.0
,
1.0
-
abs
(
distance
)
/
2.5
)
ctx
.
global_alpha
=
max
(
0.0
,
1.0
-
abs
(
distance
)
/
2.5
)
ctx
.
text
(
song
.
name
)
ctx
.
text
(
text
)
ctx
.
global_alpha
=
1.0
ctx
.
global_alpha
=
1.0
offset
+=
30
offset
+=
30
...
@@ -268,9 +272,17 @@ class SelectView(BaseView):
...
@@ -268,9 +272,17 @@ class SelectView(BaseView):
if
self
.
letter_timeout
>
0
:
if
self
.
letter_timeout
>
0
:
self
.
letter_timeout
-=
delta_ms
/
1000.0
self
.
letter_timeout
-=
delta_ms
/
1000.0
self
.
show_artist
=
ins
.
captouch
.
petals
[
5
].
pressed
if
self
.
input
.
captouch
.
petals
[
5
].
whole
.
pressed
or
self
.
input
.
captouch
.
petals
[
5
].
whole
.
released
:
self
.
_scroll_pos
=
math
.
pi
/
2
if
self
.
input
.
buttons
.
app
.
left
.
pressed
or
(
self
.
input
.
buttons
.
app
.
left
.
repeated
and
not
self
.
_sc
.
at_left_limit
()):
if
self
.
input
.
buttons
.
app
.
left
.
pressed
or
(
self
.
input
.
buttons
.
app
.
left
.
repeated
and
not
self
.
_sc
.
at_left_limit
()):
utils
.
play_crunch
(
self
.
app
)
utils
.
play_crunch
(
self
.
app
)
if
self
.
input
.
buttons
.
app
.
left
.
pressed
:
if
self
.
input
.
buttons
.
app
.
left
.
pressed
:
if
self
.
_sc
.
at_left_limit
():
self
.
_sc
.
scroll_to
(
len
(
self
.
songs
)
-
1
)
else
:
self
.
_sc
.
scroll_left
()
self
.
_sc
.
scroll_left
()
else
:
else
:
self
.
_sc
.
scroll_to
(
self
.
_sc
.
target_position
()
-
(
4
if
self
.
repeat_count
>
4
else
1
))
self
.
_sc
.
scroll_to
(
self
.
_sc
.
target_position
()
-
(
4
if
self
.
repeat_count
>
4
else
1
))
...
@@ -278,6 +290,9 @@ class SelectView(BaseView):
...
@@ -278,6 +290,9 @@ class SelectView(BaseView):
elif
self
.
input
.
buttons
.
app
.
right
.
pressed
or
(
self
.
input
.
buttons
.
app
.
right
.
repeated
and
not
self
.
_sc
.
at_right_limit
()):
elif
self
.
input
.
buttons
.
app
.
right
.
pressed
or
(
self
.
input
.
buttons
.
app
.
right
.
repeated
and
not
self
.
_sc
.
at_right_limit
()):
utils
.
play_crunch
(
self
.
app
)
utils
.
play_crunch
(
self
.
app
)
if
self
.
input
.
buttons
.
app
.
right
.
pressed
:
if
self
.
input
.
buttons
.
app
.
right
.
pressed
:
if
self
.
_sc
.
at_right_limit
():
self
.
_sc
.
scroll_to
(
0
)
else
:
self
.
_sc
.
scroll_right
()
self
.
_sc
.
scroll_right
()
else
:
else
:
self
.
_sc
.
scroll_to
(
self
.
_sc
.
target_position
()
+
(
4
if
self
.
repeat_count
>
4
else
1
))
self
.
_sc
.
scroll_to
(
self
.
_sc
.
target_position
()
+
(
4
if
self
.
repeat_count
>
4
else
1
))
...
@@ -313,6 +328,13 @@ class SelectView(BaseView):
...
@@ -313,6 +328,13 @@ class SelectView(BaseView):
if
pos
!=
cur_target
:
if
pos
!=
cur_target
:
self
.
play
()
self
.
play
()
if
self
.
is_active
()
and
not
self
.
processing_now
and
not
self
.
to_process
and
not
self
.
loading
and
len
(
self
.
songs
):
if
self
.
show_artist
:
st3m
.
ui
.
led_patterns
.
highlight_petal_rgb
(
5
,
0.5
,
0.5
,
0.5
)
else
:
st3m
.
ui
.
led_patterns
.
highlight_petal_rgb
(
5
,
0.42
,
0.42
,
0.42
)
leds
.
update
()
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
super
().
on_enter
(
vm
)
super
().
on_enter
(
vm
)
if
self
.
vm
.
direction
==
ViewTransitionDirection
.
FORWARD
or
(
self
.
app
and
self
.
app
.
after_score
):
if
self
.
vm
.
direction
==
ViewTransitionDirection
.
FORWARD
or
(
self
.
app
and
self
.
app
.
after_score
):
...
@@ -320,6 +342,7 @@ class SelectView(BaseView):
...
@@ -320,6 +342,7 @@ class SelectView(BaseView):
self
.
play
()
self
.
play
()
if
self
.
app
:
if
self
.
app
:
self
.
app
.
after_score
=
False
self
.
app
.
after_score
=
False
leds
.
set_slew_rate
(
192
)
def
play
(
self
):
def
play
(
self
):
if
self
.
songs
:
if
self
.
songs
:
...
@@ -335,4 +358,6 @@ class SelectView(BaseView):
...
@@ -335,4 +358,6 @@ class SelectView(BaseView):
super
().
on_exit
()
super
().
on_exit
()
if
self
.
vm
.
direction
==
ViewTransitionDirection
.
BACKWARD
:
if
self
.
vm
.
direction
==
ViewTransitionDirection
.
BACKWARD
:
utils
.
play_back
(
self
.
app
)
utils
.
play_back
(
self
.
app
)
leds
.
set_all_rgb
(
0
,
0
,
0
)
leds
.
update
()
return
True
return
True
This diff is collapsed.
Click to expand it.
song.py
+
1
−
1
View file @
9cc759b0
...
@@ -393,7 +393,7 @@ class SongView(BaseView):
...
@@ -393,7 +393,7 @@ class SongView(BaseView):
self
.
loaded
=
True
self
.
loaded
=
True
media
.
load
(
self
.
song
.
dirName
+
'
/song.mp3
'
,
True
)
media
.
load
(
self
.
song
.
dirName
+
'
/song.mp3
'
,
True
)
if
self
.
song
and
self
.
song
.
loaded
and
self
.
time
>=
-
self
.
song
.
delay
and
not
self
.
started
:
if
self
.
song
and
self
.
loaded
and
self
.
time
>=
-
self
.
song
.
delay
and
not
self
.
started
:
self
.
started
=
True
self
.
started
=
True
media
.
play
()
media
.
play
()
...
...
This diff is collapsed.
Click to expand it.
songinfo.py
+
3
−
0
View file @
9cc759b0
...
@@ -53,6 +53,9 @@ class SongInfo(object):
...
@@ -53,6 +53,9 @@ class SongInfo(object):
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
"
Exception while reading
{
infoFileName
}
:
{
e
}
"
)
print
(
f
"
Exception while reading
{
infoFileName
}
:
{
e
}
"
)
def
load
(
self
):
return
self
def
_set
(
self
,
attr
,
value
):
def
_set
(
self
,
attr
,
value
):
if
not
self
.
info
.
has_section
(
"
song
"
):
if
not
self
.
info
.
has_section
(
"
song
"
):
self
.
info
.
add_section
(
"
song
"
)
self
.
info
.
add_section
(
"
song
"
)
...
...
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