Skip to content

Commit

Permalink
Swap mansail for fluidd
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed May 3, 2021
1 parent fe20614 commit c9f9205
Show file tree
Hide file tree
Showing 18 changed files with 362 additions and 39 deletions.
6 changes: 4 additions & 2 deletions src/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export DIST_NAME=VCoreOS
export DIST_VERSION=0.5.0
export DIST_VERSION=0.7.0
export BASE_IMAGE_ENLARGEROOT=4000
export BASE_IMAGE_RESIZEROOT=500
export MODULES="base(network,raspicam,klipper_moonraker,mainsail,mjpgstreamer,ratrig,password-for-sudo)"
export BASE_RELEASE_IMG_NAME=vcoreos-raspios-lite-latest.img
export BASE_IMG_NAME=vcoreos-raspios-lite-latest.img
export MODULES="base(network,raspicam,klipper_moonraker,fluidd,mjpgstreamer,ratrig,password-for-sudo)"
1 change: 1 addition & 0 deletions src/modules/fluidd/config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLUIDD_VAR="This is a module variable"
Empty file.
16 changes: 16 additions & 0 deletions src/modules/fluidd/filesystem/home/pi/klipper_config/client.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# These are required for Fluidd to correctly function.
# You can copy these entries into your printer.cfg.
#
# Alternatively, import this file by adding
# this line into your printer.cfg;
#
# [include client.cfg]

# Virtual SD Card
[virtual_sdcard]
path: ~/gcode_files

# Pause/Resume Functionality
[pause_resume]

[display_status]
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# These macros are required for Fluidd to correctly function.
# You can copy these entries into your printer.cfg.
#
# Alternatively, import this file by adding
# this line into your printer.cfg;
#
# [include client_macros.cfg]

