Skip to content

Commit

Permalink
add dummy driver
Browse files Browse the repository at this point in the history
  • Loading branch information
SiwatS committed Dec 13, 2023
1 parent 1686753 commit 4f76aa5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
Expand Down
2 changes: 1 addition & 1 deletion src/espmega_lightshow.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -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: [email protected]
Expand Down
3 changes: 1 addition & 2 deletions src/espmega_lightshow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 19 additions & 1 deletion src/espmega_lightshow/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4f76aa5

Please sign in to comment.