Skip to content
Snippets Groups Projects
Commit e9ffbf4d authored by moon2's avatar moon2 :speech_balloon: Committed by q3k
Browse files

tiny bugfixes in demo application

parent f4188a36
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,7 @@ def draw_text_big(text, x, y):
def highlight_bottom_petal(num, r, g, b):
start = 4 + 8*num
for i in range(7):
set_led_rgb((i+start%40), r, g, b)
set_led_rgb(((i+start)%40), r, g, b)
update_leds()
def long_bottom_petal_captouch_blocking(num, ms):
......@@ -96,7 +96,7 @@ def run_menu():
cap_touch_demo.foreground()
if long_bottom_petal_captouch_blocking(1,20):
clear_all_leds()
highlight_bottom_petal(0,255,0,0)
highlight_bottom_petal(1,255,0,0)
display_fill(background)
display_update()
foreground = melodic_demo.run
......
from synth import tinysynth
from hardware import *
octave = 0
synths = []
scale = [0,2,4,5,7,9,11]
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.5)
chord = chords[i]
print("set chord " +str(i))
update_leds()
def highlight_bottom_petal(num, r, g, b):
start = 4 + 8*num
for i in range(7):
set_led_rgb(((i+start)%40), r, g, b)
def change_playing_field_color(r,g,b):
highlight_bottom_petal(0, r, g, b)
highlight_bottom_petal(1, r, g, b)
highlight_bottom_petal(3, r, g, b)
highlight_bottom_petal(4, r, g, b)
highlight_bottom_petal(2, 255, 0, 255)
set_led_rgb(18, 255, 0, 255)
set_led_rgb(19, 255, 0, 255)
set_led_rgb(27, 255, 0, 255)
set_led_rgb(28, 255, 0, 255)
update_leds()
def adjust_playing_field_to_octave():
global octave
if(octave == -1):
change_playing_field_color(0,0,255)
elif(octave == 0):
change_playing_field_color(0,127,127)
elif(octave == 1):
change_playing_field_color(0,255,0)
def run():
global scale
......@@ -26,10 +39,13 @@ def run():
if(get_captouch(i)):
if(i == 4):
octave = -1
adjust_playing_field_to_octave()
elif(i == 5):
octave = 0
adjust_playing_field_to_octave()
elif(i == 6):
octave = 1
adjust_playing_field_to_octave()
else:
k = i
if(k>3):
......@@ -41,27 +57,11 @@ def run():
def init():
global synths
for i in range(1):
synths += [tinysynth(440,1)]
for synth in synths:
synth.decay(100)
synth.waveform(1)
def highlight_bottom_petal(num, r, g, b):
start = 4 + 8*num
for i in range(7):
set_led_rgb((i+start%40), r, g, b)
update_leds()
def foreground():
highlight_bottom_petal(0, 0, 0, 255)
highlight_bottom_petal(1, 0, 0, 255)
highlight_bottom_petal(4, 0, 0, 255)
highlight_bottom_petal(3, 0, 0, 255)
set_led_rgb(18, 255, 0, 255)
set_led_rgb(19, 255, 0, 255)
set_led_rgb(27, 255, 0, 255)
set_led_rgb(28, 255, 0, 255)
highlight_bottom_petal(2, 255, 0, 255)
adjust_playing_field_to_octave()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment