time_since_midnite = hour * 60 + minute

    # display the time in a nice big font
    format_str = "%d:%02d"
    if AM_PM:
        if hour >= 12:
            hour -= 12
            format_str = format_str + "   P"
        else:
            format_str = format_str + "   A"
        if hour == 0:
            hour = 12
    if hour < 10:
        format_str = "    " + format_str
    time_str = format_str % (hour, minute)
    time_textarea.text = time_str

    if gremlin_since_midnite < mogwai_since_midnite:
        #print("Gremlin time before mogwai time")
        if gremlin_since_midnite <= time_since_midnite < mogwai_since_midnite:
            is_gremlin_time = True
        else:
            is_gremlin_time = False
    else:
        #print("Mogwai time before gremlin time")
        if mogwai_since_midnite <= time_since_midnite < gremlin_since_midnite:
            is_gremlin_time = False
        else:
            is_gremlin_time = True

    if is_gremlin_time != last_gremlin_time:
示例#2
0
文件: code.py 项目: n0bel/PyPoClock
pp = displayio.Group(max_size=10)
pages.append(pp)

desc_label = Label(font1, max_glyphs=200, color=0xbbbbff, x=0, y=120)
pp.append(desc_label)

pixel_around()

try:
    pyportal.get_local_time()
except:
    microcontroller.reset()
last_time = time.monotonic()

pyportal.set_background(cwd + "/background.bmp")
date_label.text = "Almost Ready..."
date_label.x = 160 - int(date_label.bounding_box[2] / 2)

pixel_around()

prior_day = 0
prior_sec = 0
prior_hpixel = 0
prior_mpixel = 0
prior_spixel = 0

while True:
    if (time.monotonic() - last_time) > 3600:
        last_time = time.monotonic()
        try:
            pyportal.get_local_time()