pyvisionect 0.1.0__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.
- pyvisionect/__init__.py +120 -0
- pyvisionect/devices/__init__.py +92 -0
- pyvisionect/devices/enums.py +403 -0
- pyvisionect/devices/panels.py +242 -0
- pyvisionect/devices/tclv.py +460 -0
- pyvisionect/imaging/README.md +175 -0
- pyvisionect/imaging/__init__.py +181 -0
- pyvisionect/imaging/checksum.py +114 -0
- pyvisionect/imaging/constants.py +131 -0
- pyvisionect/imaging/data/blue_noise_64.npy +0 -0
- pyvisionect/imaging/decode.py +172 -0
- pyvisionect/imaging/dither.py +357 -0
- pyvisionect/imaging/encoder.py +594 -0
- pyvisionect/imaging/geometry.py +129 -0
- pyvisionect/imaging/grey.py +104 -0
- pyvisionect/imaging/interlace.py +244 -0
- pyvisionect/imaging/pack.py +142 -0
- pyvisionect/imaging/panel.py +339 -0
- pyvisionect/imaging/partial.py +931 -0
- pyvisionect/imaging/rects.py +466 -0
- pyvisionect/io/__init__.py +33 -0
- pyvisionect/io/tcp.py +795 -0
- pyvisionect/io/usb/__init__.py +237 -0
- pyvisionect/io/usb/cli.py +278 -0
- pyvisionect/io/usb/commands.py +781 -0
- pyvisionect/io/usb/console.py +730 -0
- pyvisionect/io/usb/device.py +914 -0
- pyvisionect/io/usb/discovery.py +260 -0
- pyvisionect/io/usb/encryption.py +262 -0
- pyvisionect/io/usb/errors.py +175 -0
- pyvisionect/io/usb/fake.py +292 -0
- pyvisionect/io/usb/parsers.py +1464 -0
- pyvisionect/io/usb/provisioning.py +502 -0
- pyvisionect/packets/__init__.py +135 -0
- pyvisionect/packets/control.py +95 -0
- pyvisionect/packets/file.py +325 -0
- pyvisionect/packets/image.py +234 -0
- pyvisionect/packets/misc.py +202 -0
- pyvisionect/packets/param.py +284 -0
- pyvisionect/packets/status.py +518 -0
- pyvisionect/packets/stored.py +217 -0
- pyvisionect/py.typed +0 -0
- pyvisionect/session/__init__.py +100 -0
- pyvisionect/session/connection.py +1043 -0
- pyvisionect/session/device.py +587 -0
- pyvisionect/session/events.py +196 -0
- pyvisionect/session/filetransfer.py +251 -0
- pyvisionect/session/pending.py +425 -0
- pyvisionect/wire/__init__.py +91 -0
- pyvisionect/wire/blocks.py +350 -0
- pyvisionect/wire/checksum.py +115 -0
- pyvisionect/wire/errors.py +176 -0
- pyvisionect/wire/framing.py +334 -0
- pyvisionect-0.1.0.dist-info/METADATA +1030 -0
- pyvisionect-0.1.0.dist-info/RECORD +58 -0
- pyvisionect-0.1.0.dist-info/WHEEL +4 -0
- pyvisionect-0.1.0.dist-info/entry_points.txt +3 -0
- pyvisionect-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"""Panel geometry and display drivers -- data, not subclasses.
|
|
2
|
+
|
|
3
|
+
The vendor covers eleven hardware families with one code path by deriving
|
|
4
|
+
nothing from the model, and ``driver.driverList`` has exactly **five** drivers
|
|
5
|
+
whose entire per-device variability is two booleans plus a pixel filter. We
|
|
6
|
+
mirror that.
|
|
7
|
+
|
|
8
|
+
``DisplayType`` must stay an **opaque uint32**. The live 32" sign reports
|
|
9
|
+
``0xC2050128``, which is *not* in the vendor's enum (it falls through to
|
|
10
|
+
``DISPLAY_UNKNOWN``) and yet is a perfectly valid firmware-service key. So:
|
|
11
|
+
look the raw value up, fall back to a default row, and take *capabilities* from
|
|
12
|
+
the device's own ``PV2Features`` advertisement -- never from the model.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from dataclasses import dataclass, replace
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"Driver",
|
|
21
|
+
"DRIVERS",
|
|
22
|
+
"Panel",
|
|
23
|
+
"PANELS",
|
|
24
|
+
"DEFAULT_PANEL",
|
|
25
|
+
"DISPLAY_TYPE_NAMES",
|
|
26
|
+
"DISPLAY_TYPE_DRIVER",
|
|
27
|
+
"panel_for",
|
|
28
|
+
"driver_for",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(frozen=True, slots=True)
|
|
33
|
+
class Driver:
|
|
34
|
+
"""The entire per-device variability in the vendor's display layer.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
name: the vendor's driver-class string.
|
|
38
|
+
mirror: horizontal mirror. True for the ``*-flip`` drivers; the live 32"
|
|
39
|
+
sign is ``eink-flip``, and an un-mirrored push lands backwards.
|
|
40
|
+
color_mask: the 32" colour-mask pixel filter.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
name: str
|
|
44
|
+
mirror: bool
|
|
45
|
+
color_mask: bool
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
DRIVERS: dict[str, Driver] = {
|
|
49
|
+
"eink-generic": Driver("eink-generic", mirror=False, color_mask=False),
|
|
50
|
+
"eink-flip": Driver("eink-flip", mirror=True, color_mask=False),
|
|
51
|
+
"pl-generic": Driver("pl-generic", mirror=False, color_mask=False),
|
|
52
|
+
"eink-32-inch-color-mask": Driver(
|
|
53
|
+
"eink-32-inch-color-mask", mirror=False, color_mask=True
|
|
54
|
+
),
|
|
55
|
+
"eink-32-inch-color-mask-flip": Driver(
|
|
56
|
+
"eink-32-inch-color-mask-flip", mirror=True, color_mask=True
|
|
57
|
+
),
|
|
58
|
+
# Named by DISPLAY_TYPE_DRIVER but not in driverList; treated as generic.
|
|
59
|
+
"eink-42-v2": Driver("eink-42-v2", mirror=False, color_mask=False),
|
|
60
|
+
"eink-42-flip": Driver("eink-42-flip", mirror=True, color_mask=False),
|
|
61
|
+
"no display": Driver("no display", mirror=False, color_mask=False),
|
|
62
|
+
"unknown": Driver("unknown", mirror=False, color_mask=False),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@dataclass(frozen=True, slots=True)
|
|
67
|
+
class Panel:
|
|
68
|
+
"""Geometry the server models for a given raw ``DisplayType``.
|
|
69
|
+
|
|
70
|
+
``width``/``height`` are the dimensions of **one virtual display**; the full
|
|
71
|
+
canvas is ``displays`` of them stacked. For the 32" sign the server models
|
|
72
|
+
``4 x 1440x640`` (canvas 1440x2560) and then the ``eink-flip`` driver's
|
|
73
|
+
interlacing step emits **two** rectangles of ``2880x640`` on the wire, with
|
|
74
|
+
``ScreenID`` 0 and 1. Both the repack and the mirror have to be reproduced
|
|
75
|
+
or the image lands garbled.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
width: int
|
|
79
|
+
height: int
|
|
80
|
+
displays: int
|
|
81
|
+
driver: str
|
|
82
|
+
display_type: int | None = None
|
|
83
|
+
"""The raw ``DisplayType`` this row was looked up with, when known."""
|
|
84
|
+
|
|
85
|
+
is_default: bool = False
|
|
86
|
+
"""True when this is the fallback row rather than a recognised panel.
|
|
87
|
+
|
|
88
|
+
Worth surfacing in diagnostics: our sign's ``0xC2050128`` is not in the
|
|
89
|
+
vendor's enum at all, so "unrecognised panel, assuming 2880x640" is an
|
|
90
|
+
honest thing to tell a user, and silently using a guess is not. Capabilities
|
|
91
|
+
still come from the device's own ``PV2Features``, not from this.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def name(self) -> str:
|
|
96
|
+
"""The firmware-service name, or ``DISPLAY_UNKNOWN``."""
|
|
97
|
+
if self.display_type is None:
|
|
98
|
+
return "DISPLAY_UNSPECIFIED"
|
|
99
|
+
return DISPLAY_TYPE_NAMES.get(self.display_type, "DISPLAY_UNKNOWN")
|
|
100
|
+
|
|
101
|
+
def describe(self) -> str:
|
|
102
|
+
"""A one-line human description, for diagnostics."""
|
|
103
|
+
prefix = "unrecognised panel, assuming" if self.is_default else self.name
|
|
104
|
+
return (
|
|
105
|
+
f"{prefix} {self.canvas_width}x{self.canvas_height} "
|
|
106
|
+
f"({self.displays} x {self.width}x{self.height}, driver {self.driver})"
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def canvas_width(self) -> int:
|
|
111
|
+
return self.width
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def canvas_height(self) -> int:
|
|
115
|
+
return self.height * self.displays
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def driver_spec(self) -> Driver:
|
|
119
|
+
return DRIVERS.get(self.driver, DRIVERS["unknown"])
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
DISPLAY_TYPE_NAMES: dict[int, str] = {
|
|
123
|
+
0: "DISPLAY_NONE",
|
|
124
|
+
1: "DISPLAY_EINK_6_0",
|
|
125
|
+
2: "DISPLAY_EINK_9_7",
|
|
126
|
+
3: "DISPLAY_EINK_13_3",
|
|
127
|
+
4: "DISPLAY_PLASTIC_LOGIC_10_7",
|
|
128
|
+
5: "DISPLAY_EINK_30_0",
|
|
129
|
+
6: "DISPLAY_EINK_6_0_NEW",
|
|
130
|
+
7: "DISPLAY_EINK_9_7_C228",
|
|
131
|
+
8: "DISPLAY_EINK_6_0_C219",
|
|
132
|
+
9: "DISPLAY_EINK_6_0_C246",
|
|
133
|
+
10: "DISPLAY_EINK_9_7_C242",
|
|
134
|
+
11: "DISPLAY_EINK_9_7_HVOLT",
|
|
135
|
+
12: "DISPLAY_EINK_13_3_C222",
|
|
136
|
+
13: "DISPLAY_EINK_31_2_D039",
|
|
137
|
+
14: "DISPLAY_EINK_31_2_D041",
|
|
138
|
+
15: "DISPLAY_EINK_31_2_R064",
|
|
139
|
+
16: "DISPLAY_EINK_31_2_W001",
|
|
140
|
+
17: "DISPLAY_EINK_31_2_C247",
|
|
141
|
+
0x60110154: "DISPLAY_EINK_42_V2",
|
|
142
|
+
0x60110191: "DISPLAY_EINK_42_V2",
|
|
143
|
+
0x80000000: "DISPLAY_EINK_42",
|
|
144
|
+
0xA30500F3: "DISPLAY_EINK_9_7_C243",
|
|
145
|
+
0xAD0500F3: "DISPLAY_EINK_13_3_C243",
|
|
146
|
+
}
|
|
147
|
+
"""``status.(*DisplayType).FwServerString`` @ ``0x69baa0``.
|
|
148
|
+
|
|
149
|
+
Anything absent is ``DISPLAY_UNKNOWN`` -- including our sign's ``0xC2050128``.
|
|
150
|
+
"""
|
|
151
|
+
|
|
152
|
+
DISPLAY_TYPE_DRIVER: dict[int, str] = {
|
|
153
|
+
0: "no display",
|
|
154
|
+
1: "eink-generic",
|
|
155
|
+
2: "eink-generic",
|
|
156
|
+
3: "eink-generic",
|
|
157
|
+
4: "pl-generic",
|
|
158
|
+
5: "eink-flip",
|
|
159
|
+
6: "eink-generic",
|
|
160
|
+
7: "eink-generic",
|
|
161
|
+
8: "eink-generic",
|
|
162
|
+
9: "eink-generic",
|
|
163
|
+
10: "eink-generic",
|
|
164
|
+
11: "eink-generic",
|
|
165
|
+
12: "eink-generic",
|
|
166
|
+
13: "eink-flip",
|
|
167
|
+
14: "eink-flip",
|
|
168
|
+
15: "eink-flip",
|
|
169
|
+
16: "eink-flip",
|
|
170
|
+
17: "eink-flip",
|
|
171
|
+
0x60110154: "eink-42-v2",
|
|
172
|
+
0x60110191: "eink-42-v2",
|
|
173
|
+
0x7FFFFFFD: "eink-generic",
|
|
174
|
+
0x80000000: "eink-42-flip",
|
|
175
|
+
0xA30500F3: "eink-generic",
|
|
176
|
+
0xAD0500F3: "eink-generic",
|
|
177
|
+
}
|
|
178
|
+
"""``status.(*DisplayType).String`` @ ``0x69b9c0`` -- the driver class."""
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
DEFAULT_PANEL = Panel(
|
|
182
|
+
width=1440, height=640, displays=4, driver="eink-flip", is_default=True
|
|
183
|
+
)
|
|
184
|
+
"""The ``default:`` arm of ``SetupDisplaysType``.
|
|
185
|
+
|
|
186
|
+
The vendor's switch sends ``{5, 13, 14, 15, 16, 17, default}`` to
|
|
187
|
+
``1440x640 forced to 4 displays``, logging
|
|
188
|
+
``"We expect 4 virtual displays for one 32\\" eink display!"`` and rewriting a
|
|
189
|
+
device-reported ``2880x640`` into ``4 x 1440x640``. Our sign's unknown
|
|
190
|
+
``0xC2050128`` lands here, which is why it works at all.
|
|
191
|
+
"""
|
|
192
|
+
|
|
193
|
+
PANELS: dict[int, Panel] = {
|
|
194
|
+
0x7FFFFFFD: Panel(80, 32, 1, "eink-generic"),
|
|
195
|
+
1: Panel(600, 800, 1, "eink-generic"),
|
|
196
|
+
6: Panel(1024, 758, 1, "eink-generic"),
|
|
197
|
+
2: Panel(1200, 825, 1, "eink-generic"),
|
|
198
|
+
7: Panel(1200, 825, 1, "eink-generic"),
|
|
199
|
+
8: Panel(1200, 825, 1, "eink-generic"),
|
|
200
|
+
9: Panel(1200, 825, 1, "eink-generic"),
|
|
201
|
+
10: Panel(1200, 825, 1, "eink-generic"),
|
|
202
|
+
11: Panel(1200, 825, 1, "eink-generic"),
|
|
203
|
+
0xA30500F3: Panel(1200, 825, 1, "eink-generic"),
|
|
204
|
+
3: Panel(1600, 1200, 1, "eink-generic"),
|
|
205
|
+
12: Panel(1600, 1200, 1, "eink-generic"),
|
|
206
|
+
0xAD0500F3: Panel(1600, 1200, 1, "eink-generic"),
|
|
207
|
+
4: Panel(1280, 960, 1, "pl-generic"),
|
|
208
|
+
5: Panel(1440, 640, 4, "eink-flip"),
|
|
209
|
+
13: Panel(1440, 640, 4, "eink-flip"),
|
|
210
|
+
14: Panel(1440, 640, 4, "eink-flip"),
|
|
211
|
+
15: Panel(1440, 640, 4, "eink-flip"),
|
|
212
|
+
16: Panel(1440, 640, 4, "eink-flip"),
|
|
213
|
+
17: Panel(1440, 640, 4, "eink-flip"),
|
|
214
|
+
}
|
|
215
|
+
"""Keyed on the **raw uint32** ``DisplayType``, with :data:`DEFAULT_PANEL` as the
|
|
216
|
+
default row. Geometry from ``SetupDisplaysType``."""
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def panel_for(display_type: int) -> Panel:
|
|
220
|
+
"""Panel geometry for a raw ``DisplayType``, defaulting to the 32" 4x1440x640 row.
|
|
221
|
+
|
|
222
|
+
The returned :class:`Panel` carries the ``display_type`` it was looked up
|
|
223
|
+
with and an :attr:`Panel.is_default` flag, so a caller can say
|
|
224
|
+
"unrecognised panel, assuming 2880x640" instead of silently guessing.
|
|
225
|
+
"""
|
|
226
|
+
found = PANELS.get(display_type)
|
|
227
|
+
if found is None:
|
|
228
|
+
return replace(DEFAULT_PANEL, display_type=display_type)
|
|
229
|
+
return replace(found, display_type=display_type)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def driver_for(display_type: int) -> Driver:
|
|
233
|
+
"""Driver spec for a raw ``DisplayType``."""
|
|
234
|
+
name = DISPLAY_TYPE_DRIVER.get(display_type)
|
|
235
|
+
if name is None:
|
|
236
|
+
name = panel_for(display_type).driver
|
|
237
|
+
return DRIVERS.get(name, DRIVERS["unknown"])
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def display_type_name(display_type: int) -> str:
|
|
241
|
+
"""Firmware-service name for a raw ``DisplayType``, or ``DISPLAY_UNKNOWN``."""
|
|
242
|
+
return DISPLAY_TYPE_NAMES.get(display_type, "DISPLAY_UNKNOWN")
|