Skip to content
Snippets Groups Projects
Commit 04eaabb8 authored by dx's avatar dx Committed by q3k
Browse files

python: reorder stuff

parent 6cb51e6c
No related branches found
No related tags found
No related merge requests found
...@@ -3,20 +3,13 @@ from hardware import * ...@@ -3,20 +3,13 @@ from hardware import *
import time import time
import cap_touch_demo import cap_touch_demo
import melodic_demo import melodic_demo
boot = Pin(0, Pin.IN) boot = Pin(0, Pin.IN)
vol_up = Pin(35, Pin.IN, Pin.PULL_UP) vol_up = Pin(35, Pin.IN, Pin.PULL_UP)
vol_down = Pin(37, Pin.IN, Pin.PULL_UP) vol_down = Pin(37, Pin.IN, Pin.PULL_UP)
# pin numbers foreground = 0
# right side: left 37, down 0, right 35 volume = 0
# left side: left 7, down 6, right 5
# NOTE: All except for 0 should be initialized with Pin.PULL_UP
# 0 (bootsel) probably not but idk? never tried
def clear_all_leds():
for i in range(40):
set_led_rgb(i, 0, 0, 0)
update_leds()
select = [\ select = [\
[0,1,1,0,0,1,1,1,1,0,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,0,1],\ [0,1,1,0,0,1,1,1,1,0,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0,1,1,1,1,1,0,1],\
...@@ -28,6 +21,22 @@ select = [\ ...@@ -28,6 +21,22 @@ select = [\
[0,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,1,1,0,0,0,0,1,0,0,0,1],\ [0,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,1,1,0,0,0,0,1,0,0,0,1],\
] ]
background = 0
g = 0b0000011111100000
r = 0b1111100000000000
b = 0b0000000000011111
# pin numbers
# right side: left 37, down 0, right 35
# left side: left 7, down 6, right 5
# NOTE: All except for 0 should be initialized with Pin.PULL_UP
# 0 (bootsel) probably not but idk? never tried
def clear_all_leds():
for i in range(40):
set_led_rgb(i, 0, 0, 0)
update_leds()
def draw_text_big(text, x, y): def draw_text_big(text, x, y):
ypos = 120+int(len(text)/2) + int(y) ypos = 120+int(len(text)/2) + int(y)
xpos = 120+int(len(text[0])/2) + int(x) xpos = 120+int(len(text[0])/2) + int(x)
...@@ -52,18 +61,11 @@ def long_bottom_petal_captouch_blocking(num, ms): ...@@ -52,18 +61,11 @@ def long_bottom_petal_captouch_blocking(num, ms):
return True return True
return False return False
foreground = 0
volume = 0
def init_menu():
pass
def draw_rect(x,y,w,h,col): def draw_rect(x,y,w,h,col):
for j in range(w): for j in range(w):
for k in range(h): for k in range(h):
display_draw_pixel(x+j,y+k,col) display_draw_pixel(x+j,y+k,col)
def draw_volume_slider(): def draw_volume_slider():
global volume global volume
length = 96 + ((volume - 20) * 1.6) length = 96 + ((volume - 20) * 1.6)
...@@ -111,21 +113,6 @@ def foreground_menu(): ...@@ -111,21 +113,6 @@ def foreground_menu():
draw_text_big(select, 0, 0) draw_text_big(select, 0, 0)
display_update() display_update()
background = 0;
g = 0b0000011111100000;
r = 0b1111100000000000;
b = 0b0000000000011111;
time.sleep_ms(5000)
captouch_autocalib()
cap_touch_demo.init()
melodic_demo.init()
init_menu()
foreground = run_menu
foreground_menu()
set_global_volume_dB(volume)
def set_rel_volume(vol): def set_rel_volume(vol):
global volume global volume
vol += volume vol += volume
...@@ -140,6 +127,17 @@ def set_rel_volume(vol): ...@@ -140,6 +127,17 @@ def set_rel_volume(vol):
set_global_volume_dB(volume) set_global_volume_dB(volume)
time.sleep_ms(100) time.sleep_ms(100)
def main():
global foreground
time.sleep_ms(5000)
captouch_autocalib()
cap_touch_demo.init()
melodic_demo.init()
foreground = run_menu
foreground_menu()
set_global_volume_dB(volume)
while True: while True:
if(boot.value() == 0): if(boot.value() == 0):
if foreground == run_menu: if foreground == run_menu:
...@@ -152,3 +150,5 @@ while True: ...@@ -152,3 +150,5 @@ while True:
if(vol_down.value() == 0): if(vol_down.value() == 0):
set_rel_volume(-3) set_rel_volume(-3)
foreground() foreground()
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment