kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Badger2040: Add launcher dark mode, USER button is shift
rodzic
b2fed2b6dc
commit
e44017e0a0
|
@ -14,6 +14,7 @@ MIN_BATTERY_VOLTAGE = 3.2
|
||||||
|
|
||||||
page = 0
|
page = 0
|
||||||
font_size = 1
|
font_size = 1
|
||||||
|
inverted = False
|
||||||
|
|
||||||
icons = bytearray(launchericons.data())
|
icons = bytearray(launchericons.data())
|
||||||
|
|
||||||
|
@ -181,25 +182,37 @@ def launch_example(index):
|
||||||
|
|
||||||
|
|
||||||
def button(pin):
|
def button(pin):
|
||||||
global page, font_size
|
global page, font_size, inverted
|
||||||
if pin == button_user:
|
|
||||||
font_size += 1
|
if button_user.value(): # User button is NOT held down
|
||||||
if font_size == len(font_sizes):
|
if pin == button_a:
|
||||||
font_size = 0
|
launch_example(0)
|
||||||
render()
|
if pin == button_b:
|
||||||
if pin == button_a:
|
launch_example(1)
|
||||||
launch_example(0)
|
if pin == button_c:
|
||||||
if pin == button_b:
|
launch_example(2)
|
||||||
launch_example(1)
|
if pin == button_up:
|
||||||
if pin == button_c:
|
if page > 0:
|
||||||
launch_example(2)
|
page -= 1
|
||||||
if pin == button_up:
|
render()
|
||||||
if page > 0:
|
if pin == button_down:
|
||||||
page -= 1
|
if page < MAX_PAGE - 1:
|
||||||
|
page += 1
|
||||||
|
render()
|
||||||
|
else: # User button IS held down
|
||||||
|
if pin == button_up:
|
||||||
|
font_size += 1
|
||||||
|
if font_size == len(font_sizes):
|
||||||
|
font_size = 0
|
||||||
render()
|
render()
|
||||||
if pin == button_down:
|
if pin == button_down:
|
||||||
if page < MAX_PAGE - 1:
|
font_size -= 1
|
||||||
page += 1
|
if font_size < 0:
|
||||||
|
font_size = 0
|
||||||
|
render()
|
||||||
|
if pin == button_a:
|
||||||
|
inverted = not inverted
|
||||||
|
display.invert(inverted)
|
||||||
render()
|
render()
|
||||||
|
|
||||||
|
|
||||||
|
@ -226,7 +239,4 @@ while True:
|
||||||
if button_down.value():
|
if button_down.value():
|
||||||
button(button_down)
|
button(button_down)
|
||||||
|
|
||||||
if not button_user.value():
|
|
||||||
button(button_user)
|
|
||||||
|
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
Ładowanie…
Reference in New Issue