display and espmega driver
This commit is contained in:
parent
5e019fef20
commit
29e28b8dca
21 changed files with 43 additions and 9 deletions
|
@ -1,9 +1,11 @@
|
||||||
import paho.mqtt.client as mqtt
|
import paho.mqtt.client as mqtt
|
||||||
|
import espmega_mqtt.ESPMegaMQTT as ESPMegaMQTT
|
||||||
|
|
||||||
BASE_TOPIC = "/facescan"
|
plc = ESPMegaMQTT()
|
||||||
|
|
||||||
class access_control:
|
class access_control:
|
||||||
def __init__(self, serial_port: str):
|
def __init__(self, serial_port: str):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def light_on(self):
|
def light_on(self):
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
import serial
|
||||||
class Display:
|
class Display:
|
||||||
def __init__(self) -> None:
|
def __init__(self, serial_port: str) -> None:
|
||||||
pass
|
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)
|
|
@ -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:
|
def __init__(self) -> None:
|
||||||
pass
|
self.mqtt = pahomqtt.Client(client_id="pyfacescan")
|
||||||
def write_pwm():
|
self.mqtt.connect(host=BROKER,port=1883,keepalive=60)
|
||||||
pass
|
self.mqtt.subscribe(f'{BASE_TOPIC}/input/#')
|
||||||
def read_digital():
|
self.mqtt.on_message=self.handle_message
|
||||||
pass
|
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
|
|
@ -4,6 +4,7 @@ import time
|
||||||
import face_processing as fp
|
import face_processing as fp
|
||||||
from access_control import access_control
|
from access_control import access_control
|
||||||
from database import database, Student, Parent
|
from database import database, Student, Parent
|
||||||
|
from displ
|
||||||
|
|
||||||
SERIAL_PORT_STM32 = "COM12"
|
SERIAL_PORT_STM32 = "COM12"
|
||||||
SERIAL_PORT_DISPLAY = "COM15"
|
SERIAL_PORT_DISPLAY = "COM15"
|
||||||
|
@ -11,6 +12,7 @@ CAMERA_INDEX = 0
|
||||||
|
|
||||||
cam = cv2.VideoCapture(CAMERA_INDEX)
|
cam = cv2.VideoCapture(CAMERA_INDEX)
|
||||||
stm32 = access_control(SERIAL_PORT_STM32)
|
stm32 = access_control(SERIAL_PORT_STM32)
|
||||||
|
display =
|
||||||
|
|
||||||
global img
|
global img
|
||||||
global frame_ready
|
global frame_ready
|
||||||
|
|
BIN
display/DoorOpen.png
Normal file
BIN
display/DoorOpen.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
BIN
display/Fonts/comicsans-32.zi
Normal file
BIN
display/Fonts/comicsans-32.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-14-ascii.zi
Normal file
BIN
display/Fonts/roboto-14-ascii.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-14.zi
Normal file
BIN
display/Fonts/roboto-14.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-16-ascii.zi
Normal file
BIN
display/Fonts/roboto-16-ascii.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-16-bold-ascii.zi
Normal file
BIN
display/Fonts/roboto-16-bold-ascii.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-16-bold.zi
Normal file
BIN
display/Fonts/roboto-16-bold.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-16.zi
Normal file
BIN
display/Fonts/roboto-16.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-24-ascii.zi
Normal file
BIN
display/Fonts/roboto-24-ascii.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-24.zi
Normal file
BIN
display/Fonts/roboto-24.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-56-ascii.zi
Normal file
BIN
display/Fonts/roboto-56-ascii.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-56.zi
Normal file
BIN
display/Fonts/roboto-56.zi
Normal file
Binary file not shown.
BIN
display/Fonts/roboto-72-ascii.zi
Normal file
BIN
display/Fonts/roboto-72-ascii.zi
Normal file
Binary file not shown.
BIN
display/Scan Parent.png
Normal file
BIN
display/Scan Parent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 KiB |
BIN
display/Scan Student.png
Normal file
BIN
display/Scan Student.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
BIN
display/display.HMI
Normal file
BIN
display/display.HMI
Normal file
Binary file not shown.
BIN
display/home.png
Normal file
BIN
display/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
Loading…
Add table
Add a link
Reference in a new issue