IS-Matrix-Forge 1.0.0.dev1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- is_matrix_forge/__init__.py +8 -0
- is_matrix_forge/assets/__init__.py +8 -0
- is_matrix_forge/assets/audio/__init__.py +36 -0
- is_matrix_forge/assets/audio/files/__init__.py +53 -0
- is_matrix_forge/assets/audio/files/plugged.wav +0 -0
- is_matrix_forge/assets/audio/files/unplugged.wav +0 -0
- is_matrix_forge/assets/char_map.json +2150 -0
- is_matrix_forge/assets/font_map.py +119 -0
- is_matrix_forge/common/__init__.py +0 -0
- is_matrix_forge/common/decorators/__init__.py +152 -0
- is_matrix_forge/common/dirs.py +20 -0
- is_matrix_forge/common/helpers/__init__.py +132 -0
- is_matrix_forge/common/helpers/github_api.py +67 -0
- is_matrix_forge/designer_gui/__init__.py +8 -0
- is_matrix_forge/designer_gui/main_window/__init__.py +252 -0
- is_matrix_forge/designer_gui/main_window/layout.py +117 -0
- is_matrix_forge/dev_tools/__init__.py +8 -0
- is_matrix_forge/dev_tools/debug.py +82 -0
- is_matrix_forge/dev_tools/presets.py +47 -0
- is_matrix_forge/inputmodule/__init__.py +164 -0
- is_matrix_forge/inputmodule/b1display.py +160 -0
- is_matrix_forge/inputmodule/c1minimal.py +35 -0
- is_matrix_forge/inputmodule/font.py +2166 -0
- is_matrix_forge/inputmodule/helpers/__init__.py +16 -0
- is_matrix_forge/inputmodule/ledmatrix.py +516 -0
- is_matrix_forge/led_matrix/Scripts/__init__.py +4 -0
- is_matrix_forge/led_matrix/Scripts/battery_monitor.py +152 -0
- is_matrix_forge/led_matrix/Scripts/install_presets/__init__.py +2 -0
- is_matrix_forge/led_matrix/Scripts/install_presets/arguments.py +84 -0
- is_matrix_forge/led_matrix/Scripts/install_presets/main.py +192 -0
- is_matrix_forge/led_matrix/__init__.py +7 -0
- is_matrix_forge/led_matrix/commands/__init__.py +84 -0
- is_matrix_forge/led_matrix/commands/map.py +46 -0
- is_matrix_forge/led_matrix/constants.py +82 -0
- is_matrix_forge/led_matrix/controller/__init__.py +26 -0
- is_matrix_forge/led_matrix/controller/controller.py +635 -0
- is_matrix_forge/led_matrix/controller/helpers/__init__.py +7 -0
- is_matrix_forge/led_matrix/controller/helpers/threading.py +41 -0
- is_matrix_forge/led_matrix/controller/multiton.py +32 -0
- is_matrix_forge/led_matrix/controller/threaded.py +72 -0
- is_matrix_forge/led_matrix/display/__init__.py +13 -0
- is_matrix_forge/led_matrix/display/animations/__init__.py +29 -0
- is_matrix_forge/led_matrix/display/animations/animation.py +593 -0
- is_matrix_forge/led_matrix/display/animations/effects/__init__.py +17 -0
- is_matrix_forge/led_matrix/display/animations/errors.py +23 -0
- is_matrix_forge/led_matrix/display/animations/font/__init__.py +17 -0
- is_matrix_forge/led_matrix/display/animations/font/font.py +4 -0
- is_matrix_forge/led_matrix/display/animations/font/map_builder.py +123 -0
- is_matrix_forge/led_matrix/display/animations/frame/__init__.py +47 -0
- is_matrix_forge/led_matrix/display/animations/frame/base.py +245 -0
- is_matrix_forge/led_matrix/display/animations/frame/helpers.py +67 -0
- is_matrix_forge/led_matrix/display/animations/keep_awake.py +1 -0
- is_matrix_forge/led_matrix/display/animations/plugged.py +0 -0
- is_matrix_forge/led_matrix/display/animations/text_scroller.py +104 -0
- is_matrix_forge/led_matrix/display/effects/__init__.py +17 -0
- is_matrix_forge/led_matrix/display/effects/breather.py +206 -0
- is_matrix_forge/led_matrix/display/effects/fade.py +0 -0
- is_matrix_forge/led_matrix/display/effects/scroller/__init__.py +92 -0
- is_matrix_forge/led_matrix/display/effects/scroller/base.py +76 -0
- is_matrix_forge/led_matrix/display/effects/scroller/helpers.py +62 -0
- is_matrix_forge/led_matrix/display/grid/__init__.py +9 -0
- is_matrix_forge/led_matrix/display/grid/grid.py +208 -0
- is_matrix_forge/led_matrix/display/grid/helpers.py +130 -0
- is_matrix_forge/led_matrix/display/grid/presets/__init__.py +64 -0
- is_matrix_forge/led_matrix/display/grid/presets/manifest.py +172 -0
- is_matrix_forge/led_matrix/display/helpers/__init__.py +110 -0
- is_matrix_forge/led_matrix/display/helpers/columns.py +33 -0
- is_matrix_forge/led_matrix/display/media.py +199 -0
- is_matrix_forge/led_matrix/display/patterns/__init__.py +59 -0
- is_matrix_forge/led_matrix/display/patterns/built_in/__init__.py +91 -0
- is_matrix_forge/led_matrix/display/patterns/built_in/commands.py +3 -0
- is_matrix_forge/led_matrix/display/patterns/built_in/constants.py +29 -0
- is_matrix_forge/led_matrix/display/patterns/built_in/stencils.py +70 -0
- is_matrix_forge/led_matrix/display/patterns/utils.py +2 -0
- is_matrix_forge/led_matrix/display/text/__init__.py +66 -0
- is_matrix_forge/led_matrix/display/text/scroller.py +136 -0
- is_matrix_forge/led_matrix/errors/__init__.py +4 -0
- is_matrix_forge/led_matrix/errors/base.py +14 -0
- is_matrix_forge/led_matrix/errors/grid.py +37 -0
- is_matrix_forge/led_matrix/errors/matrix.py +68 -0
- is_matrix_forge/led_matrix/errors/misc.py +36 -0
- is_matrix_forge/led_matrix/fonts.py +20 -0
- is_matrix_forge/led_matrix/hardware.py +172 -0
- is_matrix_forge/led_matrix/helpers/__init__.py +165 -0
- is_matrix_forge/led_matrix/helpers/core/__init__.py +17 -0
- is_matrix_forge/led_matrix/helpers/core/lazy_mod_load.py +84 -0
- is_matrix_forge/led_matrix/helpers/device.py +118 -0
- is_matrix_forge/led_matrix/helpers/status_handler.py +14 -0
- is_matrix_forge/led_matrix/helpers/stream/__init__.py +70 -0
- is_matrix_forge/led_matrix/helpers/stream/errors.py +17 -0
- is_matrix_forge/led_matrix/led_matrix.py +25 -0
- is_matrix_forge/led_matrix/status.py +8 -0
- is_matrix_forge/led_matrix/tools/__init__.py +8 -0
- is_matrix_forge/led_matrix/tools/identify.py +27 -0
- is_matrix_forge/led_matrix/utils/__init__.py +41 -0
- is_matrix_forge/log_engine.py +25 -0
- is_matrix_forge/monitor/__init__.py +68 -0
- is_matrix_forge/monitor/errors.py +35 -0
- is_matrix_forge/monitor/events.py +78 -0
- is_matrix_forge/monitor/gui/__init__.py +0 -0
- is_matrix_forge/monitor/gui/errors.py +35 -0
- is_matrix_forge/monitor/gui/event/__init__.py +8 -0
- is_matrix_forge/monitor/gui/event/collection.py +153 -0
- is_matrix_forge/monitor/gui/event/errors.py +58 -0
- is_matrix_forge/monitor/gui/event/event.py +226 -0
- is_matrix_forge/monitor/gui/layout/__init__.py +8 -0
- is_matrix_forge/monitor/gui/layout/base.py +147 -0
- is_matrix_forge/monitor/gui/metaclasses/__init__.py +20 -0
- is_matrix_forge/monitor/gui/windows/__init__.py +0 -0
- is_matrix_forge/monitor/gui/windows/base.py +325 -0
- is_matrix_forge/monitor/gui/windows/main/__init__.py +77 -0
- is_matrix_forge/monitor/gui/windows/main/layout.py +21 -0
- is_matrix_forge/monitor/helpers.py +55 -0
- is_matrix_forge/monitor/monitor.py +431 -0
- is_matrix_forge/notify/__init__.py +0 -0
- is_matrix_forge/notify/sounds/__init__.py +6 -0
- is_matrix_forge/notify/sounds/base.py +106 -0
- is_matrix_forge/progress.py +99 -0
- is_matrix_forge-1.0.0.dev1.dist-info/LICENSE.md +19 -0
- is_matrix_forge-1.0.0.dev1.dist-info/METADATA +190 -0
- is_matrix_forge-1.0.0.dev1.dist-info/RECORD +123 -0
- is_matrix_forge-1.0.0.dev1.dist-info/WHEEL +4 -0
- is_matrix_forge-1.0.0.dev1.dist-info/entry_points.txt +5 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from typing import Any, Dict, Type
|
|
2
|
+
|
|
3
|
+
class MultitonMeta(type):
|
|
4
|
+
"""
|
|
5
|
+
Metaclass that ensures only one instance per “key” exists.
|
|
6
|
+
By default, it uses the first positional argument (your `device`)
|
|
7
|
+
and looks up its `.device` attribute (if present) or `repr()` as the unique key.
|
|
8
|
+
"""
|
|
9
|
+
def __init__(cls, name, bases, attrs):
|
|
10
|
+
super().__init__(name, bases, attrs)
|
|
11
|
+
# per–subclass registry
|
|
12
|
+
cls._instances: Dict[Any, cls] = {}
|
|
13
|
+
# allow subclasses to override which attr to use on device
|
|
14
|
+
cls.MULTITON_KEY_ATTR: str = attrs.get('MULTITON_KEY_ATTR', 'device')
|
|
15
|
+
|
|
16
|
+
def __call__(cls, *args, **kwargs):
|
|
17
|
+
# pull out the “device” argument
|
|
18
|
+
if cls.MULTITON_KEY_ATTR in kwargs:
|
|
19
|
+
dev = kwargs[cls.MULTITON_KEY_ATTR]
|
|
20
|
+
elif args:
|
|
21
|
+
dev = args[0]
|
|
22
|
+
else:
|
|
23
|
+
raise TypeError(f"Missing '{cls.MULTITON_KEY_ATTR}' argument")
|
|
24
|
+
# pick a raw key from either dev.<attr> or repr(dev)
|
|
25
|
+
raw_key = getattr(dev, cls.MULTITON_KEY_ATTR, repr(dev))
|
|
26
|
+
# return existing if we've already built one
|
|
27
|
+
if raw_key in cls._instances:
|
|
28
|
+
return cls._instances[raw_key]
|
|
29
|
+
# otherwise build & cache a new one
|
|
30
|
+
inst = super().__call__(*args, **kwargs)
|
|
31
|
+
cls._instances[raw_key] = inst
|
|
32
|
+
return inst
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
import queue
|
|
3
|
+
from typing import Optional, Any
|
|
4
|
+
|
|
5
|
+
class ThreadedLEDMatrixController:
|
|
6
|
+
"""
|
|
7
|
+
Wraps an LEDMatrixController to execute commands in one or more background threads,
|
|
8
|
+
ensuring no calls are lost when invoked concurrently.
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
base = LEDMatrixController(device, default_brightness=50)
|
|
12
|
+
threaded = ThreadedLEDMatrixController(base, max_queue_size=100, num_workers=2)
|
|
13
|
+
# now you can spam commands from any thread, and they’ll all run:
|
|
14
|
+
threaded.draw_grid(grid1)
|
|
15
|
+
threaded.set_brightness(80)
|
|
16
|
+
threaded.animate(True)
|
|
17
|
+
# ...even while a long identify() or Breather is running!
|
|
18
|
+
|
|
19
|
+
Parameters:
|
|
20
|
+
controller (LEDMatrixController):
|
|
21
|
+
The controller to wrap.
|
|
22
|
+
|
|
23
|
+
max_queue_size (int, optional):
|
|
24
|
+
Maximum number of queued commands. Defaults to infinite.
|
|
25
|
+
|
|
26
|
+
num_workers (int, optional):
|
|
27
|
+
Number of worker threads processing the queue. Defaults to 1.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
controller: Any,
|
|
33
|
+
max_queue_size: Optional[int] = None,
|
|
34
|
+
num_workers: int = 1
|
|
35
|
+
):
|
|
36
|
+
self._controller = controller
|
|
37
|
+
# infinite size if you don't care about spam limits
|
|
38
|
+
self._queue = queue.Queue(maxsize=max_queue_size) if max_queue_size else queue.Queue()
|
|
39
|
+
self._workers = []
|
|
40
|
+
for i in range(max(1, num_workers)):
|
|
41
|
+
t = threading.Thread(target=self._worker, daemon=True, name=f"LEDWorker-{i}")
|
|
42
|
+
t.start()
|
|
43
|
+
self._workers.append(t)
|
|
44
|
+
|
|
45
|
+
def _worker(self):
|
|
46
|
+
while True:
|
|
47
|
+
method_name, args, kwargs = self._queue.get()
|
|
48
|
+
try:
|
|
49
|
+
getattr(self._controller, method_name)(*args, **kwargs)
|
|
50
|
+
except Exception as e:
|
|
51
|
+
# feel free to hook up your own logger here
|
|
52
|
+
print(f"[ThreadedLEDMatrixController] Error in {method_name}: {e}")
|
|
53
|
+
finally:
|
|
54
|
+
self._queue.task_done()
|
|
55
|
+
|
|
56
|
+
def enqueue(self, method_name: str, /, *args, **kwargs):
|
|
57
|
+
"""
|
|
58
|
+
Enqueue a method call by name. Raises queue.Full if the queue is full.
|
|
59
|
+
"""
|
|
60
|
+
self._queue.put((method_name, args, kwargs))
|
|
61
|
+
|
|
62
|
+
def __getattr__(self, name: str):
|
|
63
|
+
"""
|
|
64
|
+
Proxy any attribute to the wrapped controller.
|
|
65
|
+
If it’s a callable, return a wrapper that enqueues the call.
|
|
66
|
+
"""
|
|
67
|
+
attr = getattr(self._controller, name)
|
|
68
|
+
if callable(attr):
|
|
69
|
+
def wrapper(*args, **kwargs):
|
|
70
|
+
self.enqueue(name, *args, **kwargs)
|
|
71
|
+
return wrapper
|
|
72
|
+
return attr
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Display module for LED Matrix.
|
|
3
|
+
|
|
4
|
+
This module provides functions for displaying various content on the LED matrix,
|
|
5
|
+
including patterns, text, and media.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import and re-export all display-related functions
|
|
9
|
+
from .patterns.built_in.stencils import checkerboard
|
|
10
|
+
from .helpers import light_leds
|
|
11
|
+
from .helpers.columns import send_col, commit_cols
|
|
12
|
+
from .text import show_string, show_font, show_symbols
|
|
13
|
+
from .media import image, image_greyscale, camera, video, pixel_to_brightness
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from time import sleep
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from is_matrix_forge.led_matrix.hardware import brightness
|
|
5
|
+
from is_matrix_forge.led_matrix.display.text import show_string
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def clear(dev):
|
|
9
|
+
brightness(dev, 0)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def checkerboard_cycle(dev):
|
|
13
|
+
from is_matrix_forge.led_matrix.display.patterns.built_in.stencils import checkerboard
|
|
14
|
+
frame = 2
|
|
15
|
+
|
|
16
|
+
while frame < 5:
|
|
17
|
+
brightness(dev, 25)
|
|
18
|
+
print(f'Processing frame: {frame}')
|
|
19
|
+
sleep(1)
|
|
20
|
+
checkerboard(dev, frame)
|
|
21
|
+
frame += 1
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def goodbye_animation(dev):
|
|
25
|
+
clear(dev)
|
|
26
|
+
sleep(.1)
|
|
27
|
+
checkerboard_cycle(dev)
|
|
28
|
+
sleep(.5)
|
|
29
|
+
show_string(dev, 'Bye')
|