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
94e4923e
Commit
94e4923e
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
py/harmonic: port to newer API version
parent
aa25b0b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#5606
passed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_payload/apps/harmonic_demo.py
+37
-57
37 additions, 57 deletions
python_payload/apps/harmonic_demo.py
with
37 additions
and
57 deletions
python_payload/apps/harmonic_demo.py
+
37
−
57
View file @
94e4923e
from
synth
import
tinysynth
from
hardware
import
*
import
leds
chords
=
[
[
-
4
,
0
,
3
,
8
,
10
],
...
...
@@ -9,74 +11,52 @@ chords = [
[
3
,
7
,
10
,
14
,
15
],
]
chord_index
=
3
chord
=
chords
[
3
]
synths
=
[]
def
set_chord
(
i
):
global
chord_index
global
chord
if
i
!=
chord_index
:
chord_index
=
i
for
j
in
range
(
40
):
hue
=
int
(
72
*
(
i
+
0.5
))
%
360
set_led_hsv
(
j
,
hue
,
1
,
0.2
)
chord
=
chords
[
i
]
update_leds
()
def
run
():
global
chord_index
global
chord
global
synths
for
i
in
range
(
10
):
if
get_captouch
(
i
):
if
i
%
2
:
k
=
int
((
i
-
1
)
/
2
)
set_chord
(
k
)
else
:
k
=
int
(
i
/
2
)
synths
[
k
].
tone
(
chord
[
k
])
synths
[
k
].
start
()
def
init
():
global
chord_index
global
chord
global
synths
for
i
in
range
(
5
):
synths
+=
[
tinysynth
(
440
,
1
)]
for
synth
in
synths
:
synth
.
decay
(
100
)
synth
.
waveform
(
1
)
def
foreground
():
global
chord_index
global
chord
global
synths
tmp
=
chord_index
chord_index
=
-
1
set_chord
(
tmp
)
from
st3m.application
import
Application
class
HarmonicApp
(
Application
):
def
on_init
(
self
):
init
()
# foreground()
self
.
color_intensity
=
0
self
.
chord_index
=
None
self
.
chord
=
None
self
.
synths
=
[
tinysynth
(
440
,
1
)
for
i
in
range
(
5
)
]
for
synth
in
self
.
synths
:
synth
.
decay
(
100
)
synth
.
waveform
(
1
)
self
.
_set_chord
(
3
)
def
_set_chord
(
self
,
i
):
hue
=
int
(
72
*
(
i
+
0.5
))
%
360
if
i
!=
self
.
chord_index
:
self
.
chord_index
=
i
for
j
in
range
(
40
):
leds
.
set_hsv
(
j
,
hue
,
1
,
0.2
)
self
.
chord
=
chords
[
i
]
leds
.
update
()
def
on_foreground
(
self
):
# foreground()
pass
def
on_draw
(
self
,
ctx
):
i
=
self
.
color_intensity
ctx
.
rgb
(
i
,
i
,
i
).
rectangle
(
-
120
,
-
120
,
240
,
240
).
fill
()
def
main_foreground
(
self
):
run
()
if
self
.
color_intensity
>
0
:
self
.
color_intensity
-=
self
.
color_intensity
/
20
for
i
in
range
(
10
):
if
get_captouch
(
i
):
if
i
%
2
:
k
=
int
((
i
-
1
)
/
2
)
self
.
_set_chord
(
k
)
else
:
k
=
int
(
i
/
2
)
self
.
synths
[
k
].
tone
(
self
.
chord
[
k
])
self
.
synths
[
k
].
start
()
self
.
color_intensity
=
1.0
app
=
HarmonicApp
(
"
harmonic
"
)
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