kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Make Galatic clock example responsive
rodzic
8f5a94482b
commit
16c2dc0356
|
@ -158,11 +158,13 @@ down_button = machine.Pin(CosmicUnicorn.SWITCH_VOLUME_DOWN, machine.Pin.IN, mach
|
|||
|
||||
|
||||
def adjust_utc_offset(pin):
|
||||
global utc_offset
|
||||
global utc_offset, last_second
|
||||
if pin == up_button:
|
||||
utc_offset += 1
|
||||
last_second = None
|
||||
if pin == down_button:
|
||||
utc_offset -= 1
|
||||
last_second = None
|
||||
|
||||
|
||||
up_button.irq(trigger=machine.Pin.IRQ_FALLING, handler=adjust_utc_offset)
|
||||
|
@ -214,9 +216,11 @@ sync_time()
|
|||
while True:
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
cu.adjust_brightness(+0.01)
|
||||
last_second = None
|
||||
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
cu.adjust_brightness(-0.01)
|
||||
last_second = None
|
||||
|
||||
if cu.is_pressed(CosmicUnicorn.SWITCH_A):
|
||||
sync_time()
|
||||
|
|
|
@ -159,11 +159,13 @@ down_button = machine.Pin(GalacticUnicorn.SWITCH_VOLUME_DOWN, machine.Pin.IN, ma
|
|||
|
||||
|
||||
def adjust_utc_offset(pin):
|
||||
global utc_offset
|
||||
global utc_offset, last_second
|
||||
if pin == up_button:
|
||||
utc_offset += 1
|
||||
last_second = None
|
||||
if pin == down_button:
|
||||
utc_offset -= 1
|
||||
last_second = None
|
||||
|
||||
|
||||
up_button.irq(trigger=machine.Pin.IRQ_FALLING, handler=adjust_utc_offset)
|
||||
|
@ -215,9 +217,11 @@ sync_time()
|
|||
while True:
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
gu.adjust_brightness(+0.01)
|
||||
last_second = None
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
gu.adjust_brightness(-0.01)
|
||||
last_second = None
|
||||
|
||||
if gu.is_pressed(GalacticUnicorn.SWITCH_A):
|
||||
sync_time()
|
||||
|
|
|
@ -158,11 +158,13 @@ down_button = machine.Pin(StellarUnicorn.SWITCH_VOLUME_DOWN, machine.Pin.IN, mac
|
|||
|
||||
|
||||
def adjust_utc_offset(pin):
|
||||
global utc_offset
|
||||
global utc_offset, last_second
|
||||
if pin == up_button:
|
||||
utc_offset += 1
|
||||
last_second = None
|
||||
if pin == down_button:
|
||||
utc_offset -= 1
|
||||
last_second = None
|
||||
|
||||
|
||||
up_button.irq(trigger=machine.Pin.IRQ_FALLING, handler=adjust_utc_offset)
|
||||
|
@ -214,9 +216,11 @@ sync_time()
|
|||
while True:
|
||||
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_UP):
|
||||
su.adjust_brightness(+0.01)
|
||||
last_second = None
|
||||
|
||||
if su.is_pressed(StellarUnicorn.SWITCH_BRIGHTNESS_DOWN):
|
||||
su.adjust_brightness(-0.01)
|
||||
last_second = None
|
||||
|
||||
if su.is_pressed(StellarUnicorn.SWITCH_A):
|
||||
sync_time()
|
||||
|
|
Ładowanie…
Reference in New Issue