From 4f76aa5219a5bc07006e6ef4be365cb8aace691c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Wed, 13 Dec 2023 12:37:52 +0700 Subject: [PATCH] add dummy driver --- setup.py | 2 +- src/espmega_lightshow.egg-info/PKG-INFO | 2 +- src/espmega_lightshow/__main__.py | 3 +-- src/espmega_lightshow/drivers.py | 20 +++++++++++++++++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 361fe65..b1d3c54 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ def readme(): setup( name='espmega_lightshow', - version='4.0', + version='4.1', license='Apache 2.0', author="Siwat Sirichai", author_email='siwat@siwatinc.com', diff --git a/src/espmega_lightshow.egg-info/PKG-INFO b/src/espmega_lightshow.egg-info/PKG-INFO index b9c96c0..ca88111 100644 --- a/src/espmega_lightshow.egg-info/PKG-INFO +++ b/src/espmega_lightshow.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: espmega-lightshow -Version: 4.0 +Version: 4.1 Home-page: https://github.com/SiwatINC/espmega-lightshow Author: Siwat Sirichai Author-email: siwat@siwatinc.com diff --git a/src/espmega_lightshow/__main__.py b/src/espmega_lightshow/__main__.py index fa54a5f..df7efc3 100644 --- a/src/espmega_lightshow/__main__.py +++ b/src/espmega_lightshow/__main__.py @@ -2,8 +2,7 @@ from tkinter import ttk import json from tkinter import filedialog -from espmega.espmega_r3 import ESPMega_standalone, ESPMega_slave, ESPMega -from espmega_lightshow.drivers import ESPMegaLightGrid, ESPMegaLightDriver, ESPMegaStandaloneLightDriver, LightDriver +from espmega_lightshow.drivers import ESPMegaLightGrid, LightDriver from dataclasses import dataclass import sys import json diff --git a/src/espmega_lightshow/drivers.py b/src/espmega_lightshow/drivers.py index 76e358d..36b7794 100644 --- a/src/espmega_lightshow/drivers.py +++ b/src/espmega_lightshow/drivers.py @@ -159,6 +159,24 @@ def get_driver_properties() -> dict: "support_color": False } +class DummyLightDriver(LightDriver): + def __init__(self, **kwargs): + self.connected = True + self.state = False + + def set_light_state(self, state: bool) -> None: + self.state = state + + def get_light_state(self) -> bool: + return self.state + + @staticmethod + def get_driver_properties() -> dict: + return { + "name": "Dummy", + "support_brightness": False, + "support_color": False + } class ESPMegaLightGrid: def __init__(self, light_server: str, light_server_port: int, rows: int = 0, columns: int = 0, rapid_mode: bool = False, design_mode: bool = False): @@ -211,7 +229,7 @@ def _assign_light(self, row_index, column_index, light): print(f"Assigning light at {row_index}, {column_index}, its base topic is {light['base_topic']}, The controller loaded are {self.drivers}") if self.design_mode: self.connected_drivers[light["base_topic"]] = None - self.assign_physical_light(row_index, column_index, None) + self.assign_physical_light(row_index, column_index, DummyLightDriver()) return if light is None: self.assign_physical_light(row_index, column_index, None)