Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions Buckaroo_Plant_Care_Bot/buckaroo_plant_care_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -62,13 +80,15 @@
sense_pin = board.P1
analog = AnalogIn(board.P1)


def read_and_average(ain, times, wait):
asum = 0
for _ in range(times):
asum += ain.value
time.sleep(wait)
return asum / times


time.sleep(5)

while True:
Expand All @@ -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
Expand Down