led-ticker 0.3.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.
@@ -0,0 +1,17 @@
1
+ firmware/src/secrets.h
2
+ firmware/wokwi-merged.bin
3
+ .pio
4
+ .vscode/
5
+ __pycache__/
6
+ tools/.ruff_cache/
7
+ tools/uv.lock
8
+ .superpowers/
9
+ specs/
10
+ ios/
11
+ docs/
12
+ .DS_Store
13
+ notes/
14
+ assets/features-landscape.png
15
+ assets/device-sketch-hires.png
16
+ .antigravitycli/
17
+ dist/
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: led-ticker
3
+ Version: 0.3.0
4
+ Summary: Python client library and CLI for the LED-Ticker BLE device
5
+ Project-URL: Homepage, https://github.com/ssayala/esp32-led-simple
6
+ Project-URL: Repository, https://github.com/ssayala/esp32-led-simple
7
+ Author: Sunil Sayala
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: bleak>=0.21
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8; extra == 'dev'
14
+ Description-Content-Type: text/markdown
15
+
16
+ # `led_ticker` — Python library & CLI for the LED Ticker
17
+
18
+ `led_ticker` speaks the same BLE service as the iOS app, so you can drive the
19
+ device — or build your own tools — from any machine with Bluetooth. The device
20
+ advertises as `LED-Ticker-XXXX`.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install led-ticker # or: uv add led-ticker
26
+ ```
27
+
28
+ This installs the importable `led_ticker` package and the `led` command.
29
+ From a checkout you can also run the CLI with no install via uv:
30
+
31
+ ```bash
32
+ uv run tools/led.py <cmd> # uses ./src directly
33
+ ```
34
+
35
+ ## Library
36
+
37
+ ```python
38
+ from led_ticker import LedTicker, scan
39
+
40
+ # Scan for available devices (returns DeviceInfo with name, address, rssi):
41
+ for d in scan():
42
+ print(d.name, d.address, d.rssi)
43
+
44
+ # Reuse one connection for several operations:
45
+ with LedTicker(pin="482913") as d:
46
+ d.set_tickers(["AAPL", "MSFT"])
47
+ d.set_status("BUSY", minutes=30)
48
+ print(d.get_version()) # -> "0.3.0"
49
+ s = d.get_status() # -> Status(text="BUSY", seconds=1800)
50
+
51
+ # Or a one-shot for a single call (opens and closes its own connection):
52
+ import led_ticker
53
+ led_ticker.set_mode(["stocks", "weather"])
54
+ ```
55
+
56
+ `LedTicker(select=None, address=None, name_prefix="LED-Ticker", scan_timeout=4.0, timeout=15.0, pin=None)`.
57
+ By default the first `LED-Ticker-*` in range is used; if several are in range it raises
58
+ `AmbiguousDeviceError` (whose `.candidates` is a list of `DeviceInfo`). Pass `select=` — a
59
+ name suffix (the `XXXX` in `LED-Ticker-XXXX`), full name, or address — to choose one, or
60
+ `address=` to target a known address directly (skips the scan). Methods raise
61
+ `ValidationError`, `AuthError`, `DeviceNotFoundError`, `AmbiguousDeviceError`, or
62
+ `ProtocolError` (all subclasses of `LedTickerError`).
63
+
64
+ ## Selecting a device
65
+
66
+ With more than one LED-Ticker in range, list them and target one explicitly:
67
+
68
+ ```bash
69
+ uv run tools/led.py devices # list units: name, address, signal
70
+ uv run tools/led.py --device A1B2 status "BUSY" 30 # target by name suffix
71
+ ```
72
+
73
+ `--device` matches a unit by its name suffix (the `XXXX` in `LED-Ticker-XXXX`),
74
+ its full name, or its Bluetooth address. If you run a command with several units
75
+ in range and no `--device`, an interactive terminal prompts you to choose; in a
76
+ script (no TTY) it lists the candidates and exits non-zero so you can re-run with
77
+ `--device`.
78
+
79
+ ## CLI
80
+
81
+ ```bash
82
+ # Sign mode
83
+ uv run tools/led.py status "BUSY" 30 # show for 30 min, then auto-clear
84
+ uv run tools/led.py status "ON AIR" # indefinite
85
+ uv run tools/led.py status clear
86
+
87
+ # Timer mode (countdown sign — random animation at zero, then resumes ambient)
88
+ uv run tools/led.py timer 10 # 10-minute countdown
89
+ uv run tools/led.py timer cancel
90
+
91
+ # Ambient mode (subset of stocks/weather/clock, 'all', or 'none' for sign-only)
92
+ uv run tools/led.py mode stocks weather
93
+ uv run tools/led.py mode clock
94
+ uv run tools/led.py mode all
95
+ uv run tools/led.py mode none
96
+
97
+ # Power (volatile — power cycle returns to on)
98
+ uv run tools/led.py power on
99
+ uv run tools/led.py power off
100
+
101
+ # Display settings (persisted on the device)
102
+ uv run tools/led.py display # show current brightness + scroll speed
103
+ uv run tools/led.py display brightness 8 # brightness 0-15
104
+ uv run tools/led.py display speed 50 # scroll ms/step 20-500 (lower = faster)
105
+ uv run tools/led.py display 8 50 # both at once
106
+
107
+ # Timezone (persisted; POSIX TZ string — the iOS app has a friendly picker)
108
+ uv run tools/led.py timezone # show current
109
+ uv run tools/led.py timezone "EST5EDT,M3.2.0,M11.1.0" # US Eastern
110
+
111
+ # Data
112
+ uv run tools/led.py tickers AAPL TSLA NVDA SPY
113
+ uv run tools/led.py locations "47.61,-122.33,Seattle" # lat,lon,label (look up coords online)
114
+ uv run tools/led.py apikey your-finnhub-key
115
+ uv run tools/led.py wifi My Network Name password
116
+
117
+ # Inspect
118
+ uv run tools/led.py get version # firmware version on the device
119
+ uv run tools/led.py get wifi|apikey|tickers|status|locations|mode|power|display|timezone|version # read other settings
120
+
121
+ # Auth
122
+ uv run tools/led.py pin 482913 # save the device's PIN locally (~/.config/led-ticker/pin)
123
+ uv run tools/led.py pin clear # forget the saved PIN
124
+ uv run tools/led.py pin-enforce on # device: require PIN for writes (default after a fresh flash)
125
+ uv run tools/led.py pin-enforce off # device: stop requiring PIN (escape hatch)
126
+
127
+ # Maintenance
128
+ uv run tools/led.py reload # force stock refresh
129
+ uv run tools/led.py reset # wipe NVS, rotate PIN, revert to config.h defaults
130
+ ```
131
+
132
+ Stale-PIN safety: every write probes the device after sending the PIN and exits with a clear error if the PIN was rotated by a factory reset — a write never fails silently because of an out-of-date local PIN.
133
+
134
+ ## License
135
+
136
+ [Apache-2.0](LICENSE) © 2026 Sunil Sayala — free to use, including commercially, with attribution. (The firmware in the parent repo is also Apache-2.0; the hardware design files are CC BY 4.0 — see the [repo root](https://github.com/ssayala/esp32-led-simple).)
@@ -0,0 +1,121 @@
1
+ # `led_ticker` — Python library & CLI for the LED Ticker
2
+
3
+ `led_ticker` speaks the same BLE service as the iOS app, so you can drive the
4
+ device — or build your own tools — from any machine with Bluetooth. The device
5
+ advertises as `LED-Ticker-XXXX`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install led-ticker # or: uv add led-ticker
11
+ ```
12
+
13
+ This installs the importable `led_ticker` package and the `led` command.
14
+ From a checkout you can also run the CLI with no install via uv:
15
+
16
+ ```bash
17
+ uv run tools/led.py <cmd> # uses ./src directly
18
+ ```
19
+
20
+ ## Library
21
+
22
+ ```python
23
+ from led_ticker import LedTicker, scan
24
+
25
+ # Scan for available devices (returns DeviceInfo with name, address, rssi):
26
+ for d in scan():
27
+ print(d.name, d.address, d.rssi)
28
+
29
+ # Reuse one connection for several operations:
30
+ with LedTicker(pin="482913") as d:
31
+ d.set_tickers(["AAPL", "MSFT"])
32
+ d.set_status("BUSY", minutes=30)
33
+ print(d.get_version()) # -> "0.3.0"
34
+ s = d.get_status() # -> Status(text="BUSY", seconds=1800)
35
+
36
+ # Or a one-shot for a single call (opens and closes its own connection):
37
+ import led_ticker
38
+ led_ticker.set_mode(["stocks", "weather"])
39
+ ```
40
+
41
+ `LedTicker(select=None, address=None, name_prefix="LED-Ticker", scan_timeout=4.0, timeout=15.0, pin=None)`.
42
+ By default the first `LED-Ticker-*` in range is used; if several are in range it raises
43
+ `AmbiguousDeviceError` (whose `.candidates` is a list of `DeviceInfo`). Pass `select=` — a
44
+ name suffix (the `XXXX` in `LED-Ticker-XXXX`), full name, or address — to choose one, or
45
+ `address=` to target a known address directly (skips the scan). Methods raise
46
+ `ValidationError`, `AuthError`, `DeviceNotFoundError`, `AmbiguousDeviceError`, or
47
+ `ProtocolError` (all subclasses of `LedTickerError`).
48
+
49
+ ## Selecting a device
50
+
51
+ With more than one LED-Ticker in range, list them and target one explicitly:
52
+
53
+ ```bash
54
+ uv run tools/led.py devices # list units: name, address, signal
55
+ uv run tools/led.py --device A1B2 status "BUSY" 30 # target by name suffix
56
+ ```
57
+
58
+ `--device` matches a unit by its name suffix (the `XXXX` in `LED-Ticker-XXXX`),
59
+ its full name, or its Bluetooth address. If you run a command with several units
60
+ in range and no `--device`, an interactive terminal prompts you to choose; in a
61
+ script (no TTY) it lists the candidates and exits non-zero so you can re-run with
62
+ `--device`.
63
+
64
+ ## CLI
65
+
66
+ ```bash
67
+ # Sign mode
68
+ uv run tools/led.py status "BUSY" 30 # show for 30 min, then auto-clear
69
+ uv run tools/led.py status "ON AIR" # indefinite
70
+ uv run tools/led.py status clear
71
+
72
+ # Timer mode (countdown sign — random animation at zero, then resumes ambient)
73
+ uv run tools/led.py timer 10 # 10-minute countdown
74
+ uv run tools/led.py timer cancel
75
+
76
+ # Ambient mode (subset of stocks/weather/clock, 'all', or 'none' for sign-only)
77
+ uv run tools/led.py mode stocks weather
78
+ uv run tools/led.py mode clock
79
+ uv run tools/led.py mode all
80
+ uv run tools/led.py mode none
81
+
82
+ # Power (volatile — power cycle returns to on)
83
+ uv run tools/led.py power on
84
+ uv run tools/led.py power off
85
+
86
+ # Display settings (persisted on the device)
87
+ uv run tools/led.py display # show current brightness + scroll speed
88
+ uv run tools/led.py display brightness 8 # brightness 0-15
89
+ uv run tools/led.py display speed 50 # scroll ms/step 20-500 (lower = faster)
90
+ uv run tools/led.py display 8 50 # both at once
91
+
92
+ # Timezone (persisted; POSIX TZ string — the iOS app has a friendly picker)
93
+ uv run tools/led.py timezone # show current
94
+ uv run tools/led.py timezone "EST5EDT,M3.2.0,M11.1.0" # US Eastern
95
+
96
+ # Data
97
+ uv run tools/led.py tickers AAPL TSLA NVDA SPY
98
+ uv run tools/led.py locations "47.61,-122.33,Seattle" # lat,lon,label (look up coords online)
99
+ uv run tools/led.py apikey your-finnhub-key
100
+ uv run tools/led.py wifi My Network Name password
101
+
102
+ # Inspect
103
+ uv run tools/led.py get version # firmware version on the device
104
+ uv run tools/led.py get wifi|apikey|tickers|status|locations|mode|power|display|timezone|version # read other settings
105
+
106
+ # Auth
107
+ uv run tools/led.py pin 482913 # save the device's PIN locally (~/.config/led-ticker/pin)
108
+ uv run tools/led.py pin clear # forget the saved PIN
109
+ uv run tools/led.py pin-enforce on # device: require PIN for writes (default after a fresh flash)
110
+ uv run tools/led.py pin-enforce off # device: stop requiring PIN (escape hatch)
111
+
112
+ # Maintenance
113
+ uv run tools/led.py reload # force stock refresh
114
+ uv run tools/led.py reset # wipe NVS, rotate PIN, revert to config.h defaults
115
+ ```
116
+
117
+ Stale-PIN safety: every write probes the device after sending the PIN and exits with a clear error if the PIN was rotated by a factory reset — a write never fails silently because of an out-of-date local PIN.
118
+
119
+ ## License
120
+
121
+ [Apache-2.0](LICENSE) © 2026 Sunil Sayala — free to use, including commercially, with attribution. (The firmware in the parent repo is also Apache-2.0; the hardware design files are CC BY 4.0 — see the [repo root](https://github.com/ssayala/esp32-led-simple).)
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env -S uv run
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # dependencies = ["bleak"]
5
+ # ///
6
+ """Thin entry point for the LED-Ticker CLI.
7
+
8
+ All logic lives in the `led_ticker` package under ./src. This shim keeps the
9
+ historical `uv run tools/led.py <cmd>` invocation working without installing
10
+ the package; `pip install led-ticker` additionally provides a `led` command.
11
+ """
12
+ import pathlib
13
+ import sys
14
+
15
+ sys.path.insert(0, str(pathlib.Path(__file__).parent / "src"))
16
+
17
+ from led_ticker.cli import main # noqa: E402 (path set up above)
18
+
19
+ if __name__ == "__main__":
20
+ sys.exit(main())
@@ -0,0 +1,31 @@
1
+ [project]
2
+ name = "led-ticker"
3
+ version = "0.3.0"
4
+ description = "Python client library and CLI for the LED-Ticker BLE device"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Sunil Sayala" }]
9
+ requires-python = ">=3.11"
10
+ dependencies = ["bleak>=0.21"]
11
+
12
+ [project.urls]
13
+ Homepage = "https://github.com/ssayala/esp32-led-simple"
14
+ Repository = "https://github.com/ssayala/esp32-led-simple"
15
+
16
+ [project.scripts]
17
+ led = "led_ticker.cli:main"
18
+
19
+ [project.optional-dependencies]
20
+ dev = ["pytest>=8"]
21
+
22
+ [build-system]
23
+ requires = ["hatchling"]
24
+ build-backend = "hatchling.build"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["src/led_ticker"]
28
+
29
+ [tool.pytest.ini_options]
30
+ testpaths = ["tests"]
31
+ pythonpath = ["src"]
@@ -0,0 +1,83 @@
1
+ """led_ticker — Python client for the LED-Ticker BLE device."""
2
+ from .client import (
3
+ LedTicker,
4
+ cancel_timer,
5
+ scan,
6
+ clear_status,
7
+ get_apikey,
8
+ get_display,
9
+ get_locations,
10
+ get_mode,
11
+ get_power,
12
+ get_status,
13
+ get_tickers,
14
+ get_timezone,
15
+ get_version,
16
+ get_wifi,
17
+ reload,
18
+ reset,
19
+ set_apikey,
20
+ set_brightness,
21
+ set_display,
22
+ set_locations,
23
+ set_mode,
24
+ set_pin_enforce,
25
+ set_power,
26
+ set_scroll_speed,
27
+ set_status,
28
+ set_tickers,
29
+ set_timer,
30
+ set_timezone,
31
+ set_wifi,
32
+ )
33
+ from .errors import (
34
+ AmbiguousDeviceError,
35
+ AuthError,
36
+ DeviceNotFoundError,
37
+ LedTickerError,
38
+ ProtocolError,
39
+ ValidationError,
40
+ )
41
+ from .protocol import DeviceInfo, Display, Status
42
+
43
+ __all__ = [
44
+ "AmbiguousDeviceError",
45
+ "AuthError",
46
+ "DeviceInfo",
47
+ "DeviceNotFoundError",
48
+ "Display",
49
+ "LedTicker",
50
+ "LedTickerError",
51
+ "ProtocolError",
52
+ "scan",
53
+ "Status",
54
+ "ValidationError",
55
+ # one-shot helpers
56
+ "cancel_timer",
57
+ "clear_status",
58
+ "get_apikey",
59
+ "get_display",
60
+ "get_locations",
61
+ "get_mode",
62
+ "get_power",
63
+ "get_status",
64
+ "get_tickers",
65
+ "get_timezone",
66
+ "get_version",
67
+ "get_wifi",
68
+ "reload",
69
+ "reset",
70
+ "set_apikey",
71
+ "set_brightness",
72
+ "set_display",
73
+ "set_locations",
74
+ "set_mode",
75
+ "set_pin_enforce",
76
+ "set_power",
77
+ "set_scroll_speed",
78
+ "set_status",
79
+ "set_tickers",
80
+ "set_timer",
81
+ "set_timezone",
82
+ "set_wifi",
83
+ ]
@@ -0,0 +1,41 @@
1
+ """PIN resolution and the local PIN cache.
2
+
3
+ Resolution order: explicit override -> LED_TICKER_PIN env var -> cache file.
4
+ The cache path is injectable so tests never touch a real home directory.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import os
9
+ import pathlib
10
+
11
+ DEFAULT_PIN_PATH = pathlib.Path.home() / ".config" / "led-ticker" / "pin"
12
+
13
+
14
+ def resolve_pin(override: str | None = None, *, path: pathlib.Path = DEFAULT_PIN_PATH) -> str | None:
15
+ if override:
16
+ return override.strip()
17
+ env = os.environ.get("LED_TICKER_PIN")
18
+ if env:
19
+ return env.strip()
20
+ if path.exists():
21
+ return path.read_text().strip() or None
22
+ return None
23
+
24
+
25
+ def saved_pin(*, path: pathlib.Path = DEFAULT_PIN_PATH) -> str | None:
26
+ if path.exists():
27
+ return path.read_text().strip() or None
28
+ return None
29
+
30
+
31
+ def save_pin(pin: str, *, path: pathlib.Path = DEFAULT_PIN_PATH) -> None:
32
+ path.parent.mkdir(parents=True, exist_ok=True)
33
+ path.write_text(pin + "\n")
34
+ path.chmod(0o600)
35
+
36
+
37
+ def clear_pin(*, path: pathlib.Path = DEFAULT_PIN_PATH) -> bool:
38
+ if path.exists():
39
+ path.unlink()
40
+ return True
41
+ return False