Skip to content

Commit

Permalink
Merge pull request #797 from North101/main
Browse files Browse the repository at this point in the history
Make Galactic clock example responsive
  • Loading branch information
Gadgetoid authored Aug 3, 2023
2 parents 6bd5a44 + 16c2dc0 commit 5bc85c0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion micropython/examples/cosmic_unicorn/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,13 @@ def sync_time():


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)
Expand Down Expand Up @@ -214,9 +216,11 @@ def redraw_display_if_reqd():
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()
Expand Down
6 changes: 5 additions & 1 deletion micropython/examples/galactic_unicorn/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ def sync_time():


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)
Expand Down Expand Up @@ -215,9 +217,11 @@ def redraw_display_if_reqd():
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()
Expand Down
6 changes: 5 additions & 1 deletion micropython/examples/stellar_unicorn/clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@ def sync_time():


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)
Expand Down Expand Up @@ -216,9 +218,11 @@ def redraw_display_if_reqd():
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()
Expand Down

0 comments on commit 5bc85c0

Please sign in to comment.