├── README.md ├── _config.yml ├── docs ├── _config.yml ├── index.md ├── print_event_end.md ├── print_prepare.md ├── reading_values_from_other_macros.md └── using_an_output_pin_as_a_boolean_flag.md └── scripts ├── rebuild-index.sh └── rebuild.sh /README.md: -------------------------------------------------------------------------------- 1 | # Macros for Klipper 2 | 3 | Published on https://klipperondocker.github.io/macros/ 4 | 5 | Just macros I use or play with. 6 | 7 | Please submit any interesting macros you find. 8 | 9 | Thanks! 10 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | title: Klipper Macros 3 | description: List of interesting macros 4 | logo: https://avatars3.githubusercontent.com/u/54269590?s=200&v=4 -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal 2 | title: Klipper Macros 3 | description: List of interesting macros 4 | logo: https://avatars3.githubusercontent.com/u/54269590?s=200&v=4 -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | 2 | * [Printing ended](print_event_end.md) 3 | * [Print prepare](print_prepare.md) 4 | * [Macro variables usage](reading_values_from_other_macros.md) 5 | * [Using an output pin as a boolean flag](using_an_output_pin_as_a_boolean_flag.md) 6 | -------------------------------------------------------------------------------- /docs/print_event_end.md: -------------------------------------------------------------------------------- 1 | # Printing ended 2 | 3 | ``` 4 | [gcode_macro print_event_end] 5 | gcode: 6 | 7 | # move z up 8 | G91 9 | G1 Z+10 10 | 11 | # retract 12 | G1 E-3 F300 13 | 14 | # move printhead to a specific position 15 | G90 16 | G1 X10 Y220 F2000 17 | 18 | # Disable heaters 19 | M104 S0 20 | M140 S0 21 | 22 | 23 | # disable steppers 24 | M84 25 | 26 | # disable bed mesh 27 | BED_MESH_CLEAR 28 | ``` -------------------------------------------------------------------------------- /docs/print_prepare.md: -------------------------------------------------------------------------------- 1 | # Print prepare 2 | 3 | 4 | ``` 5 | [gcode_macro print_prepare TEMP_BED TEMP_EXTRUDER] 6 | variable_parameter_TEMP_BED: 60 7 | variable_parameter_TEMP_EXTRUDER: 190 8 | variable_parameter_PERCENT_BED_READY: 0.85 9 | gcode: 10 | 11 | # Stop part cooling fan if running 12 | {% if printer.fan.speed > 0.0 %} 13 | M106 S0 14 | {% endif %} 15 | 16 | # Heating 17 | # - heat bed up to 85% (or whatever PERCENT_BED_READY is set to) 18 | # - set bed to heat to 100% 19 | # - set extruder to heat to 100% 20 | # - wait for extruder to finish heating 21 | # - wait for bed to finish heating 22 | 23 | M140 S{TEMP_BED} 24 | {% if printer.heater_bed.temperature < params.TEMP_BED|float* params.PERCENT_BED_READY|float %} 25 | M190 S{params.TEMP_BED|float*params.PERCENT_BED_READY|float} 26 | {% endif %} 27 | 28 | M140 S{TEMP_BED} 29 | M109 S{TEMP_EXTRUDER} 30 | M190 S{TEMP_BED} 31 | 32 | # Home 33 | G28 34 | 35 | # Use the bed mesh 36 | BED_MESH_PROFILE LOAD=default 37 | ``` 38 | 39 | Inspiration 40 | * https://github.com/fl0r1s/cr10_klipper/blob/master/macros.cfg 41 | -------------------------------------------------------------------------------- /docs/reading_values_from_other_macros.md: -------------------------------------------------------------------------------- 1 | # Macro variables usage 2 | 3 | Set variables with default value and gcode that does nothing 4 | ``` 5 | [gcode_macro CONFIGS] 6 | variable_my_stored_variable: 0 7 | gcode: 8 | M118 Stored variable as {printer["gcode_macro CONFIGS"].my_stored_variable} 9 | ``` 10 | 11 | 12 | Use those variables in another macro 13 | ``` 14 | [gcode_macro PRINT_STORED_VARIABLE] 15 | gcode: 16 | M118 Value is {printer[gcode_macro CONFIGS"].my_stored_variable} 17 | ``` 18 | 19 | Change the variables from another macro 20 | ``` 21 | [gcode_macro SET_VAR_TO_1] 22 | gcode: 23 | SET_GCODE_VARIABLE MACRO=CONFIGS VARIABLE=my_stored_variable VALUE=1 24 | M118 Changed! 25 | ``` 26 | 27 | Source: 28 | - https://github.com/KevinOConnor/klipper/blob/master/docs/Command_Templates.md 29 | -------------------------------------------------------------------------------- /docs/using_an_output_pin_as_a_boolean_flag.md: -------------------------------------------------------------------------------- 1 | # Using an output pin as a boolean flag 2 | 3 | 4 | Configured pin 5 | ``` 6 | [output_pin statex] 7 | pin: PC11 8 | value: 1 9 | ``` 10 | 11 | Reading pin state and doing something based on value 12 | ``` 13 | [macro DO_STUFF_IF_OTUPUT_PIN_1] 14 | gcode: 15 | {% if printer["output_pin statex"].value == 1.0 %} 16 | G0 X10 17 | {% else %} 18 | G0 X20 19 | {% endif %} 20 | ``` 21 | 22 | Writing pin state 23 | ``` 24 | [macro CHANGE_PIN_STATEX] 25 | gcode: 26 | SET_PIN PIN=statex VALUE=0 27 | ``` 28 | 29 | -------------------------------------------------------------------------------- /scripts/rebuild-index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INITIAL_DIR=$(pwd) 3 | cd ../docs 4 | 5 | FILES=$(ls *.md) 6 | 7 | echo "" > index.md 8 | cat index.prefix.md >> index.md 9 | 10 | for FILE in *.md 11 | do 12 | SKIP=0 13 | 14 | if [ "$FILE" == "index.md" ]; then 15 | echo "skipping index file" 16 | SKIP=1 17 | fi 18 | if [ "$FILE" == "index.prefix.md" ]; then 19 | echo "skipping index file" 20 | SKIP=1 21 | fi 22 | if [ "$FILE" == "index.suffix.md" ]; then 23 | echo "skipping index file" 24 | SKIP=1 25 | fi 26 | 27 | if [ "$SKIP" == "0" ]; then 28 | echo $FILE 29 | TITLE=$(cat $FILE | grep "# " | head -n 1) 30 | echo $TITLE 31 | 32 | echo "* [${TITLE:2}]($FILE)" >> index.md 33 | fi 34 | done 35 | 36 | cat index.suffix.md >> index.md 37 | 38 | 39 | cd $INITIAL_DIR 40 | 41 | 42 | -------------------------------------------------------------------------------- /scripts/rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | INITIAL_DIR=$(pwd) 3 | cd .. 4 | git reset --hard 5 | git pull 6 | cd $INITIAL_DIR 7 | bash rebuild-index.sh 8 | cd .. 9 | git add * 10 | git commit -m "auto-rebuild index" 11 | git push 12 | cd $INITIAL_DIR 13 | --------------------------------------------------------------------------------