uwscli 0.2.0__tar.gz → 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.
Files changed (31) hide show
  1. {uwscli-0.2.0/src/uwscli.egg-info → uwscli-0.3.0}/PKG-INFO +25 -6
  2. {uwscli-0.2.0 → uwscli-0.3.0}/README.md +24 -5
  3. {uwscli-0.2.0 → uwscli-0.3.0}/pyproject.toml +4 -1
  4. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/__init__.py +2 -1
  5. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/cli.py +104 -15
  6. uwscli-0.3.0/src/uwscli/data/__init__.py +0 -0
  7. uwscli-0.3.0/src/uwscli/data/twinkle.bin +0 -0
  8. uwscli-0.3.0/src/uwscli/tl_effects.py +1355 -0
  9. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/wireless.py +138 -22
  10. {uwscli-0.2.0 → uwscli-0.3.0/src/uwscli.egg-info}/PKG-INFO +25 -6
  11. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli.egg-info/SOURCES.txt +3 -0
  12. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_cli_output.py +221 -10
  13. {uwscli-0.2.0 → uwscli-0.3.0}/LICENSE +0 -0
  14. {uwscli-0.2.0 → uwscli-0.3.0}/setup.cfg +0 -0
  15. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/lcd.py +0 -0
  16. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/led.py +0 -0
  17. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/logging_utils.py +0 -0
  18. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/structs.py +0 -0
  19. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/system_usb.py +0 -0
  20. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/tinyuz.py +0 -0
  21. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/tlcontroller.py +0 -0
  22. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli/usbutil.py +0 -0
  23. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli.egg-info/dependency_links.txt +0 -0
  24. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli.egg-info/entry_points.txt +0 -0
  25. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli.egg-info/requires.txt +0 -0
  26. {uwscli-0.2.0 → uwscli-0.3.0}/src/uwscli.egg-info/top_level.txt +0 -0
  27. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_cli_errors.py +0 -0
  28. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_led_compression.py +0 -0
  29. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_usbutil.py +0 -0
  30. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_wireless_integration.py +0 -0
  31. {uwscli-0.2.0 → uwscli-0.3.0}/tests/test_wireless_led_packets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uwscli
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Uni-Wireless-Sync: wireless control toolkit for TL LCD fan hubs
5
5
  Author: Study Hsueh
6
6
  License: MIT License
@@ -80,10 +80,7 @@ Other Uni Fan series are currently not supported.
80
80
  - Send one-shot PWM commands to TL wireless fans over the 2.4 GHz dongle.
81
81
  - Bind or unbind wireless hubs against the active master controller.
82
82
  - Toggle motherboard PWM sync mode for one hub or every bound hub.
83
-
84
- ## Roadmap
85
-
86
- - Broadcast static RGB payloads to wireless hubs (CLI command not yet implemented).
83
+ - Broadcast static RGB payloads to wireless hubs (experimental).
87
84
 
88
85
  ## Installation
89
86
 
@@ -130,7 +127,29 @@ uws fan pwm-sync --mac aa:bb:cc:dd:ee:ff --once
130
127
  - `uws lcd control --serial <usb-serial> [--mode show-jpg|show-app-sync|lcd-test] [--jpg-index N] [--brightness 0-100] [--fps N] [--rotation 0|90|180|270] [--test-color R,G,B]` – send an `LCDControlSetting` payload.
131
128
  - `uws fan list` – fetch a snapshot of bound wireless devices via the RF receiver.
132
129
  - `uws fan set-fan --mac <aa:bb:..> --pwm <0-255>` – send a single shot PWM update to the matching wireless hub using the RF sender.
133
- - `uws fan set-led --mac <aa:bb:..> --mode static|rainbow|frames` – apply LED effects (experimental).
130
+ - `uws fan set-led --mac <aa:bb:..> --mode static|rainbow|frames|effect|random-effect` – apply wireless LED effects (**experimental**).
131
+
132
+ ### `uws fan set-led` modes
133
+
134
+ - `static`: requires `--color R,G,B` or `--color-list R,G,B;...` to paint the LED strip once.
135
+ - `rainbow`: procedural rainbow; optional `--frames N` (default 24) and `--interval-ms` (default 50).
136
+ - `frames`: feed a JSON animation via `--frames-file`. Each frame is an array of `[R, G, B]` triples; see `examples/tl_frames_sample.json` for a minimal illustration (the CLI will pad or truncate per device LED count).
137
+ - `effect`: drives any of the 29 TL presets. Choose an effect with `--effect <name>` (e.g. `twinkle`, `meteor_shower`), adjust brightness 0‑255 via `--effect-brightness`, pick direction with `--effect-direction 0|1`, and select which segment to update using `--effect-scope front|behind|both` (default `both`).
138
+ - `random-effect`: picks a random preset each time; accepts the same brightness/direction/scope flags as `effect`.
139
+
140
+ Available effect names (case-insensitive): `rainbow`, `rainbow_morph`, `static_color`, `breathing`, `runway`, `meteor`, `color_cycle`, `staggered`, `tide`, `mixing`, `voice`, `door`, `render`, `ripple`, `reflect`, `tail_chasing`, `paint`, `ping_pong`, `stack`, `cover_cycle`, `wave`, `racing`, `lottery`, `intertwine`, `meteor_shower`, `collide`, `electric_current`, `kaleidoscope`, `twinkle`.
141
+
142
+ Example:
143
+
144
+ ```
145
+ uws fan set-led --mac aa:bb:cc:dd:ee:ff --mode effect --effect twinkle --effect-brightness 180 --effect-direction 0 --effect-scope both
146
+ ```
147
+
148
+ Random example:
149
+
150
+ ```
151
+ uws fan set-led --mac aa:bb:cc:dd:ee:ff --mode random-effect --effect-brightness 200 --effect-direction 1
152
+ ```
134
153
  - `uws fan pwm-sync --all|--mac [--once]` – mirror motherboard PWM output to bound hubs (looping by default, single iteration with `--once`).
