From 1c13605465c4d2bb531d7e15c8768844df8acf3d Mon Sep 17 00:00:00 2001 From: Andrii Panasiuk Date: Sun, 5 May 2024 18:05:59 +0300 Subject: [PATCH] chore(voron): lots of mods --- cells/klipper/packages/katapult-firmware.nix | 2 +- cells/klipper/packages/klipper-firmware.nix | 2 + .../hosts/voron/hardware-configuration.nix | 7 ++ .../configs/klipper.d/features/meshing.cfg | 2 +- .../configs/klipper.d/hardware/btt-sfs.cfg | 2 +- .../configs/klipper.d/hardware/leds.cfg | 98 ++++++++----------- .../klipper.d/hardware/motherboard.cfg | 3 +- .../configs/klipper.d/hardware/tap.cfg | 89 +++++++++++++++++ .../configs/klipper.d/hardware/toolhead.cfg | 33 +------ .../voron/klipper/configs/klipper.d/macro.cfg | 9 +- .../voron/klipper/configs/klipper.d/main.cfg | 4 +- .../hosts/voron/klipper/klipper-screen.nix | 1 + cells/rpi/overlays.nix | 7 +- flake.lock | 17 ++++ flake.nix | 2 + 15 files changed, 180 insertions(+), 98 deletions(-) create mode 100644 cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/tap.cfg diff --git a/cells/klipper/packages/katapult-firmware.nix b/cells/klipper/packages/katapult-firmware.nix index 1063df37..0578ae9a 100644 --- a/cells/klipper/packages/katapult-firmware.nix +++ b/cells/klipper/packages/katapult-firmware.nix @@ -51,9 +51,9 @@ in installPhase = '' mkdir -p $out cp ./.config $out/config - ls -la out/ cp out/katapult.bin $out/ || true cp out/deployer.bin $out/ || true + cp out/katapult.uf2 $out/ || true ''; strictDeps = true; diff --git a/cells/klipper/packages/klipper-firmware.nix b/cells/klipper/packages/klipper-firmware.nix index d1ceb231..0a733afa 100644 --- a/cells/klipper/packages/klipper-firmware.nix +++ b/cells/klipper/packages/klipper-firmware.nix @@ -50,7 +50,9 @@ stdenv.mkDerivation rec { installPhase = '' mkdir -p $out cp ./.config $out/config + ls -la out/ cp out/klipper.bin $out/ || true + cp out/klipper.uf2 $out/ || true ''; strictDeps = true; diff --git a/cells/nixos/hosts/voron/hardware-configuration.nix b/cells/nixos/hosts/voron/hardware-configuration.nix index f8db7d7b..79ed96fa 100644 --- a/cells/nixos/hosts/voron/hardware-configuration.nix +++ b/cells/nixos/hosts/voron/hardware-configuration.nix @@ -1,8 +1,15 @@ { lib, pkgs, + modulesPath, ... }: { + imports = [ + "${modulesPath}/installer/sd-card/sd-image-aarch64-installer.nix" + ]; + + sdImage.compressImage = false; + boot = { kernelPackages = pkgs.linuxPackages_rpi4; loader = { diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/features/meshing.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/features/meshing.cfg index 5e1ee0c5..823f22e7 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/features/meshing.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/features/meshing.cfg @@ -2,7 +2,7 @@ # Below you can include specific configuration files depending on what you want KAMP to do: [include ./../plugins/kamp/Adaptive_Meshing.cfg] # Include to enable adaptive meshing configuration. -[include ./../plugins/kamp/Line_Purge.cfg] # Include to enable adaptive line purging configuration. +# [include ./../plugins/kamp/Line_Purge.cfg] # Include to enable adaptive line purging configuration. # [include ./../plugins/kamp/Voron_Purge.cfg] # Include to enable adaptive Voron logo purging configuration. [include ./../plugins/kamp/Smart_Park.cfg] # Include to enable the Smart Park function, which parks the printhead near the print area for final heating. diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/btt-sfs.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/btt-sfs.cfg index 2e7da028..a941a6de 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/btt-sfs.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/btt-sfs.cfg @@ -24,7 +24,7 @@ runout_gcode: [filament_motion_sensor SFSEN] switch_pin: ^PC15 -detection_length: 10 +detection_length: 8 pause_on_runout: False event_delay: 3.0 pause_delay: 0.5 diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/leds.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/leds.cfg index 19e72297..8948cb2c 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/leds.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/leds.cfg @@ -3,31 +3,31 @@ initial_duration: 1 gcode: _STATUS_READY -# [neopixel chamber_right] -# pin: back_xiao:gpio7 -# chain_count: 18 -# color_order: GRBW -# initial_red: 0.0 -# initial_green: 0.0 -# initial_blue: 0.0 -# initial_white: 0.0 - -# [neopixel chamber_left] -# pin: back_xiao:gpio6 -# chain_count: 18 -# color_order: GRBW -# initial_red: 0.0 -# initial_green: 0.0 -# initial_blue: 0.0 -# initial_white: 0.0 - -# [led_effect chamber_light] -# frame_rate: 15 -# leds: -# neopixel:chamber_left -# neopixel:chamber_right -# layers: -# static 0 0 top (0, 0, 0, 1.0) +[neopixel chamber_right] +pin: back_xiao:gpio7 +chain_count: 18 +color_order: GRBW +initial_red: 0.0 +initial_green: 0.0 +initial_blue: 0.0 +initial_white: 0.0 + +[neopixel chamber_left] +pin: back_xiao:gpio6 +chain_count: 18 +color_order: GRBW +initial_red: 0.0 +initial_green: 0.0 +initial_blue: 0.0 +initial_white: 0.0 + +[led_effect chamber_light] +frame_rate: 15 +leds: + neopixel:chamber_left + neopixel:chamber_right +layers: + static 0 0 top (0, 0, 0, 1.0) [led_effect sb_logo_busy] autostart: false @@ -186,40 +186,22 @@ layers: static 0 0 top (1.0, 1.0, 1.0) [gcode_macro LED_PROFILE_APPLY] -# variable_profiles: -# { -# "full": { -# "off": [], -# "ready": ["rainbow", "set_nozzle_leds", "chamber_light"], -# "part_ready": ["sb_nozzle_part_ready", "sb_logo_part_ready", "chamber_light"], -# "busy": ["sb_logo_busy", "set_nozzle_leds", "chamber_light"], -# "heating": ["sb_logo_heating", "sb_nozzle_heating", "chamber_light"], -# "cooling": ["sb_logo_cooling", "sb_nozzle_cooling", "chamber_light"], -# "leveling": ["sb_logo_leveling", "set_nozzle_leds", "chamber_light"], -# "homing": ["sb_logo_homing", "set_nozzle_leds", "chamber_light"], -# "cleaning": ["sb_logo_cleaning", "set_nozzle_leds", "chamber_light"], -# "meshing": ["sb_logo_meshing", "set_nozzle_leds", "chamber_light"], -# "calibrating_z": ["sb_logo_calibrating_z", "set_nozzle_leds", "chamber_light"], -# "printing": ["sb_logo_printing", "set_nozzle_leds", "chamber_light"] -# }, -# "toolhead": { -# "off": [], -# "ready": ["rainbow", "set_nozzle_leds"], -# "part_ready": ["sb_nozzle_part_ready", "sb_logo_part_ready"], -# "busy": ["sb_logo_busy", "set_nozzle_leds"], -# "heating": ["sb_logo_heating", "sb_nozzle_heating"], -# "cooling": ["sb_logo_cooling", "sb_nozzle_cooling"], -# "leveling": ["sb_logo_leveling", "set_nozzle_leds"], -# "homing": ["sb_logo_homing", "set_nozzle_leds"], -# "cleaning": ["sb_logo_cleaning", "set_nozzle_leds"], -# "meshing": ["sb_logo_meshing", "set_nozzle_leds"], -# "calibrating_z": ["sb_logo_calibrating_z", "set_nozzle_leds"], -# "printing": ["sb_logo_printing", "set_nozzle_leds"] -# }, -# } - variable_profiles: { + "full": { + "off": [], + "ready": ["rainbow", "set_nozzle_leds", "chamber_light"], + "part_ready": ["sb_nozzle_part_ready", "sb_logo_part_ready", "chamber_light"], + "busy": ["sb_logo_busy", "set_nozzle_leds", "chamber_light"], + "heating": ["sb_logo_heating", "sb_nozzle_heating", "chamber_light"], + "cooling": ["sb_logo_cooling", "sb_nozzle_cooling", "chamber_light"], + "leveling": ["sb_logo_leveling", "set_nozzle_leds", "chamber_light"], + "homing": ["sb_logo_homing", "set_nozzle_leds", "chamber_light"], + "cleaning": ["sb_logo_cleaning", "set_nozzle_leds", "chamber_light"], + "meshing": ["sb_logo_meshing", "set_nozzle_leds", "chamber_light"], + "calibrating_z": ["sb_logo_calibrating_z", "set_nozzle_leds", "chamber_light"], + "printing": ["sb_logo_printing", "set_nozzle_leds", "chamber_light"] + }, "toolhead": { "off": [], "ready": ["rainbow", "set_nozzle_leds"], @@ -236,7 +218,7 @@ variable_profiles: }, } -variable_selected_profile: "toolhead" +variable_selected_profile: "full" variable_last_status: "ready" variable_debug: 0 diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/motherboard.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/motherboard.cfg index a44136fd..0ea84d63 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/motherboard.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/motherboard.cfg @@ -90,7 +90,8 @@ microsteps: 32 # endstop_pin: ^PF2 # position_endstop: 0.899 position_max: 250 -position_min: -5 +# To QGL some really not leveled gantry +position_min: -10 homing_speed: 15 second_homing_speed: 3 homing_retract_dist: 3 diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/tap.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/tap.cfg new file mode 100644 index 00000000..77f2bdc6 --- /dev/null +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/tap.cfg @@ -0,0 +1,89 @@ +[stepper_z] +endstop_pin: probe:z_virtual_endstop + +[force_move] +enable_force_move: True + +[homing_override] +axes: XYZ +gcode: + {% set Mx = printer['configfile'].config["stepper_x"]["position_max"]|float %} + {% set My = printer['configfile'].config["stepper_y"]["position_max"]|float %} + {% set safe_z = 15 %} + {% set z_feedrate = 6000 %} + + G90 + + {% set home_x, home_y, home_z = False, False, False %} + + {% if not 'X' in params + and not 'Y' in params + and not 'Z' in params %} + + {% set home_x, home_y, home_z = True, True, True %} + { action_respond_info("homing_override goint to home all axes") } + {% elif 'X' in params + and 'Y' in params + and 'Z' in params %} + + {% set home_x, home_y, home_z = True, True, True %} + { action_respond_info("homing_override goint to home all axes") } + {% else %} + {% if 'X' in params %} + {% set home_x = True %} + { action_respond_info("homing_override goint to home X") } + {% endif %} + + {% if 'Y' in params %} + {% set home_y = True %} + { action_respond_info("homing_override goint to home Y") } + {% endif %} + + {% if 'Z' in params %} + {% set home_z = True %} + { action_respond_info("homing_override goint to home Z") } + {% endif %} + {% endif %} + + {% if home_z %} + {% if 'x' not in printer.toolhead.homed_axes or 'y' not in printer.toolhead.homed_axes%} + { action_respond_info("X or Y not homed, forcing full G28") } + + {% set home_x, home_y, home_z = True, True, True %} + {% endif %} + {% endif %} + + {% if 'z' in printer.toolhead.homed_axes %} + {% if printer.gcode_move.gcode_position.z < safe_z %} + { action_respond_info("moving to a safe Z distance") } + G0 Z{safe_z} F{z_feedrate} + {% endif %} + {% else %} + { action_respond_info("moving to a safe Z distance") } + SET_KINEMATIC_POSITION Z=0 + G0 Z{safe_z} F{z_feedrate} + {% endif %} + + {% if home_y %} + { action_respond_info("Homing Y") } + + SET_KINEMATIC_POSITION Y=0 + G28 Y0 + {% endif %} + + {% if home_x %} + { action_respond_info("Homing X") } + + SET_KINEMATIC_POSITION X=0 + G28 X0 + {% endif %} + + + {% if home_z %} + # Move to center + G0 X{Mx/2} Y{My/2} F19500 + + G28 Z0 + + G0 Z{safe_z} F{z_feedrate} + {% endif %} diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/toolhead.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/toolhead.cfg index 3e85e0b6..7b115ba3 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/toolhead.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/hardware/toolhead.cfg @@ -44,9 +44,9 @@ rtd_num_of_wires: 2 min_temp: 0 max_temp: 350 control: pid -pid_Kp: 19.769 -pid_Ki: 1.757 -pid_Kd: 55.602 +pid_Kp: 24.179 +pid_Ki: 2.178 +pid_Kd: 67.096 # Rapido V1 # sensor_type: ATC Semitec 104NT-4-R025H42G @@ -74,7 +74,7 @@ heater_temp: 50.0 [probe] pin: ^ebb:PB7 -z_offset: -1.480 +z_offset: -1.690 x_offset: 0 y_offset: 0 speed: 5 @@ -109,28 +109,3 @@ initial_red: 0.0 initial_green: 0.0 initial_blue: 0.0 initial_white: 0.0 - -# Voron TAP -[stepper_z] -endstop_pin: probe:z_virtual_endstop - -[force_move] -enable_force_move: True - -[homing_override] -axes: yxz -gcode: - {% set Mx = printer['configfile'].config["stepper_x"]["position_max"]|float %} - {% set My = printer['configfile'].config["stepper_y"]["position_max"]|float %} - - SET_KINEMATIC_POSITION X=0 Y=0 Z=0 - - G0 Z15 F6000 - G28 Y0 - G28 X0 - - G90 - G1 X{Mx/2} Y{My/2} F19500 - - G28 Z0 - G0 Z15 F6000 diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/macro.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/macro.cfg index 375ee747..9650711a 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/macro.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/macro.cfg @@ -47,10 +47,10 @@ gcode: {% endif %} _STATUS_PRINTING + # LINE_PURGE # KAMP + # M400 _ENABLE_FILAMENT_SENSOR - LINE_PURGE - [gcode_macro CANCEL_PRINT] description: Cancel the actual running print rename_existing: CANCEL_PRINT_BASE @@ -59,6 +59,7 @@ gcode: END_PRINT [gcode_macro END_PRINT] +variable_retraction: 25 gcode: CLEAR_PAUSE M400 @@ -75,7 +76,7 @@ gcode: G91 G1 E-2 F2100 G1 Z{z_safe} F3000 - G1 E-25 F250 + G1 E-{retraction} F600 G90 G92 E0 M104 S0 @@ -190,7 +191,7 @@ gcode: G90 PARK_REAR SAVE_GCODE_STATE NAME=PAUSEPARK - M104 S0 + # M104 S0 SET_IDLE_TIMEOUT TIMEOUT=43200 {% endif %} diff --git a/cells/nixos/hosts/voron/klipper/configs/klipper.d/main.cfg b/cells/nixos/hosts/voron/klipper/configs/klipper.d/main.cfg index abd21f2a..28c830bc 100644 --- a/cells/nixos/hosts/voron/klipper/configs/klipper.d/main.cfg +++ b/cells/nixos/hosts/voron/klipper/configs/klipper.d/main.cfg @@ -4,8 +4,8 @@ canbus_uuid: 42545159bd5a [mcu ebb] canbus_uuid: bb5e63afce85 -# [mcu back_xiao] -# canbus_uuid: 6b76bb2f8b9c +[mcu back_xiao] +canbus_uuid: 6b76bb2f8b9c [include ./features/*.cfg] [include ./hardware/*.cfg] diff --git a/cells/nixos/hosts/voron/klipper/klipper-screen.nix b/cells/nixos/hosts/voron/klipper/klipper-screen.nix index 657ac540..30ba03ef 100644 --- a/cells/nixos/hosts/voron/klipper/klipper-screen.nix +++ b/cells/nixos/hosts/voron/klipper/klipper-screen.nix @@ -74,6 +74,7 @@ (overlay "disable-bt") (overlay "vc4-kms-v3d-pi4") (overlay "vc4-kms-dsi-7inch") + (overlay "rpi-ft5406") ]; }; diff --git a/cells/rpi/overlays.nix b/cells/rpi/overlays.nix index 9d3d92ff..1b661025 100644 --- a/cells/rpi/overlays.nix +++ b/cells/rpi/overlays.nix @@ -6,9 +6,14 @@ inherit (inputs.nixpkgs) system; config.allowUnfree = true; }; + + rpi-4-kernel = import inputs.rpi-4-kernel { + inherit (inputs.nixpkgs) system; + config.allowUnfree = true; + }; in { packages = _: _: cell.packages; kernel = _: _: { - inherit (latest) raspberrypiWirelessFirmware raspberrypifw linuxPackages_rpi4; + inherit (rpi-4-kernel) raspberrypiWirelessFirmware raspberrypifw linuxPackages_rpi4; }; } diff --git a/flake.lock b/flake.lock index f236bfea..ca5cbb2b 100644 --- a/flake.lock +++ b/flake.lock @@ -934,6 +934,7 @@ "nixos" ], "nvfetcher": "nvfetcher", + "rpi-4-kernel": "rpi-4-kernel", "sops-nix": "sops-nix", "std": [ "hive", @@ -941,6 +942,22 @@ ] } }, + "rpi-4-kernel": { + "locked": { + "lastModified": 1714096167, + "narHash": "sha256-O0+cYJ+D995LRMXCqaT0gEE/U2XerRz3VJWDNRv+ysY=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "c95a445e66cffd32c02548891ad368206d0bd30c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "refs/pull/292880/merge", + "repo": "nixpkgs", + "type": "github" + } + }, "sops-nix": { "inputs": { "nixpkgs": [ diff --git a/flake.nix b/flake.nix index 74e52c20..8c8bdce6 100644 --- a/flake.nix +++ b/flake.nix @@ -100,6 +100,8 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "latest"; }; + + rpi-4-kernel.url = "github:nixos/nixpkgs/refs/pull/292880/merge"; }; # tools