Upload files to "klipper/DNV-TPU-Ender3/klipper_config/klipper-macros"

This commit is contained in:
2023-11-13 14:39:13 +01:00
parent b22a1c2613
commit 68284073dd
5 changed files with 2184 additions and 0 deletions

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@@ -0,0 +1,995 @@
# klipper-macros
This is a collection of macros for the
[Klipper 3D printer firmware](https://github.com/Klipper3d/klipper). I
originally created this repo just to have a consistent set of macros shared
between my own 3D printers. But since I've found them useful, I thought other
people might as well.
## What can I do with these?
Most of these macros improve basic functionality (e.g. [selectable build sheets
](#bed-surface)) and Klipper compatability with g-code targeting Marlin
printers. However, there are also some nice extras:
* **[Schedule commands at heights and layer changes](#layer-triggers)** -
This is similar to what your slicer can already do, but I find it simpler, and
you can schedule these commands while a print is active. As an example of
usage, I added an [LCD menu item](#lcd-menus) to pause the print at the next
layer change. This way the pause won't mar the print by e.g. pausing inside
an external perimeter.
* **Dynamically scale [heaters](#heaters) and [fans](#fans)** - This makes it
easy to do things like persistently adjust fan settings during a live print,
or maintain simpler slicer profiles by moving things like a heater bump for a
hardened steel nozzle into state stored on the printer.
* **Cleaner [LCD menu interface](#lcd-menus)** - I've simplified the menus and
provided a much easier way to customize materials in the LCD menu (or at least
I think so). I've also added confirmation dialogs for commands that would
abort an active print.
* **[Optimized mesh bed leveling](#bed-mesh-improvements)** - Probes only within
the printed area, which can save a lot of time on smaller prints.
* **[Automated purge lines](#draw_purge_line)** - Set the desired extrusion
length as `variable_start_purge_length` in your config and a correctly sized
set of purge lines will be extruded in front of the print area immediately
before the print starts.
## A few warnings...
* **BACK UP YOUR FULL CONFIG BEFORE MAKING ANY CHANGES!!!** I've seen so many
newcomers desperately looking for help on public forums because they didn't
have a good config to fall back to after messing up their current config while
experimenting with other people's macros. You'll save yourself and everyone
else a whole lot of time and nuisance if you just make sure you always have a
working config backed up.
* **You really should avoid custom macros like this until you're comfortable
using Klipper with a basic config.** Advanced Klipper macros tend to rely
extensively on [monkey patching](https://en.wikipedia.org/wiki/Monkey_patch),
which can lead to problems with unusual configurations or when mixing macros
from various sources. So, you really want to know what you're doing before
including someone else's macros—particularly when including macros with
overlapping functionality from different sources.
* You must have a `heater_bed`, `extruder`, and other [sections listed
below](#klipper-setup) configured, otherwise the macros will ***force a
printer shutdown at startup***. Unfortunately, the Klipper macro system
doesn't have a more graceful way of handling this sort of thing.
* The multi-extruder and chamber heater functionality is very under-tested and
may have bugs, since I haven't used it much at all. Patches welcome.
* There's probably other stuff I haven't used enough to test thoroughly, so use
these macros at your own risk.
# Troubleshooting
* Double check that you followed the [installation instructions](#installation)
and are not seeing any console or log errors.
* Ensure that you're running the most current version of stock Klipper, and not
a fork or otherwise altered or outdated copy.
* Ensure you're using the most current version of these macros and haven't
made changes to any files in the `klipper-macros` directory.
* Ensure that you've restarted Klipper after any updates or config changes.
* Run `CHECK_KM_CONFIG` in the Klipper console and fix any errors it reports
to the console and/or logs (it won't output anything if no config errors
were detected).
* Run `_INIT_SURFACES` in the Klipper console to validate that bed surfaces are
being initialized without any errors reported to the console and/or logs.
* Verify your slicer settings and review that the gcode output is correct. Pay
particular attention the initialization portions of the gcode and the
parameters passed to PRINT_START.
# Reporting Bugs
If you've followed the troubleshooting steps and were unable to resolve the
issue you can [report a bug via Github](
https://github.com/jschuh/klipper-macros/issues/new/choose). I will probably
respond within a few days (almost certainly within a week). I probably won't
respond through other channels (e.g. Discord, Twitter), because I don't find
them useful for handling bug reports.
Some important things to remember when reporting bugs:
* **Paste the full text of the command that triggered the error, along with any
error messages printed to the console** (and relevant sections of the klipper
logs if appropriate).
* **Attach your config to the bug report.** There's generally no way to diagnose
anything without the configs.
* **Verify that your issue reproduces on the current, stock installation of
Klipper and klipper-macros.** Non-stock configurations and outdated versions
make diagnosis nearly impossible.
* Please don't treat bug reports as a substitute for following the installation
and troubleshooting instructions.
* If you file a feature request I will most likely close it (unless it's
something I was already planning on adding). Sorry, but I wrote these macros
to meet my own needs, so that's what I work on.
> **Note:** Reports that do not follow the above guidelines _**will likely be
> closed without any other action taken.**_
# Contributing
I'm happy to accept bugfix PRs. I'm also potentially open to accepting new
features or additions. However, I may decline the PR if it's something I'm not
interested in or just looks like it would be a hassle for me to maintain.
## Formatting
There's no standard style for Klipper macros, so please just try to follow the
style in the files. That stated, here are a few rules to remember:
* Wrap at 80 characters if at all possible
* Indent 2 spaces, and in line with the logical block when wrapping (no tabs)
* Prefix internal macros with `_` or `_km_`
* Prefix any sort of global state with `_KM_` (e.g. `_KM_SAVE_GCODE_STATE`)
## Commit Messages
These are the rules for commit messages, but you can also just look at the
commit log and follow the observed pattern:
* Use the 50/72 rule for commit messages: No more than 50 characters in the
title and break lines in the description at 72 characters.
* Begin the title with the module name (usually the main file being modified,
minus any extension) followed by a colon.
* Title-only commit messages are fine for simple commits, but be sure to
include a blank line after the title.
* Squash multiple commits if what you're working on makes more sense as a
single logical commit. _This might require you to do a force push on an open
PR._
# Installation
To install the macros, first clone this repository inside of your
`printer_data/config` directory with the following command.
```
git clone https://github.com/jschuh/klipper-macros.git
```
Then paste the below sections into your `printer.cfg` to get started. Or even
better, paste all of it into a seperate file in the same path as your config,
and include that file. That will make it easier if you want to remove these
macros in the future.
You may need to customize some settings for your own config. All configurable
settings are in [globals.cfg](globals.cfg#L5), and can be overridden by creating
a corresponding variable with a new value in your `[gcode_macro _km_options]`
section. _**Do not directly modify the variable declarations in globals.cfg.**_
The macro initialization assumes certain default values, and direct
modifications are likely to break things in very unexpected ways.
> **Note:** The paths in this README follow [Moonraker's data folder structure.
> ](https://moonraker.readthedocs.io/en/latest/installation/#data-folder-structure)
> You may need to change them if you are using a different structure.
> **Note:** Make sure you don't currently have any macros that provide the same
> basic function as the macros in this repository (e.g. the default
> [Mainsail](https://docs.mainsail.xyz/configuration#macros) or
> [fluidd](https://docs.fluidd.xyz/configuration/initial_setup#macros) macros).
> As a rule, you should avoid using multiple sets of macros that override the
> same base macro (unless you really know what you're doing) because conflicting
> macros can cause all sorts of weird and frustrating problems.
> **Note:** If you have a `[homing_override]` section you will need to update
> any `G28` commands in the gcode part to use `G28.6245197` instead (which is
> the renamed version of Klipper's built-in `G28`). Failure to do this will
> cause `G28` commands to error out with the message ***Macro G28 called
> recursively***.
# Klipper Setup
```
# All customizations are documented in globals.cfg. Just copy a variable from
# there into the section below, and change the value to meet your needs.
[gcode_macro _km_options]
# These are examples of some likely customizations:
# Any sheets in the below list will be available with a configurable offset.
#variable_bed_surfaces: ['smooth_1','texture_1']
# Length (in mm) of filament to load (bowden tubes will be longer).
#variable_load_length: 90.0
# Hide the Octoprint LCD menu since I don't use it.
#variable_menu_show_octoprint: False
# Customize the filament menus (up to 10 entries).
#variable_menu_temperature: [
# {'name' : 'PLA', 'extruder' : 200.0, 'bed' : 60.0},
# {'name' : 'PETG', 'extruder' : 230.0, 'bed' : 85.0},
# {'name' : 'ABS', 'extruder' : 245.0, 'bed' : 110.0, 'chamber' : 60}]
# Length of filament (in millimeters) to purge at print start.
#variable_start_purge_length: 30 # This value works for most setups.
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
# ADJUST_SURFACE_OFFSETS
# This line includes all the standard macros.
[include klipper-macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
#[include klipper-macros/optional/lcd_menus.cfg]
# Optimized bed leveling
#[include klipper-macros/optional/bed_mesh.cfg]
# The sections below here are required for the macros to work. If your config
# already has some of these sections you should merge the duplicates into one
# (or if they are identical just remove one of them).
[idle_timeout]
gcode:
_KM_IDLE_TIMEOUT # This line must be in your idle_timeout section.
[pause_resume]
[respond]
[save_variables]
filename: ~/printer_data/variables.cfg # UPDATE THIS FOR YOUR PATH!!!
[virtual_sdcard]
path: ~/gcode_files # UPDATE THIS FOR YOUR PATH!!!
[display_status]
# Uncomment the sections below if Fluidd complains (because it's confused).
#[gcode_macro CANCEL_PRINT]
#rename_existing: CANCEL_PRINT_FAKE_BASE
#gcode: CANCEL_PRINT_FAKE_BASE {rawparams}
```
## Slicer Configuration
### PrusaSlicer / SuperSlicer
PrusaSlicer and its variants are fairly easy to configure. Just open **Printer
Settings → Custom G-code** for your Klipper printer and paste the below text
into the relevant sections.
#### Start G-code
```
M190 S0
M109 S0
PRINT_START EXTRUDER={first_layer_temperature[initial_tool]} BED=[first_layer_bed_temperature] MESH_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} MESH_MAX={first_layer_print_max[0]},{first_layer_print_max[1]} LAYERS={total_layer_count} NOZZLE_SIZE={nozzle_diameter[0]}
; This is the place to put slicer purge lines if you haven't set a non-zero
; variable_start_purge_length to have START_PRINT automatically purge (e.g. if
; using a Mosaic Palette, which requires the slicer to generate the purge).
```
#### End G-code
```
PRINT_END
```
#### Before layer change G-code
```
;BEFORE_LAYER_CHANGE
;[layer_z]
BEFORE_LAYER_CHANGE HEIGHT=[layer_z] LAYER=[layer_num]
```
#### After layer change G-code
```
;AFTER_LAYER_CHANGE
;[layer_z]
AFTER_LAYER_CHANGE
```
### Ultimaker Cura
Cura is a bit more difficult to configure, and it comes with the following known
issues:
- Cura doesn't have proper placeholders for before and after layer changes, so
the before triggers all fire and are followed immediately by the after
triggers, all of which happens inside the layer change. This probably doesn't
matter, but it does mean that you can't use the before and after triggers to
avoid running code in the layer change.
- Cura doesn't provide the Z-height of the current layer, so it's inferred from
the current nozzle position, which will include the Z-hop if the nozzle is
currently raised. This means height based gcode triggers may fire earlier than
expected.
- Cura's **Insert at layer change** fires the `After` trigger and then the
`Before` trigger (i.e before or after the *layer*, versus before or after the
*layer change*). These macros and PrusaSlicer do the opposite, which is
something to keep in mind if you're used to how Cura does it. Note that these
macros do use an **Insert at layer change** script to force `LAYER` comment
generation, but that doesn't affect the trigger ordering.
- Cura does not provide the first layer bounding rectangle, only the model
bounding volume. This means the XY bounding box used to speed up mesh probing
may be larger than it needs to be, resulting in bed probing that's not as fast
as it could be.
Accepting the caveats, the macros work quite well with Cura if you follow the
configuration steps listed below.
#### Start G-code
```
M190 S0
M109 S0
PRINT_START EXTRUDER={material_print_temperature_layer_0} BED={material_bed_temperature_layer_0} NOZZLE_SIZE={machine_nozzle_size}
; This is the place to put slicer purge lines if you haven't set a non-zero
; variable_start_purge_length to have START_PRINT automatically purge (e.g. if
; using a Mosaic Palette, which requires the slicer to generate the purge).
```
#### End G-code
```
PRINT_END
```
#### Post Processing Plugin
Use the menu item for **Extensions → Post Processing → Modify G-Code** to
open the **Post Processing Plugin** and add the following four scripts. *The
scripts must be run in the order listed below and be sure to copy the strings
exactly, with no leading or trailing spaces.*
##### Search and Replace
- Search: `(\n;(MIN|MAX)X:([^\n]+)\n;\2Y:([^\n]+))`
- Replace: `\1\nPRINT_START_SET MESH_\2=\3,\4`
- Use Regular Expressions: ☑️
##### Search and Replace
- Search: `(\n;LAYER_COUNT:([^\n]+))`
- Replace: `\1\nINIT_LAYER_GCODE LAYERS=\2\nPRINT_START_SET LAYERS=\2`
- Use Regular Expressions: ☑️
##### Insert at layer change
- When to insert: `Before`
- G-code to insert: `;BEFORE_LAYER_CHANGE`
##### Search and Replace
- Search: `(\n;LAYER:([^\n]+))`
- Replace: `\1\nBEFORE_LAYER_CHANGE LAYER=\2\nAFTER_LAYER_CHANGE`
- Use Regular Expressions: ☑️
## Moonraker Configuration
Once you have the macros working and are comfortable using them, you can have
Moonraker keep them up to date by adding the following into your
`moonraker.conf`.
```
[update_manager klipper-macros]
type: git_repo
origin: https://github.com/jschuh/klipper-macros.git
path: ~/printer_data/config/klipper-macros # UPDATE THIS FOR YOUR PATH!!!
primary_branch: main
is_system_service: False
managed_services: klipper
```
> **Note:** I'd advise against adding the auto-update entries to Moonraker until
> you have everything working well, because it can make uninstallation a bit
> harder due to how Moonraker's autoupdate behavior.
## Removal
If you choose to uninstall these macros you basically need to reverse the
installation steps. However, the most critical parts are listed below.
### Klipper Configuration Removal
Ensure that you remove the following from your Klipper config (and any included
configs):
* The full `[gcode_macro _km_options]` section
* Any `include` sections with `klipper-macros` in the path
* `_KM_IDLE_TIMEOUT` in the `[idle_timeout]` section
If you do not have Moonraker autoupdates configured you can delete the
`klipper-macros` directory with something like the following command (adjusted
for your own paths):
```
rm -rf ~/printer_data/config/klipper-macros
```
### Slicer Configuration Removal
If you do not want to change your slicer config, you should be able to leave
it as is, because it generates only a small amount of additional gcode, and the
basic parameters should work with any other `PRINT_START` macros.
## Moonraker Configuration Removal
If you've configured Moonraker auto-updates you will need to remove the entire
`[update_manager klipper-macros]` section and restart moonraker prior to
deleting the `klipper-macros` directory, otherwise Moonraker may attempt to
recreate it. You may also find that it takes a few Moonraker update checks and
restarts before the klipper-macros section disappears from the UI.
# Command Reference
## Customization
All features are configured by setting `variable_` values in the
`[gcode_macro _km_options]` section. All available variables and their purpose
are listed in [globals.cfg](globals.cfg#L5).
> **Note:** `PRINT_START` specific customizations are [covered in more detail
below](#print-start-and-end).
### Bed Mesh Improvements
`BED_MESH_CALIBRATE_FAST`
Wraps the Klipper `BED_MESH_CALIBRATE` command to scale and redistribute the
probe points so that only the appropriate area in `MESH_MIN` and `MESH_MAX` is probed. This can dramatically reduce probing times for anything that doesn't
fill the first layer of the bed. `PRINT_START` will automatically use this for
bed mesh calibration if a `[bed_mesh]` section is detected in your config.
The following additional configuration options are available from
[globals.cfg](globals.cfg#L5).
* `variable_probe_mesh_padding` - Extra padding around the rectangle defined by
`MESH_MIN` and `MESH_MAX`.
* `variable_probe_min_count` - Minimum number of probes for partial probing of a
bed mesh.
* `variable_probe_count_scale` - Scaling factor to increase probe count for
partial bed probes.
> **Note:** See the [optional section](#bed-mesh) for additional macros.
> **Note:** The bed mesh optimizations are silently disabled for delta printers
and when the mesh parameters include a [`RELATIVE_REFERENCE_INDEX`
](https://www.klipper3d.org/Bed_Mesh.html#the-relative-reference-index)
(which is icnompatible with dynamic mesh generation).
`BED_MESH_CHECK`
Checks the `[bed_mesh]` config and warns if `mesh_min` or `mesh_max` could allow
a move out of range during `BED_MESH_CALIBRATE`. This is run implictily at
Klipper startup and at the start of `BED_MESH_CALIBRATE`.
### Bed Surface
Provides a set of macros for selecting different bed surfaces with
correspdonding Z offset adjustments to compensate for their thickness. All
available surfaces must be listed in the `variable_bed_surfaces` array.
Corresponding LCD menus for sheet selection and babystepping will be added to
*Setup* and *Tune* if [`lcd_menus.cfg`](#lcd-menus) is included. Any Z offset
adjustments made in the LCD menus, console, or other clients (e.g. Mainsail,
Fluidd) will be applied to the current sheet and persisted across restarts.
#### `SET_SURFACE_ACTIVE`
Sets the provided surface active (from one listed in listed in
`variable_bed_surfaces`) and adjusts the current Z offset to match the
offset for the surface. If no `SURFACE` argument is provided the available
surfaces are listed, with active surface preceded by a `*`.
* `SURFACE` - Bed surface with an associated offset.
#### `SET_SURFACE_OFFSET`
Directly sets the the Z offset of `SURFACE` to the value of `OFFSET`. If no
argument for `SURFACE` is provided the current active surface is used. If no
argument for `OFFSET` is provided the current offset is displayed.
* `OFFSET` - New Z offset for the given surface.
* `SURFACE` *(default: current surface)* - Bed surface.
> **Note:** The `SET_GCODE_OFFSET` macro is overridden to update the
> offset for the active surface. This makes the bed surface work with Z offset
> adjustments made via any interface or client.
#### `ADJUST_SURFACE_OFFSETS`
Adjusts surface offsets to account for changes in the Z endstop position or
probe Z offset. A message to invoke this command will be shown in the console
when a relevant change is made to `printer.cfg`.
* `IGNORE` - Set to 1 to reset the saved offsets without adjusting the surfaces.
### Beep
Implements the M300 command (if a corresponding `[output_pin beeper]` section is
present). This command causes the speaker to emit an audible tone.
#### `M300`
Emits an audible tone.
* `P` *(default: `variable_beep_duration`)* - Duration of tone.
* `S` *(default: `variable_beep_frequency`)* - Frequency of tone.
### Draw
Provides convenience methods for extruding along a path and drawing purge lines.
> **Note:** The drawing macros require every `extruder` config(s) to have
> correct `nozzle_diameter` and `filament_diameter` settings.
#### DRAW_LINE_TO
Extrudes a line of filament at the specified height and width from the current
coordinate to the supplied XY coordinate (using the currently active extruder).
* `X` *(default: current X position)* - Absolute X coordinate to draw to.
* `Y` *(default: current Y position)* - Absolute Y coordinate to draw to.
* `HEIGHT` *(default: set via `SET_DRAW_PARAMS`)* - Height (in mm) used to
calculate extrusion volume.
* `WIDTH` *(default: set via `SET_DRAW_PARAMS`)* - Extrusion width in mm.
* `FEEDRATE` *(default: set via `SET_DRAW_PARAMS`)* - Drawing feedrate in mm/m.
> **Note:** The Z axis position must be set prior to caling this macro. The
> `HEIGHT` parameter is used only to calculate the extrusion volume.
#### SET_DRAW_PARAMS
Sets the default parameters used by DRAW_LINE_TO. This is helpful in reducing
`DRAW_LINE_TO` command line lengths (particluarly important when debugging in
the console).
* `HEIGHT` *(optional; 0.2mm at startup)* - Height (in mm) used to
calculate extrusion volume.
* `WIDTH` *(optional; nozzle diameter at startup)* - Extrusion width in mm.
* `FEEDRATE` *(optional; 1200mm/m at startup)* - Drawing feedrate in mm/m.
#### DRAW_PURGE_LINE
Moves to a position at the front edge of the first print layer and purges the
specified length of filament as a line (or rows of lines) in front of the
supplied print area. If no print area is specified the purge lines are drawn at
the front edge of the maximum printable area. If no printable area is set it
defaults to the respective axis limits.
* `PRINT_MIN` *(default: `variable_print_min`)* - Upper boundary of print.
* `PRINT_MAX` *(default: `variable_print_max`)* - Lower boundary of print.
* `HEIGHT` *(default: 62.5% of nozzle diameter)* - Extrusion height in mm.
* `WIDTH` *(default: 125% of nozzle diameter)* - Extrusion width in mm.
* `LENGTH` *(default: `variable_start_purge_length`)* - Length of filament
to purge. *The default in `variable_start_purge_length` is also the amount
that is automatically purged at print start.*
> **Note:** You must set `variable_print_min` and `variable_print_max` if the
> X and Y axis limits in your config allow your toolhead to move outside the
> printable area (e.g. for dockable probes or purge buckets).
> **Note:** If your print touches the front edge of the bed it will overlap with
> with the extrusions from `DRAW_PURGE_LINE`.
### Fans
Implements scaling parameters that alter the behavior of the M106 command. Once
set, these parameters apply to any fan speed until they are cleared (by default
this happens at the start and end of the print).
#### `SET_FAN_SCALING`
Sets scaling parameters for the extruder fan.
* `BOOST` *(default: `0`)* - Added to the fan speed.
* `SCALE` *(default: `1.0`)* - The `BOOST` value is added an then the fan
speed is multiplied by `SCALE`.
* `MAXIMUM` *(default: `255`)* - The fan speed is clamped to no larger
than `MAXIMUM`.
* `MINIMUM` *(default: `0`)* - The fan speed is clamped to no less
than `MINIMUM`; if this is a non-zero value the fan can be stopped only via
the M107 command.
* `SPEED` *(optional)* - This specifies a new speed target, otherwise any new
adjustments will be applied to the unadjusted value of the last set fan speed.
#### `RESET_FAN_SCALING`
* Clears all existing fan scaling factors.
### Filament
#### `LOAD_FILAMENT` / `UNLOAD_FILAMENT`
Loads or unloads filament to the nozzle.
* `LENGTH` *(default: `variable_load_length`)* - The length of filament to load
or unload.
* `SPEED` *(default: `variable_load_speed`)* - Speed (in mm/m) to feed the
filament.
* `MINIMUM` *(default: `min_extrude_temp` + 5)* - Ensures the extruder is heated
to at least the specified temperature.
#### Marlin Compatibility
* The `M701` and `M702` commands are implemented with a default filament length
of `variable_load_length`.
### Heaters
Adds scaling parameters that can alter the behavior of the specified heater.
Once set, these parameters apply to any temperature target on that heater until
the scalaing parameters are cleared. A zero target temperature will turn the
heater off regardless of scaling parameters.
#### `SET_HEATER_SCALING`
Sets scaling parameters for the specified heater. If run without any arguments
any currently scaled heaters and thier scaling parameters will be listed. By
default the scaling is cleared at the start and end of a print.
* `HEATER` - The name of the heater to scale.
* `BOOST` *(default: `0.0`)* - Added to a non-zero target temperature.
* `SCALE` *(default: `1.0`)* - Multiplied with the boosted target
temperature.
* `MAXIMUM` *(default: `max_temp`)* - The target temperature is clamped
to no larger than `MAXIMUM`. This value must be between `min_temp` and
`min_temp`, inclusive.
* `MINIMUM` *(default: `min_temp`)* - A non-zero target temperature is
clamped to no less than `MINIMUM`. This value must be between `min_temp` and
`min_temp`, inclusive.
* `TARGET` *(optional)* - This specifies a new target temperature, otherwise any
new adjustments will be applied to the unadjusted value of the last set target
temperature.
> **Note:** a zero target temperature will turn the heater off regardless of
> scaling parameters.
#### `RESET_HEATER_SCALING`
Clears current heater scaling.
* `HEATER` *(optional)* - The name of the heater to reset.
> **Note:** if no HEATER argument is specified scaling parameters will be reset
> for all heaters.
#### `SET_HEATER_TEMPERATURE_SCALED`
The scaled version of Klipper's `SET_HEATER_TEMPERATURE`. All arguments are the
same and the function is identical, except that scaling values are applied.
#### `TEMPERATURE_WAIT_SCALED`
The scaled version of Klipper's `TEMPERATURE_WAIT`. All arguments are the
same and the function is identical, except that scaling values are applied.
#### Marlin Compatibility
* The chamber heating commands `M141` and `M191` are implemented if a
corresponding `[heater_generic chamber]` section is defined in the config.
* The `R` temperature parameter from Marlin is implemented for the `M109` and
`M190` commands. This parameter will cause a wait until the target temperature
stabilizes (i.e. the normal Klipper behavior for `S`).
* The `S` parameter for the `M109` and `M190` commands is altered to behave as
it does in Marlin. Rather than causing a wait until the temperature
stabilizes, the wait will complete as soon as the temperature target is
exceeded.
* The `M109`, `M190`, `M191`, `M104`, `M140`, and `M141` are all overridden to
implement the heater scaling described above.
> **Note:** Both `SET_HEATER_TEMPERATURE` and `TEMPERATURE_WAIT` are **not**
> overriden and will not scale values. This means that heater scaling
> adjustments made in clients like Mainsail and Fluidd will not be scaled
> (because that seemed like the clearest behavior). The
> [custom LCD menus](#lcd-menus) will also replace the temperature controls
> with non-scaling versions. If you use the stock menus you'll get scaled
> values.
### Kinematics
#### `G28`
Extends the `G28` command to add lazy homing by not re-homing already homed axes
when the `O` argument is included (equivalent to the same argument in Marlin).
See Klipper `G28` documentation for general information and detail on the other
arguments.
* `O` - Omits axes from the homing procedure if they are already homed.
> **Note:** If you have a `[homing_override]` section you will need to update
> any `G28` commands in the gcode part to use `G28.6245197` instead (which is
> the renamed version of Klipper's built-in `G28`). Failure to do this will
> cause `G28` commands to error out with the message ***Macro G28 called
> recursively***.
### Layer Triggers
Provides the capability to run user-specified g-code commands at arbitrary layer
changes.
#### `GCODE_AT_LAYER`
Runs abritrary, user-provided g-code commands at the user-specified layer or
height. If no arguments are specified it will display all currently scheduled
g-code commands along with their associated layer or height.
* `HEIGHT` - Z height (in mm) to run the command. Exactly one of `HEIGHT` or
`LAYER` must be specified.
* `LAYER` - Layer number (zero indexed) to run the command. Exactly one of
`HEIGHT` or `LAYER` must be specified. The special value `next` may be
specified run the command at the next layer change.
* `COMMAND` - The command to run at layer change. Take care to properly quote
spaces and escape any special characters.
* `BEFORE` *(default: `0`)* - Set to 1 run the command before the layer
change (i.e. immediately following completion of the previous layer). By
default commands run after the layer change (i.e. immediately preceding the
next layer). In most cases this distinction here doesn't matter, but it can
be important when dealing with toolchangers or other multi-material printing.
#### `CANCEL_ALL_LAYER_GCODE`
Cancels all g-code commands previously scheduled at any layer or height.
#### Convenient Layer Change Macros
* `PAUSE_NEXT_LAYER ...`
* Schedules the current print to pause at the next layer change. See
[`PAUSE`](#pause) macro for additional arguments.
* `PAUSE_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...`
* Schedules the current print to pause at the specified layer change.
See [`PAUSE`](#pause) for additional arguments.
* `SPEED_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } SPEED=<percentage>`
* Schedules a feedrate adjustment at the specified layer change. (`SPEED`
parameter behaves the same as the `M220` `S` parameter.)
* `FLOW_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } FLOW=<percentage>`
* Schedules a flow-rate adjustment at the specified layer change. (`FLOW`
parameter behaves the same as the `M221` `S` parameter.)
* `FAN_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...`
* Schedules a fan adjustment at the specified layer change. See
[`SET_FAN_SCALING`](#set_fan_scaling) for additional arguments.
* `HEATER_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...`
* Schedules a heater adjustment at the specified layer change. See
[`SET_HEATER_SCALING`](#set_heater_scaling) for additional arguments.
> **Note:** If any triggers cause an exception the current print will
> abort. The convenience macros above validate their arguments as much as is
> possible to reduce the chances of an aborted print, but they cannot entirely
> eliminate the risk of a macro doing something that aborts the print.
### Park
Implements toolhead parking.
#### `PARK`
Parks the toolhead.
* `P` *(default: `2`)* - Parking mode
* `P=0` - If current Z-pos is lower than Z-park then the nozzle will be raised
to reach Z-park height
* `P=1` - No matter the current Z-pos, the nozzle will be raised/lowered to
reach Z-park height.
* `P=2` - The nozzle height will be raised by Z-park amount but never going
over the machines Z height limit.
* `X` *(default: `variable_park_x`)* - Absolute X parking coordinate.
* `Y` *(default: `variable_park_y`)* - Absolute Y parking coordinate.
* `Z` *(default: `variable_park_z`)* - Z parking coordinate applied according
to the `P` parameter.
* `LAZY` *(default: 1)* - Will home any unhomed axes if needed and will not
move any axis if already homed and parked (even if `P=2`).
> **Note:** If a print is in progress the larger of the tallest printed layer or
> the current Z position will be used as the current Z position, to avoid
> collisions with already printed objects during a sequential print.
#### Marlin Compatibility
* The `G27` command is implemented with a default `P0` argument.
### Pause, Resume, Cancel
#### `PAUSE`
Pauses the current print.
* `X` *(default: `variable_park_x`)* - Absolute X parking coordinate.
* `Y` *(default: `variable_park_y`)* - Absolute Y parking coordinate.
* `Z` *(default: `variable_park_z`)* - Relative Z parking coordinate
* `E` *(default: `5`)* - Retraction length to prevent ooze.
* `B` *(default: `10`)* - Number of beeps to emit (if `M300` is enabled).
#### `RESUME`
* `E` *(default: `5`)* - Retraction length to prevent ooze.
#### `CANCEL_PRINT`
Cancels the print and performs all the same functions as `PRINT_END`.
#### Marlin Compatibility
* The `M24`, `M25`, `M600`, `M601`, and `M602` commands are all implemented by
wrapping the above commands.
### Print Start and End
#### `PRINT_START`
Sets up the printer prior to starting a print (called from the slicer's print
start g-code). A target `CHAMBER` temperature may be provided if a
`[heater_generic chamber]` section is present in the klipper config.
If `MESH_MIN` and `MESH_MAX` are provided, then `BED_MESH_CALIBRATE` will probe
only the area within the specified rectangle, and will scale the number of
probes to the appropriate density (this can dramatically reduce probe times for
smaller prints).
* `BED` - Bed heater starting temperature.
* `EXTRUDER` - Extruder heater starting temperature.
* `CHAMBER` *(optional)* - Chamber heater starting temperature.
* `MESH_MIN` *(optional)* - Minimum x,y coordinate of the first layer.
* `MESH_MAX` *(optional)* - Maximum x,y coordinate of the first layer.
* `NOZZLE_SIZE` *(default: nozzle_diameter)* - Nozzle diameter of the primary
extruder.
* `LAYERS` *(optional)* - Total number of layers in the print.
These are the customization options you can add to your
`[gcode_macro _km_options]` section to alter `PRINT_START` behavior:
* `variable_start_bed_heat_delay` *(default: 2000)* - This delay (in
microseconds) is used to allow the bed to stabilize after it reaches it's
target temperature. This is present to account for the fact that the
temperature sensors for most beds are located close to the heating element,
and thus will register as being at the target temperature before the surface
of the bed is. For larger or thicker beds you may want to increase this value.
For smaller or thinner beds you may want to disable this entirely by setting
it to `0`.
* `variable_start_bed_heat_overshoot` *(default: 2.0)* - This value (in degrees
Celsius) is added to the supplied target bed temperature and use as the
initial target temperature when preheating the bed. After the bed preheats to
this target it there is a brief delay before the final target is set. This
allows the bed to stabilize at it's final temperature more quickly. For
smaller or thinner beds you may want to reduce this value or disable it
entirely by setting it to `0.0`.
* `variable_start_end_park_y` *(default: `print_max` Y coordinate)* - The final
Y position of the toolhead in the `PRINT_END` macro, to ensure that the
toolhead is out of the way when the bed is presented for print removal.
* `variable_start_extruder_preheat_scale` *(default: 0.5)* - This value is
multiplied by the target extruder temperature and the result is used as the
preheat value for the extruder while the bed is heating. This is done to
reduce oozing from the extruder while the bed is heating or being probed. Set
to `1.0` to preheat the extruder to the full target temperature, or to `0.0`
to not preheat the extruder at all until the bed reaches temperature.
* `variable_start_extruder_set_target_before_level` *(default: True)* - If
`True` the extruder is set to its target temperature before bed leveling
begins. If `False` the target is set after bed level completes. Setting `True`
warms up the extruder faster and `False` prevents oozing during bed level.
The extruder preheat is applied independent of this setting.
* `variable_start_gcode_before_print` *(default: None)* - Optional user-supplied
gcode run after any leveling operations are complete and the bed, extruder,
and chamber are all stabilized at their target temperatures. Immediately after
this gcode executes the purge line will be printed (if specified) and then the
file from the virtual sdcard will begin printing. This is a useful to add any
probe docking commands, loading from a multi-material unit, or other
operations that must occur before any filament is extruded.
* `variable_start_level_bed_at_temp` *(default: True if `bed_mesh` configured
)* - If true the `PRINT_START` macro will run [`BED_MESH_CALIBRATE_FAST`](
#bed-mesh-improvements) after the bed has stabilized at its target
temperature.
* `variable_start_home_z_at_temp` *(default: True if `probe:z_virtual_endstop`
configured)* - Rehomes the Z axis once the bed reaches its target temperature,
to account for movement during heating.
* `variable_start_clear_adjustments_at_end` *(default: True)* - Clears temporary
adjustments after the print completes or is cancelled (e.g. feedrate,
flow percentage).
* `variable_start_purge_clearance` *(default: 5.0)* Distance (in millimeters)
between the purge lines and the print area (if a `start_purge_length` is
provided).
* `variable_start_purge_length` *(default: 0.0)* - Length of filament (in
millimeters) to purge after the extruder finishes heating and prior to
starting the print. For most setups `30` is a good starting point.
* `variable_start_purge_prime_length` *(default: 10.0)* Length of filament (in
millimeters) to prime the extruder before drawing the purge lines.
* `variable_start_quad_gantry_level_at_temp` *(default: True if
`quad_gantry_level` configured)* - If true the `PRINT_START` macro will run
`QUAD_GANTRY_LEVEL` after the bed has stabilized at its target temperature.
* `variable_start_z_tilt_adjust_at_temp` *(default: True if `z_tilt`
configured)* - If true the `PRINT_START` macro will run `Z_TILT_ADJUST` after
the bed has stabilized at its target temperature.
You can further customize the `PRINT_START` macro by declaring your own override
wrapper. This can be useful for things like loading mesh/skew profiles, or any
other setup that may need to be performed prior to printing.
Here's a skeleton of a `PRINT_START` override wrapper:
```
[gcode_macro PRINT_START]
rename_existing: KM_PRINT_START
gcode:
# Put macro code here to run before PRINT_START.
KM_PRINT_START {rawparams}
# Put macro code here to run after PRINT_START but before the print gcode
```
> **Note:** You can use this same pattern to wrap other macros in order to
account for customizations specific to your printer. E.g. If you have a
dockable probe you may choose to wrap `BED_MESH_CALIBRATE` with the
appropriate docking/undocking commands.
#### `PRINT_END`
Parks the printhead, shuts down heaters, fans, etc, and performs general state
housekeeping at the end of the print (called from the slicer's print end
g-code).
### Velocity
These are some basic wrappers for Klipper's analogs to some of Marlin's velocity
related commands, such as accelleration, jerk, and linear advance.
#### Marlin Compatibility
* The `M201`, `M203`, `M204`, and `M205` commands are implemented by calling
Klipper's `SET_VELOCITY_LIMIT` command. For calls that set the `ACCEL`
parameter, the `ACCEL_TO_DECEL` parameter is also set and scaled by
`variable_velocity_decel_scale` *(default: `0.5`)*.
* The `M900` command is implemented by calling Klipper's `SET_PRESSURE_ADVANCE`
command. The `K` factor is scaled by `variable_pressure_advance_scale`
*(default: `-1.0`)*. If the scaling value is negative the `M900` command has no
effect.
## Optional Configs
### Bed Mesh
`BED_MESH_CALIBRATE` and `G20`
Overrides the default `BED_MESH_CALIBRATE` to use `BED_MESH_CALIBRATE_FAST`
instead, and adds the `G20` command.
***Configuration:***
```
[include klipper-macros/optional/bed_mesh.cfg]
```
***Requirements:** A properly configured `bed_mesh` section.*
### LCD Menus
Adds relevant menu items to an LCD display and improves some existing
functionality. See the [customization](#customization) section above for more
information on how to configure specific behaviors.
* Confirmation added for cancelling the print or disabling steppers during a
print.
* Several temperature menu changes:
* Up to 10 filaments and their corresponding temperatures can be set via
`variable_menu_temperature`.
* Per filament chamber temperature controls are available if a
`[heater_generic chamber]` section is configured.
* The cooldown commands are moved to the top level temperature menu.
* The filament loading commands are replaced with macros that use the lengths
and speeds specified in `variable_load_length` and `variable_load_speed`,
which includes a priming phase at the end of the load (controlled via
`variable_load_priming_length` and `variable_load_priming_speed`).
* [Bed surface](#bed-surface) management is integrated into the setup and tuning
menus.
* The SD card menu has been streamlined for printing and non-printing modes.
* The setup menu includes host shutdown, host restart, speed, and flow controls.
* You can hide the Octoprint or SD card menus if you don't use them
(via `variable_menu_show_octoprint` and `variable_menu_show_sdcard`,
respectively).
***Configuration:***
```
[include klipper-macros/optional/lcd_menus.cfg]
```
***Requirements:** A properly configured `display` section.*

View File

@@ -0,0 +1,281 @@
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
[gcode_macro before_layer_change]
description: Add this to the "before layer change" input box in the slicer.
Usage: BEFORE_LAYER_CHANGE HEIGHT=<current_height> LAYER=<current_layer>
gcode:
{% set height = params.HEIGHT|default(printer.toolhead.position.z)|float %}
{% set layer = params.LAYER|default(-1)|int + 1 %}
{% if height >= 0.0 and layer >= 0 %}
SET_PRINT_STATS_INFO CURRENT_LAYER="{layer}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=cur_height VALUE="{height}"
{% if printer["gcode_macro _km_layer_run"].clearance_z < height %}
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=clearance_z VALUE="{
height}"
{% endif %}
{% endif %}
_KM_LAYER_RUN BEFORE=1
[gcode_macro after_layer_change]
description: Add this to the "after layer change" input box in the slicer.
Usage: AFTER_LAYER_CHANGE
gcode:
_KM_LAYER_RUN BEFORE=0
[gcode_macro gcode_at_layer]
description: Schedules the specified g-code command to be run at the specified layer. LAYER=next will cause the command to run at the next layer change.
Usage: GCODE_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } COMMAND=<gcode>
[BEFORE=<0|1>] [ALLOW_DUPLICATE=<0|1>]
gcode:
{% set commands = printer["gcode_macro _km_layer_run"].commands %}
{% set tot_layers = printer.print_stats.info.total_layer %}
{% if params|length > 0 %}
{% if not printer.pause_resume.is_paused and
printer.idle_timeout.state|string != "Printing" %}
{action_raise_error("No active print.")}
{% endif %}
{% set when = "before" if (params.BEFORE|default(0)|int) else "after" %}
{% if "LAYER" in params %}
{% set cur_layer = printer.print_stats.info.current_layer %}
{% if "HEIGHT" in params %}
{action_raise_error("Conflicting HEIGHT and LAYER arguments provided.")}
{% elif params.LAYER|string|lower == "next" %}
{% set LAYER = cur_layer + 1 %}
{% else %}
{% set LAYER = params.LAYER|int %}
{% endif %}
{% if LAYER <= cur_layer %}
{action_raise_error("LAYER[%i] must be above current print layer[%i]."
| format(LAYER, cur_layer))}
{% elif tot_layers and LAYER >= tot_layers %}
{action_raise_error("LAYER[%i] must be below top layer[%i]."
| format(LAYER, tot_layers))}
{% endif %}
{% set key = "%12i_layer_%s"|format(LAYER, when)%}
{% elif "HEIGHT" in params %}
{% set HEIGHT = params.HEIGHT|float %}
{% set cur_height = printer["gcode_macro _km_layer_run"].cur_height %}
{% if HEIGHT <= cur_height %}
{action_raise_error(
"HEIGHT[%.3f] must be above current print height[%.3f].")
| format(HEIGHT, cur_height)}
{% elif HEIGHT >= printer.toolhead.axis_maximum.z %}
{action_raise_error(
"HEIGHT[%.3f] must be below maximum Z height[%.3f].")
| format(HEIGHT, printer.toolhead.axis_maximum.z)}
{% endif %}
{% set key = "%12.3f_height_%s"|format(HEIGHT, when)%}
{% else %}
{action_raise_error("No HEIGHT or LAYER argument provided.")}
{% endif %}
{% set COMMAND = params.COMMAND %}
{% if key not in commands %}
{% set dummy = commands.__setitem__(key, []) %}
{% endif %}
{% if COMMAND in commands[key] or params.ALLOW_DUPLICATE|default(0)|int %}
{action_raise_error("Duplicate command previously scheduled.")}
{% else %}
{% set dummy = commands[key].append(COMMAND) %}
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=commands VALUE="{
commands|replace('\"','\\\"')}"
{% set args = key.split('_') %}
{% set pos = ("%i"|format(args[0]|int)) if args[1] == "layer" else
("%.3fmm"|format(args[0]|float)) %}
{action_respond_info("%s %s (%s):\n* %s" |
format(args[1], pos, args[2], COMMAND))}
{% endif %}
# No arguments means just list all the triggers.
{% else %}
{% set layers = [] %}
{% set heights = [] %}
{% for k in commands|list|sort %}
{% set args = k.split('_') %}
{% if args[1] == "layer" %}
{% set dummy = layers.append("layer %i (%s):"
| format(args[0]|int, args[2])) %}
{% for c in commands[k] %}
{% set dummy = layers.append("* %s" | format(c)) %}
{% endfor %}
{% else %}
{% set dummy = heights.append("height %.3fmm (%s):"
| format(args[0]|float, args[2])) %}
{% for c in commands[k] %}
{% set dummy = heights.append("* %s" | format(c)) %}
{% endfor %}
{% endif %}
{% endfor %}
{% set dummy = layers.extend(heights) %}
{action_respond_info(layers|join('\n'))}
{% endif %}
[gcode_macro init_layer_gcode]
description: Clears scheduled gcode commands and state for all layers.
Usage: INIT_LAYER_GCODE LAYERS=<num>
gcode:
SET_PRINT_STATS_INFO TOTAL_LAYER="{params.LAYERS|int}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=cur_height VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=clearance_z VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=commands VALUE="{{}}"
[gcode_macro _reset_layer_gcode]
description: Clears scheduled gcode commands and state for all layers.
Usage: _RESET_LAYER_GCODE
gcode:
SET_PRINT_STATS_INFO TOTAL_LAYER="0"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=cur_height VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=clearance_z VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=commands VALUE="{{}}"
[gcode_macro cancel_all_layer_gcode]
description: Clears all scheduled gcode commands.
Usage: CANCEL_ALL_LAYER_GCODE
gcode:
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=commands VALUE="{{}}"
[gcode_macro pause_next_layer]
description: Convenience macro to schedule the current print to pause at the next layer change. See PAUSE for additional arguments.
Usage: PAUSE_NEXT_LAYER ...
gcode:
_CHECK_KINEMATIC_LIMITS{% for k in params%}{' ' ~k~ '=' ~ params[k]
}{% endfor %}
GCODE_AT_LAYER LAYER=NEXT COMMAND="PAUSE{% for k in params %}{
' ' ~ k ~ '=' ~ params[k]}{% endfor %}"
[gcode_macro _km_layer_run]
description: Runs pending commands for the current layer change.
Usage: _KM_LAYER_RUN BEFORE=<0|1>
variable_cur_height: 0.0
variable_clearance_z: 0.0
variable_commands: {}
gcode:
{% set BEFORE = params.BEFORE|int %}
{% set cur_layer = printer.print_stats.info.current_layer %}
{% for k in commands | list | sort %}
{% set args = k.split('_') %}
{% set cmd_pos = args[0]|float %}
{% set cmd_type = args[1] %}
{% set cmd_before = 1 if args[2] == "before" else 0 %}
{% if cmd_before == BEFORE and (
(cmd_type == "layer" and cmd_pos|int <= cur_layer) or
(cmd_type == "height" and cmd_pos <= cur_height)) %}
{action_respond_info("Executing scheduled commands at %s %s:\n%s" |
format(args[1], args[0].strip(), commands[k]|join('\n')))}
{% for c in commands[k] %}
{c}
{% endfor %}
{% set dummy = commands.__delitem__(k) %}
{% endif %}
{% endfor %}
SET_GCODE_VARIABLE MACRO=_km_layer_run VARIABLE=commands VALUE="{
commands|replace('\"','\\\"')}"
[gcode_macro pause_at_layer]
description: Convenience macro to schedule the current print to pause at the specified layer change. LAYER=next will cause the command to run at the next layer change. See PAUSE for additional arguments.
Usage: PAUSE_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
gcode:
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.LAYER|default(layer number)|float %}
{% set dummy = params.HEIGHT|default(Z height)|int %}
" %} # End argument block for Mainsail
{% set filtered_params = params|reject('in',['HEIGHT','LAYER'])|list|sort %}
_CHECK_KINEMATIC_LIMITS{% for k in filtered_params%}{' ' ~k~ '=' ~ params[k]
}{% endfor %}
GCODE_AT_LAYER {% for k in params|select('in',['HEIGHT','LAYER'])|list %}{
' ' ~ k ~ '=' ~ params[k] }{% endfor
%} COMMAND="PAUSE{% for k in filtered_params %}{
' ' ~ k ~ '=' ~ params[k]}{% endfor %}"
[gcode_macro speed_at_layer]
description: Convenience macro to schedule a feedrate adjustment at the specified layer change. LAYER=next will cause the command to run at the next layer change. (SPEED parameter behaves the same as the M220 S parameter.)
Usage: SPEED_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } SPEED=<percentage>
gcode:
{% set SPEED = params.SPEED|default(0)|int %}
{% if SPEED < 1 or SPEED > 500 %}
{action_raise_error("SPEED[%i] parameter between 1 and 500 is required."
% SPEED)}
{% endif %}
GCODE_AT_LAYER {% for k in params|select('in',['HEIGHT','LAYER'])|list %}{
' ' ~ k ~ '=' ~ params[k] }{% endfor %} COMMAND="M220 S{SPEED|int}"
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.LAYER|default(layer number)|float %}
{% set dummy = params.HEIGHT|default(Z height)|int %}
{% set dummy = params.SPEED|default(percentage)|int %}
" %} # End argument block for Mainsail
[gcode_macro flow_at_layer]
description: Convenience macro to schedule a flow percentage adjustment at the specified layer change. LAYER=next will cause the command to run at the next layer change. (FLOW parameter behaves the same as the M221 S parameter.)
Usage: FLOW_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } FLOW=<percentage>
gcode:
{% set FLOW = params.FLOW|default(0)|int %}
{% if FLOW < 1 or FLOW > 500 %}
{action_raise_error("FLOW[%i] parameter between 1 and 500 is required."
% FLOW)}
{% endif %}
GCODE_AT_LAYER {% for k in params|select('in',['HEIGHT','LAYER'])|list %}{
' ' ~ k ~ '=' ~ params[k] }{% endfor %} COMMAND="M221 S{FLOW|int}"
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.LAYER|default(layer number)|float %}
{% set dummy = params.HEIGHT|default(Z height)|int %}
{% set dummy = params.FLOW|default(percentage)|int %}
" %} # End argument block for Mainsail
[gcode_macro fan_at_layer]
description: Convenience macro to schedule a fan adjustment at the specified layer change. LAYER=next will cause the command to run at the next layer change. See SET_FAN_SCALING for additional arguments.
Usage: FAN_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
gcode:
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.LAYER|default(layer number)|float %}
{% set dummy = params.HEIGHT|default(Z height)|int %}
{% set dummy = params.SCALE|default(1.0)|float %}
{% set dummy = params.BUMP|default(0)|int %}
{% set dummy = params.MAXIMUM|default(0)|int %}
{% set dummy = params.MINIMUM|default(255)|int %}
{% set dummy = params.SPEED|default(current speed)|int %}
" %} # End argument block for Mainsail
{% set filtered_params = params|reject('in',['HEIGHT','LAYER'])|list|sort %}
{% if filtered_params|length == 0 %}
{action_raise_error("No fan parameters provided.")}
{% endif %}
_CHECK_FAN_PARAMS{% for k in filtered_params %}{' '~k~'='~params[k]
}{% endfor %}
GCODE_AT_LAYER {% for k in params|select('in',['HEIGHT','LAYER'])|list %}{
' ' ~ k ~ '=' ~ params[k] }{% endfor
%} COMMAND="SET_FAN_SCALING{% for k in filtered_params %}{
' ' ~ k ~ '=' ~ params[k]}{% endfor %}"
[gcode_macro heater_at_layer]
description: Convenience macro to schedule a heater adjustment at the specified layer change. LAYER=next will cause the command to run at the next layer change. See SET_HEATER_SCALING for additional arguments.
Usage: HEATER_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
gcode:
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.LAYER|default(layer number)|float %}
{% set dummy = params.HEIGHT|default(Z height)|int %}
{% set dummy = params.HEATER|default(e.g. extruder) %}
{% set dummy = params.SCALE|default(1.0)|float %}
{% set dummy = params.BUMP|default(0.0)|float %}
{% set dummy = params.MAXIMUM|default(max_temp)|float %}
{% set dummy = params.MINIMUM|default(min_temp)|float %}
{% set dummy = params.TARGET|default(current target)|float %}
" %} # End argument block for Mainsail
{% set filtered_params = params|reject('in',['HEIGHT','LAYER'])|list|sort %}
_CHECK_HEATER_PARAMS{% for k in filtered_params%}{' ' ~ k ~ '=' ~ params[k]
}{% endfor %}
GCODE_AT_LAYER{% for k in params|select('in',['HEIGHT','LAYER'])|list %}{
' ' ~ k ~ '=' ~ params[k] }{% endfor
%} COMMAND="SET_HEATER_SCALING{% for k in filtered_params %}{
' ' ~ k ~ '=\\\"' ~ params[k]|replace('\\','\\\\')|replace('\'','\\\'')
|replace('\"','\\\"') ~ '\\\"'
}{% endfor %}"

View File

@@ -0,0 +1,90 @@
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
[gcode_macro park]
description: Park the toolhead
Usage: PARK [P=<0|1|2>] [X=<pos>] [Y=<pos>] [Z=<pos>] [LAZY=<1|0>]
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
{% set LAZY = params.LAZY|default(1)|int %}
{% if printer.toolhead.homed_axes != "xyz" %}
{% if LAZY %}
M118 checkpoint PARK G28 01
G28 O
M118 checkpoint PARK G28 1
{% else %}
{action_raise_error("Must home axes first.")}
{% endif %}
{% endif %}
# Z position type from G27 (if below, absolute, relative)
{% set P = (params.P|default(2))|int %} # Default to 2 because it's sanest.
{% set X = params.X|default(km.park_x)|float %}
{% set Y = params.Y|default(km.park_y)|float %}
{% set Z = params.Z|default(km.park_z)|float %}
_CHECK_KINEMATIC_LIMITS X="{X}" Y="{Y}" Z="{Z}"
_PARK_INNER X="{X}" Y="{Y}" Z="{Z}" P="{P}" LAZY="{LAZY}"
# Dummy argument block for Mainsail
{% set dummy = None if True else "
{% set dummy = params.P|default(mode=<0|1|2>)|int %}
{% set dummy = params.X|default(X position)|int %}
{% set dummy = params.Y|default(Y position)|int %}
{% set dummy = params.Z|default(Z position)|int %}
" %} # End argument block for Mainsail
[gcode_macro _park_inner]
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
{% set travel_speed_xy = km.travel_speed_xy %}
{% set travel_speed_z = km.travel_speed_z %}
{% set position = printer.gcode_move.gcode_position %}
# Use the taller of the highest printed layer or the current Z height, which
# should helps crashes e.g. when a sequential print in progress.
{% set clearance_z = (printer["gcode_macro _km_layer_run"].clearance_z,
position.z) | max %}
{% set P = params.P|int %}
{% set X = params.X|float %}
{% set Y = params.Y|float %}
{% set Z = params.Z|float %}
{% set LAZY = params.LAZY|int %}
# Convert everything to absolute coordinates.
# P == 1 is absolute, so needs no adjustment.
{% if P == 0 %} # Move absolute to Z if below current Z
{% if clearance_z > Z %}
{% set Z = clearance_z %}
{% endif %}
{% elif P == 2 %} # Move Z relative
{% set Z = Z + clearance_z %}
{% elif P != 1 %}
{action_raise_error("Invalid parameter P=%i. Value must be 0, 1, or 2." |
format(P)) }
{% endif %}
# Clamp to the printer limits.
{% set Z = ((Z, printer.toolhead.axis_maximum.z)|min,
printer.toolhead.axis_minimum.z)|max %}
# Don't move if it's a lazy park and we're already in position.
{% if (not LAZY) or P != 2 or X != position.x or Y != position.y
or Z < clearance_z %}
SAVE_GCODE_STATE NAME=_KM_PARK
G90
G0 Z{Z} F{travel_speed_z}
G0 X{X} Y{Y} F{travel_speed_xy}
RESTORE_GCODE_STATE NAME=_KM_PARK MOVE=0
{% endif %}
[gcode_macro g27]
description: Parks the toolhead.
Usage: G27 [P=<0|1|2>]
gcode:
# Wraps any arguments for the PARK macro and defaults P=0 for Marlin compat.
PARK P={params.P|default(0)} {% for k in params|reject("in", "GP") %}{
' '~k~'="'~params[k]~'"'
}{% endfor %}

View File

@@ -0,0 +1,144 @@
# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
# Enables pause/resume functionality
[gcode_macro pause]
description: Pauses the current print.
Usage: PAUSE [X=<pos>] [Y=<pos>] [Z=<pos>] [E=<retract_length>] [B=<beeps>]
rename_existing: _KM_PAUSE_BASE
gcode:
{% set km = printer["gcode_macro _km_globals"] %}
# Retract length (negative)
{% set E = (params.E|default(5))|float %}
# Beeps
{% set B = (params.B|default(10))|float %}
{% if printer.virtual_sdcard.is_active %}
{% set position = printer.gcode_move.gcode_position %}
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_x VALUE="{position.x}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_y VALUE="{position.y}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_z VALUE="{position.z}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_e VALUE="{E}"
SAVE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE
_KM_PAUSE_BASE
M83
G1 E{'%.4f' % -E} F{km.load_speed}
PARK P=2{% for k in params|select("in", "XYZ") %}
{' '~k~'="'~params[k]~'"'}
{% endfor %}
# Beep on pause if there's an M300 macro.
{% if "output_pin beeper" in printer %}
{% for i in range(B|int) %}
M300 P100
G4 P200
{% endfor %}
{% endif %}
{% else %}
{ action_respond_info("Print from SD card is not in progress.") }
{% endif %}
[gcode_macro m600]
description: Pauses the current print.
Usage: M600 [B<beeps>] [E<pos>] [L<pos>] [R<temp>] [U<pos>] [X<pos>] [Y<pos>]
[Z<pos>]
gcode:
PAUSE P=2{% for k in params|select("in", "BEXYZ") %}{
' '~k~'="'~params[k]~'"'}{% endfor %}
SET_GCODE_VARIABLE MACRO=_load_unload VARIABLE=is_printing VALUE="{0}"
UNLOAD_FILAMENT{% if 'U' in params %} LENGTH={params.U}{% endif %}
{% if 'R' in params %}M109 S{params.R}{% endif %}
[gcode_macro m601]
description: Pauses the current print.
Usage: M601
gcode:
PAUSE
[gcode_macro m602]
description: Resumes the currently paused print.
Usage: M602
gcode:
RESUME
[gcode_macro m24]
rename_existing: M24.6245197
gcode:
{% if printer.pause_resume.is_paused %}
RESUME
{% else %}
M24.6245197
{% endif %}
[gcode_macro m25]
rename_existing: M25.6245197
gcode:
PAUSE
[gcode_macro resume]
description: Resumes the currently paused print.
Usage: RESUME [E<pos>]
rename_existing: _KM_RESUME_BASE
variable_saved_extruder_temp: 0
variable_saved_x: 0.0
variable_saved_y: 0.0
variable_saved_z: 0.0
variable_saved_e: 0.0
gcode:
{% if printer.pause_resume.is_paused %}
{% set km = printer["gcode_macro _km_globals"] %}
# Warm the extruder back up if needed.
{% set extruder = printer[printer.toolhead.extruder] %}
{% if extruder.target <= printer.configfile.settings[
printer.toolhead.extruder].min_temp
| float + 0.5 %}
M109 S{saved_extruder_temp}
{% endif %}
# If there's no saved_e assume we're completing a filament change and
# retract enough to avoid drooling on the model.
{% if 'E' not in params and not saved_e %}
{% set saved_e = 5.0 %}
G1 E{'%.4f' % -saved_e } F{km.load_speed}
{% endif %}
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{0}"
G90
# Move back to last position before unretracting.
G0 X{saved_x} Y{saved_y} F{km.travel_speed_xy}
G0 Z{saved_z} F{km.travel_speed_z}
G91
# Unretract
G1 E{'%.4f' % (params.E|default(saved_e))} F{km.load_speed}
RESTORE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE MOVE=1
_KM_RESUME_BASE
{% else %}
{ action_respond_info("Printer is not paused.") }
{% endif %}
[gcode_macro cancel_print]
description: Cancels the current print.
Usage: CANCEL_PRINT
rename_existing: _KM_CANCEL_PRINT_BASE
gcode:
{% set was_paused = printer.pause_resume.is_paused %}
{% if was_paused or printer.idle_timeout.state|string == "Printing" %}
PRINT_END
SDCARD_RESET_FILE
{% else %}
{ action_respond_info("No print from SD card in progress.") }
{% endif %}
_KM_CANCEL_PRINT_BASE
{% if was_paused %}
RESTORE_GCODE_STATE NAME=_KM_PAUSE_OVERRIDE_STATE MOVE=0
{% endif %}
CLEAR_PAUSE
[gcode_macro clear_pause]
description: Clears the current pause state.
Usage: CLEAR_PAUSE
rename_existing: _KM_CLEAR_PAUSE
gcode:
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_e VALUE="{0.0}"
SET_GCODE_VARIABLE MACRO=resume VARIABLE=saved_extruder_temp VALUE="{0}"
_KM_CLEAR_PAUSE