135
154
 
136
155
  ## Dependencies
@@ -23,10 +23,7 @@ Other Uni Fan series are currently not supported.
23
23
  - Send one-shot PWM commands to TL wireless fans over the 2.4 GHz dongle.
24
24
  - Bind or unbind wireless hubs against the active master controller.
25
25
  - Toggle motherboard PWM sync mode for one hub or every bound hub.
26
-
27
- ## Roadmap
28
-
29
- - Broadcast static RGB payloads to wireless hubs (CLI command not yet implemented).
26
+ - Broadcast static RGB payloads to wireless hubs (experimental).
30
27
 
31
28
  ## Installation
32
29
 
@@ -73,7 +70,29 @@ uws fan pwm-sync --mac aa:bb:cc:dd:ee:ff --once
73
70
  - `uws lcd control --serial <usb-serial> [--mode show-jpg|show-app-sync|lcd-test] [--jpg-index N] [--brightness 0-100] [--fps N] [--rotation 0|90|180|270] [--test-color R,G,B]` – send an `LCDControlSetting` payload.
74
71
  - `uws fan list` – fetch a snapshot of bound wireless devices via the RF receiver.
75
72
  - `uws fan set-fan --mac <aa:bb:..> --pwm <0-255>` – send a single shot PWM update to the matching wireless hub using the RF sender.
76
- - `uws fan set-led --mac <aa:bb:..> --mode static|rainbow|frames` – apply LED effects (experimental).
73
+ - `uws fan set-led --mac <aa:bb:..> --mode static|rainbow|frames|effect|random-effect` – apply wireless LED effects (**experimental**).
74
+
75
+ ### `uws fan set-led` modes
76
+
77
+ - `static`: requires `--color R,G,B` or `--color-list R,G,B;...` to paint the LED strip once.
78
+ - `rainbow`: procedural rainbow; optional `--frames N` (default 24) and `--interval-ms` (default 50).
79
+ - `frames`: feed a JSON animation via `--frames-file`. Each frame is an array of `[R, G, B]` triples; see `examples/tl_frames_sample.json` for a minimal illustration (the CLI will pad or truncate per device LED count).
80
+ - `effect`: drives any of the 29 TL presets. Choose an effect with `--effect <name>` (e.g. `twinkle`, `meteor_shower`), adjust brightness 0‑255 via `--effect-brightness`, pick direction with `--effect-direction 0|1`, and select which segment to update using `--effect-scope front|behind|both` (default `both`).
81
+ - `random-effect`: picks a random preset each time; accepts the same brightness/direction/scope flags as `effect`.
82
+
83
+ Available effect names (case-insensitive): `rainbow`, `rainbow_morph`, `static_color`, `breathing`, `runway`, `meteor`, `color_cycle`, `staggered`, `tide`, `mixing`, `voice`, `door`, `render`, `ripple`, `reflect`, `tail_chasing`, `paint`, `ping_pong`, `stack`, `cover_cycle`, `wave`, `racing`, `lottery`, `intertwine`, `meteor_shower`, `collide`, `electric_current`, `kaleidoscope`, `twinkle`.
84
+
85
+ Example:
86
+
87
+ ```
88
+ uws fan set-led --mac aa:bb:cc:dd:ee:ff --mode effect --effect twinkle --effect-brightness 180 --effect-direction 0 --effect-scope both
89
+ ```
90
+
91
+ Random example:
92
+
93
+ ```
94
+ uws fan set-led --mac aa:bb:cc:dd:ee:ff --mode random-effect --effect-brightness 200 --effect-direction 1
95
+ ```
77
96
  - `uws fan pwm-sync --all|--mac [--once]` – mirror motherboard PWM output to bound hubs (looping by default, single iteration with `--once`).
