Skip to content

Commit

Permalink
catch self discovery exception in simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
kongo09 committed Jan 1, 2024
1 parent fc684ad commit c57a66f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pixoo import Channel, ImageResampleMode, Pixoo
from pixoo.font import Font
from pixoo import Channel, ImageResampleMode, Pixoo, Font

'''
Create a connection to a Pixoo
Expand Down
27 changes: 20 additions & 7 deletions pixoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from pixoo.config import PixooConfig
from pixoo._colors import Palette
from pixoo.exceptions import NoPixooDevicesFound
from pixoo.font import Font
from pixoo.simulator import Simulator, SimulatorConfig
from pixoo.api import PixooBaseApi
Expand Down Expand Up @@ -85,24 +86,36 @@ class Pixoo(PixooBaseApi):

def __init__(
self,
pixoo_config=PixooConfig(),
pixoo_config=None,
debug=False,
simulated=False,
simulation_config=SimulatorConfig(),
):
self.refresh_connection_automatically = (
pixoo_config.refresh_connection_automatically
)
super().__init__(pixoo_config.address)
self.debug = debug
self.size = pixoo_config.size
self.simulated = simulated

_pixoo_config = pixoo_config
if _pixoo_config == None and self.simulated:
_pixoo_config = PixooConfig(address="simulated", size=64)
elif _pixoo_config == None:
try:
_pixoo_config = PixooConfig()
except NoPixooDevicesFound:
if self.debug:
print(f"No Pixoo device found")
return

self.refresh_connection_automatically = (
_pixoo_config.refresh_connection_automatically
)
super().__init__(_pixoo_config.address)
self.size = _pixoo_config.size

# Total number of pixels
self.pixel_count = self.size * self.size

# Generate URL
self.__url = f"http://{pixoo_config.address}/post"
self.__url = f"http://{_pixoo_config.address}/post"

# Prefill the buffer
self.fill()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="pixoo",
version="0.8.1",
version="0.8.2",
author="Ron Talman, kongo09",
description=(
"A library to easily communicate with the Divoom Pixoo 64",
Expand Down

0 comments on commit c57a66f

Please sign in to comment.