feat: Add support for cycle effect in CLI client
- apply_tag_color() now uses reader.apply_effect() with speed param - on_tag_remove() properly stops cycle effect before turning off pad - Updated help text to document "cycle" effect option - Works with tag_colors.json: set "effect": "cycle" for revolving lights
This commit is contained in:
+14
-16
@@ -260,21 +260,9 @@ def portal_mode(server_ip, port):
|
|||||||
if name:
|
if name:
|
||||||
print(f" Theme: {name}")
|
print(f" Theme: {name}")
|
||||||
|
|
||||||
# Calculate timing based on speed
|
# Apply effect using the new apply_effect method
|
||||||
base_time = 10 # Base ticks (~50ms each)
|
# For cycle effect, it automatically uses all pads
|
||||||
on_time = int(base_time * speed)
|
reader.apply_effect(pad, color, effect, speed)
|
||||||
off_time = int(base_time * speed)
|
|
||||||
|
|
||||||
# Apply effect to ONLY the specific pad where tag is placed
|
|
||||||
if effect == 'pulse':
|
|
||||||
# Slow pulsing fade on specific pad (count=255 for continuous)
|
|
||||||
reader.fade_pad(pad, color, speed=int(15 * speed), count=255)
|
|
||||||
elif effect == 'flash':
|
|
||||||
# Quick flashing on specific pad
|
|
||||||
reader.flash_pad(pad, color, on_time=on_time, off_time=off_time, count=255)
|
|
||||||
else:
|
|
||||||
# Solid color on specific pad
|
|
||||||
reader.set_pad_color(pad, color)
|
|
||||||
|
|
||||||
def on_tag_insert(tag: TagInfo):
|
def on_tag_insert(tag: TagInfo):
|
||||||
nonlocal last_sent_key, last_sent_time
|
nonlocal last_sent_key, last_sent_time
|
||||||
@@ -327,8 +315,12 @@ def portal_mode(server_ip, port):
|
|||||||
if tag.pad.value in active_pads:
|
if tag.pad.value in active_pads:
|
||||||
del active_pads[tag.pad.value]
|
del active_pads[tag.pad.value]
|
||||||
|
|
||||||
# Turn off ONLY this pad's LED (not all pads!)
|
# Stop any effects and turn off ONLY this pad's LED (not all pads!)
|
||||||
if reader:
|
if reader:
|
||||||
|
# Stop cycle effect if running (it uses all pads)
|
||||||
|
reader.stop_cycle_effect()
|
||||||
|
# Stop individual pad effect and turn off
|
||||||
|
reader.stop_effect(tag.pad)
|
||||||
reader.set_pad_color(tag.pad, COLORS['OFF'])
|
reader.set_pad_color(tag.pad, COLORS['OFF'])
|
||||||
|
|
||||||
def on_connect():
|
def on_connect():
|
||||||
@@ -441,6 +433,12 @@ Examples:
|
|||||||
|
|
||||||
# Use different server
|
# Use different server
|
||||||
python dimensions_cli_client.py -s 192.168.1.100 -p 8547
|
python dimensions_cli_client.py -s 192.168.1.100 -p 8547
|
||||||
|
|
||||||
|
Effects in tag_colors.json:
|
||||||
|
"solid" - Constant color on the pad
|
||||||
|
"flash" - Blinking effect
|
||||||
|
"pulse" - Breathing/fading effect
|
||||||
|
"cycle" - Revolving lights across all pads (police lights!)
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user