[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT

[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
G91
G1 E-{E} F2100
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000

[gcode_macro RESUME]
rename_existing: BASE_RESUME
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### end of definitions #####
G91
G1 E{E} F2100
RESTORE_GCODE_STATE NAME=PAUSE_state
BASE_RESUME
39 changes: 39 additions & 0 deletions src/modules/fluidd/filesystem/root/etc/logrotate.d/rsyslog
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/var/log/syslog
{
rotate 4
daily
maxsize 256M
missingok
notifempty
delaycompress
compress
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}

/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
rotate 4
weekly
maxsize 256M
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
/usr/lib/rsyslog/rsyslog-rotate
endscript
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
upstream apiserver {
ip_hash;
server 127.0.0.1:7125;
}

upstream mjpgstreamer {
ip_hash;
server 127.0.0.1:8080;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
server {
listen 80 default_server;

access_log /var/log/nginx/fluidd-access.log;
error_log /var/log/nginx/fluidd-error.log;

# disable this section on smaller hardware like a pi zero
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_proxied expired no-cache no-store private auth;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;

# web_path from fluidd static files
root /home/pi/fluidd;

index index.html;
server_name _;

# disable max upload size checks
client_max_body_size 0;

# disable proxy request buffering
proxy_request_buffering off;

location / {
try_files $uri $uri/ /index.html;
}

location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}

location /websocket {
proxy_pass http://apiserver/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 86400;
}

location ~ ^/(printer|api|access|machine|server)/ {
proxy_pass http://apiserver$request_uri;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
}

location /webcam/ {
proxy_pass http://mjpgstreamer/;
}

location = /vcore.log {
alias "/var/log/vcore.log";
}
}
31 changes: 31 additions & 0 deletions src/modules/fluidd/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Fluidd installation script
# Installs Fluidd and nginx
# Written by Craig Bassett
# Thanks to Raymond Himle
# GPL V3
########


# Source error handling, leave this in place
set -x
set -e

source /common.sh
install_cleanup_trap

unpack /filesystem/home/pi /home/pi pi

echo "Installing nginx and Fluidd"

apt update
apt install nginx -y
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/fluidd /etc/nginx/sites-enabled/
cd /home/pi/
sudo -u pi mkdir /home/pi/fluidd
sudo -u pi wget -q -O fluidd.zip https://github.com/cadriel/fluidd/releases/latest/download/fluidd.zip && sudo -u pi unzip fluidd.zip -d /home/pi/fluidd && rm fluidd.zip
# Run installation steps defined above

# Unpack root at the end, so files are modified before
unpack /filesystem/root /
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ config_path: ~/klipper_config

[authorization]
cors_domains:
*://app.fluidd.xyz
https://my.mainsail.xyz
http://my.mainsail.xyz
http://*.local
Expand All @@ -28,18 +29,24 @@ trusted_clients:
# this enables moonraker's update manager
[update_manager]

[update_manager client mainsail]
type: web
repo: meteyou/mainsail
path: ~/mainsail
# [update_manager client mainsail]
# type: web
# repo: meteyou/mainsail
# path: ~/mainsail

[update_manager client ratrig-theme]
type: git_repo
path: /home/pi/klipper_config/.theme
origin: https://github.com/Rat-Rig/mainsail-theme.git
# [update_manager client ratrig-theme]
# type: git_repo
# path: /home/pi/klipper_config/.theme
# origin: https://github.com/Rat-Rig/mainsail-theme.git

[update_manager client vcore3]
type: git_repo
path: /home/pi/klipper_config/v-core-3
origin: https://github.com/Rat-Rig/v-core-3-klipper-config.git
install_script: /home/pi/klipper_config/v-core-3/scripts/vcore-install.sh
install_script: /home/pi/klipper_config/v-core-3/scripts/vcore-install.sh

# enables fluidd updates
[update_manager client fluidd]
type: web
repo: cadriel/fluidd
path: ~/fluidd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#
# Current working directory is the mjpg-streamer base directory.
#
#camera_http_webroot="./www-mainsail"
#camera_http_webroot="./www-vcoreos"
#camera_http_options="-n"

### EXPERIMENTAL
Expand Down
10 changes: 5 additions & 5 deletions src/modules/mjpgstreamer/filesystem/home/root/bin/webcamd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
### ---------------------------------------------------------------- ###
### There is no need to edit this file for changing resolution, ###
### frame rates or any other mjpg-streamer parameters. Please edit ###
### /boot/mainsail.txt instead - that's what it's there for! You can ###
### /boot/vcoreos.txt instead - that's what it's there for! You can ###
### even do this with your Pi powered down by directly accessing the ###
### file when using the SD card as thumb drive in your regular ###
### computer. ###
Expand All @@ -17,13 +17,13 @@ MJPGSTREAMER_INPUT_RASPICAM="input_raspicam.so"

brokenfps_usb_devices=("046d:082b" "1908:2310" "0458:708c" "1e4e:0102" "0471:0311" "038f:6001" "046d:0804" "046d:0825" "046d:0994" "0ac8:3450")

config_dir="/boot/mainsail.conf.d"
config_dir="/boot/vcoreos.conf.d"

echo "Starting up webcamDaemon..."
echo ""

cfg_files=()
cfg_files+=/boot/mainsail.txt
cfg_files+=/boot/vcoreos.txt
if [[ -d ${config_dir} ]]; then
cfg_files+=( `ls ${config_dir}/*.txt` )
fi
Expand All @@ -41,7 +41,7 @@ array_assigned_device=()

echo "--- Configuration: ----------------------------"
for cfg_file in ${cfg_files[@]}; do
# init configuration - DO NOT EDIT, USE /boot/mainsail.conf.d/*.txt INSTEAD!
# init configuration - DO NOT EDIT, USE /boot/vcoreos.conf.d/*.txt INSTEAD!
camera="auto"
camera_usb_options="-r 640x480 -f 10"
camera_raspi_options="-fps 10"
Expand All @@ -54,7 +54,7 @@ for cfg_file in ${cfg_files[@]}; do
fi
usb_options="$camera_usb_options"

# if webcam device is explicitly given in /boot/mainsail.txt, save the path of the device
# if webcam device is explicitly given in /boot/vcoreos.txt, save the path of the device
# to a variable and remove its parameter from usb_options
extracted_device=`echo $usb_options | sed 's@.*-d \(/dev/\(video[0-9]\+\|v4l/[^ ]*\)\).*@\1@'`
if [ "$extracted_device" != "$usb_options" ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[Unit]
Description=the OctoPi webcam daemon with the user specified config
Description=the VCoreOS webcam daemon with the user specified config

[Service]
WorkingDirectory=/root/bin
Expand Down
55 changes: 55 additions & 0 deletions src/modules/ratrig/filesystem/home/pi/klipper/.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# CONFIG_LOW_LEVEL_OPTIONS is not set
# CONFIG_MACH_AVR is not set
# CONFIG_MACH_ATSAM is not set
# CONFIG_MACH_ATSAMD is not set
# CONFIG_MACH_LPC176X is not set
CONFIG_MACH_STM32=y
# CONFIG_MACH_PRU is not set
# CONFIG_MACH_LINUX is not set
# CONFIG_MACH_SIMU is not set
CONFIG_STEP_DELAY=2
CONFIG_BOARD_DIRECTORY="stm32"
CONFIG_MCU="stm32f407xx"
CONFIG_CLOCK_FREQ=168000000
CONFIG_USBSERIAL=y
CONFIG_FLASH_START=0x8008000
CONFIG_FLASH_SIZE=0x80000
CONFIG_RAM_START=0x20000000
CONFIG_RAM_SIZE=0x20000
CONFIG_STACK_SIZE=512
CONFIG_STM32_SELECT=y
# CONFIG_MACH_STM32F103 is not set
# CONFIG_MACH_STM32F207 is not set
# CONFIG_MACH_STM32F401 is not set
# CONFIG_MACH_STM32F405 is not set
CONFIG_MACH_STM32F407=y
# CONFIG_MACH_STM32F429 is not set
# CONFIG_MACH_STM32F446 is not set
# CONFIG_MACH_STM32F031 is not set
# CONFIG_MACH_STM32F042 is not set
# CONFIG_MACH_STM32F070 is not set
CONFIG_MACH_STM32F4=y
CONFIG_HAVE_STM32_USBOTG=y
CONFIG_HAVE_STM32_CANBUS=y
# CONFIG_STM32_FLASH_START_C000 is not set
CONFIG_STM32_FLASH_START_8000=y
# CONFIG_STM32_FLASH_START_4000 is not set
# CONFIG_STM32_FLASH_START_0000 is not set
CONFIG_CLOCK_REF_FREQ=8000000
CONFIG_STM32F0_TRIM=16
CONFIG_STM32_USB_PA11_PA12=y
# CONFIG_STM32_SERIAL_USART1 is not set
# CONFIG_STM32_CANBUS_PA11_PA12 is not set
CONFIG_CANBUS_FREQUENCY=500000
CONFIG_USB_VENDOR_ID=0x1d50
CONFIG_USB_DEVICE_ID=0x614e
CONFIG_USB_SERIAL_NUMBER_CHIPID=y
CONFIG_USB_SERIAL_NUMBER="12345"
CONFIG_HAVE_GPIO=y
CONFIG_HAVE_GPIO_ADC=y
CONFIG_HAVE_GPIO_SPI=y
CONFIG_HAVE_GPIO_I2C=y
CONFIG_HAVE_GPIO_BITBANGING=y
CONFIG_HAVE_STRICT_TIMING=y
CONFIG_HAVE_CHIPID=y
CONFIG_INLINE_STEPPER_HACK=y
Loading

0 comments on commit c9f9205

Please sign in to comment.