stm32-fmt-code/access_control_python/display.py

15 lines
587 B
Python

import serial
class Display:
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)