indication_driver V1 finished
This commit is contained in:
parent
83e2cadd9d
commit
171c3f17cd
15
config.py
Normal file
15
config.py
Normal file
@ -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
|
||||||
|
}
|
28
indication_driver.py
Normal file
28
indication_driver.py
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user