### Setup Virtual Environment Source: https://docs.mainsail.xyz/setup/manual Create a Python virtual environment and install dependencies. ```bash virtualenv -p python3 ~/moonraker-env ~/moonraker-env/bin/pip install -r ~/moonraker/scripts/moonraker-requirements.txt ``` -------------------------------- ### Example active configuration Source: https://docs.mainsail.xyz/sonar/configuration A typical configuration for an active setup. ```toml [sonar] enable: true debug_log: false persistent_log: false target: auto count: 3 interval: 60 restart_threshold: 10 ``` -------------------------------- ### Setup Virtual Environment Source: https://docs.mainsail.xyz/setup/manual Create a Python virtual environment and install required dependencies. ```bash virtualenv -p python3 ~/klippy-env ~/klippy-env/bin/pip install -r ~/klipper/scripts/klippy-requirements.txt ``` -------------------------------- ### Install Sonar Source: https://docs.mainsail.xyz/sonar/installation Execute the installation script with root privileges. ```bash sudo make install ``` -------------------------------- ### Run the Configuration Script Source: https://docs.mainsail.xyz/sonar/installation Initialize the interactive installer configuration process. ```bash cd ~/sonar make config ``` -------------------------------- ### Install the Klipper MCU Systemd Service Source: https://docs.mainsail.xyz/mainsailos/faq/linux-mcu Commands to install and enable the klipper-mcu service to ensure it starts before Klipper. ```bash cd ~/klipper/ sudo cp ./scripts/klipper-mcu.service /etc/systemd/system/ sudo systemctl enable klipper-mcu.service ``` -------------------------------- ### Download and run KIAUH Source: https://docs.mainsail.xyz/setup/kiauh Commands to update the system, install git, clone the KIAUH repository, and launch the interactive installer. ```bash sudo apt-get update && sudo apt-get install git -y cd ~ && git clone https://github.com/dw-0/kiauh.git ./kiauh/kiauh.sh ``` -------------------------------- ### Enable and start Moonraker service Source: https://docs.mainsail.xyz/setup/manual Use systemctl to configure Moonraker to start on boot and initiate the service immediately. ```bash sudo systemctl enable moonraker sudo systemctl start moonraker ``` -------------------------------- ### Clone the repository Source: https://docs.mainsail.xyz/development/contributing Initial setup to create a local copy of your fork. ```bash git clone https://github.com/YOUR-USERNAME/mainsail.git cd mainsail ``` -------------------------------- ### Install project dependencies Source: https://docs.mainsail.xyz/development/development-setup Installs the exact dependency versions defined in the package-lock.json file. ```bash npm ci ``` -------------------------------- ### Install NGINX web server Source: https://docs.mainsail.xyz/setup/manual Install the NGINX package to serve the Mainsail web interface and proxy requests. ```bash sudo apt install nginx ``` -------------------------------- ### Verify Installation Source: https://docs.mainsail.xyz/sonar/installation Commands to check the service status and view logs. ```bash sudo systemctl status sonar ``` ```bash sudo journalctl -u sonar -f ``` -------------------------------- ### Start the development server Source: https://docs.mainsail.xyz/development/development-setup Launches the local development server with hot module replacement enabled. ```bash npm run serve ``` -------------------------------- ### Configure Multi-Instance Setup Source: https://docs.mainsail.xyz/crowsnest/setup/installation Launches the configuration wizard for systems running multiple Klipper instances. ```bash make config ``` -------------------------------- ### action:prompt_begin Source: https://docs.mainsail.xyz/features/macro-prompts Starts the definition of a new prompt dialog with a specified headline. ```APIDOC ## action:prompt_begin ### Description Starts the definition of a prompt. The sets the title displayed at the top of the prompt dialog. ``` -------------------------------- ### Enable and Start Klipper Service Source: https://docs.mainsail.xyz/setup/manual Activate the Klipper service to run on system boot. ```bash sudo systemctl enable klipper sudo systemctl start klipper ``` -------------------------------- ### Begin Prompt Command Source: https://docs.mainsail.xyz/features/macro-prompts Starts the definition of a prompt with a specified headline. ```text // action:prompt_begin ``` -------------------------------- ### Run Crowsnest Installer Source: https://docs.mainsail.xyz/crowsnest/setup/installation Executes the installation script after the configuration step is complete. ```bash sudo make install ``` -------------------------------- ### Example Serial Path Output Source: https://docs.mainsail.xyz/faq/klipper_errors/command-format-mismatch An example of the expected output when listing serial devices. ```text /dev/serial/by-id/usb-Klipper_stm32f042x6_010007000C43565335383320-if00 ``` -------------------------------- ### Configure environment variables Source: https://docs.mainsail.xyz/development/development-setup Copies the example environment file to create a local configuration for development. ```bash cp .env.development.local.example .env.development.local ``` -------------------------------- ### Update System and Install Dependencies Source: https://docs.mainsail.xyz/setup/manual Commands to update the package list, upgrade installed packages, and install essential utilities like git and unzip. ```bash sudo apt update && sudo apt upgrade -y sudo apt install git unzip ``` ```bash sudo apt update && sudo apt upgrade -y sudo apt install git unzip ``` ```bash sudo apt update --allow-releaseinfo-change && sudo apt upgrade -y sudo apt install git unzip ``` -------------------------------- ### Simple Question Prompt Example Source: https://docs.mainsail.xyz/features/macro-prompts Demonstrates a basic confirmation prompt with footer buttons. ```gcode [gcode_macro SHOW_PROMPT] gcode: RESPOND TYPE=command MSG="action:prompt_begin Question" RESPOND TYPE=command MSG="action:prompt_text Do you want to cancel the print?" RESPOND TYPE=command MSG="action:prompt_footer_button continue|RESPOND TYPE=command MSG=action:prompt_end" RESPOND TYPE=command MSG="action:prompt_footer_button CANCEL|CANCEL_PRINT|error" RESPOND TYPE=command MSG="action:prompt_show" ``` -------------------------------- ### Show Prompt Command Source: https://docs.mainsail.xyz/features/macro-prompts Finalizes the prompt setup and displays the dialog to the user. ```text // action:prompt_show ``` -------------------------------- ### Install Missing Dependencies Source: https://docs.mainsail.xyz/faq/moonraker_warnings/policykit-permissions Run the Moonraker installation script with the -r flag to ensure all required dependencies are present. ```bash ~/moonraker/scripts/install-moonraker.sh -r ``` -------------------------------- ### Example .env.development.local configuration Source: https://docs.mainsail.xyz/development/development-setup Defines the connection settings for the Moonraker instance and localization defaults. ```text # hostname or ip of the Moonraker instance VUE_APP_HOSTNAME=printer.local # port of the Moonraker instance VUE_APP_PORT=7125 # route_prefix of the Moonraker instance VUE_APP_PATH="/" # reconnect interval in ms VUE_APP_RECONNECT_INTERVAL=5000 # where should Mainsail read instances from (moonraker, browser or json) VUE_APP_INSTANCES_DB="moonraker" # defaults for multi language tests VUE_APP_I18N_LOCALE=en VUE_APP_I18N_FALLBACK_LOCALE=en ``` -------------------------------- ### Install PackageKit Dependency Source: https://docs.mainsail.xyz/faq/moonraker_warnings/policykit-permissions Install the packagekit package if warnings persist after applying PolicyKit rules. ```bash sudo apt update sudo apt install packagekit ``` -------------------------------- ### Install Moonraker Dependencies Source: https://docs.mainsail.xyz/setup/manual Install required system packages based on the Debian version. ```bash sudo apt install python3-virtualenv python3-dev libopenjp2-7 libsodium-dev zlib1g-dev libjpeg-dev packagekit \ wireless-tools curl build-essential ``` ```bash sudo apt install python3-virtualenv python3-dev libopenjp2-7 python3-libgpiod curl libcurl4-openssl-dev \ libssl-dev liblmdb-dev libsodium-dev zlib1g-dev libjpeg-dev packagekit wireless-tools ``` -------------------------------- ### Configure Start G-Code for Layer Information Source: https://docs.mainsail.xyz/slicers/orcaslicer Add this command to the Start G-Code section in Printer Settings to initialize layer tracking. ```gcode SET_PRINT_STATS_INFO TOTAL_LAYER=[total_layer_count] ``` -------------------------------- ### Check Supported Resolutions Source: https://docs.mainsail.xyz/crowsnest/configuration/cam-section Example output from crowsnest.log showing supported formats and resolutions for a device. ```text [11/16/22 20:16:26] crowsnest: Supported Formats: [11/16/22 20:16:26] crowsnest: [0]: 'MJPG' (Motion-JPEG, compressed) [11/16/22 20:16:26] crowsnest: Size: Discrete 1920x1080 ... ``` -------------------------------- ### Start Button Group Command Source: https://docs.mainsail.xyz/features/macro-prompts Begins a group to display multiple buttons in the same row. ```text // action:prompt_button_group_start ``` -------------------------------- ### Start Mainsail with Docker Compose Source: https://docs.mainsail.xyz/setup/docker Starts the Mainsail service in detached mode. ```bash docker compose up -d ``` -------------------------------- ### Install Klipper Dependencies Source: https://docs.mainsail.xyz/setup/manual Install required system packages for Klipper based on the Debian version. ```bash sudo apt install python3-virtualenv python3-dev libffi-dev build-essential libncurses-dev avrdude gcc-avr \ binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi \ libusb-dev libusb-1.0-0 libusb-1.0-0-dev pkg-config ``` ```bash sudo apt install python3-virtualenv python3-dev libffi-dev build-essential libncurses-dev avrdude gcc-avr \ binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi \ libusb-dev libusb-1.0-0 libusb-1.0-0-dev ``` ```bash sudo apt install python3-virtualenv python3-dev python3-dev libffi-dev build-essential libncurses-dev \ libusb-dev avrdude gcc-avr binutils-avr avr-libc stm32flash dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi \ binutils-arm-none-eabi libusb-1.0 ``` -------------------------------- ### Reboot Prompt Source: https://docs.mainsail.xyz/sonar/installation Final prompt after a successful installation. ```text Installation successful. To take changes effect, you need to reboot your machine! Reboot NOW? [y/N]: ``` -------------------------------- ### Configure V4L2 Controls Source: https://docs.mainsail.xyz/crowsnest/configuration/cam-section Example of passing manual focus parameters to a camera via v4l2ctl. ```text v4l2ctl: focus_auto=0,focus_absolute=30 ``` -------------------------------- ### Install PolicyKit Rules Source: https://docs.mainsail.xyz/setup/manual Apply necessary permissions for Moonraker using the provided script. ```bash ~/moonraker/scripts/set-policykit-rules.sh ``` -------------------------------- ### Clone Crowsnest Repository Source: https://docs.mainsail.xyz/crowsnest/setup/installation Initializes the installation by updating system packages and cloning the repository to the home directory. ```bash sudo apt-get update && sudo apt-get install git -y cd ~ git clone https://github.com/mainsail-crew/crowsnest.git cd ~/crowsnest ``` -------------------------------- ### Identify GPIO Chips Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/raspberry-pi Install and use the gpiod utility to list available GPIO chips and their lines on the system. ```bash sudo apt install gpiod gpioinfo ``` -------------------------------- ### Prompt with Multiple Button Groups Example Source: https://docs.mainsail.xyz/features/macro-prompts Demonstrates creating a prompt with multiple button groups and various color styles. ```gcode [gcode_macro SHOW_PROMPT_BUTTON_GROUPS] gcode: RESPOND TYPE=command MSG="action:prompt_begin MacroPrompt" RESPOND TYPE=command MSG="action:prompt_text These are all button colors" RESPOND TYPE=command MSG="action:prompt_button default|TEST" RESPOND TYPE=command MSG="action:prompt_button_group_start" RESPOND TYPE=command MSG="action:prompt_button primary|TEST|primary" RESPOND TYPE=command MSG="action:prompt_button secondary|TEST|secondary" RESPOND TYPE=command MSG="action:prompt_button_group_end" RESPOND TYPE=command MSG="action:prompt_button_group_start" RESPOND TYPE=command MSG="action:prompt_button info|TEST|info" RESPOND TYPE=command MSG="action:prompt_button warning|TEST|warning" RESPOND TYPE=command MSG="action:prompt_button error|TEST|error" RESPOND TYPE=command MSG="action:prompt_button_group_end" RESPOND TYPE=command MSG="action:prompt_show" ``` -------------------------------- ### Example log output Source: https://docs.mainsail.xyz/crowsnest/configuration/crowsnest-section Sample output format generated by the Crowsnest service. ```text [06/16/22 09:57:01] crowsnest: crowsnest - A webcam service for multiple cams and stream services. [06/16/22 09:57:01] crowsnest: Version: v2.4.0-15-ge42799b [06/16/22 09:57:01] crowsnest: Prepare Startup ... [06/16/22 09:57:01] crowsnest: INFO: Checking Dependencies ... ``` -------------------------------- ### Conventional Commit Message Examples Source: https://docs.mainsail.xyz/development/contributing Examples of valid commit messages following the Conventional Commits specification. ```text feat(console): add auto-scroll toggle fix(webcam): resolve stream reconnection issue docs: update contributing guide ``` -------------------------------- ### Specify Device Path Source: https://docs.mainsail.xyz/crowsnest/configuration/cam-section Example of using a persistent V4L device path instead of a generic video index. ```text device: /dev/v4l/by-id/usb-PixArt_Imaging_Inc._USB2.0_Camera-video-index0 ``` -------------------------------- ### Configure I2C Temperature Sensor Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/orange-pi-3-lts Example Klipper configuration for an I2C-based temperature sensor. ```ini [temperature_sensor example] sensor_type: HTU21D i2c_mcu: host i2c_bus: i2c.0 ``` -------------------------------- ### Configure GPIO and I2C on Host MCU Source: https://docs.mainsail.xyz/mainsailos/faq/linux-mcu Examples for referencing host pins for an LED strip and configuring an I2C sensor. ```ini [output_pin caselight] pin: host:gpio20 # You can also write the pin in extended form by specifying # the reference gpiochip. #pin: host:gpiochip0/gpio20 ``` ```ini [temperature_sensor enclosure_temp] sensor_type: HTU21D i2c_mcu: host i2c_bus: i2c.1 htu21d_hold_master: False ``` -------------------------------- ### Check Supported V4L2 Controls Source: https://docs.mainsail.xyz/crowsnest/configuration/cam-section Example output from crowsnest.log showing available V4L2 controls and their ranges. ```text [11/16/22 20:16:28] crowsnest: Supported Controls: [11/16/22 20:16:28] crowsnest: brightness 0x00980900 (int) : min=-64 max=64 step=1 default=-15 value=-15 ... ``` -------------------------------- ### Configure UART4 Overlay Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/orange-pi-4-lts Example configuration changes to enable UART4 by disabling the SPI1 overlay. ```text # Change this: overlays=spi-spidev param_spidev_spi_bus=1 # To this: overlays=uart4 #param_spidev_spi_bus=1 ``` -------------------------------- ### Install PolicyKit Permissions Source: https://docs.mainsail.xyz/faq/moonraker_warnings/policykit-permissions Execute these commands via SSH to apply the necessary PolicyKit rules and restart the Moonraker service. ```bash cd ~/moonraker/scripts ./set-policykit-rules.sh sudo service moonraker restart ``` -------------------------------- ### Configure printer instances in config.json Source: https://docs.mainsail.xyz/setup/docker Define the network addresses and ports for your 3D printers. Replace the example IP addresses with your actual printer hostnames or IPs. ```json { "defaultLocale": "en", "instancesDB": "json", "instances": [ { "hostname": "192.168.0.1", "port": 7125 }, { "hostname": "192.168.0.2", "port": 7125 }, { "hostname": "192.168.0.3", "port": 7125 } ] } ``` -------------------------------- ### Define Mainsail service in docker-compose.yml Source: https://docs.mainsail.xyz/setup/docker Example configuration for running Mainsail using Docker Compose. ```yaml services: mainsail: container_name: mainsail image: ghcr.io/mainsail-crew/mainsail restart: always ports: - "8080:80" volumes: - ./config.json:/usr/share/nginx/html/config.json ``` -------------------------------- ### Configure ADXL345 Accelerometer Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/orange-pi-3-lts Example Klipper configuration for an ADXL345 accelerometer using the SPI1 interface. ```ini [adxl345] cs_pin: host:gpiochip1/gpio227 spi_bus: spidev1.0 ``` -------------------------------- ### Define Camera Sections Source: https://docs.mainsail.xyz/crowsnest/configuration/cam-section Example of defining multiple camera configurations using the [cam] keyword. ```ini [cam raspi] mode: camera-streamer ... [cam logiC270] mode: ustreamer ... ``` -------------------------------- ### Configure Authorized Clients in moonraker.conf Source: https://docs.mainsail.xyz/faq/mainsail_errors/connection-unauthorized Example of the [authorization] section in moonraker.conf updated to include a specific IP range. ```ini [authorization] trusted_clients: 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 FE80::/10 ::1/128 192.168.0.0/24 cors_domains: *.lan *.local *://my.mainsail.xyz ``` -------------------------------- ### Update Klipper Dependencies Source: https://docs.mainsail.xyz/update/manual Install the required Python dependencies for Klipper using the virtual environment. ```bash cd ~/klipper ./klippy-env/bin/pip install -r ./klipper/scripts/klippy-requirements.txt ``` -------------------------------- ### Manual Moonraker Update Manager Configuration Source: https://docs.mainsail.xyz/sonar/installation Configuration block to add to moonraker.conf if manual setup is required. ```ini [update_manager sonar] type: git_repo path: ~/sonar origin: https://github.com/mainsail-crew/sonar.git primary_branch: main managed_services: sonar system_dependencies: resources/system-dependencies.json ``` -------------------------------- ### Upgrade Crowsnest via SSH Source: https://docs.mainsail.xyz/crowsnest/faq/upgrade-from-v4-to-v5 Execute these commands in the terminal to update the Crowsnest installation. ```bash cd ~/crowsnest git pull make upgrade ``` -------------------------------- ### Define Board Pins for Arduino Source: https://docs.mainsail.xyz/faq/klipper_warnings/deprecated_options Example configuration block for defining board pins when using multiple Arduino controllers. ```ini [board_pins arduino-mega] mcu: mcu ``` -------------------------------- ### Moonraker API response example Source: https://docs.mainsail.xyz/setup/manual A successful response from the printer info endpoint returns a JSON object containing system state and component information. ```json {"result": {"klippy_connected": false, "klippy_state": "disconnected", "components": ["klippy_connection", "application", "websockets", "internal_transport", "dbus_manager", "database", "file_manager", "klippy_apis", "secrets", "template", "shell_command", "machine", "data_store", "proc_stats", "job_state", "job_queue", "http_client", "announcements", "webcam", "extensions", "authorization", "octoprint_compat", "history", "update_manager"], "failed_components": [], "registered_directories": ["config", "logs", "gcodes"], "warnings": [], "websocket_count": 0, "moonraker_version": "v0.7.1-747-g779997c", "missing_klippy_requirements": [], "api_version": [1, 0, 5], "api_version_string": "1.0.5"}} ``` -------------------------------- ### Configure GPIO Relay Power Device Source: https://docs.mainsail.xyz/features/printer-power-device Example configuration for a GPIO-controlled relay, including automatic restart and safety settings. ```ini [power printer] type: gpio pin: gpio26 off_when_shutdown: True on_when_job_queued: True locked_while_printing: True restart_klipper_when_powered: True restart_delay: 1 bound_services: klipper ``` -------------------------------- ### Create Klipper Directory Structure Source: https://docs.mainsail.xyz/setup/manual Initialize the necessary directories and an empty configuration file. ```bash mkdir ~/printer_data/ mkdir ~/printer_data/config mkdir ~/printer_data/logs mkdir ~/printer_data/gcodes mkdir ~/printer_data/systemd mkdir ~/printer_data/comms touch ~/printer_data/config/printer.cfg ``` -------------------------------- ### Define Custom Navigation Entries Source: https://docs.mainsail.xyz/features/custom-themes/custom-navigation Examples of defining navigation items in navi.json, ranging from a basic link to a fully configured entry with icons and positioning. ```json [ { "title": "Google", "href": "https://www.google.com" } ] ``` ```json [ { "title": "Moonraker API", "href": "/server/info", "target": "_blank", "position": 85, "icon": "M5 5H7V11H5V5M10 5H8V11H10V5M5 19H7V13H5V19M10 13H8V19H10V17H15V15H10V13M2 21H4V3H2V21M20 3V7H13V5H11V11H13V9H20V15H18V13H16V19H18V17H20V21H22V3H20Z" } ] ``` -------------------------------- ### Identify Unauthorized Connection in moonraker.log Source: https://docs.mainsail.xyz/faq/mainsail_errors/connection-unauthorized Example log output showing a connection attempt from an unauthorized IP address. ```text 2024-10-26 18:18:43,340 [application.py:log_request()] - 101 GET /websocket (192.168.0.31) [No User] 9.56ms 2024-10-26 18:18:43,341 [websockets.py:open()] - Websocket Opened: ID: 281473655837840, Proxied: False, User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36, Host Name: 192.168.0.215 2024-10-26 18:18:43,351 [common.py:build_error()] - JSON-RPC Request Error - Requested Method: server.connection.identify, Code: -32602, Message: Unauthorized 2024-10-26 18:18:53,496 [websockets.py:on_close()] - Websocket Closed: ID: 281473655837840 Close Code: None, Close Reason: None, Pong Time Elapsed: 0.15 ``` -------------------------------- ### Configure Moonraker Trusted Clients and CORS Source: https://docs.mainsail.xyz/faq/remote-access Example address ranges for local LAN and VPN tunnel devices to be configured in Moonraker's trusted_clients and cors_domains settings. ```text 192.168.1.x // devices on your regular LAN 192.168.50.x // devices connected through your VPN tunnel ``` -------------------------------- ### Add G-Code Metadata Placeholders Source: https://docs.mainsail.xyz/slicers/ideamaker Include these lines in the Start G-code section of printer settings to enable filament and nozzle information display in Mainsail. ```G-code ;Nozzle diameter = {machine_nozzle_diameter1} ;Filament type = {filament_name_abbreviation1} ;Filament name = {filament_name1} ``` -------------------------------- ### Apply custom styles to navigation header Source: https://docs.mainsail.xyz/features/custom-themes/custom-css Example CSS rule to modify the color and font family of the navigation header title. ```css #nav-header .v-toolbar__title { color: gold; font-family: fantasy; } ``` -------------------------------- ### Configure WiFi Credentials in headless_nm.txt Source: https://docs.mainsail.xyz/mainsailos/faq/change-wifi-credentials Template file used to define WiFi network settings on the SD card boot partition. ```text # Enter the SSID (network name) of the WiFi network. SSID="" # Enter the password for the WiFi network. PASSWORD="" # Set to "true" if the network is hidden, otherwise "false". HIDDEN="false" # Country code (ISO 3166-1 alpha-2) for WiFi regulatory domain. REGDOMAIN="GB" ``` -------------------------------- ### Open config.txt for editing Source: https://docs.mainsail.xyz/mainsailos/faq/enable-bluetooth-on-rpi Use the nano text editor to modify the Raspberry Pi boot configuration file. ```bash sudo nano /boot/config.txt ``` -------------------------------- ### Configure network_config.txt for WiFi Source: https://docs.mainsail.xyz/mainsailos/faq/change-wifi-credentials Update these settings in the network_config.txt file on the boot partition to enable WiFi and set credentials. ```text # Set to 1 to apply any network related settings below NC_net_change_defaults=1 # Enable WiFi and disable Ethernet NC_net_ethernet_enabled=0 NC_net_wifi_enabled=1 # Enter your WiFi credentials NC_net_wifi_ssid='MySSID' NC_net_wifi_key='MyWiFiKEY' # Country code for WiFi regulatory domain NC_net_wifi_countrycode='GB' ``` -------------------------------- ### Configure Klipper Environment Variables Source: https://docs.mainsail.xyz/setup/manual Create the environment file to pass configuration arguments to the Klipper script. ```bash sudo nano ~/printer_data/systemd/klipper.env ``` ```bash KLIPPER_ARGS="/home/pi/klipper/klippy/klippy.py /home/pi/printer_data/config/printer.cfg -l /home/pi/printer_data/logs/klippy.log -I /home/pi/printer_data/comms/klippy.serial -a /home/pi/printer_data/comms/klippy.sock" ``` -------------------------------- ### Configure wpa_supplicant.conf for WiFi Source: https://docs.mainsail.xyz/mainsailos/faq/change-wifi-credentials Create this file in the boot partition of the SD card to define WiFi network credentials. Ensure the file uses LF line endings. ```text ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev country= update_config=1 network={ ssid="" psk="" } ``` -------------------------------- ### Enable Mainsail NGINX Configuration Source: https://docs.mainsail.xyz/setup/manual Commands to create the storage directory, remove the default site, enable the new configuration, and restart NGINX. ```bash mkdir ~/mainsail sudo rm /etc/nginx/sites-enabled/default sudo ln -s /etc/nginx/sites-available/mainsail /etc/nginx/sites-enabled/ sudo systemctl restart nginx ``` -------------------------------- ### Run project checks Source: https://docs.mainsail.xyz/development/contributing Execute formatting, linting, and unit tests to ensure code quality before committing. ```bash npm run format npm run lint:fix npm run test:unit ``` -------------------------------- ### Build Klipper Firmware Source: https://docs.mainsail.xyz/faq/klipper_errors/command-format-mismatch Commands to clear the build cache and compile the firmware binary. ```bash make clean make ``` -------------------------------- ### Configure Klipper Systemd Service Source: https://docs.mainsail.xyz/setup/manual Create and configure the systemd service file for Klipper. ```bash sudo nano /etc/systemd/system/klipper.service ``` ```ini [Unit] Description=Klipper 3D Printer Firmware SV1 Documentation=https://www.klipper3d.org/ After=network-online.target Wants=udev.target [Install] WantedBy=multi-user.target [Service] Type=simple User=pi RemainAfterExit=yes WorkingDirectory=/home/pi/klipper EnvironmentFile=/home/pi/printer_data/systemd/klipper.env ExecStart=/home/pi/klippy-env/bin/python $KLIPPER_ARGS Restart=always RestartSec=10 ``` -------------------------------- ### Create Mainsail NGINX Site Configuration Source: https://docs.mainsail.xyz/setup/manual Command to initiate the creation of the Mainsail site configuration file. ```bash sudo nano /etc/nginx/sites-available/mainsail ``` -------------------------------- ### Verify Moonraker status Source: https://docs.mainsail.xyz/setup/manual Perform a GET request to the Moonraker API to confirm the service is responding. ```bash curl -X GET http://localhost:7125/printer/info ``` -------------------------------- ### Build the Linux MCU Firmware Source: https://docs.mainsail.xyz/mainsailos/faq/linux-mcu Commands to clean and configure the firmware for the Linux process. ```bash cd ~/klipper/ make clean make menuconfig ``` -------------------------------- ### Compile Klipper Firmware Source: https://docs.mainsail.xyz/faq/klipper_errors/command-format-mismatch Commands to navigate to the Klipper directory and open the configuration menu for firmware compilation. ```bash cd ~/klipper make menuconfig ``` -------------------------------- ### Configure Klipper Firmware for UART Source: https://docs.mainsail.xyz/mainsailos/faq/serial-mcu-connection Commands to navigate to the Klipper directory and open the menu configuration tool. ```bash cd ~/klipper/ make menuconfig ``` -------------------------------- ### Troubleshooting commands Source: https://docs.mainsail.xyz/crowsnest/faq/how-to-set-up-raspicam Commands used to verify camera hardware and system status via SSH. ```bash sudo raspi-config ``` ```bash sudo apt update && sudo apt upgrade ``` ```bash libcamera-hello ``` -------------------------------- ### Run unit tests Source: https://docs.mainsail.xyz/development/contributing Executes the project's unit test suite to verify changes before submission. ```bash npm run test:unit ``` -------------------------------- ### Enable Bluetooth system services Source: https://docs.mainsail.xyz/mainsailos/faq/enable-bluetooth-on-rpi Activate the necessary systemd services for Bluetooth operation. ```bash sudo systemctl enable hciuart.service sudo systemctl enable bluetooth.service ``` -------------------------------- ### Configure browser mode Source: https://docs.mainsail.xyz/configuration/config-json Sets the instance database to use the browser's localStorage, allowing individual printer lists per user. ```json { "instancesDB": "browser" } ``` -------------------------------- ### Clone the Mainsail repository Source: https://docs.mainsail.xyz/development/development-setup Use these commands to download your fork of the Mainsail repository to your local machine. ```bash git clone https://github.com/YOUR-USERNAME/mainsail.git cd mainsail ``` -------------------------------- ### Configuration Prompts Source: https://docs.mainsail.xyz/sonar/installation Interactive prompts displayed during the configuration process. ```text #### Sonar Install Configurator #### This will guide you through install configuration After successful configuration use sudo make install to install Sonar ... Continue? [Y/n]: ``` ```text Please specify path for printer_data directory NOTE: Skip trailing backslash! Default: /home//printer_data Hit ENTER to use default. Please enter path: ``` ```text Should the update_manager entry added to your moonraker.conf? NOTE: This will only work if your moonraker.conf shares the same path as your Sonar.conf!!! If you want/have to do that manually, please see 'resources/moonraker_update.txt' Copy the content in your moonraker.conf Add update_manager entry? [Y/n]: ``` -------------------------------- ### Default config.json structure Source: https://docs.mainsail.xyz/configuration/config-json The base configuration file structure defining default UI settings and connection parameters. ```json { "defaultLocale": "en", "defaultMode": "dark", "defaultTheme": "mainsail", "hostname": null, "port": null, "path": null, "instancesDB": "moonraker", "instances": [] } ``` -------------------------------- ### Configure Moonraker Source: https://docs.mainsail.xyz/setup/manual Create and edit the moonraker.conf configuration file. ```bash nano ~/printer_data/config/moonraker.conf ``` ```ini [server] host: 0.0.0.0 port: 7125 # The maximum size allowed for a file upload (in MiB). Default 1024 MiB max_upload_size: 1024 # Path to klippy Unix Domain Socket klippy_uds_address: ~/printer_data/comms/klippy.sock [file_manager] # post processing for object cancel. Not recommended for low resource SBCs such as a Pi Zero. Default False enable_object_processing: False [authorization] cors_domains: *://my.mainsail.xyz *://*.local *://*.lan trusted_clients: 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 FE80::/10 ::1/128 # enables partial support of Octoprint API [octoprint_compat] # enables moonraker to track and store print history. [history] # this enables moonraker announcements for mainsail [announcements] subscriptions: mainsail # this enables moonraker's update manager [update_manager] refresh_interval: 168 enable_auto_refresh: True [update_manager mainsail] type: web channel: stable repo: mainsail-crew/mainsail path: ~/mainsail ``` -------------------------------- ### Configure the Host MCU in printer.cfg Source: https://docs.mainsail.xyz/mainsailos/faq/linux-mcu The configuration block required to enable the SBC as a secondary MCU. ```ini [mcu host] serial: /tmp/klipper_host_mcu ``` -------------------------------- ### Flash the Linux MCU Firmware Source: https://docs.mainsail.xyz/mainsailos/faq/linux-mcu Commands to stop Klipper, build the firmware, and restart the service. ```bash sudo systemctl stop klipper.service make flash sudo systemctl start klipper.service ``` -------------------------------- ### action:prompt_show Source: https://docs.mainsail.xyz/features/macro-prompts Finalizes and displays the prompt dialog. ```APIDOC ## action:prompt_show ### Description Displays the prompt dialog. This command finalizes the prompt setup and makes it visible to the user. ``` -------------------------------- ### Create NGINX Upstreams Configuration Source: https://docs.mainsail.xyz/setup/manual Command to initiate the creation of the upstreams configuration file. ```bash sudo nano /etc/nginx/conf.d/upstreams.conf ``` -------------------------------- ### Create Systemd Service Source: https://docs.mainsail.xyz/setup/manual Define the systemd service file to manage the Moonraker process. ```bash sudo nano /etc/systemd/system/moonraker.service ``` ```ini #Systemd moonraker Service [Unit] Description=API Server for Klipper SV1 Requires=network-online.target After=network-online.target [Install] WantedBy=multi-user.target [Service] Type=simple User=pi SupplementaryGroups=moonraker-admin RemainAfterExit=yes WorkingDirectory=/home/pi/moonraker EnvironmentFile=/home/pi/printer_data/systemd/moonraker.env ExecStart=/home/pi/moonraker-env/bin/python $MOONRAKER_ARGS Restart=always RestartSec=10 ``` -------------------------------- ### Define the .theme directory structure Source: https://docs.mainsail.xyz/features/custom-themes The .theme folder supports specific filenames for logos, backgrounds, favicons, and custom CSS. All files are optional and only loaded if present. ```text .theme/ ├── sidebar-logo.svg|jpg|png|gif ├── sidebar-background.svg|jpg|png|gif ├── main-background.svg|jpg|png|gif ├── favicon-16x16.png ├── favicon-32x32.png └── custom.css ``` -------------------------------- ### Mount config.json on Windows Source: https://docs.mainsail.xyz/setup/docker Use this volume mounting syntax specifically when running Docker on Windows systems. ```bash -v "%cd%//config.json:/usr/share/nginx/html/config.json" ``` -------------------------------- ### Clone Klipper Repository Source: https://docs.mainsail.xyz/setup/manual Download the Klipper source code from GitHub. ```bash cd ~ git clone https://github.com/Klipper3d/klipper ``` -------------------------------- ### Configure moonraker mode Source: https://docs.mainsail.xyz/configuration/config-json Sets the instance database to use the Moonraker database for storage, connecting to a specific host. ```json { "instancesDB": "moonraker", "hostname": "192.168.0.210", "port": 7125, "path": "/" } ``` -------------------------------- ### Clone the Sonar Repository Source: https://docs.mainsail.xyz/sonar/installation Download the Sonar source code into the home directory via SSH. ```bash cd ~ git clone https://github.com/mainsail-crew/sonar.git ``` -------------------------------- ### Create NGINX Common Variables Configuration Source: https://docs.mainsail.xyz/setup/manual Command to initiate the creation of the common variables configuration file. ```bash sudo nano /etc/nginx/conf.d/common_vars.conf ``` -------------------------------- ### Configure rollover_on_start Source: https://docs.mainsail.xyz/crowsnest/configuration/crowsnest-section Enables log rotation on service restart to keep logs focused on the latest execution. ```yaml rollover_on_start: true ``` -------------------------------- ### Create a feature branch Source: https://docs.mainsail.xyz/development/contributing Prepare a new branch based on the develop branch for your changes. ```bash git checkout develop git checkout -b your-feature-branch ``` -------------------------------- ### Locate configuration file Source: https://docs.mainsail.xyz/sonar/configuration The path to the Sonar configuration file. ```text ~/printer_data/config/sonar.conf ``` -------------------------------- ### Identify UART and Bluetooth settings Source: https://docs.mainsail.xyz/mainsailos/faq/enable-bluetooth-on-rpi Locate these lines in the configuration file to prepare for modification. ```text ## Enable Hardware UART for Serial Communication ## This also disables Bluetooth! enable_uart=1 dtoverlay=disable-bt ``` -------------------------------- ### Configure Printer Power Device Source: https://docs.mainsail.xyz/features/printer-power-device Define the power device in moonraker.conf with the mandatory name 'printer' and bound_services set to 'klipper'. ```ini [power printer] type: bound_services: klipper ``` -------------------------------- ### Restart Sonar service Source: https://docs.mainsail.xyz/sonar/configuration Command to apply configuration changes. ```bash sudo systemctl restart sonar ``` -------------------------------- ### Calculate GPIO Line Numbers Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/orange-pi-3-lts Formula for converting Allwinner SoC port names to GPIO line numbers. ```text line number = port base + pin number ``` -------------------------------- ### Configure YUYV format for USB cameras Source: https://docs.mainsail.xyz/crowsnest/faq/common-issues Adjust the custom_flags in crowsnest.conf to switch from MJPG to YUYV format for specific streamers. ```text ustreamer: custom_flags: --format=YUYV ``` ```text camera-streamer: custom_flags: --camera-format=YUYV ``` -------------------------------- ### Custom M600 Filament Change Macro Source: https://docs.mainsail.xyz/configuration/mainsail-cfg Demonstrates calling the PAUSE macro with custom X, Y, and Z_MIN parameters for a filament change sequence. ```gcode [gcode_macro M600] description: Filament change gcode: PAUSE X=10 Y=10 Z_MIN=50 ``` -------------------------------- ### action:prompt_text Source: https://docs.mainsail.xyz/features/macro-prompts Adds descriptive text to the current prompt. ```APIDOC ## action:prompt_text ### Description Adds a descriptive text to the prompt. ``` -------------------------------- ### Configure Environment Variables Source: https://docs.mainsail.xyz/setup/manual Set the environment variables required by the Moonraker service. ```bash nano ~/printer_data/systemd/moonraker.env ``` ```bash MOONRAKER_ARGS="/home/pi/moonraker/moonraker/moonraker.py -d /home/pi/printer_data" ``` -------------------------------- ### action:prompt_button_group_start / end Source: https://docs.mainsail.xyz/features/macro-prompts Manages grouping of buttons in the same row. ```APIDOC ## action:prompt_button_group_start / action:prompt_button_group_end ### Description Begins or closes a button group, allowing multiple buttons to be displayed in the same row within the prompt dialog. ``` -------------------------------- ### Configure Serial MCU Path Source: https://docs.mainsail.xyz/features/query-devices Use this configuration block in printer.cfg to define the serial connection for an MCU. ```ini [mcu] serial: /dev/serial/by-id/usb-Klipper_... ``` -------------------------------- ### Edit Armbian Environment Configuration Source: https://docs.mainsail.xyz/mainsailos/supported-sbcs/orange-pi-4-lts Command to open the configuration file for modifying overlays. ```bash sudo nano /boot/armbianEnv.txt ``` -------------------------------- ### Format code with Prettier Source: https://docs.mainsail.xyz/development/contributing Executes the Prettier formatter to ensure consistent code style across the project. ```bash npm run format ``` -------------------------------- ### action:prompt_button Source: https://docs.mainsail.xyz/features/macro-prompts Adds a button to the prompt dialog body. ```APIDOC ## action:prompt_button