コード例 #1
0
 def __init__(self):
     self.group = displayio.Group()
     self.glyph_width, self.glyph_height = font.get_bounding_box()[:2]
     self.pbar = ProgressBar(0,
                             0,
                             board.DISPLAY.width,
                             self.glyph_height * 2,
                             bar_color=0x0000ff,
                             outline_color=0x333333,
                             stroke=1)
     self.iconbar = icons.IconBar()
     self.iconbar.group.y = 1000
     for i in range(5, 8):
         self.iconbar.icons[i].x += 32
     self.label = adafruit_display_text.label.Label(font, line_spacing=1.0)
     self.label.y = 6
     self._bitmap_filename = None
     self._fallback_bitmap = ["/rsrc/background.bmp"]
     self._rms = 0.
     self._text = ""
     self.set_bitmap([])  # Must be first!
     self.group.append(self.pbar)
     self.group.append(self.label)
     self.group.append(self.iconbar.group)
     self.pixels = neopixel.NeoPixel(board.NEOPIXEL, 5)
     self.pixels.auto_write = False
     self.pixels.fill(0)
     self.pixels.show()
     self.paused = False
     self.next_choice = 0
     self.tile_grid = None
コード例 #2
0
# CircuitPython 6 & 7 compatible
clue_bg = displayio.OnDiskBitmap(open(clue_bgBMP, "rb"))
clue_tilegrid = displayio.TileGrid(clue_bg,
                                   pixel_shader=getattr(
                                       clue_bg, 'pixel_shader',
                                       displayio.ColorConverter()))
clueGroup.append(clue_tilegrid)

# # CircuitPython 7+ compatible
# clue_bg = displayio.OnDiskBitmap(clue_bgBMP)
# clue_tilegrid = displayio.TileGrid(clue_bg, pixel_shader=clue_bg.pixel_shader)
# clueGroup.append(clue_tilegrid)

#  creating the ProgressBar object
bar_group = displayio.Group()
prog_bar = ProgressBar(1, 1, 239, 25, bar_color=0x652f8f)
bar_group.append(prog_bar)

clueGroup.append(bar_group)

#  text for step goal
steps_countdown = Label(small_font,
                        text='%d Steps Remaining' % step_goal,
                        color=clue.WHITE)
steps_countdown.x = 55
steps_countdown.y = 12

#  text for steps
text_steps = Label(big_font, text="0     ", color=0xe90e8b)
text_steps.x = 45
text_steps.y = 70
コード例 #3
0
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)

# set progress bar width and height relative to board's display
BAR_WIDTH = magtag.graphics.display.width - 80
BAR_HEIGHT = 30

BAR_X = magtag.graphics.display.width // 2 - BAR_WIDTH // 2
BAR_Y = 80

# Create a new progress_bar object at (x, y)
progress_bar = ProgressBar(BAR_X,
                           BAR_Y,
                           BAR_WIDTH,
                           BAR_HEIGHT,
                           1.0,
                           bar_color=0x999999,
                           outline_color=0x000000)

magtag.graphics.splash.append(progress_bar)

try:
    magtag.network.get_local_time()
    now = rtc.RTC().datetime
    progress_bar.progress = now.tm_yday / days_in_year(now)
    magtag.set_text("{:.2f}%".format(now.tm_yday / days_in_year(now) * 100.0),
                    index=1)

    print(now)
    magtag.exit_and_deep_sleep(24 * 60 * 60)  # one day
コード例 #4
0
    text_position=(
        (magtag.graphics.display.width // 2) - 1,
        85,
    ),
    text_anchor_point=(0.5, 0.5),
    is_data=False,
)  # Fully vaccinated text

BAR_WIDTH = magtag.graphics.display.width - 80
BAR_HEIGHT = 25
BAR_X = magtag.graphics.display.width // 2 - BAR_WIDTH // 2

progress_bar = ProgressBar(BAR_X,
                           50,
                           BAR_WIDTH,
                           BAR_HEIGHT,
                           1.0,
                           bar_color=0x999999,
                           outline_color=0x000000)

progress_bar_1 = ProgressBar(BAR_X,
                             95,
                             BAR_WIDTH,
                             BAR_HEIGHT,
                             1.0,
                             bar_color=0x999999,
                             outline_color=0x000000)

magtag.graphics.splash.append(progress_bar)
magtag.graphics.splash.append(progress_bar_1)
magtag.graphics.set_background("/bmps/background.bmp")
コード例 #5
0
    text_transform=texturl_transform,
    text_anchor_point=(0.5, 1.0),
)

# set progress bar width and height relative to board's display
BAR_WIDTH = magtag.graphics.display.width - 80
BAR_HEIGHT = 30

BAR_X = magtag.graphics.display.width // 2 - BAR_WIDTH // 2
BAR_Y = 66

# Create a new progress_bar object at (x, y)
progress_bar = ProgressBar(BAR_X,
                           BAR_Y,
                           BAR_WIDTH,
                           BAR_HEIGHT,
                           1.0,
                           bar_color=0x999999,
                           outline_color=0x000000)

magtag.graphics.splash.append(progress_bar)

timestamp = None

try:
    value = magtag.fetch()
    print("Response is", value)
    progress_bar.progress = value[1] / 100.0
    magtag.refresh()
    magtag.exit_and_deep_sleep(24 * 60 * 60)  # one day
except (ValueError, RuntimeError) as e:
コード例 #6
0
    btn_x += 63

# append buttons to splash group
for b in buttons:
    splash.append(b)

# refrsh timer label
label_timer = Label(font)
label_timer.x = (display.width // 2) // 13
label_timer.y = 15
splash.append(label_timer)

# create a new progress bar
progress_bar = ProgressBar(display.width // 5,
                           125,
                           200,
                           30,
                           bar_color=0xAAAAAA)

splash.append(progress_bar)

# how long to stay on if not in always_on mode
countdown = ON_SECONDS

# current button state, defaults to first item in totp_keys
current_button = secrets['totp_keys'][0][0]
buttons[0].selected = True

while ALWAYS_ON or (countdown > 0):
    # Calculate current time based on NTP + monotonic
    unix_time = t - mono_time + int(time.monotonic())
display = PyGameDisplay(width=320, height=240, auto_refresh=False)
splash = displayio.Group(max_size=10)
display.show(splash)

color_bitmap = displayio.Bitmap(display.width, display.height, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0x2266AA  # Teal-ish-kinda

bg_sprite = displayio.TileGrid(color_bitmap, pixel_shader=color_palette, x=0, y=0)
splash.append(bg_sprite)

progress_bar = ProgressBar(
    width=180,
    height=40,
    x=10,
    y=20,
    progress=0.0,
    bar_color=0x1100FF,
    outline_color=0x777777,
)
splash.append(progress_bar)

horizontal_bar = HorizontalProgressBar(
    (10, 80),
    (180, 40),
    fill_color=0x778822,
    outline_color=0x0000FF,
    bar_color=0x00FF00,
    direction=HorizontalFillDirection.LEFT_TO_RIGHT,
)
splash.append(horizontal_bar)