-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_rpi.sh
More file actions
152 lines (127 loc) · 3.72 KB
/
Copy pathsetup_rpi.sh
File metadata and controls
152 lines (127 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
# Raspberry Pi optimization script for Art-Net Controller
echo "Optimizing Art-Net Controller for Raspberry Pi..."
# Update system
echo "Updating system packages..."
sudo apt update
# Install system dependencies
echo "Installing system dependencies..."
sudo apt install -y python3-pip python3-venv python3-dev
sudo apt install -y libqt6-dev qt6-base-dev
sudo apt install -y libasound2-dev portaudio19-dev
# Install GPIO library for Pi
echo "Installing Raspberry Pi GPIO library..."
pip install RPi.GPIO
# Create performance optimization config
echo "Creating performance optimization config..."
cat > rpi_config.json << EOF
{
"performance": {
"gui_refresh_rate": 15,
"dmx_refresh_rate": 20,
"max_memory_usage": 256,
"enable_gpu_acceleration": false,
"reduce_logging": true
},
"artnet": {
"max_universes": 4,
"buffer_size": 1024,
"send_threaded": true
},
"webserver": {
"max_file_size": 25,
"thread_count": 2
}
}
EOF
# Create systemd service for auto-start
echo "Creating systemd service..."
sudo tee /etc/systemd/system/artnet-controller.service > /dev/null << EOF
[Unit]
Description=Art-Net Controller
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/ArtNetController
ExecStart=/home/pi/ArtNetController/venv/bin/python run.py --no-debug
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
# Enable GPU memory split for better performance
echo "Configuring GPU memory split..."
if ! grep -q "gpu_mem=64" /boot/config.txt; then
echo "gpu_mem=64" | sudo tee -a /boot/config.txt
fi
# Optimize network settings for Art-Net
echo "Optimizing network settings..."
sudo tee -a /etc/sysctl.conf > /dev/null << EOF
# Art-Net Controller optimizations
net.core.rmem_max = 134217728
net.core.rmem_default = 65536
net.core.wmem_max = 134217728
net.core.wmem_default = 65536
net.core.netdev_max_backlog = 5000
EOF
# Create Pi-specific launch script
cat > run_pi.py << 'EOF'
#!/usr/bin/env python3
"""
Raspberry Pi optimized launcher for Art-Net Controller
"""
import os
import sys
import platform
from pathlib import Path
# Add src directory to Python path
sys.path.insert(0, str(Path(__file__).parent / "src"))
def is_raspberry_pi():
"""Check if running on Raspberry Pi"""
try:
with open('/proc/cpuinfo', 'r') as f:
cpuinfo = f.read()
return 'BCM' in cpuinfo and 'ARM' in platform.machine().upper()
except:
return False
def optimize_for_pi():
"""Apply Pi-specific optimizations"""
# Set environment variables for better Qt performance
os.environ['QT_QPA_PLATFORM'] = 'xcb'
os.environ['QT_QUICK_BACKEND'] = 'software'
# Reduce GUI refresh rate
os.environ['ARTNET_GUI_REFRESH'] = '15'
# Enable reduced logging
os.environ['ARTNET_REDUCED_LOGGING'] = '1'
def main():
"""Main entry point"""
if is_raspberry_pi():
print("Running on Raspberry Pi - applying optimizations...")
optimize_for_pi()
# Import main application
from main import main as app_main
# Run with Pi-optimized settings
sys.argv.extend(['--debug'] if '--debug' in sys.argv else [])
try:
app_main()
except KeyboardInterrupt:
print("\nShutting down gracefully...")
sys.exit(0)
except Exception as e:
print(f"Error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()
EOF
chmod +x run_pi.py
echo "Raspberry Pi optimization complete!"
echo ""
echo "To start the service automatically:"
echo " sudo systemctl enable artnet-controller"
echo " sudo systemctl start artnet-controller"
echo ""
echo "To run manually with Pi optimizations:"
echo " python3 run_pi.py"
echo ""
echo "Note: Reboot recommended to apply all optimizations."