Type hinting
This commit is contained in:
@@ -11,15 +11,17 @@ class ProjectorSerial(SerialDevice):
|
||||
|
||||
super().__init__(serial_port, baudrate)
|
||||
|
||||
def send_command(self, command: str, verbose: bool = False, device_id: str = "ZZ"):
|
||||
def send_command(
|
||||
self, command: str, verbose: bool = False, device_id: str = "ZZ"
|
||||
) -> str:
|
||||
assert device_id in ["01", "02", "03", "04", "05", "06", "ZZ"]
|
||||
|
||||
full_command = f"\x02AD{device_id};{command}\x03"
|
||||
|
||||
return super().send_command(full_command, verbose)
|
||||
|
||||
def power_on(self):
|
||||
def power_on(self) -> None:
|
||||
self.send_command("PON")
|
||||
|
||||
def power_off(self):
|
||||
def power_off(self) -> None:
|
||||
self.send_command("POF")
|
||||
|
||||
@@ -7,7 +7,7 @@ class SerialDevice:
|
||||
self.serial_port: str = serial_port
|
||||
self.baudrate = baudrate
|
||||
|
||||
def send_command(self, command: str, verbose: bool = False):
|
||||
def send_command(self, command: str, verbose: bool = False) -> str:
|
||||
with Serial(self.serial_port, self.baudrate, timeout=1) as s:
|
||||
if verbose:
|
||||
print("Send:", command)
|
||||
|
||||
Reference in New Issue
Block a user