diff --git a/config.py b/config.py new file mode 100644 index 0000000..d13097a --- /dev/null +++ b/config.py @@ -0,0 +1,15 @@ +from enum import Enum +import board + +PIXEL_PIN = board.D18 +NUM_PIXELS = 60 +NEOPIXEL_BRIGHTNESS = 0.2 + + +TRASH_LOCATION = { + "COMBUSTIBLE" : 5, + "INCOMBUSTIBLE" : 15, + "BOTTLES" : 25, + "CANS" : 35, + "PAPER" : 45 +} \ No newline at end of file diff --git a/indication_driver.py b/indication_driver.py new file mode 100644 index 0000000..e2ced8a --- /dev/null +++ b/indication_driver.py @@ -0,0 +1,28 @@ +import neopixel +from config import PIXEL_PIN, NUM_PIXELS, NEOPIXEL_BRIGHTNESS, TRASH_LOCATION +from time import sleep + +class IndicationDriver: + def __init__(self): + self.pixels = neopixel.NeoPixel( + PIXEL_PIN, + NUM_PIXELS, + brightness= NEOPIXEL_BRIGHTNESS, + auto_write=False, + pixel_order=neopixel.GRB + ) + self.stop() + + def stop(self): + self.pixels.fill((0,0,0)) + self.pixels.show() + + def indicate(self, trash_type: str): + self.stop() + if trash_type in TRASH_LOCATION.keys(): + location = TRASH_LOCATION[trash_type] + for idx in range(location-2, location+3): + self.pixels[idx] = (0, 255, 0) + self.pixels.show() + else: + raise ValueError \ No newline at end of file