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
7aa5d3d6
Commit
7aa5d3d6
authored
1 year ago
by
iggy
Committed by
q3k
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
basic sequencer and popcorn
parent
e8559e2c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
python_payload/demo_sparabo.py
+46
-0
46 additions, 0 deletions
python_payload/demo_sparabo.py
python_payload/event.py
+22
-1
22 additions, 1 deletion
python_payload/event.py
with
68 additions
and
1 deletion
python_payload/demo_sparabo.py
0 → 100644
+
46
−
0
View file @
7aa5d3d6
import
event
import
hardware
from
synth
import
tinysynth
import
math
def
xy_from_polar
(
r
,
deg
):
#rad = deg/180*math.pi
return
(
(
r
*
math
.
sin
(
deg
),
#x
r
*
math
.
cos
(
deg
)
#y
)
)
ctx
=
hardware
.
get_ctx
()
ctx
.
text_align
=
ctx
.
CENTER
ctx
.
text_baseline
=
ctx
.
MIDDLE
synth
=
tinysynth
(
440
,
1
)
synth
.
decay
(
25
)
popcorn
=
[
9
,
7
,
9
,
5
,
0
,
5
,
-
3
,
999
]
def
on_step
(
data
):
note
=
popcorn
[
data
[
"
step
"
]]
if
note
!=
999
:
synth
.
tone
(
note
)
synth
.
start
()
ctx
.
rgb
(
1
,
1
,
0
).
rectangle
(
-
120
,
-
120
,
240
,
240
).
fill
()
(
x
,
y
)
=
xy_from_polar
(
90
,
-
2
*
math
.
pi
/
8
*
data
[
"
step
"
]
+
math
.
pi
)
size
=
180
ctx
.
rgb
(
0.8
,
0.8
,
0
)
ctx
.
round_rectangle
(
x
-
size
/
2
,
y
-
size
/
2
,
size
,
size
,
size
//
2
).
fill
()
ctx
.
move_to
(
x
,
y
).
rgb
(
0.5
,
0.5
,
0
).
text
(
"
{}
"
.
format
(
data
[
"
step
"
]))
hardware
.
display_update
()
event
.
Sequence
(
bpm
=
160
,
steps
=
8
,
action
=
on_step
,
loop
=
True
)
event
.
the_engine
.
eventloop
()
This diff is collapsed.
Click to expand it.
python_payload/event.py
+
22
−
1
View file @
7aa5d3d6
...
...
@@ -126,6 +126,22 @@ class EventTimed(Event):
def
__repr__
(
self
):
return
(
"
event on tick {} ({})
"
.
format
(
self
.
deadline
,
self
.
name
))
class
Sequence
():
def
__init__
(
self
,
bpm
=
60
,
loop
=
True
,
steps
=
16
,
action
=
None
):
self
.
bpm
=
bpm
if
not
action
:
self
.
action
=
lambda
data
:
print
(
"
step {}
"
.
format
(
data
.
get
(
"
step
"
)))
else
:
self
.
action
=
action
stepsize_ms
=
int
(
60
*
1000
/
bpm
)
for
i
in
range
(
steps
):
EventTimed
(
stepsize_ms
*
i
,
name
=
"
seq{}
"
.
format
(
i
),
action
=
self
.
action
,
data
=
{
'
step
'
:
i
})
if
loop
:
EventTimed
(
stepsize_ms
*
steps
,
name
=
"
loop
"
,
action
=
lambda
data
:
Sequence
(
bpm
=
bpm
,
loop
=
loop
,
steps
=
steps
,
action
=
action
))
global
the_engine
the_engine
=
Engine
()
...
...
@@ -136,5 +152,10 @@ Event(name="baz",
condition
=
lambda
data
:
data
.
get
(
'
type
'
)
==
"
captouch
"
)
#Sequence(action=axelf)
print
(
the_engine
.
events_timed
)
#e.eventloop()
#the_engine.eventloop()
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