Remove max_size usage from displayio.Group\nUpdate OnDiskBitmap pixel_shader usage
@@ -15,23 +15,39 @@ moist_level = 50 # adjust this value as needed for your plant
board.DISPLAY.brightness = 0.8
clue.pixel.fill(0) # turn off NeoPixel
-clue_display = displayio.Group(max_size=4)
+clue_display = displayio.Group()
# draw the dry plant
dry_plant_file = open("dry.bmp", "rb")
dry_plant_bmp = displayio.OnDiskBitmap(dry_plant_file)
-dry_plant_sprite = displayio.TileGrid(dry_plant_bmp, pixel_shader=displayio.ColorConverter())
+# CircuitPython 6 & 7 compatible
+dry_plant_sprite = displayio.TileGrid(
+ dry_plant_bmp,
+ pixel_shader=getattr(dry_plant_bmp, "pixel_shader", displayio.ColorConverter()),
+)
+# CircuitPython 7 compatible
+# dry_plant_sprite = displayio.TileGrid(
+# dry_plant_bmp, pixel_shader=dry_plant_bmp.pixel_shader
+# )
clue_display.append(dry_plant_sprite)
# draw the happy plant on top (so it can be moved out of the way when needed)
happy_plant_file = open("happy.bmp", "rb")
happy_plant_bmp = displayio.OnDiskBitmap(happy_plant_file)
-happy_plant_sprite = displayio.TileGrid(happy_plant_bmp, pixel_shader=displayio.ColorConverter())
+# CircuitPython 6 & 7 compatible
+happy_plant_sprite = displayio.TileGrid(
+ happy_plant_bmp,
+ pixel_shader=getattr(happy_plant_bmp, "pixel_shader", displayio.ColorConverter()),
+)
+# CircuitPython 7 compatible
+# happy_plant_sprite = displayio.TileGrid(
+# happy_plant_bmp, pixel_shader=happy_plant_bmp.pixel_shader
+# )
clue_display.append(happy_plant_sprite)
# Create text
# first create the group
-text_group = displayio.Group(max_size=3, scale=3)
+text_group = displayio.Group(scale=3)
# Make a label
title_label = label.Label(terminalio.FONT, text="CLUE Plant", color=0x00FF22)
# Position the label
@@ -45,7 +61,9 @@ soil_label.x = 4
soil_label.y = 64
text_group.append(soil_label)
-motor_label = label.Label(terminalio.FONT, text="Motor off", color=0xFF0000, max_glyphs=9)
+motor_label = label.Label(
+ terminalio.FONT, text="Motor off", color=0xFF0000, max_glyphs=9
+)
motor_label.x = 4
motor_label.y = 74
text_group.append(motor_label)
@@ -62,6 +80,7 @@ buzzer.frequency = 1000
sense_pin = board.P1
analog = AnalogIn(board.P1)
+
def read_and_average(ain, times, wait):
asum = 0
for _ in range(times):
@@ -69,6 +88,7 @@ def read_and_average(ain, times, wait):
time.sleep(wait)
return asum / times
+
time.sleep(5)
while True:
