- Process 't' field to distinguish between beat ('b') and update ('u') messages - Beat messages: execute pattern immediately using current parameters - Update messages: only update parameters, don't execute pattern - Maintains backward compatibility with default to beat if 't' not specified - Enables proper synchronization between controller and bars
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
LED Bar Configuration Script
|
|
Updates the settings.json file for each LED bar with its unique name
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
|
|
# LED Bar names/IDs
|
|
LED_BAR_NAMES = ["100", "101", "102", "103", "104", "105", "106", "107"]
|
|
|
|
def update_bar_settings(bar_name, settings_file="settings.json"):
|
|
"""Update the settings.json file with the bar name"""
|
|
if not os.path.exists(settings_file):
|
|
print(f"Error: {settings_file} not found")
|
|
return False
|
|
|
|
# Read current settings
|
|
with open(settings_file, 'r') as f:
|
|
settings = json.load(f)
|
|
|
|
# Update the name
|
|
settings["name"] = bar_name
|
|
|
|
# Write back to file
|
|
with open(settings_file, 'w') as f:
|
|
json.dump(settings, f, indent=4)
|
|
|
|
print(f"Updated {settings_file} with name: {bar_name}")
|
|
return True
|
|
|
|
def main():
|
|
print("LED Bar Configuration Script")
|
|
print("=" * 40)
|
|
print("Available bar names:", LED_BAR_NAMES)
|
|
print()
|
|
|
|
while True:
|
|
print("Enter bar name to configure (or 'quit' to exit):")
|
|
bar_name = input("> ").strip()
|
|
|
|
if bar_name.lower() == 'quit':
|
|
break
|
|
|
|
if bar_name not in LED_BAR_NAMES:
|
|
print(f"Invalid bar name. Must be one of: {LED_BAR_NAMES}")
|
|
continue
|
|
|
|
if update_bar_settings(bar_name):
|
|
print(f"Successfully configured LED bar as '{bar_name}'")
|
|
else:
|
|
print("Failed to update settings")
|
|
|
|
print()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|