diff --git a/Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py b/Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py index 32421bf44..dc3447a11 100644 --- a/Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py +++ b/Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py @@ -15,23 +15,39 @@ 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.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 @@ 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: @@ -86,7 +106,7 @@ def read_and_average(ain, times, wait): motor.value = True motor_label.text = "Motor ON" motor_label.color = 0x00FF00 - buzzer.duty_cycle = 2**15 + buzzer.duty_cycle = 2 ** 15 time.sleep(0.5) # always turn off quickly