diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..dc129cc5 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,35 @@ +## Project Overview +This project consists of three main components: +1. **Matrix Control**: There is one controller program for a 128x128 LED matrix. The main entry point is `src_matrix/main.cpp`. +2. **Desktop Application**: The desktop application is based on ImGui and the source code is located in "src_desktop/". The main entry point is `src_desktop/main.cpp`. +3. **React-Native**: This react-native application is used to control the matrix. It'll be used as web version and as mobile app. The source code is in `react_native/`. + +### Plugins +Both the desktop application and the matrix load plugins. The plugins are located in the `plugins/` directory. Each plugin has its own subdirectory, e.g., `plugins/AudioVisualizer/`. Matrix plugins are loaded from `plugins/matrix/`, while desktop plugins are loaded from `plugins/desktop/`. + +### Shared Libraries +The project uses shared libraries for common functionality. There are three shared libraries: +- `common`: Used for common code between the matrix and the desktop application. +- `matrix`: Contains code specific to the matrix controller. +- `desktop`: Contains code specific to the desktop application. + +### Build System +This project uses CMake as the build system and CMake presets are defined in the `CMakePresets.json` file. The presets are used to build the matrix, desktop application, and plugins. +The presets you'll use most often are: +- `emulator`: Builds a emulator of the matrix for testing purposes (this will be compiled with x64 instead of arm64) +- `cross-compile`: Builds the matrix controller application (arm64 cross-compiled for Raspberry Pi) +- `desktop`: Builds the desktop application. +Notice: Use SKIP_WEB_BUILD=ON to skip the web build of the react-native app. This is useful if you haven't made changes to the react-native app and want to speed up the build process. + + +## Matrix Controller +This is the main controller for the LED matrix. It handles the rendering of images, animations, and other visual effects on the matrix. The controller is designed to be run on a Raspberry Pi or similar device. +The controller hosts a web server that allows to control the matrix via a web interface or a mobile app. The web server is implemented using `restinio` and is located in `src_matrix/server/`. +A UDP socket is also listening, this is used to receive data from the desktop application. + +## Desktop Application +The desktop application is built using ImGui and is used to do heavy lifting, such as rendering GPU intensive animations (like GLSL shaders) and host specific visualizations (like the real-time audio visualizer). It communicates with the matrix controller via a UDP socket (for streaming pixel data and custom UDP packets, which share a common class `UdpPacket`). For non-streaming data, it uses a WebSocket connection to the matrix controller. + + +## React-Native Application +The React-Native application is used to control the matrix from a mobile device. It communicates with the matrix controller via a REST-Interface (you'll need to update the README.md file if you add new endpoints or modify them). This application uses tailwindcss for styling and is designed to be responsive and good looking on both web and mobile devices. \ No newline at end of file diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 00000000..9b949d0f --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,119 @@ +name: "Copilot Setup Steps" + +# Automatically run the setup steps when they are changed to allow for easy validation, and +# allow manual testing through the repository's "Actions" tab +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +jobs: + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. + copilot-setup-steps: + runs-on: ubuntu-latest + + # Set the permissions to the lowest permissions possible needed for your steps. + # Copilot will be given its own token for its operations. + permissions: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + packages: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: python3-jinja2 pkg-config autoconf automake libtool python3 linux-libc-dev curl libltdl-dev libx11-dev libxft-dev libxext-dev libwayland-dev libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev mono-complete libxrandr-dev libxrandr2 wayland-protocols extra-cmake-modules xorg-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev libgtk-3-dev libayatana-appindicator3-dev + version: 1.0 + + - name: Update certificates + run: | + sudo apt-get update + sudo apt-get install --reinstall ca-certificates + sudo update-ca-certificates + sudo cert-sync /etc/ssl/certs/ca-certificates.crt + cert-sync --user /etc/ssl/certs/ca-certificates.crt + + - uses: lukka/get-cmake@latest + with: + cmakeVersion: "~3.25.0" + + - name: Setup anew (or from cache) vcpkg (and does not build any package) + uses: lukka/run-vcpkg@v11 + with: + vcpkgConfigurationJsonGlob: "vcpkg-configuration.json" + + - name: Add NuGet sources (Linux) + shell: bash + env: + VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg + USERNAME: sshcrack + FEED_URL: https://nuget.pkg.github.com/sshcrack/index.json + run: | + mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \ + sources add \ + -Source "${{ env.FEED_URL }}" \ + -StorePasswordInClearText \ + -Name GitHubPackages \ + -UserName "${{ env.USERNAME }}" \ + -Password "${{ secrets.GH_PACKAGES_TOKEN }}" + mono `${{ env.VCPKG_EXE }} fetch nuget | tail -n 1` \ + setapikey "${{ secrets.GH_PACKAGES_TOKEN }}" \ + -Source "${{ env.FEED_URL }}" + + - name: Cache cross-compile toolchain + id: cache-toolchain + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/cross-compile + key: cross-compile-toolchain-v0.0.1-beta + + - name: Download and extract cross-compile toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: | + mkdir -p ${{ runner.temp }}/cross-compile + cd ${{ runner.temp }}/cross-compile + wget -O cross-compile.tar.xz "https://github.com/sshcrack/led-matrix/releases/download/v0.0.1-beta/cross-compile.tar.xz" + tar -xvf cross-compile.tar.xz + rm cross-compile.tar.xz + + - name: Create vcpkg triplet for arm64-rpi + run: | + mkdir -p $VCPKG_ROOT/triplets/community + cat > $VCPKG_ROOT/triplets/community/arm64-rpi.cmake << 'EOF' + set(VCPKG_TARGET_ARCHITECTURE arm64) + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE static) + + set(VCPKG_CMAKE_SYSTEM_NAME Linux) + + set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${{ runner.temp }}/cross-compile/PI.cmake) + EOF + + # React Native web build only for led-matrix build + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 10 + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: "pnpm" + cache-dependency-path: "react-native/pnpm-lock.yaml" + + - name: Install React Native dependencies + working-directory: react-native + run: pnpm install diff --git a/README.md b/README.md index 62e53c3b..685508bb 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Transform your space with a **powerful C++ application** that turns RGB LED matr **✨ Perfect for makers, developers, and digital artists ✨** -> **🎯 Recommended:** 128x128 matrix (four 64x64 panels) + Raspberry Pi 4 for optimal results! +> **🎯 Recommended:** 128x128 matrix + Raspberry Pi 4 for optimal results! [![GitHub stars](https://img.shields.io/github/stars/sshcrack/led-matrix?style=for-the-badge)](https://github.com/sshcrack/led-matrix/stargazers) [![License](https://img.shields.io/github/license/sshcrack/led-matrix?style=for-the-badge)](LICENSE)