#!/usr/bin/env python3 """Entry point for the Raspberry Pi Touchscreen Mixer UI. A Kivy-based multi-touch mixer control surface for the Raspberry Pi RT Audio Mixer. Connects to the mixer engine via REST API + OSC. Usage: python3 main_touch.py python3 main_touch.py --host 192.168.1.10 --port 8000 python3 main_touch.py --api-key my-secret-key KIVY_DPI=220 python3 main_touch.py """ from __future__ import annotations import argparse import os import sys def main(): parser = argparse.ArgumentParser( description="Raspberry Pi Touchscreen Mixer UI", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" Examples: %(prog)s # local mixer on :8000 %(prog)s --host 192.168.1.10 # remote mixer %(prog)s --host 127.0.0.1 --api-key abc123 # with auth KIVY_DPI=220 %(prog)s # force 220 DPI Environment: MIXER_HOST mixer hostname (default 127.0.0.1) MIXER_PORT REST API port (default 8000) MIXER_OSC_PORT OSC server port (default 9001) MIXER_API_KEY API key for authentication KIVY_DPI force screen DPI (auto-detected otherwise) """, ) parser.add_argument( "--host", default=os.environ.get("MIXER_HOST", "127.0.0.1"), help="Mixer server hostname (default: 127.0.0.1)", ) parser.add_argument( "--port", type=int, default=int(os.environ.get("MIXER_PORT", "8000")), help="REST API port (default: 8000)", ) parser.add_argument( "--osc-port", type=int, default=int(os.environ.get("MIXER_OSC_PORT", "9001")), help="OSC server port (default: 9001)", ) parser.add_argument( "--api-key", default=os.environ.get("MIXER_API_KEY", ""), help="API key for mixer authentication", ) args = parser.parse_args() # Ensure src is on the path project_root = os.path.dirname(os.path.abspath(__file__)) if project_root not in sys.path: sys.path.insert(0, project_root) # Import Kivy app (late import after CLI parsing) from src.ui.app import MixerApp app = MixerApp( host=args.host, rest_port=args.port, osc_port=args.osc_port, api_key=args.api_key, ) print(f"Starting touchscreen mixer UI...") print(f" Mixer server: {args.host}:{args.port}") print(f" OSC server: {args.host}:{args.osc_port}") print(f" Touch to begin. ESC to cycle screens.") print() app.run() if __name__ == "__main__": main()