From c6f870a65513ae719adc260e3e7e09e958abdcd0 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sun, 22 Nov 2020 20:33:49 -0500 Subject: [PATCH 001/136] docs: Update RPi_microcontroller.md links to render correctly on klipper3d.org Signed-off-by: Kevin O'Connor --- docs/RPi_microcontroller.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/RPi_microcontroller.md b/docs/RPi_microcontroller.md index d86a38a4..18b5a8ab 100644 --- a/docs/RPi_microcontroller.md +++ b/docs/RPi_microcontroller.md @@ -54,8 +54,8 @@ Remaining configuration Complete the installation by configuring Klipper secondary MCU following the instructions in -[RaspberryPi sample config](../config/sample-raspberry-pi.cfg) and -[Multi MCU sample config](../config/sample-multi-mcu.cfg). +[RaspberryPi sample config](https://github.com/KevinOConnor/klipper/tree/master/config/sample-raspberry-pi.cfg) and +[Multi MCU sample config](https://github.com/KevinOConnor/klipper/tree/master/config/sample-multi-mcu.cfg). Optional: Identify the correct gpiochip ======================================= From 665ec5e9877ec56c93fb519f069a6c932dbe91a9 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 23 Nov 2020 09:52:20 -0500 Subject: [PATCH 002/136] spi_temperature: Fix incorrect max31856 spi initialization Writes to the max31856 chip use "burst mode", so only one address during the initialization sequence can be sent. This fixes erroneous "Cold Junction Fault" errors. Reported by @NBouquain. Signed-off-by: Kevin O'Connor --- klippy/extras/spi_temperature.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/klippy/extras/spi_temperature.py b/klippy/extras/spi_temperature.py index defc0037..b6f33a9a 100644 --- a/klippy/extras/spi_temperature.py +++ b/klippy/extras/spi_temperature.py @@ -174,12 +174,10 @@ class MAX31856(SensorBase): "16" : MAX31856_CR1_AVGSEL16 } value |= config.getchoice('tc_averaging_count', averages, "1") - cmds.append(0x80 + MAX31856_CR1_REG) cmds.append(value) value = (MAX31856_MASK_VOLTAGE_UNDER_OVER_FAULT | MAX31856_MASK_THERMOCOUPLE_OPEN_FAULT) - cmds.append(0x80 + MAX31856_MASK_REG) cmds.append(value) return cmds From 0d5b05c704d1e15de2ce075f70d0de9f29ba1386 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 18 Nov 2020 20:26:58 -0500 Subject: [PATCH 003/136] lib: Add kconfiglib code Signed-off-by: Kevin O'Connor --- lib/README | 4 + lib/kconfiglib/LICENSE.txt | 5 + lib/kconfiglib/genconfig.py | 154 + lib/kconfiglib/kconfiglib.py | 7160 ++++++++++++++++++++++++++++++++ lib/kconfiglib/menuconfig.py | 3278 +++++++++++++++ lib/kconfiglib/olddefconfig.py | 28 + 6 files changed, 10629 insertions(+) create mode 100644 lib/kconfiglib/LICENSE.txt create mode 100755 lib/kconfiglib/genconfig.py create mode 100644 lib/kconfiglib/kconfiglib.py create mode 100755 lib/kconfiglib/menuconfig.py create mode 100755 lib/kconfiglib/olddefconfig.py diff --git a/lib/README b/lib/README index 3fa524e4..79bd4a15 100644 --- a/lib/README +++ b/lib/README @@ -78,3 +78,7 @@ the modifications. The fast-hash directory contains code from: https://github.com/ztanml/fast-hash revision ae3bb53c199fe75619e940b5b6a3584ede99c5fc + +The kconfiglib directory contains code from: + https://github.com/ulfalizer/Kconfiglib.git +version v14.1.0 (061e71f7d78cb057762d88de088055361863deff). diff --git a/lib/kconfiglib/LICENSE.txt b/lib/kconfiglib/LICENSE.txt new file mode 100644 index 00000000..8b31efca --- /dev/null +++ b/lib/kconfiglib/LICENSE.txt @@ -0,0 +1,5 @@ +Copyright (c) 2011-2019, Ulf Magnusson + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/lib/kconfiglib/genconfig.py b/lib/kconfiglib/genconfig.py new file mode 100755 index 00000000..62f065ba --- /dev/null +++ b/lib/kconfiglib/genconfig.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2018-2019, Ulf Magnusson +# SPDX-License-Identifier: ISC + +""" +Generates a header file with #defines from the configuration, matching the +format of include/generated/autoconf.h in the Linux kernel. + +Optionally, also writes the configuration output as a .config file. See +--config-out. + +The --sync-deps, --file-list, and --env-list options generate information that +can be used to avoid needless rebuilds/reconfigurations. + +Before writing a header or configuration file, Kconfiglib compares the old +contents of the file against the new contents. If there's no change, the write +is skipped. This avoids updating file metadata like the modification time, and +might save work depending on your build setup. + +By default, the configuration is generated from '.config'. A different +configuration file can be passed in the KCONFIG_CONFIG environment variable. + +A custom header string can be inserted at the beginning of generated +configuration and header files by setting the KCONFIG_CONFIG_HEADER and +KCONFIG_AUTOHEADER_HEADER environment variables, respectively (this also works +for other scripts). The string is not automatically made a comment (this is by +design, to allow anything to be added), and no trailing newline is added, so +add '/* */', '#', and newlines as appropriate. + +See https://www.gnu.org/software/make/manual/make.html#Multi_002dLine for a +handy way to define multi-line variables in makefiles, for use with custom +headers. Remember to export the variable to the environment. +""" +import argparse +import os +import sys + +import kconfiglib + + +DEFAULT_SYNC_DEPS_PATH = "deps/" + + +def main(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description=__doc__) + + parser.add_argument( + "--header-path", + metavar="HEADER_FILE", + help=""" +Path to write the generated header file to. If not specified, the path in the +environment variable KCONFIG_AUTOHEADER is used if it is set, and 'config.h' +otherwise. +""") + + parser.add_argument( + "--config-out", + metavar="CONFIG_FILE", + help=""" +Write the configuration to CONFIG_FILE. This is useful if you include .config +files in Makefiles, as the generated configuration file will be a full .config +file even if .config is outdated. The generated configuration matches what +olddefconfig would produce. If you use sync-deps, you can include +deps/auto.conf instead. --config-out is meant for cases where incremental build +information isn't needed. +""") + + parser.add_argument( + "--sync-deps", + metavar="OUTPUT_DIR", + nargs="?", + const=DEFAULT_SYNC_DEPS_PATH, + help=""" +Enable generation of symbol dependency information for incremental builds, +optionally specifying the output directory (default: {}). See the docstring of +Kconfig.sync_deps() in Kconfiglib for more information. +""".format(DEFAULT_SYNC_DEPS_PATH)) + + parser.add_argument( + "--file-list", + metavar="OUTPUT_FILE", + help=""" +Write a list of all Kconfig files to OUTPUT_FILE, with one file per line. The +paths are relative to $srctree (or to the current directory if $srctree is +unset). Files appear in the order they're 'source'd. +""") + + parser.add_argument( + "--env-list", + metavar="OUTPUT_FILE", + help=""" +Write a list of all environment variables referenced in Kconfig files to +OUTPUT_FILE, with one variable per line. Each line has the format NAME=VALUE. +Only environment variables referenced with the preprocessor $(VAR) syntax are +included, and not variables referenced with the older $VAR syntax (which is +only supported for backwards compatibility). +""") + + parser.add_argument( + "kconfig", + metavar="KCONFIG", + nargs="?", + default="Kconfig", + help="Top-level Kconfig file (default: Kconfig)") + + args = parser.parse_args() + + + kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True) + kconf.load_config() + + if args.header_path is None: + if "KCONFIG_AUTOHEADER" in os.environ: + kconf.write_autoconf() + else: + # Kconfiglib defaults to include/generated/autoconf.h to be + # compatible with the C tools. 'config.h' is used here instead for + # backwards compatibility. It's probably a saner default for tools + # as well. + kconf.write_autoconf("config.h") + else: + kconf.write_autoconf(args.header_path) + + if args.config_out is not None: + kconf.write_config(args.config_out, save_old=False) + + if args.sync_deps is not None: + kconf.sync_deps(args.sync_deps) + + if args.file_list is not None: + with _open_write(args.file_list) as f: + for path in kconf.kconfig_filenames: + f.write(path + "\n") + + if args.env_list is not None: + with _open_write(args.env_list) as f: + for env_var in kconf.env_vars: + f.write("{}={}\n".format(env_var, os.environ[env_var])) + + +def _open_write(path): + # Python 2/3 compatibility. io.open() is available on both, but makes + # write() expect 'unicode' strings on Python 2. + + if sys.version_info[0] < 3: + return open(path, "w") + return open(path, "w", encoding="utf-8") + + +if __name__ == "__main__": + main() diff --git a/lib/kconfiglib/kconfiglib.py b/lib/kconfiglib/kconfiglib.py new file mode 100644 index 00000000..c67895ce --- /dev/null +++ b/lib/kconfiglib/kconfiglib.py @@ -0,0 +1,7160 @@ +# Copyright (c) 2011-2019, Ulf Magnusson +# SPDX-License-Identifier: ISC + +""" +Overview +======== + +Kconfiglib is a Python 2/3 library for scripting and extracting information +from Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt) +configuration systems. + +See the homepage at https://github.com/ulfalizer/Kconfiglib for a longer +overview. + +Since Kconfiglib 12.0.0, the library version is available in +kconfiglib.VERSION, which is a (, , ) tuple, e.g. +(12, 0, 0). + + +Using Kconfiglib on the Linux kernel with the Makefile targets +============================================================== + +For the Linux kernel, a handy interface is provided by the +scripts/kconfig/Makefile patch, which can be applied with either 'git am' or +the 'patch' utility: + + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am + $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -p1 + +Warning: Not passing -p1 to patch will cause the wrong file to be patched. + +Please tell me if the patch does not apply. It should be trivial to apply +manually, as it's just a block of text that needs to be inserted near the other +*conf: targets in scripts/kconfig/Makefile. + +Look further down for a motivation for the Makefile patch and for instructions +on how you can use Kconfiglib without it. + +If you do not wish to install Kconfiglib via pip, the Makefile patch is set up +so that you can also just clone Kconfiglib into the kernel root: + + $ git clone git://github.com/ulfalizer/Kconfiglib.git + $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch') + +Warning: The directory name Kconfiglib/ is significant in this case, because +it's added to PYTHONPATH by the new targets in makefile.patch. + +The targets added by the Makefile patch are described in the following +sections. + + +make kmenuconfig +---------------- + +This target runs the curses menuconfig interface with Python 3. As of +Kconfiglib 12.2.0, both Python 2 and Python 3 are supported (previously, only +Python 3 was supported, so this was a backport). + + +make guiconfig +-------------- + +This target runs the Tkinter menuconfig interface. Both Python 2 and Python 3 +are supported. To change the Python interpreter used, pass +PYTHONCMD= to 'make'. The default is 'python'. + + +make [ARCH=] iscriptconfig +-------------------------------- + +This target gives an interactive Python prompt where a Kconfig instance has +been preloaded and is available in 'kconf'. To change the Python interpreter +used, pass PYTHONCMD= to 'make'. The default is 'python'. + +To get a feel for the API, try evaluating and printing the symbols in +kconf.defined_syms, and explore the MenuNode menu tree starting at +kconf.top_node by following 'next' and 'list' pointers. + +The item contained in a menu node is found in MenuNode.item (note that this can +be one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all +symbols and choices have a 'nodes' attribute containing their menu nodes +(usually only one). Printing a menu node will print its item, in Kconfig +format. + +If you want to look up a symbol by name, use the kconf.syms dictionary. + + +make scriptconfig SCRIPT= + + + From 6e48ee537f0503bc8d87e5387bd642a9b74df0b0 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 3 Dec 2020 15:27:38 -0500 Subject: [PATCH 041/136] docs: Fix "github pages" rendering of pictures in Resonance_Compensation.md The "github pages" service wont properly render a table with "|:--:|:--:|" and no table contents. In contrast, normal github markdown contents wont show the table without it. For now, remove the line as the normal github markdown contens look okay even if the content isn't rendered as a table. Signed-off-by: Kevin O'Connor --- docs/Resonance_Compensation.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/Resonance_Compensation.md b/docs/Resonance_Compensation.md index 5bc8d9f5..2a1e8a67 100644 --- a/docs/Resonance_Compensation.md +++ b/docs/Resonance_Compensation.md @@ -6,8 +6,7 @@ Klipper supports Input Shaping - a technique that can be used to reduce ringing printing defect when, typically, elements like edges repeat themselves on a printed surface as a subtle 'echo': -|![Ringing test](img/ringing-test.jpg) |![3D Benchy](img/ringing-3dbenchy.jpg) | -|:--:|:--:| +|![Ringing test](img/ringing-test.jpg)|![3D Benchy](img/ringing-3dbenchy.jpg)| Ringing is caused by mechanical vibrations in the printer due to quick changes of the printing direction. @@ -73,7 +72,6 @@ First, measure the **ringing frequency**. or calipers: |![Mark ringing](img/ringing-mark.jpg)|![Measure ringing](img/ringing-measure.jpg)| - |:--:|:--:| 9. Compute the ringing frequency = *V* · *N* / *D* (Hz) where *V* is the velocity for outer perimeters (mm/sec). For the example above, we marked 6 From 14952ccef5b932751b38077b1dd949c330a64b7d Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 3 Dec 2020 18:11:29 -0500 Subject: [PATCH 042/136] docs: Add links to default display.cfg and menu.cfg in Config_Reference.md Signed-off-by: Kevin O'Connor --- docs/Config_Reference.md | 12 ++++++++++++ klippy/extras/display/display.cfg | 5 +++++ klippy/extras/display/menu.cfg | 7 +++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 1d3ce221..2f1a8fa3 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -3123,6 +3123,12 @@ groups. The display will show all the data items for a given group if the display_group option in the [display] section is set to the given group name. +A +[default set of display groups](../klippy/extras/display/display.cfg) +are automatically created. One can replace or extend these +display_data items by overriding the defaults in the main printer.cfg +config file. + ``` [display_data my_group_name my_data_name] position: @@ -3206,6 +3212,12 @@ thus they do not support the "menu" options or button configuration. ## [menu] +Customizable lcd display menus. + +A [default set of menus](../klippy/extras/display/menu.cfg) are +automatically created. One can replace or extend the menu by +overriding the defaults in the main printer.cfg config file. + Available options in menu Jinja2 template context: Read-only attributes for menu element: diff --git a/klippy/extras/display/display.cfg b/klippy/extras/display/display.cfg index a6377914..042c3272 100644 --- a/klippy/extras/display/display.cfg +++ b/klippy/extras/display/display.cfg @@ -1,5 +1,10 @@ # This file defines the default layout of the printer's lcd display. +# It is not necessary to edit this file to change the display. +# Instead, one may override any of the sections defined here by +# defining a section with the same name in the main printer.cfg config +# file. + ###################################################################### # Helper macros for showing common screen values diff --git a/klippy/extras/display/menu.cfg b/klippy/extras/display/menu.cfg index 77009a1d..f107b829 100644 --- a/klippy/extras/display/menu.cfg +++ b/klippy/extras/display/menu.cfg @@ -1,5 +1,8 @@ -# This file serves as default menu structure. -# See the "example-menu.cfg" file for description of common config parameters. +# This file defines the default layout of the printer's menu. + +# It is not necessary to edit this file to change the menu. Instead, +# one may override any of the sections defined here by defining a +# section with the same name in the main printer.cfg config file. ### DEFAULT MENU ### # Main From 1f9516ad7f3cdcd942ab5dbc1c9d41e766b45645 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 3 Dec 2020 18:44:31 -0500 Subject: [PATCH 043/136] docs: Simplify javascript link modification for external references Signed-off-by: Kevin O'Connor --- docs/_layouts/default.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index b672ef67..b6bfee68 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -121,10 +121,9 @@ From 21a3a8559d34957a8ed210d68f344d1c7e3288cd Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 3 Dec 2020 19:24:40 -0500 Subject: [PATCH 044/136] docs: Add indentation to generated table-of-contents on klipper3d.org site Signed-off-by: Kevin O'Connor --- docs/_layouts/default.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index b6bfee68..5bbb3cca 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -107,12 +107,22 @@ padding-top: .5em; padding-bottom: .5em; } + .toc-item-H1 { margin-left: 0px; } + .toc-item-H2 { margin-left: 8px; } + .toc-item-H3, .toc-item-H4, .toc-item-H5, .toc-item-H6 { margin-left: 16px; }