alpha-led-sign 0.1.0__tar.gz
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.
- alpha_led_sign-0.1.0/LICENSE +21 -0
- alpha_led_sign-0.1.0/PKG-INFO +199 -0
- alpha_led_sign-0.1.0/README.md +169 -0
- alpha_led_sign-0.1.0/pyproject.toml +234 -0
- alpha_led_sign-0.1.0/pyproject.toml.orig +178 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/__init__.py +104 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/capability-matrices.json +1183 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/cli.py +501 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/discovery.py +125 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/markup.py +428 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/models.py +515 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/__init__.py +205 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/addresses.py +17 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/capabilities.py +75 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/codes.py +563 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/commands.py +1316 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/control_codes.py +230 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/framing.py +26 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/labels.py +14 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/matching.py +114 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/memory.py +224 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/message.py +256 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/packet.py +189 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/pictures.py +136 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/requirements.py +187 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/responses.py +121 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/protocol/versions.py +25 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/py.typed +0 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/sign.py +712 -0
- alpha_led_sign-0.1.0/src/alpha_led_sign/transport.py +163 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Syne Ardwin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: alpha-led-sign
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Typed Python control for Alpha-protocol LED message signs
|
|
5
|
+
Keywords: alpha,led sign,message sign,betabrite,serial,protocol
|
|
6
|
+
Author: Syne Ardwin
|
|
7
|
+
Author-email: Syne Ardwin <syne@syne.tel>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Communications
|
|
18
|
+
Classifier: Topic :: System :: Hardware
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Dist: pyserial>=3.5
|
|
21
|
+
Requires-Dist: typer>=0.29.1 ; extra == 'cli'
|
|
22
|
+
Requires-Python: >=3.12
|
|
23
|
+
Project-URL: Homepage, https://github.com/ellisgeek/alpha-sign-python
|
|
24
|
+
Project-URL: Documentation, https://ellisgeek.github.io/alpha-sign-python/
|
|
25
|
+
Project-URL: Repository, https://github.com/ellisgeek/alpha-sign-python
|
|
26
|
+
Project-URL: Issues, https://github.com/ellisgeek/alpha-sign-python/issues
|
|
27
|
+
Project-URL: Changelog, https://github.com/ellisgeek/alpha-sign-python/blob/main/CHANGELOG.md
|
|
28
|
+
Provides-Extra: cli
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# alpha-led-sign
|
|
32
|
+
|
|
33
|
+
[](https://github.com/ellisgeek/alpha-sign-python/actions/workflows/ci.yml)
|
|
34
|
+
[](https://codecov.io/gh/ellisgeek/alpha-sign-python)
|
|
35
|
+
[](https://pypi.org/project/alpha-led-sign/)
|
|
36
|
+
|
|
37
|
+
A typed Python library for controlling Alpha-protocol LED message signs (for
|
|
38
|
+
example the Alpha 4000 Series) over a serial line.
|
|
39
|
+
|
|
40
|
+
It covers the Alpha 1.0 protocol: TEXT and STRING Files with Modes, colors,
|
|
41
|
+
fonts, and live time, date, and STRING values; the Priority TEXT File; Memory
|
|
42
|
+
Configuration and scheduling; the clock; tones; reads; and finding Signs on a
|
|
43
|
+
network. Every byte sequence is tested against the worked examples in Alpha's
|
|
44
|
+
protocol manual.
|
|
45
|
+
|
|
46
|
+
The [documentation](https://ellisgeek.github.io/alpha-sign-python/) has a user
|
|
47
|
+
guide and the API reference.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
pip install alpha-led-sign # the library; needs Python 3.12 or later
|
|
53
|
+
pip install 'alpha-led-sign[cli]' # with the alpha-led-sign command
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Example
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from datetime import datetime
|
|
60
|
+
|
|
61
|
+
from alpha_led_sign import (
|
|
62
|
+
Color, CurrentTime, Frame, Message, Mode, Position, Sign, StringFile, StringRef,
|
|
63
|
+
TextFile, models,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
with Sign.serial("/dev/tty.usbserial-1410", model=models.ALPHA_4120C) as sign:
|
|
67
|
+
sign.show("Hello") # TEXT File "A"
|
|
68
|
+
|
|
69
|
+
# Writing the Memory Configuration erases every File on the Sign.
|
|
70
|
+
sign.configure_memory([TextFile("A", size=512), StringFile("T", size=16)])
|
|
71
|
+
sign.write_text("A", Message(
|
|
72
|
+
Frame(Mode.ROTATE, Position.TOP, [Color.RED, "Temp: ", StringRef("T")]),
|
|
73
|
+
Frame(Mode.HOLD, Position.BOTTOM, [Color.GREEN, CurrentTime()]),
|
|
74
|
+
))
|
|
75
|
+
sign.write_string("T", "72F") # updates without blanking the display
|
|
76
|
+
sign.set_clock(datetime.now())
|
|
77
|
+
|
|
78
|
+
sign.priority(Frame(Mode.FLASH, content=["EMERGENCY"]))
|
|
79
|
+
sign.clear_priority()
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Markup
|
|
83
|
+
|
|
84
|
+
A string given to `show`, `write_text`, `write_string`, or `priority` is markup:
|
|
85
|
+
text, with Control Codes and Frames in braces.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
sign.write_text("A", "{frame rotate top}{color red}Temp: {string T}"
|
|
89
|
+
"{frame hold bottom}{color green}{time}")
|
|
90
|
+
sign.write_string("T", escape_markup(reading)) # outside values: keep braces literal
|
|
91
|
+
print(to_markup(sign.read_text("A")))
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A token is a kind and its values: `{color red}`, `{font seven_high}`,
|
|
95
|
+
`{speed 3}`, `{wide on}`, `{date mmm_dd_yyyy}`, `{time}`, `{new_line}`,
|
|
96
|
+
`{string T}`, `{picture A}`, and `{raw 1F...}` for bytes the library does not
|
|
97
|
+
model. Values are the enum member names in lowercase. `{frame MODE POSITION}`
|
|
98
|
+
starts a Frame (`{frame special snow}`, `{frame graphic fireworks}`); `{{` and
|
|
99
|
+
`}}` are literal braces. A string inside a list of Segments is never parsed.
|
|
100
|
+
|
|
101
|
+
The default position is `fill`. On a two-line Sign such as the 4000 Series, Fill,
|
|
102
|
+
Top, and Bottom show fonts at most 7 rows high, so use `{frame hold middle}` for
|
|
103
|
+
`{font full_height}`; the library warns otherwise.
|
|
104
|
+
|
|
105
|
+
## Pictures
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
arrow = DotsPicture.parse("0010\n0111\n1111\n0111\n0010") # p. 40 pixel codes
|
|
109
|
+
sign.configure_memory([TextFile("A", size=64), DotsPictureFile("P", rows=5, columns=4)])
|
|
110
|
+
sign.write_dots_picture("P", arrow) # the size must match its File
|
|
111
|
+
sign.show("Go {picture P}")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`Sign.serial` accepts any [pyserial URL](https://pyserial.readthedocs.io/en/latest/url_handlers.html),
|
|
115
|
+
including `socket://host:port` for a serial-to-TCP bridge. The default line
|
|
116
|
+
settings are 9600 baud, 8N1; pass `serial_format=SerialFormat.SEVEN_E_TWO` for
|
|
117
|
+
7E2.
|
|
118
|
+
|
|
119
|
+
## Sign Models
|
|
120
|
+
|
|
121
|
+
A Sign Model profile (`models.ALPHA_4120C`, the rest of the 4000 Series,
|
|
122
|
+
`models.BETABRITE`) gives the Sign Type to address and the Capabilities from
|
|
123
|
+
the manual's tables. Content a model lacks raises a warning, or
|
|
124
|
+
`UnsupportedCapability` with `Sign(..., strict=True)`. `models.GENERIC` works
|
|
125
|
+
with any Alpha sign and checks only the Protocol Version.
|
|
126
|
+
|
|
127
|
+
## Scheduling
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from datetime import time
|
|
131
|
+
|
|
132
|
+
from alpha_led_sign import RunDay, RunDays, RunTime
|
|
133
|
+
|
|
134
|
+
sign.set_run_times({
|
|
135
|
+
"A": RunTime.between(time(8, 0), time(17, 0)), # 10-minute steps
|
|
136
|
+
"B": RunTime.ALWAYS,
|
|
137
|
+
})
|
|
138
|
+
sign.set_run_days({"A": RunDays(RunDay.WEEKDAYS)})
|
|
139
|
+
sign.run_sequence("AB") # each File during its Run Time
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Writing Run Times or Run Days ends a Priority TEXT File. The Sign also has
|
|
143
|
+
`set_speaker`, `tone`, and `set_sign_address`.
|
|
144
|
+
|
|
145
|
+
## Reading and discovery
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
sign.read_text("A") # -> Message
|
|
149
|
+
sign.read_string("T") # -> ("72F",)
|
|
150
|
+
sign.info() # firmware, clock, memory
|
|
151
|
+
sign.serial_errors().ok # did the last Packets arrive intact?
|
|
152
|
+
|
|
153
|
+
from alpha_led_sign import discover
|
|
154
|
+
discover(sign.transport, max_address=15) # Signs and their Sign Addresses
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Every Sign that matches the address answers a read, so reads to Sign Address 0
|
|
158
|
+
(the default) or a `?` pattern raise `ValueError`. Give the Sign's own address, or
|
|
159
|
+
pass `broadcast_reads=True` when only one Sign is on the line.
|
|
160
|
+
|
|
161
|
+
Discovery waits 1 s plus 0.5 s for each address searched, because each Sign
|
|
162
|
+
answers in turn. Lower `max_address` when the addresses are known to be small.
|
|
163
|
+
|
|
164
|
+
## Command line
|
|
165
|
+
|
|
166
|
+
The `cli` extra installs an `alpha-led-sign` command for setting up a Sign and
|
|
167
|
+
reading its state:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
170
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 info
|
|
171
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 configure A:text:512 T:string:16
|
|
172
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 show "{color red}Hello"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`alpha-led-sign --help` lists the commands. The port and line settings can also come
|
|
176
|
+
from `ALPHA_SIGN_PORT`, `ALPHA_SIGN_MODEL`, `ALPHA_SIGN_ADDRESS`, `ALPHA_SIGN_BAUD`,
|
|
177
|
+
and `ALPHA_SIGN_FORMAT`.
|
|
178
|
+
|
|
179
|
+
## Status
|
|
180
|
+
|
|
181
|
+
The library has been run against a real 4120C. What it found, item by item against
|
|
182
|
+
the manual, is in [docs/hardware-results.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/hardware-results.md); the hardware
|
|
183
|
+
checklist in [docs/spec.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/spec.md) lists what still needs confirmation. To
|
|
184
|
+
run the hardware tests:
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
just test-hardware /dev/tty.usbserial-1410
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The design, test seams, and open work are in [docs/spec.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/spec.md);
|
|
191
|
+
the domain terms are in [GLOSSARY.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/GLOSSARY.md). See
|
|
192
|
+
[CONTRIBUTING.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/CONTRIBUTING.md) to work on it.
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT; see [LICENSE](https://github.com/ellisgeek/alpha-sign-python/blob/main/LICENSE). The emulator's font data
|
|
197
|
+
(`emulator/src/core/display/manual-glyphs.ts`, and the test images drawn with it) is
|
|
198
|
+
copied from Appendix O of Alpha's protocol manual and is not covered by that license.
|
|
199
|
+
It is not part of the Python package.
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# alpha-led-sign
|
|
2
|
+
|
|
3
|
+
[](https://github.com/ellisgeek/alpha-sign-python/actions/workflows/ci.yml)
|
|
4
|
+
[](https://codecov.io/gh/ellisgeek/alpha-sign-python)
|
|
5
|
+
[](https://pypi.org/project/alpha-led-sign/)
|
|
6
|
+
|
|
7
|
+
A typed Python library for controlling Alpha-protocol LED message signs (for
|
|
8
|
+
example the Alpha 4000 Series) over a serial line.
|
|
9
|
+
|
|
10
|
+
It covers the Alpha 1.0 protocol: TEXT and STRING Files with Modes, colors,
|
|
11
|
+
fonts, and live time, date, and STRING values; the Priority TEXT File; Memory
|
|
12
|
+
Configuration and scheduling; the clock; tones; reads; and finding Signs on a
|
|
13
|
+
network. Every byte sequence is tested against the worked examples in Alpha's
|
|
14
|
+
protocol manual.
|
|
15
|
+
|
|
16
|
+
The [documentation](https://ellisgeek.github.io/alpha-sign-python/) has a user
|
|
17
|
+
guide and the API reference.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pip install alpha-led-sign # the library; needs Python 3.12 or later
|
|
23
|
+
pip install 'alpha-led-sign[cli]' # with the alpha-led-sign command
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from datetime import datetime
|
|
30
|
+
|
|
31
|
+
from alpha_led_sign import (
|
|
32
|
+
Color, CurrentTime, Frame, Message, Mode, Position, Sign, StringFile, StringRef,
|
|
33
|
+
TextFile, models,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
with Sign.serial("/dev/tty.usbserial-1410", model=models.ALPHA_4120C) as sign:
|
|
37
|
+
sign.show("Hello") # TEXT File "A"
|
|
38
|
+
|
|
39
|
+
# Writing the Memory Configuration erases every File on the Sign.
|
|
40
|
+
sign.configure_memory([TextFile("A", size=512), StringFile("T", size=16)])
|
|
41
|
+
sign.write_text("A", Message(
|
|
42
|
+
Frame(Mode.ROTATE, Position.TOP, [Color.RED, "Temp: ", StringRef("T")]),
|
|
43
|
+
Frame(Mode.HOLD, Position.BOTTOM, [Color.GREEN, CurrentTime()]),
|
|
44
|
+
))
|
|
45
|
+
sign.write_string("T", "72F") # updates without blanking the display
|
|
46
|
+
sign.set_clock(datetime.now())
|
|
47
|
+
|
|
48
|
+
sign.priority(Frame(Mode.FLASH, content=["EMERGENCY"]))
|
|
49
|
+
sign.clear_priority()
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Markup
|
|
53
|
+
|
|
54
|
+
A string given to `show`, `write_text`, `write_string`, or `priority` is markup:
|
|
55
|
+
text, with Control Codes and Frames in braces.
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
sign.write_text("A", "{frame rotate top}{color red}Temp: {string T}"
|
|
59
|
+
"{frame hold bottom}{color green}{time}")
|
|
60
|
+
sign.write_string("T", escape_markup(reading)) # outside values: keep braces literal
|
|
61
|
+
print(to_markup(sign.read_text("A")))
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
A token is a kind and its values: `{color red}`, `{font seven_high}`,
|
|
65
|
+
`{speed 3}`, `{wide on}`, `{date mmm_dd_yyyy}`, `{time}`, `{new_line}`,
|
|
66
|
+
`{string T}`, `{picture A}`, and `{raw 1F...}` for bytes the library does not
|
|
67
|
+
model. Values are the enum member names in lowercase. `{frame MODE POSITION}`
|
|
68
|
+
starts a Frame (`{frame special snow}`, `{frame graphic fireworks}`); `{{` and
|
|
69
|
+
`}}` are literal braces. A string inside a list of Segments is never parsed.
|
|
70
|
+
|
|
71
|
+
The default position is `fill`. On a two-line Sign such as the 4000 Series, Fill,
|
|
72
|
+
Top, and Bottom show fonts at most 7 rows high, so use `{frame hold middle}` for
|
|
73
|
+
`{font full_height}`; the library warns otherwise.
|
|
74
|
+
|
|
75
|
+
## Pictures
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
arrow = DotsPicture.parse("0010\n0111\n1111\n0111\n0010") # p. 40 pixel codes
|
|
79
|
+
sign.configure_memory([TextFile("A", size=64), DotsPictureFile("P", rows=5, columns=4)])
|
|
80
|
+
sign.write_dots_picture("P", arrow) # the size must match its File
|
|
81
|
+
sign.show("Go {picture P}")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`Sign.serial` accepts any [pyserial URL](https://pyserial.readthedocs.io/en/latest/url_handlers.html),
|
|
85
|
+
including `socket://host:port` for a serial-to-TCP bridge. The default line
|
|
86
|
+
settings are 9600 baud, 8N1; pass `serial_format=SerialFormat.SEVEN_E_TWO` for
|
|
87
|
+
7E2.
|
|
88
|
+
|
|
89
|
+
## Sign Models
|
|
90
|
+
|
|
91
|
+
A Sign Model profile (`models.ALPHA_4120C`, the rest of the 4000 Series,
|
|
92
|
+
`models.BETABRITE`) gives the Sign Type to address and the Capabilities from
|
|
93
|
+
the manual's tables. Content a model lacks raises a warning, or
|
|
94
|
+
`UnsupportedCapability` with `Sign(..., strict=True)`. `models.GENERIC` works
|
|
95
|
+
with any Alpha sign and checks only the Protocol Version.
|
|
96
|
+
|
|
97
|
+
## Scheduling
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from datetime import time
|
|
101
|
+
|
|
102
|
+
from alpha_led_sign import RunDay, RunDays, RunTime
|
|
103
|
+
|
|
104
|
+
sign.set_run_times({
|
|
105
|
+
"A": RunTime.between(time(8, 0), time(17, 0)), # 10-minute steps
|
|
106
|
+
"B": RunTime.ALWAYS,
|
|
107
|
+
})
|
|
108
|
+
sign.set_run_days({"A": RunDays(RunDay.WEEKDAYS)})
|
|
109
|
+
sign.run_sequence("AB") # each File during its Run Time
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Writing Run Times or Run Days ends a Priority TEXT File. The Sign also has
|
|
113
|
+
`set_speaker`, `tone`, and `set_sign_address`.
|
|
114
|
+
|
|
115
|
+
## Reading and discovery
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
sign.read_text("A") # -> Message
|
|
119
|
+
sign.read_string("T") # -> ("72F",)
|
|
120
|
+
sign.info() # firmware, clock, memory
|
|
121
|
+
sign.serial_errors().ok # did the last Packets arrive intact?
|
|
122
|
+
|
|
123
|
+
from alpha_led_sign import discover
|
|
124
|
+
discover(sign.transport, max_address=15) # Signs and their Sign Addresses
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Every Sign that matches the address answers a read, so reads to Sign Address 0
|
|
128
|
+
(the default) or a `?` pattern raise `ValueError`. Give the Sign's own address, or
|
|
129
|
+
pass `broadcast_reads=True` when only one Sign is on the line.
|
|
130
|
+
|
|
131
|
+
Discovery waits 1 s plus 0.5 s for each address searched, because each Sign
|
|
132
|
+
answers in turn. Lower `max_address` when the addresses are known to be small.
|
|
133
|
+
|
|
134
|
+
## Command line
|
|
135
|
+
|
|
136
|
+
The `cli` extra installs an `alpha-led-sign` command for setting up a Sign and
|
|
137
|
+
reading its state:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 info
|
|
141
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 configure A:text:512 T:string:16
|
|
142
|
+
alpha-led-sign --port /dev/tty.usbserial-1410 show "{color red}Hello"
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`alpha-led-sign --help` lists the commands. The port and line settings can also come
|
|
146
|
+
from `ALPHA_SIGN_PORT`, `ALPHA_SIGN_MODEL`, `ALPHA_SIGN_ADDRESS`, `ALPHA_SIGN_BAUD`,
|
|
147
|
+
and `ALPHA_SIGN_FORMAT`.
|
|
148
|
+
|
|
149
|
+
## Status
|
|
150
|
+
|
|
151
|
+
The library has been run against a real 4120C. What it found, item by item against
|
|
152
|
+
the manual, is in [docs/hardware-results.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/hardware-results.md); the hardware
|
|
153
|
+
checklist in [docs/spec.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/spec.md) lists what still needs confirmation. To
|
|
154
|
+
run the hardware tests:
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
just test-hardware /dev/tty.usbserial-1410
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The design, test seams, and open work are in [docs/spec.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/docs/spec.md);
|
|
161
|
+
the domain terms are in [GLOSSARY.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/GLOSSARY.md). See
|
|
162
|
+
[CONTRIBUTING.md](https://github.com/ellisgeek/alpha-sign-python/blob/main/CONTRIBUTING.md) to work on it.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT; see [LICENSE](https://github.com/ellisgeek/alpha-sign-python/blob/main/LICENSE). The emulator's font data
|
|
167
|
+
(`emulator/src/core/display/manual-glyphs.ts`, and the test images drawn with it) is
|
|
168
|
+
copied from Appendix O of Alpha's protocol manual and is not covered by that license.
|
|
169
|
+
It is not part of the Python package.
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "alpha-led-sign"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Typed Python control for Alpha-protocol LED message signs"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
keywords = [
|
|
9
|
+
"alpha",
|
|
10
|
+
"led sign",
|
|
11
|
+
"message sign",
|
|
12
|
+
"betabrite",
|
|
13
|
+
"serial",
|
|
14
|
+
"protocol",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Communications",
|
|
25
|
+
"Topic :: System :: Hardware",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
]
|
|
28
|
+
requires-python = ">=3.12"
|
|
29
|
+
dependencies = ["pyserial>=3.5"]
|
|
30
|
+
|
|
31
|
+
[[project.authors]]
|
|
32
|
+
name = "Syne Ardwin"
|
|
33
|
+
email = "syne@syne.tel"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
alpha-led-sign = "alpha_led_sign.cli:app"
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/ellisgeek/alpha-sign-python"
|
|
40
|
+
Documentation = "https://ellisgeek.github.io/alpha-sign-python/"
|
|
41
|
+
Repository = "https://github.com/ellisgeek/alpha-sign-python"
|
|
42
|
+
Issues = "https://github.com/ellisgeek/alpha-sign-python/issues"
|
|
43
|
+
Changelog = "https://github.com/ellisgeek/alpha-sign-python/blob/main/CHANGELOG.md"
|
|
44
|
+
|
|
45
|
+
[project.optional-dependencies]
|
|
46
|
+
cli = ["typer>=0.29.1"]
|
|
47
|
+
|
|
48
|
+
[build-system]
|
|
49
|
+
requires = ["uv_build>=0.10.12,<0.11.0"]
|
|
50
|
+
build-backend = "uv_build"
|
|
51
|
+
|
|
52
|
+
[dependency-groups]
|
|
53
|
+
dev = [
|
|
54
|
+
"alpha-led-sign[cli]",
|
|
55
|
+
"git-cliff>=2.14.2",
|
|
56
|
+
"prek>=0.5.10",
|
|
57
|
+
"pytest>=9.2.0",
|
|
58
|
+
"pytest-cov>=7.1.0",
|
|
59
|
+
"ruff>=0.17.4",
|
|
60
|
+
"rust-just>=1.59.0",
|
|
61
|
+
"ty>=0.0.99",
|
|
62
|
+
"types-pyserial>=3.5.0.20261104",
|
|
63
|
+
]
|
|
64
|
+
docs = [
|
|
65
|
+
"great-docs>=0.17.0",
|
|
66
|
+
"quarto-cli>=1.11.9",
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.ruff]
|
|
70
|
+
line-length = 100
|
|
71
|
+
target-version = "py312"
|
|
72
|
+
extend-exclude = ["docs"]
|
|
73
|
+
|
|
74
|
+
[tool.ruff.lint]
|
|
75
|
+
select = [
|
|
76
|
+
"E",
|
|
77
|
+
"W",
|
|
78
|
+
"F",
|
|
79
|
+
"I",
|
|
80
|
+
"B",
|
|
81
|
+
"UP",
|
|
82
|
+
"SIM",
|
|
83
|
+
"RUF",
|
|
84
|
+
"PT",
|
|
85
|
+
"N",
|
|
86
|
+
"C4",
|
|
87
|
+
"PIE",
|
|
88
|
+
"RET",
|
|
89
|
+
"TC",
|
|
90
|
+
]
|
|
91
|
+
extend-select = [
|
|
92
|
+
"D",
|
|
93
|
+
"ANN",
|
|
94
|
+
"DOC201",
|
|
95
|
+
"DOC202",
|
|
96
|
+
"DOC402",
|
|
97
|
+
"DOC403",
|
|
98
|
+
"DOC501",
|
|
99
|
+
]
|
|
100
|
+
preview = true
|
|
101
|
+
explicit-preview-rules = true
|
|
102
|
+
ignore = [
|
|
103
|
+
"D105",
|
|
104
|
+
"D107",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[tool.ruff.lint.pydocstyle]
|
|
108
|
+
convention = "google"
|
|
109
|
+
|
|
110
|
+
[tool.ruff.lint.per-file-ignores]
|
|
111
|
+
"!src/**" = [
|
|
112
|
+
"D",
|
|
113
|
+
"ANN",
|
|
114
|
+
"DOC",
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
[tool.ruff.format]
|
|
118
|
+
docstring-code-format = true
|
|
119
|
+
|
|
120
|
+
[tool.ty.environment]
|
|
121
|
+
python-version = "3.12"
|
|
122
|
+
|
|
123
|
+
[tool.ty.src]
|
|
124
|
+
exclude = ["docs"]
|
|
125
|
+
|
|
126
|
+
[tool.pytest.ini_options]
|
|
127
|
+
testpaths = [
|
|
128
|
+
"tests",
|
|
129
|
+
"src",
|
|
130
|
+
]
|
|
131
|
+
addopts = [
|
|
132
|
+
"--strict-markers",
|
|
133
|
+
"-m",
|
|
134
|
+
"not hardware",
|
|
135
|
+
"--doctest-modules",
|
|
136
|
+
]
|
|
137
|
+
markers = [
|
|
138
|
+
"hardware: needs a real sign; set ALPHA_SIGN_PORT and run with -m hardware",
|
|
139
|
+
"emulator: runs the hardware tests against the emulator; needs Node and npm ci in emulator/",
|
|
140
|
+
"witness: asks the person watching the sign; set ALPHA_SIGN_WITNESS=1 and run with -m witness -s",
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
[tool.coverage.run]
|
|
144
|
+
source = ["alpha_led_sign"]
|
|
145
|
+
branch = true
|
|
146
|
+
|
|
147
|
+
[tool.coverage.report]
|
|
148
|
+
show_missing = true
|
|
149
|
+
skip_covered = true
|
|
150
|
+
exclude_also = [
|
|
151
|
+
"if TYPE_CHECKING:",
|
|
152
|
+
"@overload",
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
[tool.git-cliff.bump]
|
|
156
|
+
features_always_bump_minor = false
|
|
157
|
+
breaking_always_bump_major = false
|
|
158
|
+
initial_tag = "0.1.0"
|
|
159
|
+
|
|
160
|
+
[tool.git-cliff.changelog]
|
|
161
|
+
header = """
|
|
162
|
+
# Changelog
|
|
163
|
+
|
|
164
|
+
All notable changes to this project will be documented in this file.
|
|
165
|
+
|
|
166
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
167
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
|
|
168
|
+
(see [ADR 0001](docs/adr/0001-semantic-versioning.md)).
|
|
169
|
+
"""
|
|
170
|
+
body = """
|
|
171
|
+
{% if version -%}
|
|
172
|
+
## [{{ version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
|
173
|
+
{% else -%}
|
|
174
|
+
## [Unreleased]
|
|
175
|
+
{% endif -%}
|
|
176
|
+
{% for group, commits in commits | group_by(attribute="group") %}
|
|
177
|
+
### {{ group | striptags | trim }}
|
|
178
|
+
{% for commit in commits %}
|
|
179
|
+
- {% if commit.breaking %}**Breaking:** {% endif %}{{ commit.message | split(pat="
|
|
180
|
+
") | first | trim | upper_first }}{% if commit.breaking and commit.breaking_description and commit.breaking_description | trim != commit.message | split(pat="
|
|
181
|
+
") | first | trim %}
|
|
182
|
+
- {{ commit.breaking_description | trim | upper_first }}{% endif %}{% endfor %}
|
|
183
|
+
{% endfor %}
|
|
184
|
+
"""
|
|
185
|
+
trim = false
|
|
186
|
+
|
|
187
|
+
[tool.git-cliff.git]
|
|
188
|
+
conventional_commits = true
|
|
189
|
+
filter_unconventional = true
|
|
190
|
+
split_commits = false
|
|
191
|
+
protect_breaking_commits = true
|
|
192
|
+
filter_commits = false
|
|
193
|
+
tag_pattern = '^[0-9]+\.[0-9]+\.[0-9]+$'
|
|
194
|
+
sort_commits = "oldest"
|
|
195
|
+
|
|
196
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
197
|
+
message = '^build\(release\)'
|
|
198
|
+
skip = true
|
|
199
|
+
|
|
200
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
201
|
+
message = '^fix\(security\)'
|
|
202
|
+
group = "<!-- 5 -->Security"
|
|
203
|
+
|
|
204
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
205
|
+
message = '^(feat|fix|perf)(\(.*\))?!?: [Dd]eprecate'
|
|
206
|
+
group = "<!-- 2 -->Deprecated"
|
|
207
|
+
|
|
208
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
209
|
+
message = '^(feat|fix|perf)(\(.*\))?!?: ([Rr]emove|[Dd]rop)'
|
|
210
|
+
group = "<!-- 3 -->Removed"
|
|
211
|
+
|
|
212
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
213
|
+
message = "^feat"
|
|
214
|
+
group = "<!-- 0 -->Added"
|
|
215
|
+
|
|
216
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
217
|
+
message = "^perf"
|
|
218
|
+
group = "<!-- 1 -->Changed"
|
|
219
|
+
|
|
220
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
221
|
+
message = "^fix"
|
|
222
|
+
group = "<!-- 4 -->Fixed"
|
|
223
|
+
|
|
224
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
225
|
+
field = "breaking"
|
|
226
|
+
pattern = "true"
|
|
227
|
+
group = "<!-- 1 -->Changed"
|
|
228
|
+
|
|
229
|
+
[[tool.git-cliff.git.commit_parsers]]
|
|
230
|
+
message = ".*"
|
|
231
|
+
skip = true
|
|
232
|
+
|
|
233
|
+
[tool.uv.sources.alpha-led-sign]
|
|
234
|
+
workspace = true
|