connection.pair() print("paired") ams = connection[AppleMediaService] # arial12 = bitmap_font.load_font("/fonts/Arial-12.bdf") arial16 = bitmap_font.load_font("/fonts/Arial-16.bdf") # arial24 = bitmap_font.load_font("/fonts/Arial-Bold-24.bdf") display = board.DISPLAY group = displayio.Group(max_size=25) title = label.Label(font=arial16, x=15, y=25, text="_", color=0xFFFFFF, max_glyphs=30) group.append(title) artist = label.Label(font=arial16, x=15, y=50, text="_", color=0xFFFFFF, max_glyphs=30) group.append(artist) album = label.Label(font=arial16, x=15, y=75,
width=BUTTON_WIDTH, height=BUTTON_HEIGHT, label="Scale-", label_font=font, style=Button.SHADOWRECT, ) buttons.append(button_scale_neg) # Show the button for b in buttons: splash.append(b.group) # Create a text label text_label = label.Label(font, text="CircuitPython Cursor!", color=0x00FF00, x=LBL_HEADER[0], y=LBL_HEADER[1]) splash.append(text_label) text_speed = label.Label(font, max_glyphs=15, color=0x00FF00, x=LBL_TEXT[0], y=LBL_TEXT[1]) splash.append(text_speed) text_scale = label.Label(font, max_glyphs=15, color=0x00FF00, x=LBL_TEXT[0],
x=0, y=0) splash.append(bg_sprite) # Draw a smaller inner rectangle inner_bitmap = displayio.Bitmap(display.width - BORDER * 2, display.height - BORDER * 2, 1) inner_palette = displayio.Palette(1) inner_palette[0] = FOREGROUND_COLOR inner_sprite = displayio.TileGrid(inner_bitmap, pixel_shader=inner_palette, x=BORDER, y=BORDER) splash.append(inner_sprite) # Draw a label text = "Hello World!" text_area = label.Label(terminalio.FONT, text=text, color=TEXT_COLOR) text_width = text_area.bounding_box[2] * FONTSCALE text_group = displayio.Group( max_size=10, scale=FONTSCALE, x=display.width // 2 - text_width // 2, y=display.height // 2, ) text_group.append(text_area) # Subgroup for text scaling splash.append(text_group) while True: pass
# Setup the first bitmap and sparkline # This sparkline has no background bitmap # sparkline1 uses a vertical y range between -1 to +1.25 and will contain a maximum of 40 items sparkline1 = Sparkline( width=chart_width, height=chart_height, max_items=40, y_min=-1, y_max=1.25, x=10, y=10, ) # Label the y-axis range text_label1a = label.Label(font=font, text=str(sparkline1.y_top), color=0xFFFFFF) # y_top label text_label1a.anchor_point = (0, 0.5) # set the anchorpoint text_label1a.anchored_position = ( 10 + chart_width, 10, ) # set the text anchored position to the upper right of the graph text_label1b = label.Label(font=font, text=str(sparkline1.y_bottom), color=0xFFFFFF) # y_bottom label text_label1b.anchor_point = (0, 0.5) # set the anchorpoint text_label1b.anchored_position = ( 10 + chart_width, 10 + chart_height, ) # set the text anchored position to the upper right of the graph
med_square = displayio.TileGrid(med_bitmap, pixel_shader=color_palette, x=71, y=15) splash.append(med_square) lrg_bitmap = displayio.Bitmap(32, 32, 1) lrg_square = displayio.TileGrid(lrg_bitmap, pixel_shader=color_palette, x=91, y=28) splash.append(lrg_square) # Draw some label text text1 = "0123456789ABCDEF123456789AB" # overly long to see where it clips text_area = label.Label(terminalio.FONT, text=text1, color=0xFFFFFF, x=8, y=8) splash.append(text_area) text2 = "SH1107" x = 9 y = 44 text_area2 = label.Label(terminalio.FONT, text=text2, scale=2, color=0xFFFFFF, x=x, y=y) splash.append(text_area2) time.sleep(1) while True: if x >= 128 or x < 0: x = int(random.random() * 128)
normalView = displayio.Group(max_size=15) detailView = displayio.Group(max_size=15) detailed = False # Set text, font, and color main_font = bitmap_font.load_font("/fonts/HelveticaNeue-24.bdf") extra_font = bitmap_font.load_font("/fonts/Helvetica-Bold-16.bdf") white = 0xFFFFFF green = 0x2ecc71 yellow = 0xF1C40F red = 0xE74C3C blue = 0x3498DB # Create the text labels cpu_label = label.Label(main_font, text='CPU: ...', color=white, max_glyphs=100) ram_label = label.Label(main_font, text='RAM: ...', color=white, max_glyphs=100) gpu_label = label.Label(main_font, text='GPU: ...', color=white, max_glyphs=100) disk_label = label.Label(main_font, text='SSD: ...', color=white, max_glyphs=100) ram_detail = label.Label(extra_font, text='..G/..G', color=blue, max_glyphs=100) disk_detail = label.Label(extra_font, text='..G/..G', color=blue, max_glyphs=100) gpu_temp = label.Label(extra_font, text='.. °C', color=red, max_glyphs=100) toggle_label = label.Label(extra_font, text='Basic', color=white, max_glyphs=100) # Set the locations cpu_label.x = 55 cpu_label.y = 33 ram_label.x = 55
display.show(main_group) layout = GridLayout( x=10, y=10, width=320, height=100, grid_size=(2, 2), cell_padding=8, ) _labels = [] _labels.append( label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Hello", background_color=0x770077)) layout.add_content(_labels[0], grid_position=(0, 0), cell_size=(1, 1)) _labels.append( label.Label(terminalio.FONT, scale=2, x=0, y=0, text="World", background_color=0x007700)) layout.add_content(_labels[1], grid_position=(1, 0), cell_size=(1, 1)) _labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Hello")) layout.add_content(_labels[2], grid_position=(0, 1), cell_size=(1, 1)) _labels.append(label.Label(terminalio.FONT, scale=2, x=0, y=0, text="Grid")) layout.add_content(_labels[3], grid_position=(1, 1), cell_size=(1, 1))
# gps.send_command(b'PMTK220,2000') # You can also speed up the rate, but don't go too fast or else you can lose # data during parsing. This would be twice a second (2hz, 500ms delay): # gps.send_command(b'PMTK220,500') displayio.release_displays() adt = adafruit_adt7410.ADT7410(i2c, address=0x48) adt.high_resolution = True display_bus = displayio.I2CDisplay(i2c, device_address=0x3C) display = adafruit_displayio_sh1107.SH1107(display_bus, width=128, height=64) #Create Lines of text splash = displayio.Group() line1 = label.Label(terminalio.FONT, text=" ", color=0xFFFF00, x=2, y=3) line2 = label.Label(terminalio.FONT, text=" ", color=0xFFFF00, x=2, y=13) line3 = label.Label(terminalio.FONT, text=" ", color=0xFFFF00, x=2, y=23) splash.append(line1) splash.append(line2) splash.append(line3) display.show(splash) def display_loc():
tile_grid = displayio.TileGrid(sprite_sheet, pixel_shader=palette, width=1, height=6, tile_width=11, tile_height=2) hexagram = displayio.Group(x=60, y=15, scale=10) hexagram.append(tile_grid) # Hexagram name label # font credit: https://www.instagram.com/cove703/ font = bitmap_font.load_font("/christopher_done_24.bdf") font.load_glyphs(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ') hexname = label.Label(font, text=" " * 40, color=FONT_COLOR) # this will initially hold the "shake for reading" message hexname.text = " SHAKE\n FOR\nREADING" hexname.anchor_point = (0.5, 0.5) hexname.anchored_position = (120, 120) # Set up main display group (splash) splash = displayio.Group() display.show(splash) # Add background and text label splash.append(background) splash.append(hexname) def show_hexagram(number):
button_a = Debouncer(lambda: clue.button_a) button_b = Debouncer(lambda: clue.button_b) # Set up display select_font = bitmap_font.load_font('/Helvetica-Bold-36.bdf') select_font.load_glyphs(b'0123456789XDd') select_color = 0xDB4379 roll_font = bitmap_font.load_font('/Anton-Regular-104.bdf') roll_font.load_glyphs(b'0123456789X') roll_color = 0xFFFFFF select_label = label.Label(select_font, x=0, y=25, text='XdXXX', color=select_color) roll_label = label.Label(roll_font, x=0, y=150, text='XXX', color=roll_color) group = displayio.Group() group.append(select_label) group.append(roll_label) board.DISPLAY.show(group) # Helper functions def roll(count, sides): select_label.text = ''