diff --git a/.gitignore b/.gitignore index 58d00568..f0867a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,12 @@ temp .version .versions .changelog +.idea package-lock.json -*.local \ No newline at end of file +*.local +docker/gcode +docker/logs +docker/config/*.cfg +docker/config/*.conf +docker/config/.mainsail.json +docker/config/.theme diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f1c4d4e2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,33 @@ +version: "3.8" +services: + api: + build: + context: ./docker + dockerfile: api/Dockerfile + image: mainsail-stack-api/1 + volumes: + - ./docker/config:/home/node/printer_config + - ./docker/logs:/tmp/logs + - ./docker/gcode:/home/node/gcode + container_name: ${APP_NAME}-stack-api + ports: + - 7125:7125 + networks: + - dev_net + application: + build: + context: ./docker + dockerfile: Dockerfile + image: mainsail-stack-npm/1 + volumes: + - ./:/home/node/mainsail + container_name: ${APP_NAME}-stack-npm + ports: + - 8080:8080 + depends_on: + - api + networks: + - dev_net +networks: + dev_net: + driver: bridge diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..9df71a89 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,12 @@ +FROM node:buster AS base + +EXPOSE 8080 + +COPY start-npm /usr/local/bin/start-npm +RUN chmod +x /usr/local/bin/start-npm + +USER node + +WORKDIR /home/node/mainsail + +ENTRYPOINT ["start-npm"] diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile new file mode 100644 index 00000000..c0f33c96 --- /dev/null +++ b/docker/api/Dockerfile @@ -0,0 +1,66 @@ +FROM debian:buster AS base + +RUN groupadd --force -g 1000 node +RUN useradd -ms /bin/bash --no-user-group -g 1000 -u 1000 node + +RUN apt-get update +RUN apt-get install -y sudo wget cmake swig git virtualenv python-dev libffi-dev build-essential libncurses-dev libusb-dev avrdude gcc-avr binutils-avr avr-libc dfu-util libnewlib-arm-none-eabi gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0 +RUN mkdir /src +WORKDIR /src +RUN wget http://download.savannah.nongnu.org/releases/simulavr/libsim_1.1.0_amd64.deb +RUN apt install /src/libsim_1.1.0_amd64.deb + +#prebuild files for simulavr, not needed currently, because we just build the python lib later +#RUN wget http://download.savannah.nongnu.org/releases/simulavr/simulavr_1.1.0_amd64.deb +#RUN apt install /src/simulavr_1.1.0_amd64.deb +#RUN wget http://download.savannah.nongnu.org/releases/simulavr/python3-simulavr_1.1.0_amd64.deb +#RUN apt install /src/python3-simulavr_1.1.0_amd64.deb + +RUN cat /etc/passwd + +RUN echo 'node ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/node && \ + chown node:node -R ./ +#if systemd is installed, we need to backup the current systemctl command +#RUN mv /bin/systemctl /bin/systemctl.bak +RUN ln -s /bin/true /bin/systemctl + +USER node + +WORKDIR /home/node +RUN git clone https://github.com/KevinOConnor/klipper +WORKDIR /home/node/klipper +COPY api/simulavr.config /home/node/klipper/.config +RUN make +RUN cp /home/node/klipper/out/klipper.elf /home/node/klipper/simulavr.elf +RUN rm /home/node/klipper/.config +COPY api/linux.config /home/node/klipper/.config +RUN make clean +RUN make +RUN chmod +x /home/node/klipper/scripts/install-debian.sh +RUN /home/node/klipper/scripts/install-debian.sh + +WORKDIR /home/node +RUN git clone https://github.com/Arksine/moonraker +WORKDIR /home/node/moonraker +RUN sed -E 's/check_klipper\(\)/check_klipper() { return 0; }\nold()/' /home/node/moonraker/scripts/install-moonraker.sh > /home/node/moonraker/scripts/install-moonraker2.sh +RUN chmod +x /home/node/moonraker/scripts/install-moonraker2.sh +RUN /home/node/moonraker/scripts/install-moonraker2.sh + +RUN sudo rm -f /bin/systemctl +#restore backed up systemctl command +#RUN sudo mv /bin/systemctl.bak /bin/systemctl + +WORKDIR /home/node/ +RUN git clone https://git.savannah.nongnu.org/git/simulavr.git +WORKDIR /home/node/simulavr +RUN make python +RUN make build + +USER root + +COPY api/run-api /usr/local/bin/run-api +RUN chmod +x /usr/local/bin/run-api + +USER node + +ENTRYPOINT ["run-api"] diff --git a/docker/api/linux.config b/docker/api/linux.config new file mode 100644 index 00000000..92f7c633 --- /dev/null +++ b/docker/api/linux.config @@ -0,0 +1,25 @@ +CONFIG_LOW_LEVEL_OPTIONS=y +# 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 is not set +# CONFIG_MACH_PRU is not set +CONFIG_MACH_LINUX=y +# CONFIG_MACH_SIMU is not set +CONFIG_STEP_DELAY=2 +CONFIG_BOARD_DIRECTORY="linux" +CONFIG_CLOCK_FREQ=50000000 +CONFIG_LINUX_SELECT=y +CONFIG_USB_VENDOR_ID=0x1d50 +CONFIG_USB_DEVICE_ID=0x614e +CONFIG_USB_SERIAL_NUMBER="12345" +# CONFIG_CUSTOM_STEP_DELAY is not set +CONFIG_INITIAL_PINS="" +CONFIG_HAVE_GPIO=y +CONFIG_HAVE_GPIO_ADC=y +CONFIG_HAVE_GPIO_SPI=y +CONFIG_HAVE_GPIO_I2C=y +CONFIG_HAVE_GPIO_HARD_PWM=y +CONFIG_HAVE_GPIO_BITBANGING=y +CONFIG_INLINE_STEPPER_HACK=y diff --git a/docker/api/run-api b/docker/api/run-api new file mode 100644 index 00000000..c82b6496 --- /dev/null +++ b/docker/api/run-api @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +PYTHONPATH="/home/node/simulavr/build/pysimulavr/" /home/node/klipper/scripts/avrsim.py -m atmega644 -s 20000000 -b 250000 /home/node/klipper/simulavr.elf & +/home/node/klippy-env/bin/python /home/node/klipper/klippy/klippy.py /home/node/printer_config/printer.cfg -l /tmp/logs/klippy.log -a /tmp/klippy_uds & +/home/node/moonraker-env/bin/python /home/node/moonraker/moonraker/moonraker.py -l /tmp/logs/moonraker.log -c /home/node/printer_config/moonraker.conf & +echo "Starting ..." >> /tmp/logs/klippy.log +tail -f /tmp/logs/klippy.log diff --git a/docker/api/simulavr.config b/docker/api/simulavr.config new file mode 100644 index 00000000..2cb3dfed --- /dev/null +++ b/docker/api/simulavr.config @@ -0,0 +1,50 @@ +CONFIG_LOW_LEVEL_OPTIONS=y +CONFIG_MACH_AVR=y +# CONFIG_MACH_ATSAM is not set +# CONFIG_MACH_ATSAMD is not set +# CONFIG_MACH_LPC176X is not set +# CONFIG_MACH_STM32 is not set +# CONFIG_MACH_PRU is not set +# CONFIG_MACH_LINUX is not set +# CONFIG_MACH_SIMU is not set +CONFIG_AVR_SELECT=y +CONFIG_STEP_DELAY=-1 +CONFIG_BOARD_DIRECTORY="avr" +# CONFIG_MACH_atmega2560 is not set +# CONFIG_MACH_atmega1280 is not set +# CONFIG_MACH_at90usb1286 is not set +# CONFIG_MACH_at90usb646 is not set +# CONFIG_MACH_atmega32u4 is not set +# CONFIG_MACH_atmega1284p is not set +CONFIG_MACH_atmega644p=y +# CONFIG_MACH_atmega328p is not set +# CONFIG_MACH_atmega328 is not set +# CONFIG_MACH_atmega168 is not set +CONFIG_MCU="atmega644p" +CONFIG_AVRDUDE_PROTOCOL="arduino" +# CONFIG_AVR_FREQ_16000000 is not set +CONFIG_AVR_FREQ_20000000=y +# CONFIG_AVR_FREQ_8000000 is not set +CONFIG_CLOCK_FREQ=20000000 +CONFIG_AVR_CLKPR=-1 +CONFIG_AVR_STACK_SIZE=256 +CONFIG_AVR_WATCHDOG=y +CONFIG_SERIAL=y +CONFIG_AVR_SERIAL_UART0=y +# CONFIG_AVR_SERIAL_UART1 is not set +CONFIG_SERIAL_PORT=0 +CONFIG_SIMULAVR=y +CONFIG_SERIAL_BAUD=250000 +CONFIG_USB_VENDOR_ID=0x1d50 +CONFIG_USB_DEVICE_ID=0x614e +CONFIG_USB_SERIAL_NUMBER="12345" +# CONFIG_CUSTOM_STEP_DELAY is not set +CONFIG_INITIAL_PINS="" +CONFIG_HAVE_GPIO=y +CONFIG_HAVE_GPIO_ADC=y +CONFIG_HAVE_GPIO_SPI=y +CONFIG_HAVE_GPIO_I2C=y +CONFIG_HAVE_GPIO_HARD_PWM=y +CONFIG_HAVE_GPIO_BITBANGING=y +CONFIG_HAVE_STRICT_TIMING=y +CONFIG_INLINE_STEPPER_HACK=y diff --git a/docker/config/moonraker.conf.example b/docker/config/moonraker.conf.example new file mode 100644 index 00000000..3e6507f7 --- /dev/null +++ b/docker/config/moonraker.conf.example @@ -0,0 +1,14 @@ +# moonraker.conf + +[server] +host: 0.0.0.0 +port: 7125 +enable_debug_logging: True +config_path: /home/node/printer_config/ + +[authorization] +enabled: True +trusted_clients: + 0.0.0.0/0 +cors_domains: + * diff --git a/docker/config/printer.cfg.example b/docker/config/printer.cfg.example new file mode 100644 index 00000000..8848211e --- /dev/null +++ b/docker/config/printer.cfg.example @@ -0,0 +1,179 @@ +[virtual_sdcard] +path: ~/gcode + +[pause_resume] +[display_status] + +[mcu] +serial: /tmp/pseudoserial +pin_map: arduino +baud: 250000 + +[stepper_x] +step_pin: PD7 +dir_pin: !PC5 +enable_pin: !PD6 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PC2 +position_endstop: 0 +position_max: 235 +homing_speed: 50 +homing_retract_dist: 0 + +[stepper_y] +step_pin: PC6 +dir_pin: !PC7 +enable_pin: !PD6 +microsteps: 16 +rotation_distance: 40 +endstop_pin: ^PC3 +position_endstop: 0 +position_max: 235 +homing_speed: 50 +homing_retract_dist: 0 + +[stepper_z] +step_pin: PB3 +dir_pin: PB2 +enable_pin: !PA5 +microsteps: 16 +rotation_distance: 8 +endstop_pin: ^PC4 +position_endstop: 0.0 +position_max: 250 +homing_retract_dist: 0 + +[extruder] +max_extrude_only_distance: 100.0 +step_pin: PB1 +dir_pin: !PB0 +enable_pin: !PD6 +microsteps: 16 +rotation_distance: 33.683 +nozzle_diameter: 0.400 +filament_diameter: 1.750 +heater_pin: PD5 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PA7 +control: watermark +min_temp: 0 +max_temp: 250 +min_extrude_temp: 50 + +[heater_bed] +heater_pin: PD4 +sensor_type: EPCOS 100K B57560G104F +sensor_pin: PA6 +control: watermark +min_temp: 0 +max_temp: 130 + +[fan] +pin: PB4 + +[heater_fan nozzle_fan] +pin: PB5 +off_below: 0.0 +shutdown_speed: 1.0 +max_power: 1.0 + +[controller_fan mcu_fan] +pin: PB6 +off_below: 0.2 +shutdown_speed: 1.0 +max_power: 1.0 + +[printer] +kinematics: cartesian +max_velocity: 300 +max_accel: 3000 +max_z_velocity: 5 +max_z_accel: 100 + +#[display] +#lcd_type: st7920 +#cs_pin: PA3 +#sclk_pin: PA1 +#sid_pin: PC1 +#encoder_pins: ^PD2, ^PD3 +#click_pin: ^!PC0 + +# The print bed can move so far to the front, that the nozzle can reach the +# plastic cover of the print bed heater cable (only when the bed is moved by +# hand). By homing the Y axis before the X axis, it is ensured the nozzle will +# not melt through the plastic part. +# BEWARE: You will lose the ability to home axes individually. The printer will +# always home all axes for every G28 command. +#[homing_override] +#gcode: +# G28 Y0 +# G28 X0 +# G28 Z0 + +[gcode_macro PAUSE] +rename_existing: BASE_PAUSE +default_parameter_X: 230 #edit to your park position +default_parameter_Y: 230 #edit to your park position +default_parameter_Z: 10 #edit to your park position +default_parameter_E: 1 #edit to your retract length +gcode: + SAVE_GCODE_STATE NAME=PAUSE_state + BASE_PAUSE + G91 + G1 E-{E} F2100 + G1 Z{Z} + G90 + G1 X{X} Y{Y} F6000 +[gcode_macro RESUME] +rename_existing: BASE_RESUME +default_parameter_E: 1 #edit to your retract length +gcode: + G91 + G1 E{E} F2100 + G90 + RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 + BASE_RESUME +[gcode_macro CANCEL_PRINT] +rename_existing: BASE_CANCEL_PRINT +gcode: + TURN_OFF_HEATERS + CLEAR_PAUSE + SDCARD_RESET_FILE + BASE_CANCEL_PRINT + +[gcode_macro START_PRINT] +default_parameter_BED_TEMP: 103.3 +default_parameter_EXTRUDER_TEMP: 103.3 +gcode: +# Start bed heating + M140 S103.3 +# Use absolute coordinates + G90 +# Reset the G-Code Z offset (adjust Z offset if needed) + SET_GCODE_OFFSET Z=0.0 +# Home the printer + G28 +# Move the nozzle near the bed + G1 Z5 F3000 +# Move the nozzle very close to the bed + G1 Z0.15 F300 +# Wait for bed to reach temperature + M190 S103.3 +# Set and wait for nozzle to reach temperature + M109 S103.3 + +[gcode_macro END_PRINT] +gcode: +# Turn off bed, extruder, and fan + M140 S0 + M104 S0 + M106 S0 +# Move nozzle away from print while retracting + G91 + G1 X-2 Y-2 E-3 F300 +# Raise nozzle by 10mm + G1 Z10 F3000 + G90 +# Disable steppers + M84 diff --git a/docker/run b/docker/run new file mode 100755 index 00000000..f80a9d68 --- /dev/null +++ b/docker/run @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +export APP_NAME=mainsail + +if [ $# -gt 0 ]; then + if [ "$1" == "restart" ]; then + docker-compose restart "$2" + elif [ "$1" == "bash" ]; then + docker exec -it "$APP_NAME-stack-$2" bash + else + docker-compose "$@" + fi +else + docker-compose ps +fi diff --git a/docker/start-npm b/docker/start-npm new file mode 100644 index 00000000..301c11b6 --- /dev/null +++ b/docker/start-npm @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +npm install +npm run serve diff --git a/docs/development/docker.md b/docs/development/docker.md new file mode 100644 index 00000000..a33aa5d6 --- /dev/null +++ b/docs/development/docker.md @@ -0,0 +1,46 @@ +--- +layout: default +title: Docker +parent: Development +has_children: false +permalink: /development/docker +description: >- +Setup docker and docker-compose for quick full stack mainsail development with simulavr without any real printer +--- + +# {{ page.title }} +{{ page.description }} + +# Setup +Install docker and docker-compose on your desired machine. + +####Debian/Ubuntu +```shell +sudo apt install docker docker-compose +``` +####Mac +https://docs.docker.com/docker-for-mac/install/ +####Windows +https://docs.docker.com/docker-for-windows/install/ + +# Start +1. Look into the docker/config folder. Copy the ".example" without the "example ending". +2. Edit the configs to your likings. They are inital setup for a minimal setup environment with simulavr. +3. In the root directory of mainsail run +```shell +docker/run up +``` + +# Development +####Commands +```shell +docker/run ps # showing running containers +docker/run restart # restarting container + # api: restarting complete api container with simulavr/moonraker/klipper services, + # npm: restarting nodejs container with running 'npm run serve' +docker/run bash # spawning bash shell inside container +``` +Restarting the api container will happen a lot, because simulavr WILL crash a lot! Timings within simulavr are not precise and klipper will bug alot about that. +# Todo +1. The current implementation of simulavr/moonraker/klipper is kinda naiv, because docker wont run with systemd. +I will fix that in later versions of the docker container, so you can restart specific containers and omit simulavr and bind a real connected printer for example. diff --git a/docs/development/index.md b/docs/development/index.md new file mode 100644 index 00000000..6989a499 --- /dev/null +++ b/docs/development/index.md @@ -0,0 +1,11 @@ +--- +layout: default +title: Development +nav_order: 15 +has_children: true +permalink: /development +description: development guide +--- + +# {{ page.title }} +{{ page.description }} diff --git a/docs/development/standalone.md b/docs/development/standalone.md new file mode 100644 index 00000000..8be336e4 --- /dev/null +++ b/docs/development/standalone.md @@ -0,0 +1,43 @@ +--- +layout: default +title: Standalone +parent: Development +has_children: false +permalink: /development/standalone +description: >- +Setup the project and start developing with your local printer(s) +--- + +# {{ page.title }} +{{ page.description }} + +# Setup +Make a copy of the '.env.development.local.example' and omit the .example. +In the new file edit it to refect your desired printer: +```dotenv +VUE_APP_HOSTNAME=192.168.0.15 #for your printer with moonraker running on 192.168.0.15 +``` +In moonraker you need to add your local ip at the cors_domains: +```yaml +cors_domains: + http://: +``` +access the local running dev environment with `http://:`. + +####Nodejs Environment >= v15.9.0 +Linux +```shell +curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash - +``` +Debian/Ubuntu +```shell +sudo apt-get install -y nodejs +``` +For other package-managers look here: +https://nodejs.org/en/download/package-manager/ + +# Start +```shell +npm install # only once and if you updated/installed packages +npm run serve # starting current build with hot module reloading +``` diff --git a/src/components/panels/MiscellaneousPanel.vue b/src/components/panels/MiscellaneousPanel.vue index fb3bd68c..e03880f4 100644 --- a/src/components/panels/MiscellaneousPanel.vue +++ b/src/components/panels/MiscellaneousPanel.vue @@ -35,7 +35,7 @@
- +
diff --git a/src/inputs/MiscellaneousSlider.vue b/src/inputs/MiscellaneousSlider.vue index f1383008..ecf09331 100644 --- a/src/inputs/MiscellaneousSlider.vue +++ b/src/inputs/MiscellaneousSlider.vue @@ -77,7 +77,7 @@ type: Number, required: false, default: 1 - }, + } }, methods: { convertName: convertName, diff --git a/src/store/printer/getters.js b/src/store/printer/getters.js index 6415ea60..801ed9ef 100644 --- a/src/store/printer/getters.js +++ b/src/store/printer/getters.js @@ -508,4 +508,4 @@ export default { checkConfigMacroCancel: state => { return Object.keys(state.configfile.config).findIndex(key => key.toLowerCase() === 'gcode_macro cancel_print') !== -1; }, -} \ No newline at end of file +}