Skip to content
Snippets Groups Projects
Commit 812f828a authored by ed8g20's avatar ed8g20
Browse files

Upload New File

parent a8205a1c
No related branches found
No related tags found
No related merge requests found
import time
def create_synchronised_time(display, button_a, button_b, button_x, button_y):
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)
datetime = [2021, 1, 1, 1, 1, 0]
selected_idx = 0
display_width, display_height = display.get_bounds()
while True:
if button_a.read():
selected_idx = (selected_idx + 1) % len(datetime)
if button_x.read():
datetime[selected_idx] += 1
if button_y.read():
datetime[selected_idx] = max(datetime[selected_idx] - 1, 1)
if button_b.read():
break
display.set_pen(BLACK)
display.clear()
display.set_pen(WHITE)
display.text("Next", 10, 10, 30, 2)
display.text("Inc", display_width - 40, 10, 30, 2)
display.text("Dec", display_width - 40, display_height - 20, 30, 2)
display.text("Confirm", 10, display_height - 20, 30, 2)
display.text("YYYY MM DD HH MM SS", 30,
display_height // 2 - 10, display_width - 30, 2)
display.text(
" ".join("%s%02d" % (">" if idx == selected_idx else "", sep)
for idx, sep in enumerate(datetime)),
30, display_height // 2 + 10, display_width - 30, 2)
display.update()
time.sleep(0.3)
delta = time.mktime(datetime + [0, 0]) - int(time.time())
def synchronised_time():
return int(time.time()) + delta
return synchronised_time
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment