run.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. # Development runner - uses the virtual environment
  3. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  4. # Check if virtual environment exists
  5. if [ ! -d "$SCRIPT_DIR/venv" ]; then
  6. echo "❌ Virtual environment not found!"
  7. echo " Run: sudo ./install.sh"
  8. echo " Or manually create: python3 -m venv venv && venv/bin/pip install -r requirements.txt"
  9. exit 1
  10. fi
  11. # Check if backend is running at localhost:8080
  12. echo "🔍 Checking backend availability at localhost:8080..."
  13. BACKEND_URL="http://localhost:8080"
  14. MAX_ATTEMPTS=30
  15. ATTEMPT=0
  16. while [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do
  17. if curl -s --connect-timeout 2 "$BACKEND_URL/serial_status" > /dev/null 2>&1; then
  18. echo "✅ Backend is available at localhost:8080"
  19. break
  20. else
  21. ATTEMPT=$((ATTEMPT + 1))
  22. if [ $ATTEMPT -eq 1 ]; then
  23. echo "⏳ Waiting for backend to become available..."
  24. echo " Make sure the main Dune Weaver application is running"
  25. echo " Attempting connection ($ATTEMPT/$MAX_ATTEMPTS)..."
  26. elif [ $((ATTEMPT % 5)) -eq 0 ]; then
  27. echo " Still waiting... ($ATTEMPT/$MAX_ATTEMPTS)"
  28. fi
  29. sleep 1
  30. fi
  31. done
  32. if [ $ATTEMPT -eq $MAX_ATTEMPTS ]; then
  33. echo "❌ Backend not available after $MAX_ATTEMPTS attempts"
  34. echo " Please ensure the main Dune Weaver application is running at localhost:8080"
  35. echo " You can start it with: cd .. && python main.py"
  36. exit 1
  37. fi
  38. # Run the application using the virtual environment
  39. echo ""
  40. echo "🚀 Starting Dune Weaver Touch (development mode)"
  41. echo " Using virtual environment: $SCRIPT_DIR/venv"
  42. echo " Connected to backend: $BACKEND_URL"
  43. echo " Press Ctrl+C to stop"
  44. echo ""
  45. cd "$SCRIPT_DIR"
  46. # Set Qt platform to linuxfb for Raspberry Pi compatibility
  47. export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0
  48. export QT_QPA_FONTDIR=/usr/share/fonts
  49. # Touch rotation is now handled by QML transform - don't rotate evdev input
  50. # (Rotation happens in main.qml via transform: Rotation)
  51. exec ./venv/bin/python main.py