diff --git a/access_control_python/access_control_mqtt.py b/access_control_python/access_control_mqtt.py index 43b95b9..0491a3b 100644 --- a/access_control_python/access_control_mqtt.py +++ b/access_control_python/access_control_mqtt.py @@ -1,9 +1,11 @@ import paho.mqtt.client as mqtt +import espmega_mqtt.ESPMegaMQTT as ESPMegaMQTT -BASE_TOPIC = "/facescan" +plc = ESPMegaMQTT() class access_control: def __init__(self, serial_port: str): + pass def light_on(self): diff --git a/access_control_python/display.py b/access_control_python/display.py index 7f9d35c..82b4520 100644 --- a/access_control_python/display.py +++ b/access_control_python/display.py @@ -1,3 +1,15 @@ +import serial class Display: - def __init__(self) -> None: - pass \ No newline at end of file + def __init__(self, serial_port: str) -> None: + self.serial_adapter = serial.Serial(serial_port,baudrate=115200) + def set_page(self, page): + command = f'page {page}'.encode("ascii") + self.serial_adapter.write(command) + self.send_stop_bit() + def set_string(self, field, text): + command = f'{field}="{text}"'.encode("ascii") + self.serial_adapter.write(command) + def send_stop_bit(self): + self.serial_adapter.write(0xFF) + self.serial_adapter.write(0xFF) + self.serial_adapter.write(0xFF) \ No newline at end of file diff --git a/access_control_python/espmega_mqtt.py b/access_control_python/espmega_mqtt.py index ff9cbff..ed267c7 100644 --- a/access_control_python/espmega_mqtt.py +++ b/access_control_python/espmega_mqtt.py @@ -1,7 +1,25 @@ -class espmega_mqtt: +import paho.mqtt.client as pahomqtt +BROKER = "192.168.0.26" +BASE_TOPIC = "/facescan" +class ESPMegaMQTT: + input_buffer = [0]*16 + mqtt: pahomqtt.Client def __init__(self) -> None: - pass - def write_pwm(): - pass - def read_digital(): - pass \ No newline at end of file + self.mqtt = pahomqtt.Client(client_id="pyfacescan") + self.mqtt.connect(host=BROKER,port=1883,keepalive=60) + self.mqtt.subscribe(f'{BASE_TOPIC}/input/#') + self.mqtt.on_message=self.handle_message + self.request_state() + self.mqtt.loop_start() + def write_pwm(self, id: int, state: bool, value: int = 4095): + self.mqtt.publish(f'{BASE_TOPIC}/pwm/{"%02d"}/set/state'%id,"on" if state else "off") + self.mqtt.publish(f'{BASE_TOPIC}/pwm/{"%02d"}/set/value'%id, str(value)) + def read_digital(self, id: int): + return self.input_buffer[id] + def request_state(self): + self.mqtt.publish(f'{BASE_TOPIC}/requeststate',"req") + def handle_message(self, client: pahomqtt.Client, data, message: pahomqtt.MQTTMessage): + if (message.topic.startswith(BASE_TOPIC+"/input/")): + id = int(message.topic[len(BASE_TOPIC)+7:len(message.topic)]) + state = int(message.payload) + self.input_buffer[id] = state \ No newline at end of file diff --git a/access_control_python/main.py b/access_control_python/main.py index 340af18..c5eae93 100644 --- a/access_control_python/main.py +++ b/access_control_python/main.py @@ -4,6 +4,7 @@ import time import face_processing as fp from access_control import access_control from database import database, Student, Parent +from displ SERIAL_PORT_STM32 = "COM12" SERIAL_PORT_DISPLAY = "COM15" @@ -11,6 +12,7 @@ CAMERA_INDEX = 0 cam = cv2.VideoCapture(CAMERA_INDEX) stm32 = access_control(SERIAL_PORT_STM32) +display = global img global frame_ready diff --git a/display/DoorOpen.png b/display/DoorOpen.png new file mode 100644 index 0000000..434b3ee Binary files /dev/null and b/display/DoorOpen.png differ diff --git a/display/Fonts/comicsans-32.zi b/display/Fonts/comicsans-32.zi new file mode 100644 index 0000000..cebbab6 Binary files /dev/null and b/display/Fonts/comicsans-32.zi differ diff --git a/display/Fonts/roboto-14-ascii.zi b/display/Fonts/roboto-14-ascii.zi new file mode 100644 index 0000000..cb5b403 Binary files /dev/null and b/display/Fonts/roboto-14-ascii.zi differ diff --git a/display/Fonts/roboto-14.zi b/display/Fonts/roboto-14.zi new file mode 100644 index 0000000..a9ad39c Binary files /dev/null and b/display/Fonts/roboto-14.zi differ diff --git a/display/Fonts/roboto-16-ascii.zi b/display/Fonts/roboto-16-ascii.zi new file mode 100644 index 0000000..cda79c3 Binary files /dev/null and b/display/Fonts/roboto-16-ascii.zi differ diff --git a/display/Fonts/roboto-16-bold-ascii.zi b/display/Fonts/roboto-16-bold-ascii.zi new file mode 100644 index 0000000..f634611 Binary files /dev/null and b/display/Fonts/roboto-16-bold-ascii.zi differ diff --git a/display/Fonts/roboto-16-bold.zi b/display/Fonts/roboto-16-bold.zi new file mode 100644 index 0000000..851b51e Binary files /dev/null and b/display/Fonts/roboto-16-bold.zi differ diff --git a/display/Fonts/roboto-16.zi b/display/Fonts/roboto-16.zi new file mode 100644 index 0000000..39fbace Binary files /dev/null and b/display/Fonts/roboto-16.zi differ diff --git a/display/Fonts/roboto-24-ascii.zi b/display/Fonts/roboto-24-ascii.zi new file mode 100644 index 0000000..a354e80 Binary files /dev/null and b/display/Fonts/roboto-24-ascii.zi differ diff --git a/display/Fonts/roboto-24.zi b/display/Fonts/roboto-24.zi new file mode 100644 index 0000000..19d48fc Binary files /dev/null and b/display/Fonts/roboto-24.zi differ diff --git a/display/Fonts/roboto-56-ascii.zi b/display/Fonts/roboto-56-ascii.zi new file mode 100644 index 0000000..350b09d Binary files /dev/null and b/display/Fonts/roboto-56-ascii.zi differ diff --git a/display/Fonts/roboto-56.zi b/display/Fonts/roboto-56.zi new file mode 100644 index 0000000..b87c74f Binary files /dev/null and b/display/Fonts/roboto-56.zi differ diff --git a/display/Fonts/roboto-72-ascii.zi b/display/Fonts/roboto-72-ascii.zi new file mode 100644 index 0000000..d7d06b9 Binary files /dev/null and b/display/Fonts/roboto-72-ascii.zi differ diff --git a/display/Scan Parent.png b/display/Scan Parent.png new file mode 100644 index 0000000..779ef7b Binary files /dev/null and b/display/Scan Parent.png differ diff --git a/display/Scan Student.png b/display/Scan Student.png new file mode 100644 index 0000000..caeddb9 Binary files /dev/null and b/display/Scan Student.png differ diff --git a/display/display.HMI b/display/display.HMI new file mode 100644 index 0000000..c09bcb2 Binary files /dev/null and b/display/display.HMI differ diff --git a/display/home.png b/display/home.png new file mode 100644 index 0000000..1a45226 Binary files /dev/null and b/display/home.png differ