Tweaks to examples

pull/61/head
helgibbons 2021-02-16 16:52:48 +00:00
rodzic 5a6a5b42c1
commit 5f1bc6b641
3 zmienionych plików z 29 dodań i 7 usunięć

Wyświetl plik

@ -10,31 +10,42 @@ display.set_backlight(0.5)
# sets up a handy function we can call to clear the screen
def clear():
display.set_pen(0,0,0)
display.set_pen(0, 0, 0)
display.clear()
display.update()
while True:
clear()
if display.is_pressed(display.BUTTON_A): # if a button press is detected then...
clear() # clear to black
display.set_pen(255, 255, 255) # change the pen colour
display.text("Button A pressed", 10, 10, 240, 4) # display some text on the screen
display.update() # update the display
utime.sleep(1) # pause for a sec
clear() # clear to black again
elif display.is_pressed(display.BUTTON_B):
clear()
display.set_pen(0, 255, 255)
display.text("Button B pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
clear()
elif display.is_pressed(display.BUTTON_X):
clear()
display.set_pen(255, 0, 255)
display.text("Button X pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
clear()
elif display.is_pressed(display.BUTTON_Y):
clear()
display.set_pen(255, 255, 0)
display.text("Button Y pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
utime.sleep(1)
clear()
else:
display.set_pen(255, 0, 0)
display.text("Press any button!", 10, 10, 240, 4)
display.update()
utime.sleep(0.1) # this number is how frequently the Pico checks for button presses

Wyświetl plik

@ -9,31 +9,42 @@ display.init(buf)
# sets up a handy function we can call to clear the screen
def clear():
display.set_pen(0,0,0)
display.set_pen(0, 0, 0)
display.clear()
display.update()
while True:
clear()
if display.is_pressed(display.BUTTON_A): # if a button press is detected then...
clear() # clear to black
display.set_pen(255, 255, 255) # change the pen colour
display.text("Button A pressed", 10, 10, 240, 4) # display some text on the screen
display.update() # update the display
utime.sleep(1) # pause for a sec
clear() # clear to black again
elif display.is_pressed(display.BUTTON_B):
clear()
display.set_pen(0, 255, 255)
display.text("Button B pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
clear()
elif display.is_pressed(display.BUTTON_X):
clear()
display.set_pen(255, 0, 255)
display.text("Button X pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
clear()
elif display.is_pressed(display.BUTTON_Y):
clear()
display.set_pen(255, 255, 0)
display.text("Button Y pressed", 10, 10, 240, 4)
display.update()
utime.sleep(1)
utime.sleep(1)
clear()
else:
display.set_pen(255, 0, 0)
display.text("Press any button!", 10, 10, 240, 4)
display.update()
utime.sleep(0.1) # this number is how frequently the Pico checks for button presses

Wyświetl plik

@ -117,7 +117,7 @@ def playtone(frequency): # this function tells your program how to ma
explorer.set_tone(frequency)
def bequiet(): # this function tells your program how not to make noise
explorer.set_tone(-1000)
explorer.set_tone(-1)
def playsong(song): # this function plays your song
a = 0 # this variable keeps track of the visualiser bars