78
97
 
79
98
  ## Dependencies
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "uwscli"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Uni-Wireless-Sync: wireless control toolkit for TL LCD fan hubs"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -48,6 +48,9 @@ uws = "uwscli.cli:main"
48
48
  where = ["src"]
49
49
  include = ["uwscli", "uwscli.*"]
50
50
 
51
+ [tool.setuptools.package-data]
52
+ "uwscli" = ["data/twinkle.bin"]
53
+
51
54
  [tool.pytest.ini_options]
52
55
  pythonpath = ["src"]
53
56
  addopts = "-ra"
@@ -1,6 +1,6 @@
1
1
  """UWS CLI package."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.3.0"
4
4
 
5
5
  __all__ = [
6
6
  "cli",
@@ -10,4 +10,5 @@ __all__ = [
10
10
  "wireless",
11
11
  "structs",
12
12
  "usbutil",
13
+ "tl_effects",
13
14
  ]
@@ -4,12 +4,13 @@ from __future__ import annotations
4
4
 
5
5
  import argparse
6
6
  import json
7
+ import random
7
8
  import time
8
9
  from importlib import metadata
9
10
  from pathlib import Path
10
11
  from typing import Any, Dict, Iterable, List, Tuple, cast
11
12
 
12
- from . import lcd, tlcontroller, wireless
13
+ from . import lcd, tl_effects, tlcontroller, wireless
13
14
  from .logging_utils import configure_logging
14
15
  from .structs import LCDControlSetting, ScreenRotation, clamp_pwm_values
15
16
 
@@ -146,6 +147,8 @@ def build_parser() -> argparse.ArgumentParser:
146
147
  help="Sequence index used by the RF command (default: 1)",
147
148
  )
148
149
 
150
+ effect_names = sorted(effect.name.lower() for effect in tl_effects.TLEffects)
151
+
149
152
  set_led_parser = fan_sub.add_parser(
150
153
  "set-led", help="Set LED effects on wireless hubs"
151
154
  )
@@ -158,7 +161,7 @@ def build_parser() -> argparse.ArgumentParser:
158
161
  )
159
162
  set_led_parser.add_argument(
160
163
  "--mode",
161
- choices=["static", "rainbow", "frames"],
164
+ choices=["static", "rainbow", "frames", "effect", "random-effect"],
162
165
  default="static",
163
166
  help="LED effect mode (default: static)",
164
167
  )
@@ -170,12 +173,6 @@ def build_parser() -> argparse.ArgumentParser:
170
173
  "--color-list",
171
174
  help="Semicolon separated RGB triples for per-LED or per-fan colors in static mode",
172
175
  )
173
- set_led_parser.add_argument(
174
- "--dict-size",
175
- type=int,
176
- default=4096,
177
- help="Dictionary size used for TinyUZ compression (default: 4096)",
178
- )
179
176
  set_led_parser.add_argument(
180
177
  "--frames",
181
178
  type=int,
@@ -193,6 +190,30 @@ def build_parser() -> argparse.ArgumentParser:
193
190
  type=Path,
194
191
  help="JSON file describing animation frames for frames mode",
195
192
  )
193
+ set_led_parser.add_argument(
194
+ "--effect",
195
+ choices=effect_names,
196
+ help="TL effect name to apply when mode=effect",
197
+ )
198
+ set_led_parser.add_argument(
199
+ "--effect-brightness",
200
+ type=int,
201
+ default=255,
202
+ help="Brightness (0-255) applied when mode=effect (default: 255)",
203
+ )
204
+ set_led_parser.add_argument(
205
+ "--effect-direction",
206
+ type=int,
207
+ choices=[0, 1],
208
+ default=1,
209
+ help="Direction for TL effects (0=reverse, 1=forward; default: 1)",
210
+ )
211
+ set_led_parser.add_argument(
212
+ "--effect-scope",
213
+ choices=["front", "behind", "both"],
214
+ default="both",
215
+ help="Fan segment for TL effects (front, behind, or both; default: both)",
216
+ )
196
217
 
197
218
  bind_parser = fan_sub.add_parser(
198
219
  "bind", help="Bind an unlinked wireless hub to the current master"
@@ -498,6 +519,9 @@ def handle_fan(args: argparse.Namespace) -> None:
498
519
  else:
499
520
  targets = [args.mac]
500
521
  results: List[Dict[str, Any]] = []
522
+ selected_random_effect = None
523
+ if args.mode == "random-effect":
524
+ selected_random_effect = random.choice(list(tl_effects.TLEffects))
501
525
  with wireless.WirelessTransceiver() as tx:
502
526
  for mac in targets:
503
527
  text: str
@@ -517,12 +541,10 @@ def handle_fan(args: argparse.Namespace) -> None:
517
541
  mac,
518
542
  base_color,
519
543
  color_list=colors,
520
- dict_size=args.dict_size,
521
544
  )
522
545
  payload = {
523
546
  "mac": mac,
524
547
  "mode": "static",
525
- "dict_size": args.dict_size,
526
548
  }
527
549
  if base_color is not None:
528
550
  payload["color"] = list(base_color)
@@ -536,16 +558,78 @@ def handle_fan(args: argparse.Namespace) -> None:
536
558
  mac,
537
559
  frames=frames,
538
560
  interval_ms=interval_ms,
539
- dict_size=args.dict_size,
540
561
  )
541
562
  payload = {
542
563
  "mac": mac,
543
564
  "mode": "rainbow",
544
565
  "frames": frames,
545
566
  "interval_ms": interval_ms,
546
- "dict_size": args.dict_size,
547
567
  }
548
568
  text = f"Applied rainbow LED effect to {mac}"
569
+ elif args.mode == "effect":
570
+ if not args.effect:
571
+ raise SystemExit(
572
+ "--effect must be provided when mode=effect"
573
+ )
574
+ effect = tl_effects.TLEffects[args.effect.upper()]
575
+ brightness = max(0, min(255, args.effect_brightness))
576
+ direction = int(args.effect_direction)
577
+ if args.effect_scope == "front":
578
+ tb = 0
579
+ elif args.effect_scope == "behind":
580
+ tb = 1
581
+ else:
582
+ tb = None
583
+ interval_ms = max(1, args.interval_ms)
584
+ tx.set_led_effect(
585
+ mac,
586
+ effect,
587
+ tb=tb,
588
+ brightness=brightness,
589
+ direction=direction,
590
+ interval_ms=interval_ms,
591
+ )
592
+ payload = {
593
+ "mac": mac,
594
+ "mode": "effect",
595
+ "effect": effect.name,
596
+ "brightness": brightness,
597
+ "direction": direction,
598
+ "scope": args.effect_scope,
599
+ "interval_ms": interval_ms,
600
+ }
601
+ text = f"Applied TL effect {effect.name} to {mac}"
602
+ elif args.mode == "random-effect":
603
+ brightness = max(0, min(255, args.effect_brightness))
604
+ direction = int(args.effect_direction)
605
+ if args.effect_scope == "front":
606
+ tb = 0
607
+ elif args.effect_scope == "behind":
608
+ tb = 1
609
+ else:
610
+ tb = None
611
+ effect = selected_random_effect or random.choice(
612
+ list(tl_effects.TLEffects)
613
+ )
614
+ interval_ms = max(1, args.interval_ms)
615
+ tx.set_led_effect(
616
+ mac,
617
+ effect,
618
+ tb=tb,
619
+ brightness=brightness,
620
+ direction=direction,
621
+ interval_ms=interval_ms,
622
+ )
623
+ payload = {
624
+ "mac": mac,
625
+ "mode": "random-effect",
626
+ "effect": effect.name,
627
+ "brightness": brightness,
628
+ "direction": direction,
629
+ "scope": args.effect_scope,
630
+ "interval_ms": interval_ms,
631
+ }
632
+ text = f"Applied random TL effect {effect.name} to {mac}"
549
633
  else:
550
634
  if not args.frames_file:
551
635
  raise SystemExit(
@@ -557,25 +641,30 @@ def handle_fan(args: argparse.Namespace) -> None:
557
641
  mac,
558
642
  frame_list,
559
643
  interval_ms=interval_ms,
560
- dict_size=args.dict_size,
561
644
  )
562
645
  payload = {
563
646
  "mac": mac,
564
647
  "mode": "frames",
565
648
  "frames": len(frame_list),
566
649
  "interval_ms": interval_ms,
567
- "dict_size": args.dict_size,
568
650
  }
569
651
  text = f"Applied custom LED frames to {mac}"
570
652
  results.append(payload)
571
653
  overall = {
572
654
  "targets": targets,
573
655
  "mode": args.mode,
574
- "dict_size": args.dict_size,
575
656
  }
576
657
  if args.mode == "rainbow":
577
658
  overall["frames"] = max(1, args.frames)
578
659
  overall["interval_ms"] = max(1, args.interval_ms)
660
+ elif args.mode in {"effect", "random-effect"}:
661
+ if args.mode == "random-effect":
662
+ overall["effect"] = (
663
+ selected_random_effect.name if selected_random_effect else None
664
+ )
665
+ else:
666
+ overall["effect"] = args.effect.upper() if args.effect else None
667
+ overall["interval_ms"] = max(1, args.interval_ms)
579
668
  elif args.mode == "frames":
580
669
  overall["frames_file"] = str(args.frames_file)
581
670
  overall["interval_ms"] = max(1, args.interval_ms)
File without changes
Binary file