diff --git a/micropython/examples/cosmic_unicorn/clock.py b/micropython/examples/cosmic_unicorn/clock.py index 0ccfc1f5..f5140425 100644 --- a/micropython/examples/cosmic_unicorn/clock.py +++ b/micropython/examples/cosmic_unicorn/clock.py @@ -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() diff --git a/micropython/examples/galactic_unicorn/clock.py b/micropython/examples/galactic_unicorn/clock.py index 3dccd02f..2d85c2dd 100644 --- a/micropython/examples/galactic_unicorn/clock.py +++ b/micropython/examples/galactic_unicorn/clock.py @@ -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() diff --git a/micropython/examples/stellar_unicorn/clock.py b/micropython/examples/stellar_unicorn/clock.py index 63fa9dd4..9a313376 100644 --- a/micropython/examples/stellar_unicorn/clock.py +++ b/micropython/examples/stellar_unicorn/clock.py @@ -160,11 +160,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) @@ -216,9 +218,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()