Skip to content

Commit c3bd839

Browse files
committed
Add WIP firmware
1 parent c3d10cc commit c3bd839

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

firmware/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Alethea Flowers for Winterbloom
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

firmware/code.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2020 Alethea Flowers for Winterbloom
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
23+
import time
24+
import audioio
25+
import analogio
26+
import board
27+
import digitalio
28+
29+
button = digitalio.DigitalInOut(board.D2)
30+
button.switch_to_input(pull=digitalio.Pull.UP)
31+
gate = digitalio.DigitalInOut(board.D0)
32+
gate.switch_to_input()
33+
pitch_cv = analogio.AnalogIn(board.A4)
34+
35+
wave_file = open("honk-sound.wav", "rb")
36+
wave = audioio.WaveFile(wave_file)
37+
audio = audioio.AudioOut(board.A0)
38+
39+
last_button_value = False
40+
last_gate_value = False
41+
button_value = None
42+
gate_value = None
43+
44+
while True:
45+
button_value = not button.value
46+
gate_value = not gate.value
47+
48+
if (not last_button_value and button_value) or (not last_gate_value and gate_value):
49+
print(pitch_cv.value)
50+
wave.sample_rate = int(44100 * ((pitch_cv.value / 65355) + 0.5))
51+
audio.play(wave)
52+
53+
last_button_value = button_value
54+
last_gate_value = gate_value

firmware/honk-sound.wav

16.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)