Skip to content
Snippets Groups Projects
Commit 38ebb704 authored by moon2's avatar moon2 :speech_balloon:
Browse files

tiny bugfixes in demo application

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