From 0ce89fab9e061e99ce7f4541ffe8c358f67fb7c9 Mon Sep 17 00:00:00 2001 From: ploedige Date: Tue, 17 Jan 2023 10:52:43 +0000 Subject: [PATCH] structure cleanup and led inclusion in rfid test --- config.py | 9 ++++++++ rfid_test.py | 12 ---------- camera_test.py => test_scripts/camera_test.py | 0 led_test.py => test_scripts/led_test.py | 0 test_scripts/rfid_test.py | 23 +++++++++++++++++++ 5 files changed, 32 insertions(+), 12 deletions(-) delete mode 100644 rfid_test.py rename camera_test.py => test_scripts/camera_test.py (100%) rename led_test.py => test_scripts/led_test.py (100%) create mode 100644 test_scripts/rfid_test.py diff --git a/config.py b/config.py index 499cb21..cfdb53e 100644 --- a/config.py +++ b/config.py @@ -12,4 +12,13 @@ TRASH_LOCATION = { "BOTTLE" : 25, "CAN" : 35, "PAPER" : 45 +} + +BARCODE_LOOKUP_TABLE = { + 'X00UP6UQN' : "PAPER" +} + +RFID_LOOKUP_TABLE = { + 151652580835 : "INCOMBUSTIBLE", + 626325260718 : "CAN" } \ No newline at end of file diff --git a/rfid_test.py b/rfid_test.py deleted file mode 100644 index 856574a..0000000 --- a/rfid_test.py +++ /dev/null @@ -1,12 +0,0 @@ -from time import sleep -import RPi.GPIO as GPIO -from mfrc522 import SimpleMFRC522 - -reader = SimpleMFRC522() - -while True: - id, text = reader.read() - print(id) - print(text) - sleep(1) -GPIO.cleanup() \ No newline at end of file diff --git a/camera_test.py b/test_scripts/camera_test.py similarity index 100% rename from camera_test.py rename to test_scripts/camera_test.py diff --git a/led_test.py b/test_scripts/led_test.py similarity index 100% rename from led_test.py rename to test_scripts/led_test.py diff --git a/test_scripts/rfid_test.py b/test_scripts/rfid_test.py new file mode 100644 index 0000000..5624caf --- /dev/null +++ b/test_scripts/rfid_test.py @@ -0,0 +1,23 @@ +from time import sleep +import RPi.GPIO as GPIO +from mfrc522 import SimpleMFRC522 + +import sys +sys.path.append('..') +import TREx.config as config +from TREx.indication_driver import IndicationDriver + +reader = SimpleMFRC522() + +indication_driver = IndicationDriver() + +while True: + id, _ = reader.read() + if id in config.RFID_LOOKUP_TABLE.keys(): + trash_category = config.RFID_LOOKUP_TABLE[id] + print(f"{id}: {trash_category}") + indication_driver.indicate(trash_category) + else: + print(id) + sleep(1) +GPIO.cleanup() \ No newline at end of file