first batch of displayio api updates

This commit is contained in:
foamyguy 2023-10-16 16:45:39 -05:00
parent 3df559ef02
commit 6cbf7ecce4
20 changed files with 28 additions and 28 deletions

View file

@ -54,7 +54,7 @@ display_bus = displayio.I2CDisplay(i2c, device_address=0x3D, reset=oled_reset)
display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=64)
splash = displayio.Group()
display.show(splash)
display.root_group = splash
font = bitmap_font.load_font('/OCRA_small.pcf')
# main label/MIDI message name text; centered
main_area = label.Label(

View file

@ -30,7 +30,7 @@ display = adafruit_displayio_ssd1306.SSD1306(display_bus, width=128, height=32)
# Make the display context
splash = displayio.Group()
display.show(splash)
display.root_group = splash
text = "hello world"
text_area = label.Label(terminalio.FONT, color=0xFFFF00, x=15, y=0)

View file

@ -35,7 +35,7 @@ text_area = bitmap_label.Label(font, text="----", color=0xFFFFFF)
text_area.x = 135
text_area.y = 90
group.append(text_area)
display.show(group)
display.root_group = group
# Connect to WiFi
print("Connecting to %s"%secrets["ssid"])

View file

@ -15,7 +15,7 @@ scale = 3
text_area = bitmap_label.Label(terminalio.FONT, text=text, scale=scale)
text_area.x = 10
text_area.y = 10
board.DISPLAY.show(text_area)
board.DISPLAY.root_group = text_area
while True:
pass

View file

@ -12,7 +12,7 @@ blinka_img = OnDiskBitmap("images/adafruit_blinka.bmp")
tile_grid = TileGrid(bitmap=blinka_img, pixel_shader=blinka_img.pixel_shader)
main_group.append(tile_grid)
board.DISPLAY.show(main_group)
board.DISPLAY.root_group = main_group
tile_grid.x = board.DISPLAY.width // 2 - blinka_img.width // 2

View file

@ -27,7 +27,7 @@ sensor = LC709203F(i2c)
print("IC version:", hex(sensor.ic_version))
board.DISPLAY.show(main_group)
board.DISPLAY.root_group = main_group
while True:
text_area.text = "Battery:\n{:.1f} Volts \n{}%".format(sensor.cell_voltage, sensor.cell_percent)

View file

@ -85,7 +85,7 @@ dot_y = [52, 82, 112, 142]
dot = Circle(220, 60, 8, outline=VFD_GREEN, fill=VFD_BG)
screen.append(dot)
clue.display.show(screen)
clue.display.root_group = screen
# constants for sine wave generation
SIN_LENGTH = 100 # more is less choppy

View file

@ -71,7 +71,7 @@ motor_label.y = 74
text_group.append(motor_label)
clue_display.append(text_group)
board.DISPLAY.show(clue_display)
board.DISPLAY.root_group = clue_display
motor = DigitalInOut(board.P2)
motor.direction = Direction.OUTPUT

View file

@ -42,7 +42,7 @@ clue.sea_level_pressure = slp if 0 < slp < 2000 else STD_SLP
# create main display group
splash = displayio.Group()
clue.display.show(splash)
clue.display.root_group = splash
# background
bg_bmp, bg_pal = adafruit_imageload.load(

View file

@ -53,7 +53,7 @@ title_label.x = 12
title_label.y = 120
homescreen_screen.append(title_label)
clue.display.show(homescreen_screen)
clue.display.root_group = homescreen_screen
# Setup temperatures screen
temp_font = bitmap_font.load_font("/font/GothamBlack-25.bdf")
@ -94,7 +94,7 @@ ibbq_connection = None
while True:
# re-display homescreen here
clue.display.show(homescreen_screen)
clue.display.root_group = homescreen_screen
print("Scanning...")
for adv in ble.start_scan(ProvideServicesAdvertisement, timeout=5):
@ -146,7 +146,7 @@ while True:
"Probe", i + 1, "is unplugged",
)
my_labels[i].text = " ---"
clue.display.show(temperatures_screen)
clue.display.root_group = temperatures_screen
except _bleio.ConnectionError:
continue

View file

@ -39,7 +39,7 @@ ble._adapter.name = MY_NAME #pylint: disable=protected-access
# Display Stuff
display = clue.display
disp_group = displayio.Group()
display.show(disp_group)
display.root_group = disp_group
# Background BMP with the Morse Code cheat sheet
bmp, pal = adafruit_imageload.load("morse_bg.bmp",

View file

@ -53,7 +53,7 @@ group = displayio.Group()
group.append(select_label)
group.append(roll_label)
board.DISPLAY.show(group)
board.DISPLAY.root_group = group
# Helper functions

View file

@ -62,7 +62,7 @@ text_group.append(text_area) # Subgroup for text scaling
splash.append(text_group)
# display everything so far
board.DISPLAY.show(splash)
board.DISPLAY.root_group = splash
# connect to the accelerometer
i2c = board.I2C() # uses board.SCL and board.SDA

View file

@ -82,7 +82,7 @@ timer_label.y = 100
text_group.append(timer_label)
clue_display.append(text_group)
clue.display.show(clue_display)
clue.display.root_group = clue_display
def countdown(seconds):
for i in range(seconds):

View file

@ -80,7 +80,7 @@ hexname.anchored_position = (120, 120)
# Set up main display group (splash)
splash = displayio.Group()
display.show(splash)
display.root_group = splash
# Add background and text label
splash.append(background)

View file

@ -122,7 +122,7 @@ class ClueLightPainter:
if not self.images:
group = displayio.Group()
group.append(centered_label('NO IMAGES', 40, 3))
board.DISPLAY.show(group)
board.DISPLAY.root_group = group
while True:
pass
@ -206,7 +206,7 @@ class ClueLightPainter:
#self.rect = Rect(-board.DISPLAY.width, 120,
# board.DISPLAY.width, 40, fill=0x00B000)
#group.append(self.rect)
board.DISPLAY.show(group)
board.DISPLAY.root_group = group
# pylint: disable=eval-used
# (It's cool, is a 'trusted string' in the code)
@ -227,7 +227,7 @@ class ClueLightPainter:
except (MemoryError, BMPError):
group = displayio.Group()
group.append(centered_label('TOO BIG', 40, 3))
board.DISPLAY.show(group)
board.DISPLAY.root_group = group
sleep(4)
board.DISPLAY.show(displayio.Group()) # Clear display
@ -330,7 +330,7 @@ class ClueLightPainter:
# Config label always appears as last item in group
# so calling func can pop() and replace it if need be.
group.append(centered_label(config_label, 30 if rect_val else 40, 3))
board.DISPLAY.show(group)
board.DISPLAY.root_group = group
return group
@ -365,7 +365,7 @@ class ClueLightPainter:
if paint:
break # Exit loop, resume paint
else:
board.DISPLAY.show(group) # Put config UI back up
board.DISPLAY.root_group = group # Put config UI back up
elif action_right is RichButton.HOLD:
break
elif action_left is RichButton.TAP:

View file

@ -468,7 +468,7 @@ if magnetometer is not None:
magnet_circ_set(0)
# Start-up splash screen
display.show(screen_group)
display.root_group = screen_group
# Start-up splash screen
popup_text(show_text,
@ -662,10 +662,10 @@ while True:
if not screen_on or opt == 2: # Screen toggle
screen_on = not screen_on
if screen_on:
display.show(screen_group)
display.root_group = screen_group
display.brightness = 1.0
else:
display.show(None)
display.root_group = None
display.brightness = 0.0
elif opt == 0: # Audio toggle
audio_on = not audio_on

View file

@ -98,7 +98,7 @@ increment_label.y = 220
screen.append(increment_label)
# show the screen
clue.display.show(screen)
clue.display.root_group = screen
def metronome(accent): # Play metronome sound and flash display

View file

@ -54,7 +54,7 @@ splash.append(mouth)
splash.append(message)
splash.append(tvoc)
splash.append(eco2)
clue.display.show(splash)
clue.display.root_group = splash
# setup SGP30 and wait for initial warm up
i2c = board.I2C() # uses board.SCL and board.SDA

View file

@ -21,7 +21,7 @@ text_area.x = 100
text_area.y = 80
# Show it
display.show(text_area)
display.root_group = text_area
# Loop forever so you can enjoy your image
while True: