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
110cbbe8
Verified
Commit
110cbbe8
authored
Sep 7, 2023
by
dos
Browse files
Options
Downloads
Patches
Plain Diff
Nicify
parent
0d494657
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
__init__.py
+5
-3
5 additions, 3 deletions
__init__.py
difficulty.py
+2
-2
2 additions, 2 deletions
difficulty.py
select.py
+11
-7
11 additions, 7 deletions
select.py
song.py
+32
-16
32 additions, 16 deletions
song.py
songinfo.py
+1
-1
1 addition, 1 deletion
songinfo.py
utils.py
+10
-2
10 additions, 2 deletions
utils.py
with
61 additions
and
31 deletions
__init__.py
+
5
−
3
View file @
110cbbe8
...
@@ -29,6 +29,7 @@ class PetalHero(Application):
...
@@ -29,6 +29,7 @@ class PetalHero(Application):
self
.
loaded
=
False
self
.
loaded
=
False
self
.
blm
=
None
self
.
blm
=
None
self
.
fiba_sound
=
None
self
.
fiba_sound
=
None
self
.
select
=
select
.
SelectView
(
self
.
app
)
#self.blm_extra = bl00mbox.Channel("Petal Hero Extra")
#self.blm_extra = bl00mbox.Channel("Petal Hero Extra")
#self.blm_extra.background_mute_override = True
#self.blm_extra.background_mute_override = True
...
@@ -123,11 +124,12 @@ class PetalHero(Application):
...
@@ -123,11 +124,12 @@ class PetalHero(Application):
self
.
repeats
+=
1
self
.
repeats
+=
1
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
self
.
app
.
in_sound
.
signals
.
trigger
.
start
()
utils
.
play_go
(
self
.
app
)
self
.
vm
.
push
(
select
.
SelectView
(
self
.
app
),
ViewTransitionSwipeLeft
())
self
.
vm
.
push
(
self
.
select
,
ViewTransitionSwipeLeft
())
self
.
select
.
play
()
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
self
.
app
.
out_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_back
(
self
.
app
)
self
.
unload
()
self
.
unload
()
if
self
.
exiting
:
if
self
.
exiting
:
...
...
This diff is collapsed.
Click to expand it.
difficulty.py
+
2
−
2
View file @
110cbbe8
...
@@ -115,8 +115,8 @@ class DifficultyView(BaseView):
...
@@ -115,8 +115,8 @@ class DifficultyView(BaseView):
utils
.
play_crunch
(
self
.
app
)
utils
.
play_crunch
(
self
.
app
)
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
self
.
app
.
in_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_go
(
self
.
app
)
self
.
vm
.
replace
(
loading
.
LoadingView
(
self
.
app
,
self
.
song
,
self
.
song
.
difficulties
[
self
.
_sc
.
target_position
()]),
ViewTransitionBlend
())
self
.
vm
.
replace
(
loading
.
LoadingView
(
self
.
app
,
self
.
song
,
self
.
song
.
difficulties
[
self
.
_sc
.
target_position
()]),
ViewTransitionBlend
())
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
self
.
app
.
out_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_back
(
self
.
app
)
This diff is collapsed.
Click to expand it.
select.py
+
11
−
7
View file @
110cbbe8
...
@@ -68,6 +68,8 @@ class SelectView(BaseView):
...
@@ -68,6 +68,8 @@ class SelectView(BaseView):
self
.
processing_now
=
None
self
.
processing_now
=
None
self
.
_sc
.
set_item_count
(
len
(
self
.
songs
))
self
.
_sc
.
set_item_count
(
len
(
self
.
songs
))
self
.
_scroll_pos
=
0
self
.
_scroll_pos
=
0
self
.
process_delay
=
250
self
.
pos
=
-
1
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
...
@@ -86,6 +88,7 @@ class SelectView(BaseView):
...
@@ -86,6 +88,7 @@ class SelectView(BaseView):
self
.
processing_now
=
None
self
.
processing_now
=
None
if
self
.
to_process
:
if
self
.
to_process
:
if
self
.
process_delay
<=
0
:
self
.
processing_now
=
self
.
to_process
.
pop
()
self
.
processing_now
=
self
.
to_process
.
pop
()
utils
.
fire_gradient
(
ctx
)
utils
.
fire_gradient
(
ctx
)
...
@@ -177,6 +180,8 @@ class SelectView(BaseView):
...
@@ -177,6 +180,8 @@ class SelectView(BaseView):
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
super
().
think
(
ins
,
delta_ms
)
super
().
think
(
ins
,
delta_ms
)
self
.
_sc
.
think
(
ins
,
delta_ms
)
self
.
_sc
.
think
(
ins
,
delta_ms
)
if
self
.
process_delay
>
0
:
self
.
process_delay
-=
delta_ms
if
not
self
.
to_process
and
not
self
.
processing_now
:
if
not
self
.
to_process
and
not
self
.
processing_now
:
media
.
think
(
delta_ms
)
media
.
think
(
delta_ms
)
self
.
flower
.
think
(
delta_ms
)
self
.
flower
.
think
(
delta_ms
)
...
@@ -203,19 +208,18 @@ class SelectView(BaseView):
...
@@ -203,19 +208,18 @@ class SelectView(BaseView):
media
.
load
(
self
.
songs
[
pos
].
dirName
+
"
/song.mp3
"
)
media
.
load
(
self
.
songs
[
pos
].
dirName
+
"
/song.mp3
"
)
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
self
.
app
.
in_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_go
(
self
.
app
)
if
self
.
songs
:
if
self
.
songs
:
self
.
vm
.
push
(
difficulty
.
DifficultyView
(
self
.
app
,
self
.
songs
[
pos
]),
ViewTransitionSwipeLeft
())
self
.
vm
.
push
(
difficulty
.
DifficultyView
(
self
.
app
,
self
.
songs
[
pos
]),
ViewTransitionSwipeLeft
())
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
os
.
middle
.
pressed
:
self
.
app
.
out_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_back
(
self
.
app
)
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
super
().
on_enter
(
vm
)
super
().
on_enter
(
vm
)
#self._vm = vm
# Ignore the button which brought us here until it is released
def
play
(
self
):
#self.input._ignore_pressed()
if
self
.
songs
:
if
self
.
songs
:
media
.
load
(
self
.
songs
[
self
.
_sc
.
target_position
()].
dirName
+
"
/song.mp3
"
)
media
.
load
(
self
.
songs
[
self
.
_sc
.
target_position
()].
dirName
+
"
/song.mp3
"
)
...
...
This diff is collapsed.
Click to expand it.
song.py
+
32
−
16
View file @
110cbbe8
...
@@ -31,10 +31,11 @@ class SongView(BaseView):
...
@@ -31,10 +31,11 @@ class SongView(BaseView):
self
.
events
=
[]
self
.
events
=
[]
self
.
petals
=
[
False
]
*
5
self
.
petals
=
[
False
]
*
5
self
.
demo_mode
=
False
self
.
demo_mode
=
False
self
.
fps
=
False
self
.
debug
=
False
def
draw
(
self
,
ctx
:
Context
)
->
None
:
def
draw
(
self
,
ctx
:
Context
)
->
None
:
# Paint the background black
if
self
.
delay
<
1750
:
if
self
.
delay
<
1000
:
sys_display
.
set_mode
(
2
)
sys_display
.
set_mode
(
2
)
ctx
.
compositing_mode
=
ctx
.
COPY
ctx
.
compositing_mode
=
ctx
.
COPY
...
@@ -44,15 +45,15 @@ class SongView(BaseView):
...
@@ -44,15 +45,15 @@ class SongView(BaseView):
ctx
.
gray
(
0.25
)
ctx
.
gray
(
0.25
)
self
.
time
-
=
DELAY
self
.
time
+
=
DELAY
for
i
in
range
(
0
,
2
):
for
i
in
range
(
0
,
2
):
ctx
.
gray
(
0.
30
-
i
/
5
*
(
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
*
0.1
5
)
ctx
.
gray
(
0.
4
+
i
*
0.12
+
(
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
*
0.1
2
)
ctx
.
line_width
=
2
+
i
/
5
*
(
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
*
2
ctx
.
line_width
=
1.75
+
i
*
0.1
2
+
(
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
*
0.1
2
pos
=
23
*
2
*
(
i
+
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
pos
=
23
*
2
*
(
i
+
1
-
(
self
.
time
/
2
/
self
.
data
.
period
)
%
1
)
if
pos
>
0
:
if
pos
>
0
:
ctx
.
arc
(
0
,
0
,
28
+
pos
,
0
,
tau
,
0
)
ctx
.
arc
(
0
,
0
,
28
+
pos
,
0
,
tau
,
0
)
ctx
.
stroke
()
ctx
.
stroke
()
self
.
time
+
=
DELAY
self
.
time
-
=
DELAY
ctx
.
line_width
=
2
ctx
.
line_width
=
2
...
@@ -65,8 +66,8 @@ class SongView(BaseView):
...
@@ -65,8 +66,8 @@ class SongView(BaseView):
for
i
in
range
(
5
):
for
i
in
range
(
5
):
ctx
.
move_to
(
0
,
0
)
ctx
.
move_to
(
0
,
0
)
ctx
.
line_to
(
0
,
-
120
)
ctx
.
line_to
(
0
,
-
120
)
ctx
.
stroke
()
ctx
.
rotate
(
tau
/
5
)
ctx
.
rotate
(
tau
/
5
)
ctx
.
stroke
()
ctx
.
restore
()
ctx
.
restore
()
ctx
.
save
()
ctx
.
save
()
...
@@ -85,7 +86,7 @@ class SongView(BaseView):
...
@@ -85,7 +86,7 @@ class SongView(BaseView):
if
self
.
demo_mode
:
if
self
.
demo_mode
:
time
-=
DELAY
time
-=
DELAY
if
(
self
.
petals
[
i
]
or
self
.
demo_mode
)
and
time
<
self
.
time
and
time
+
length
>
self
.
time
:
if
(
self
.
petals
[
i
]
or
self
.
demo_mode
)
and
time
<
self
.
time
and
time
+
length
>
self
.
time
:
length
-=
self
.
time
-
time
length
-=
self
.
time
-
time
+
DELAY
time
=
self
.
time
time
=
self
.
time
orig_time
=
time
orig_time
=
time
during
=
True
during
=
True
...
@@ -120,7 +121,7 @@ class SongView(BaseView):
...
@@ -120,7 +121,7 @@ class SongView(BaseView):
ctx
.
save
()
ctx
.
save
()
ctx
.
scale
(
0.42
,
0.42
)
ctx
.
scale
(
0.42
,
0.42
)
self
.
time
-
=
DELAY
self
.
time
+
=
DELAY
wiggle
=
math
.
cos
(((
self
.
time
/
self
.
data
.
period
/
2
)
%
1
)
*
tau
)
*
0.1
wiggle
=
math
.
cos
(((
self
.
time
/
self
.
data
.
period
/
2
)
%
1
)
*
tau
)
*
0.1
self
.
flower
.
rot
=
tau
/
5
/
2
+
wiggle
self
.
flower
.
rot
=
tau
/
5
/
2
+
wiggle
ctx
.
rgb
(
0.945
,
0.631
,
0.769
)
ctx
.
rgb
(
0.945
,
0.631
,
0.769
)
...
@@ -130,7 +131,7 @@ class SongView(BaseView):
...
@@ -130,7 +131,7 @@ class SongView(BaseView):
ctx
.
gray
(
0.3
*
(
1.0
-
((((
self
.
time
/
self
.
data
.
period
)
%
1
)
**
2
)
*
0.75
)
if
self
.
started
else
0.0
))
ctx
.
gray
(
0.3
*
(
1.0
-
((((
self
.
time
/
self
.
data
.
period
)
%
1
)
**
2
)
*
0.75
)
if
self
.
started
else
0.0
))
ctx
.
arc
(
0
,
0
,
10
,
0
,
tau
,
0
)
ctx
.
arc
(
0
,
0
,
10
,
0
,
tau
,
0
)
ctx
.
fill
()
ctx
.
fill
()
self
.
time
+
=
DELAY
self
.
time
-
=
DELAY
ctx
.
save
()
ctx
.
save
()
ctx
.
gray
(
0.5
)
ctx
.
gray
(
0.5
)
...
@@ -148,15 +149,22 @@ class SongView(BaseView):
...
@@ -148,15 +149,22 @@ class SongView(BaseView):
ctx
.
fill
()
ctx
.
fill
()
ctx
.
restore
()
ctx
.
restore
()
if
self
.
demo_mode
:
ctx
.
gray
(
0.8
)
ctx
.
gray
(
0.8
)
ctx
.
font
=
"
Camp Font 2
"
ctx
.
font_size
=
30
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_baseline
=
ctx
.
MIDDLE
ctx
.
text_baseline
=
ctx
.
MIDDLE
if
self
.
demo_mode
:
ctx
.
font
=
"
Camp Font 2
"
ctx
.
font_size
=
30
ctx
.
move_to
(
0
,
40
)
ctx
.
move_to
(
0
,
40
)
ctx
.
text
(
"
DEMO
"
)
ctx
.
text
(
"
DEMO
"
)
if
self
.
fps
:
ctx
.
font
=
"
Camp Font 3
"
ctx
.
font_size
=
16
ctx
.
move_to
(
0
,
105
)
ctx
.
text
(
f
"
{
sys_display
.
fps
()
:
.
2
f
}
"
)
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
super
().
think
(
ins
,
delta_ms
)
super
().
think
(
ins
,
delta_ms
)
media
.
think
(
delta_ms
)
media
.
think
(
delta_ms
)
...
@@ -175,6 +183,12 @@ class SongView(BaseView):
...
@@ -175,6 +183,12 @@ class SongView(BaseView):
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
if
self
.
input
.
buttons
.
app
.
middle
.
pressed
:
self
.
demo_mode
=
not
self
.
demo_mode
self
.
demo_mode
=
not
self
.
demo_mode
if
self
.
input
.
buttons
.
app
.
left
.
pressed
:
self
.
fps
=
not
self
.
fps
if
self
.
input
.
buttons
.
app
.
right
.
pressed
:
self
.
debug
=
not
self
.
debug
earlyMargin
=
60000.0
/
self
.
data
.
bpm
/
3.5
earlyMargin
=
60000.0
/
self
.
data
.
bpm
/
3.5
lateMargin
=
60000.0
/
self
.
data
.
bpm
/
3.5
lateMargin
=
60000.0
/
self
.
data
.
bpm
/
3.5
...
@@ -197,7 +211,9 @@ class SongView(BaseView):
...
@@ -197,7 +211,9 @@ class SongView(BaseView):
p
=
4
if
petal
==
0
else
petal
-
1
p
=
4
if
petal
==
0
else
petal
-
1
pressed
=
ins
.
captouch
.
petals
[
p
*
2
].
pressed
pressed
=
ins
.
captouch
.
petals
[
p
*
2
].
pressed
active
=
self
.
petals
[
petal
]
active
=
self
.
petals
[
petal
]
utils
.
petal_leds
(
petal
,
1.0
if
pressed
and
active
else
(
0.15
if
pressed
else
(
1.0
if
petal
in
notes
and
self
.
demo_mode
else
0
)))
d
=
1.0
if
pressed
and
active
else
(
0.15
if
pressed
else
(
1.0
if
petal
in
notes
and
self
.
demo_mode
else
0
))
if
d
:
utils
.
petal_leds
(
petal
,
d
)
if
not
pressed
:
if
not
pressed
:
self
.
petals
[
petal
]
=
False
self
.
petals
[
petal
]
=
False
...
@@ -223,5 +239,5 @@ class SongView(BaseView):
...
@@ -223,5 +239,5 @@ class SongView(BaseView):
sys_display
.
set_mode
(
0
)
sys_display
.
set_mode
(
0
)
super
().
on_exit
()
super
().
on_exit
()
self
.
app
.
blm
.
volume
=
14000
self
.
app
.
blm
.
volume
=
14000
self
.
app
.
out_sound
.
signals
.
trigger
.
start
(
)
utils
.
play_back
(
self
.
app
)
#gc.enable()
#gc.enable()
This diff is collapsed.
Click to expand it.
songinfo.py
+
1
−
1
View file @
110cbbe8
...
@@ -85,7 +85,7 @@ class SongInfo(object):
...
@@ -85,7 +85,7 @@ class SongInfo(object):
for
b
in
diffs
:
for
b
in
diffs
:
self
.
_difficulties
.
append
(
difficulties
[
int
(
b
)])
self
.
_difficulties
.
append
(
difficulties
[
int
(
b
)])
if
not
self
.
_difficulties
:
if
not
self
.
_difficulties
:
os
.
unlink
(
diffFileName
)
#
os.unlink(diffFileName)
# unlink's broken
raise
Exception
raise
Exception
self
.
_difficulties
.
sort
(
key
=
lambda
a
:
a
.
id
,
reverse
=
True
)
self
.
_difficulties
.
sort
(
key
=
lambda
a
:
a
.
id
,
reverse
=
True
)
return
self
.
_difficulties
return
self
.
_difficulties
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
10
−
2
View file @
110cbbe8
...
@@ -21,8 +21,10 @@ def fire_gradient(ctx):
...
@@ -21,8 +21,10 @@ def fire_gradient(ctx):
PETAL_COLORS
=
[
GO_GREEN
,
RED
,
(
1.0
,
0.69
,
0.0
),
BLUE
,
PUSH_RED
]
PETAL_COLORS
=
[
GO_GREEN
,
RED
,
(
1.0
,
0.69
,
0.0
),
BLUE
,
PUSH_RED
]
def
petal_leds
(
petal
,
val
):
def
petal_leds
(
petal
,
val
,
color
=
None
):
color
=
dim
(
PETAL_COLORS
[
petal
],
val
)
if
not
color
:
color
=
PETAL_COLORS
[
petal
]
color
=
dim
(
color
,
val
)
start
=
-
11
+
petal
*
8
start
=
-
11
+
petal
*
8
for
i
in
range
(
start
,
start
+
7
):
for
i
in
range
(
start
,
start
+
7
):
led
=
i
led
=
i
...
@@ -39,3 +41,9 @@ def play_fiba(app):
...
@@ -39,3 +41,9 @@ def play_fiba(app):
if
not
app
.
fiba_sound
:
if
not
app
.
fiba_sound
:
return
return
app
.
fiba_sound
[
random
.
randint
(
0
,
5
)].
signals
.
trigger
.
start
()
app
.
fiba_sound
[
random
.
randint
(
0
,
5
)].
signals
.
trigger
.
start
()
def
play_go
(
app
):
app
.
in_sound
.
signals
.
trigger
.
start
()
def
play_back
(
app
):
app
.
out_sound
.
signals
.
trigger
.
start
()
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