diff --git a/.gitignore b/.gitignore index acffdf238..5c169384c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ package-lock.json cypress/screenshots/ cypress/videos/ components.d.ts + +src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfgParser.js +src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfgParser.terms.js \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 83dc5cb1d..743866b39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "hls.js": "^1.3.3", "jmuxer": "^2.0.5", "js-sha256": "^0.9.0", + "lezer": "^0.13.5", "lodash.kebabcase": "^4.1.1", "lodash.throttle": "^4.1.1", "overlayscrollbars": "^1.13.1", @@ -55,7 +56,9 @@ }, "devDependencies": { "@intlify/vite-plugin-vue-i18n": "^2.5.0", + "@lezer/generator": "^1.3.0", "@mdi/js": "^7.0.0", + "@rollup/plugin-node-resolve": "^15.1.0", "@types/file-saver": "^2.0.5", "@types/jmuxer": "^2.0.3", "@types/lodash.kebabcase": "^4.1.6", @@ -71,9 +74,12 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-jsonc": "^2.2.1", "eslint-plugin-vue": "^9.0.0", + "mocha": "^10.2.0", "prettier": "^2.5.1", + "rollup": "^2.79.1", "sass": "~1.32", "start-server-and-test": "^1.14.0", + "ts-node": "^10.9.1", "typescript": "^4.5.5", "unplugin-vue-components": "^0.22.12", "vite": "^3.2.7", @@ -2280,6 +2286,28 @@ "node": ">=0.1.90" } }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@cypress/request": { "version": "2.88.10", "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.10.tgz", @@ -2702,9 +2730,9 @@ } }, "node_modules/@lezer/common": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.1.tgz", - "integrity": "sha512-8TR5++Q/F//tpDsLd5zkrvEX5xxeemafEaek7mUp7Y+bI8cKQXdSqhzTOBaOogETcMOVr0pT3BBPXp13477ciw==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.3.tgz", + "integrity": "sha512-JH4wAXCgUOcCGNekQPLhVeUtIqjH0yPBs7vvUdSjyQama9618IOKFJwkv2kcqdhF0my8hQEgCTEJU0GIgnahvA==" }, "node_modules/@lezer/css": { "version": "1.0.0", @@ -2715,6 +2743,19 @@ "@lezer/lr": "^1.0.0" } }, + "node_modules/@lezer/generator": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@lezer/generator/-/generator-1.3.0.tgz", + "integrity": "sha512-7HfulDoOMOkskb97fnwgpC6StwPVSob4ptc0iuOH72rapNQBbp6lVj05y7vc5IM0E9pjFjiLmNQeiBiSbLpCtA==", + "dev": true, + "dependencies": { + "@lezer/common": "^1.0.2", + "@lezer/lr": "^1.3.0" + }, + "bin": { + "lezer-generator": "dist/lezer-generator.cjs" + } + }, "node_modules/@lezer/highlight": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.1.tgz", @@ -2733,9 +2774,9 @@ } }, "node_modules/@lezer/lr": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.2.3.tgz", - "integrity": "sha512-qpB7rBzH8f6Mzjv2AVZRahcm+2Cf7nbIH++uXbvVOL1yIRvVWQ3HAM/saeBLCyz/togB7LGo76qdJYL1uKQlqA==", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.7.tgz", + "integrity": "sha512-ssHKb3p0MxhJXT2i7UBmgAY1BIM3Uq/D772Qutu3EVmxWIyNMU12nQ0rL3Fhu+MiFtiTzyTmd3xGwEf3ON5PSA==", "dependencies": { "@lezer/common": "^1.0.0" } @@ -2828,46 +2869,56 @@ "dev": true }, "node_modules/@rollup/plugin-node-resolve": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", - "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", + "integrity": "sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==", "dev": true, "dependencies": { - "@rollup/pluginutils": "^3.1.0", - "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", "is-module": "^1.0.0", - "resolve": "^1.19.0" + "resolve": "^1.22.1" }, "engines": { - "node": ">= 10.0.0" + "node": ">=14.0.0" }, "peerDependencies": { - "rollup": "^1.20.0||^2.0.0" + "rollup": "^2.78.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, "node_modules/@rollup/plugin-node-resolve/node_modules/@rollup/pluginutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", - "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", "dev": true, "dependencies": { - "@types/estree": "0.0.39", - "estree-walker": "^1.0.1", - "picomatch": "^2.2.2" + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" }, "engines": { - "node": ">= 8.0.0" + "node": ">=14.0.0" }, "peerDependencies": { - "rollup": "^1.20.0||^2.0.0" + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } } }, - "node_modules/@rollup/plugin-node-resolve/node_modules/estree-walker": { + "node_modules/@rollup/plugin-node-resolve/node_modules/@types/estree": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", + "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", "dev": true }, "node_modules/@rollup/plugin-replace": { @@ -2982,6 +3033,30 @@ "sourcemap-codec": "^1.4.8" } }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "node_modules/@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -3070,13 +3145,10 @@ } }, "node_modules/@types/resolve": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", - "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", - "dev": true, - "dependencies": { - "@types/node": "*" - } + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true }, "node_modules/@types/scheduler": { "version": "0.16.2", @@ -3589,6 +3661,15 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -3711,6 +3792,12 @@ } ] }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -3992,6 +4079,12 @@ "node": ">=8" } }, + "node_modules/browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "node_modules/browserslist": { "version": "4.21.9", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", @@ -4289,6 +4382,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, "node_modules/codemirror": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz", @@ -4418,6 +4522,12 @@ "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "node_modules/crelt": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.5.tgz", @@ -4945,6 +5055,18 @@ } } }, + "node_modules/decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -4991,6 +5113,15 @@ "node": ">=0.4.0" } }, + "node_modules/diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -6109,6 +6240,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true, + "bin": { + "flat": "cli.js" + } + }, "node_modules/flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -6273,6 +6413,15 @@ "node": ">=6.9.0" } }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, "node_modules/get-intrinsic": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", @@ -6776,6 +6925,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -6933,6 +7097,15 @@ "node": ">=8" } }, + "node_modules/is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -7374,6 +7547,21 @@ "node": ">= 0.8.0" } }, + "node_modules/lezer": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/lezer/-/lezer-0.13.5.tgz", + "integrity": "sha512-cAiMQZGUo2BD8mpcz7Nv1TlKzWP7YIdIRrX41CiP5bk5t4GHxskOxWUx2iAOuHlz8dO+ivbuXr0J1bfHsWD+lQ==", + "deprecated": "This package has been replaced by @lezer/lr", + "dependencies": { + "lezer-tree": "^0.13.2" + } + }, + "node_modules/lezer-tree": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/lezer-tree/-/lezer-tree-0.13.2.tgz", + "integrity": "sha512-15ZxW8TxVNAOkHIo43Iouv4zbSkQQ5chQHBpwXcD2bBFz46RB4jYLEEww5l1V0xyIx9U2clSyyrLes+hAUFrGQ==", + "deprecated": "This package has been replaced by @lezer/common" + }, "node_modules/listr2": { "version": "3.14.0", "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.14.0.tgz", @@ -7566,6 +7754,12 @@ "node": ">=12" } }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "node_modules/map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", @@ -7666,6 +7860,135 @@ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, + "node_modules/mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "dependencies": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": ">= 14.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mochajs" + } + }, + "node_modules/mocha/node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/mocha/node_modules/glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha/node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/mocha/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mocha/node_modules/minimatch/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/mocha/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "node_modules/mocha/node_modules/nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/mocha/node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -8296,6 +8619,15 @@ "throttleit": "^1.0.0" } }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -8409,7 +8741,6 @@ "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", - "deprecated": "This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser", "dev": true, "dependencies": { "@babel/code-frame": "^7.10.4", @@ -9094,6 +9425,58 @@ "punycode": "^2.1.0" } }, + "node_modules/ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tslib": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", @@ -9511,6 +9894,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "node_modules/verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -10345,7 +10734,53 @@ "ajv": ">=8" } }, - "node_modules/workbox-build/node_modules/ajv": { + "node_modules/workbox-build/node_modules/@rollup/plugin-node-resolve": { + "version": "11.2.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", + "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/workbox-build/node_modules/@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "dependencies": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/workbox-build/node_modules/@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/workbox-build/node_modules/ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", @@ -10361,6 +10796,12 @@ "url": "https://github.com/sponsors/epoberezkin" } }, + "node_modules/workbox-build/node_modules/estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, "node_modules/workbox-build/node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -10503,6 +10944,12 @@ "workbox-core": "7.0.0" } }, + "node_modules/workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -10534,6 +10981,15 @@ "node": ">=12" } }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -10568,6 +11024,60 @@ "node": ">=4" } }, + "node_modules/yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "dependencies": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "dependencies": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs-unparser/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", @@ -10578,6 +11088,15 @@ "fd-slicer": "~1.1.0" } }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -12160,6 +12679,27 @@ "dev": true, "optional": true }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } + } + }, "@cypress/request": { "version": "2.88.10", "resolved": "https://registry.npmjs.org/@cypress/request/-/request-2.88.10.tgz", @@ -12489,9 +13029,9 @@ } }, "@lezer/common": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.1.tgz", - "integrity": "sha512-8TR5++Q/F//tpDsLd5zkrvEX5xxeemafEaek7mUp7Y+bI8cKQXdSqhzTOBaOogETcMOVr0pT3BBPXp13477ciw==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.0.3.tgz", + "integrity": "sha512-JH4wAXCgUOcCGNekQPLhVeUtIqjH0yPBs7vvUdSjyQama9618IOKFJwkv2kcqdhF0my8hQEgCTEJU0GIgnahvA==" }, "@lezer/css": { "version": "1.0.0", @@ -12502,6 +13042,16 @@ "@lezer/lr": "^1.0.0" } }, + "@lezer/generator": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@lezer/generator/-/generator-1.3.0.tgz", + "integrity": "sha512-7HfulDoOMOkskb97fnwgpC6StwPVSob4ptc0iuOH72rapNQBbp6lVj05y7vc5IM0E9pjFjiLmNQeiBiSbLpCtA==", + "dev": true, + "requires": { + "@lezer/common": "^1.0.2", + "@lezer/lr": "^1.3.0" + } + }, "@lezer/highlight": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.1.1.tgz", @@ -12520,9 +13070,9 @@ } }, "@lezer/lr": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.2.3.tgz", - "integrity": "sha512-qpB7rBzH8f6Mzjv2AVZRahcm+2Cf7nbIH++uXbvVOL1yIRvVWQ3HAM/saeBLCyz/togB7LGo76qdJYL1uKQlqA==", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.3.7.tgz", + "integrity": "sha512-ssHKb3p0MxhJXT2i7UBmgAY1BIM3Uq/D772Qutu3EVmxWIyNMU12nQ0rL3Fhu+MiFtiTzyTmd3xGwEf3ON5PSA==", "requires": { "@lezer/common": "^1.0.0" } @@ -12589,34 +13139,34 @@ } }, "@rollup/plugin-node-resolve": { - "version": "11.2.1", - "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", - "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "version": "15.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.1.0.tgz", + "integrity": "sha512-xeZHCgsiZ9pzYVgAo9580eCGqwh/XCEUM9q6iQfGNocjgkufHAqC3exA+45URvhiYV8sBF9RlBai650eNs7AsA==", "dev": true, "requires": { - "@rollup/pluginutils": "^3.1.0", - "@types/resolve": "1.17.1", - "builtin-modules": "^3.1.0", + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", "is-module": "^1.0.0", - "resolve": "^1.19.0" + "resolve": "^1.22.1" }, "dependencies": { "@rollup/pluginutils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", - "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", "dev": true, "requires": { - "@types/estree": "0.0.39", - "estree-walker": "^1.0.1", - "picomatch": "^2.2.2" + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" } }, - "estree-walker": { + "@types/estree": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", - "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.1.tgz", + "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==", "dev": true } } @@ -12725,6 +13275,30 @@ } } }, + "@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -12813,13 +13387,10 @@ } }, "@types/resolve": { - "version": "1.17.1", - "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", - "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", - "dev": true, - "requires": { - "@types/node": "*" - } + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true }, "@types/scheduler": { "version": "0.16.2", @@ -13177,6 +13748,12 @@ "dev": true, "requires": {} }, + "acorn-walk": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", + "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", + "dev": true + }, "aggregate-error": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", @@ -13253,6 +13830,12 @@ "integrity": "sha512-Of/R0wqp83cgHozfIYLbBMnej79U/SVGOOyuB3VVFv1NRM/PSFMK12x9KVtiYzJqmnU5WR2qp0Z5rHb7sWGnFQ==", "dev": true }, + "arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, "argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -13461,6 +14044,12 @@ "fill-range": "^7.0.1" } }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, "browserslist": { "version": "4.21.9", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.9.tgz", @@ -13647,6 +14236,17 @@ "string-width": "^4.2.0" } }, + "cliui": { + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^7.0.0" + } + }, "codemirror": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.1.tgz", @@ -13754,6 +14354,12 @@ "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", "dev": true }, + "create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, "crelt": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.5.tgz", @@ -14145,6 +14751,12 @@ "ms": "2.1.2" } }, + "decamelize": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", + "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", + "dev": true + }, "deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -14179,6 +14791,12 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, + "diff": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", + "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "dev": true + }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -14947,6 +15565,12 @@ "path-exists": "^4.0.0" } }, + "flat": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", + "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", + "dev": true + }, "flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", @@ -15059,6 +15683,12 @@ "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", "dev": true }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, "get-intrinsic": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.1.tgz", @@ -15413,6 +16043,15 @@ "has-tostringtag": "^1.0.0" } }, + "is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "requires": { + "builtin-modules": "^3.3.0" + } + }, "is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -15516,6 +16155,12 @@ "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true + }, "is-regex": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", @@ -15845,6 +16490,19 @@ "type-check": "~0.4.0" } }, + "lezer": { + "version": "0.13.5", + "resolved": "https://registry.npmjs.org/lezer/-/lezer-0.13.5.tgz", + "integrity": "sha512-cAiMQZGUo2BD8mpcz7Nv1TlKzWP7YIdIRrX41CiP5bk5t4GHxskOxWUx2iAOuHlz8dO+ivbuXr0J1bfHsWD+lQ==", + "requires": { + "lezer-tree": "^0.13.2" + } + }, + "lezer-tree": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/lezer-tree/-/lezer-tree-0.13.2.tgz", + "integrity": "sha512-15ZxW8TxVNAOkHIo43Iouv4zbSkQQ5chQHBpwXcD2bBFz46RB4jYLEEww5l1V0xyIx9U2clSyyrLes+hAUFrGQ==" + }, "listr2": { "version": "3.14.0", "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.14.0.tgz", @@ -15989,6 +16647,12 @@ "sourcemap-codec": "^1.4.8" } }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, "map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", @@ -16065,6 +16729,109 @@ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, + "mocha": { + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "dev": true, + "requires": { + "ansi-colors": "4.1.1", + "browser-stdout": "1.3.1", + "chokidar": "3.5.3", + "debug": "4.3.4", + "diff": "5.0.0", + "escape-string-regexp": "4.0.0", + "find-up": "5.0.0", + "glob": "7.2.0", + "he": "1.2.0", + "js-yaml": "4.1.0", + "log-symbols": "4.1.0", + "minimatch": "5.0.1", + "ms": "2.1.3", + "nanoid": "3.3.3", + "serialize-javascript": "6.0.0", + "strip-json-comments": "3.1.1", + "supports-color": "8.1.1", + "workerpool": "6.2.1", + "yargs": "16.2.0", + "yargs-parser": "20.2.4", + "yargs-unparser": "2.0.0" + }, + "dependencies": { + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true + }, + "glob": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + } + } + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + } + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "nanoid": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", + "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "dev": true + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + } + } + }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -16508,6 +17275,12 @@ "throttleit": "^1.0.0" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true + }, "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -17090,6 +17863,35 @@ "punycode": "^2.1.0" } }, + "ts-node": { + "version": "10.9.1", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", + "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "dependencies": { + "diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true + } + } + }, "tslib": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.0.tgz", @@ -17384,6 +18186,12 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==" }, + "v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", @@ -18004,6 +18812,40 @@ "leven": "^3.1.0" } }, + "@rollup/plugin-node-resolve": { + "version": "11.2.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz", + "integrity": "sha512-yc2n43jcqVyGE2sqV5/YCmocy9ArjVAP/BeXyTtADTBBX6V0e5UMqwO8CdQ0kzjb6zu5P1qMzsScCMRvE9OlVg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + } + }, + "@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", @@ -18016,6 +18858,12 @@ "uri-js": "^4.2.2" } }, + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", @@ -18157,6 +19005,12 @@ "workbox-core": "7.0.0" } }, + "workerpool": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", + "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==", + "dev": true + }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -18179,6 +19033,12 @@ "integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==", "dev": true }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", @@ -18209,6 +19069,47 @@ } } }, + "yargs": { + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.0", + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" + } + }, + "yargs-parser": { + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true + }, + "yargs-unparser": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", + "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", + "dev": true, + "requires": { + "camelcase": "^6.0.0", + "decamelize": "^4.0.0", + "flat": "^5.0.2", + "is-plain-obj": "^2.1.0" + }, + "dependencies": { + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true + } + } + }, "yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", @@ -18219,6 +19120,12 @@ "fd-slicer": "~1.1.0" } }, + "yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true + }, "yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index 181eb4ea7..51f9bfad1 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,10 @@ }, "scripts": { "serve": "vite serve", - "build": "vite build && npm run build.zip", + "build": "npm run build:lang && vite build && npm run build.zip", + "build:lang": "npm run build:parser:klipperCfg && npm run build:lang:klipperCfg", + "build:lang:klipperCfg": "rollup --config src/plugins/Codemirror/KlipperCfgLang/rollup.config.js", + "build:parser:klipperCfg": "lezer-generator src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfg.grammar -o src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfgParser.js", "format": "npm run format:base -- --write", "format:base": "prettier .", "format:check": "npm run format:base -- --check", @@ -20,6 +23,8 @@ "start": "vite build && vite preview", "test": "start-server-and-test preview http://127.0.0.1:4173/ 'cypress run'", "test:ui": "cypress open", + "test:parser:klipperCfg": "mocha --config src/plugins/Codemirror/.mocharc.json src/plugins/Codemirror/KlipperCfgLang/testParser/testKlipperCfgParser.js", + "test:lint:klipperCfg": "mocha --config src/plugins/Codemirror/.mocharc.json src/plugins/Codemirror/KlipperCfgLang/testLint/testKlipperCfgLint.js", "changelog": "git cliff v0.0.4..$(git describe --tags $(git rev-list --tags --max-count=1)) --output CHANGELOG.md" }, "dependencies": { @@ -45,6 +50,7 @@ "hls.js": "^1.3.3", "jmuxer": "^2.0.5", "js-sha256": "^0.9.0", + "lezer": "^0.13.5", "lodash.kebabcase": "^4.1.1", "lodash.throttle": "^4.1.1", "overlayscrollbars": "^1.13.1", @@ -70,7 +76,9 @@ }, "devDependencies": { "@intlify/vite-plugin-vue-i18n": "^2.5.0", + "@lezer/generator": "^1.3.0", "@mdi/js": "^7.0.0", + "@rollup/plugin-node-resolve": "^15.1.0", "@types/file-saver": "^2.0.5", "@types/jmuxer": "^2.0.3", "@types/lodash.kebabcase": "^4.1.6", @@ -86,9 +94,12 @@ "eslint-config-prettier": "^8.3.0", "eslint-plugin-jsonc": "^2.2.1", "eslint-plugin-vue": "^9.0.0", + "mocha": "^10.2.0", "prettier": "^2.5.1", + "rollup": "^2.79.1", "sass": "~1.32", "start-server-and-test": "^1.14.0", + "ts-node": "^10.9.1", "typescript": "^4.5.5", "unplugin-vue-components": "^0.22.12", "vite": "^3.2.7", diff --git a/src/components/inputs/Codemirror.vue b/src/components/inputs/Codemirror.vue index 9c54459ec..15bba279c 100644 --- a/src/components/inputs/Codemirror.vue +++ b/src/components/inputs/Codemirror.vue @@ -14,13 +14,20 @@ import { EditorView, keymap } from '@codemirror/view' import { EditorState } from '@codemirror/state' import { vscodeDark } from '@uiw/codemirror-theme-vscode' import { StreamLanguage } from '@codemirror/language' -import { klipper_config } from '@/plugins/StreamParserKlipperConfig' import { gcode } from '@/plugins/StreamParserGcode' import { indentWithTab } from '@codemirror/commands' import { json } from '@codemirror/lang-json' import { css } from '@codemirror/lang-css' +import { klipperCfg } from '../../plugins/Codemirror/KlipperCfgLang/lang/klipperCfg' +import { parseErrorLint } from '../../plugins/Codemirror/parseErrorLint' +import { klipperCfgLint } from '../../plugins/Codemirror/KlipperCfgLang/lang/lint' import { indentUnit } from '@codemirror/language' +// for lezer grammar debugging +/* import { logTree } from '../../plugins/Codemirror/printLezerTree' +import { syntaxTree } from '@codemirror/language' +import { parser } from '../../plugins/Codemirror/KlipperCfgLang/dist/klipperCfgParser.es.js' */ + @Component export default class Codemirror extends Mixins(BaseMixin) { private content = '' @@ -49,6 +56,11 @@ export default class Codemirror extends Mixins(BaseMixin) { if (newVal !== cm_value) { this.setCmValue(newVal) } + // for lezer grammar debugging + /* const state = this.cminstance?.state ?? EditorState.create({}) + logTree(syntaxTree(state), state.doc.toString()) + const text = state.doc.toString() + console.log(parser.parse(text) + '') */ } mounted(): void { @@ -86,6 +98,7 @@ export default class Codemirror extends Mixins(BaseMixin) { basicSetup, vscodeDark, indentUnit.of(' '.repeat(this.tabSize)), + parseErrorLint, keymap.of([indentWithTab]), EditorView.updateListener.of((update) => { this.content = update.state?.doc.toString() @@ -95,7 +108,8 @@ export default class Codemirror extends Mixins(BaseMixin) { }), ] - if (['cfg', 'conf'].includes(this.fileExtension)) extensions.push(StreamLanguage.define(klipper_config)) + if ("printer.cfg" === this.name) extensions.push(klipperCfgLint) + if (['cfg', 'conf'].includes(this.fileExtension)) extensions.push(klipperCfg()) else if (['gcode'].includes(this.fileExtension)) extensions.push(StreamLanguage.define(gcode)) else if (['json'].includes(this.fileExtension)) extensions.push(json()) else if (['css', 'scss', 'sass'].includes(this.fileExtension)) extensions.push(css()) diff --git a/src/plugins/Codemirror/.mocharc.json b/src/plugins/Codemirror/.mocharc.json new file mode 100644 index 000000000..fbd14399f --- /dev/null +++ b/src/plugins/Codemirror/.mocharc.json @@ -0,0 +1,4 @@ +{ + "extensions": ["ts"], + "node-option": ["loader=ts-node/esm"] +} diff --git a/src/plugins/Codemirror/KlipperCfgLang/lang/complete.ts b/src/plugins/Codemirror/KlipperCfgLang/lang/complete.ts new file mode 100644 index 000000000..4af30e782 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/lang/complete.ts @@ -0,0 +1,184 @@ +import { CompletionContext } from '@codemirror/autocomplete' +import { syntaxTree } from '@codemirror/language' +import { EditorState } from '@codemirror/state' +import { SyntaxNode } from '@lezer/common' +import { parseCfgMd } from '../parserCfgMd/parserCfgMd.js' +import { exampleText } from '../parserCfgMd/ref.js' + +// Parse Cfg Reference +const [parsedMd, dependentParameters] = parseCfgMd(exampleText) + +// Map with all autocompletion objects for each blocktype +const autocompletionMap = new Map() + +// Map with all autocompletion objects for each trigger parameter +const dependentParametersMap = new Map() + +function createParameterObject(parameter: any) { + return { + label: `${parameter.name}: `, + type: 'variable', + detail: parameter.isOptional ? '(optional)' : '(required)', + info: parameter.tooltip, + } +} + +// Populate autocompletionMap +parsedMd.forEach((entry) => { + const parameters = entry.parameters.map(createParameterObject) + autocompletionMap.set(entry.type, parameters) +}) + +// Populate dependentParametersMap +dependentParameters.forEach((entry) => { + const parameters = entry.parameters.map(createParameterObject) + dependentParametersMap.set(entry.triggerParameter, parameters) +}) + +export function klipperCfgCompletionSource(context: CompletionContext) { + const parent = syntaxTree(context.state).resolveInner(context.pos, -1) + const tagBefore = getTagBefore(context.state, parent.from, context.pos) + + if (parent?.type.name === 'Comment') return null + + if (parent?.type.name === 'Parameter') { + const typeNode = findTypeNode(parent) + if (!typeNode) return null + const blockType = context.state.sliceDoc(typeNode.from, typeNode.to) + const options = getOptionsByBlockType(blockType, context.state, parent) + if (options == null) return null + + return { + from: tagBefore ? parent.from + tagBefore.index : context.pos, + options: options, + validFor: /^(\w*)?$/, + } + } + + if (parent?.parent?.type.name === 'CfgBlock') { + return { + from: tagBefore ? parent.from + tagBefore.index : context.pos, + options: getAllPossibleBlockTypes(context.state, parent), + validFor: /^(\w*)?$/, + } + } + + return null +} + +function getTagBefore(state: EditorState, from: number, pos: number) { + const textBefore = state.sliceDoc(from, pos) + return /\w*$/.exec(textBefore) +} + +function findTypeNode(node: SyntaxNode) { + let travNode: SyntaxNode | null = node + while (travNode) { + if (travNode.type.name === 'CfgBlock') { + return travNode.firstChild + } + travNode = travNode.parent + } + return null +} + +function findPrinterNode(node: SyntaxNode, state: EditorState) { + const typeNode = findTypeNode(node) + // If node is [printer] return it + if (typeNode && typeNode.type.name === 'printer') { + return typeNode + } + // If not, find Programm node and search for printer node from there + let programmNode + if (typeNode) programmNode = typeNode.parent?.parent ?? null // If node is a typeNode go up to Programm node + else programmNode = node // If typeNode is null, node must be the Programm node or inside inport (here not important) + const printerNode = + programmNode?.getChildren('CfgBlock')?.find((cfgBlockNode) => { + const blockTypeNode = cfgBlockNode.firstChild + if (!blockTypeNode) return false + return state.sliceDoc(blockTypeNode.from, blockTypeNode.to) === 'printer' + }) ?? null + return printerNode +} + +function getPrinterKinematics(state: EditorState, node: SyntaxNode) { + const printerOptions = findPrinterNode(node, state)?.getChild('Body')?.getChildren('Option') ?? [] + for (const childNode of printerOptions) { + const parameter = childNode.getChild('Parameter') + const value = childNode.getChild('Value') + if (!parameter || !value) continue + const parameterName = state.sliceDoc(parameter.from, parameter.to) + if (parameterName !== 'kinematics') continue + const printerKinematics = state.sliceDoc(value.from, value.to).replace(/(\r\n|\n|\r)/gm, '') + return printerKinematics.split('#')[0].trim() + } + return '' +} + +function getOptionsByBlockType(blocktype: string, state: EditorState, parentNode: SyntaxNode) { + let options: { label: string; type: string; info: string }[] = [] + const printerKinematics = getPrinterKinematics(state, parentNode) + if (blocktype.includes('stepper_')) { + 1 + const stepperOptions = autocompletionMap.get(blocktype + '--' + printerKinematics) + const secondaryStepperOptions = /\d/.test(blocktype) + ? autocompletionMap.get('stepper_z1') + : autocompletionMap.get('stepper_x') + if (stepperOptions) { + options.push(...stepperOptions) + } + if (secondaryStepperOptions) { + options.push(...secondaryStepperOptions) + } + } else { + const optionsForBlockType = + autocompletionMap.get(blocktype) || autocompletionMap.get(blocktype + '--' + printerKinematics) + if (optionsForBlockType) { + options.push(...optionsForBlockType) + } + } + if (blocktype.includes('extruder') && /\d/.test(blocktype)) { + const secondaryExtruderOptions = autocompletionMap.get('extruder1') + if (secondaryExtruderOptions) { + options.push(...secondaryExtruderOptions) + } + } + return editOptions(options, state, parentNode) +} + +function editOptions(options: { label: string; type: string; info: string }[], state: EditorState, node: SyntaxNode) { + const allreadyUsedOptions = new Set() + // for all options in the current cfg block check if it is a trigger parameters and add dependent parameters if necessary + for (const childNode of node.parent?.parent?.getChildren('Option') ?? []) { + const parameter = childNode.firstChild + const value = childNode.lastChild + if (!parameter || !value) continue + const parameterName = state.sliceDoc(parameter.from, parameter.to).trim() + if (!parameterName.endsWith('_')) allreadyUsedOptions.add(parameterName) // save allready used options to remove them later (not "variable_") + const valueName = state.sliceDoc(value.from, value.to).replace(/(\r\n|\n|\r)/gm, '') + const parameterValue = parameterName + ':' + valueName + const mapEntry = dependentParametersMap.get(parameterValue) + if (mapEntry) { + options = options.concat(mapEntry) + } + } + // remove all options that are already used in the current cfg block + return (options = options.filter((option) => !allreadyUsedOptions.has(option.label.replace(': ', '')))) +} + +function getAllPossibleBlockTypes(state: EditorState, node: SyntaxNode) { + const printerKinematics = getPrinterKinematics(state, node) + let blockTypes = Array.from(autocompletionMap.keys()) + if (printerKinematics !== '') { + // all blockTypes but if stepper_ only these which match the printerKinematics + blockTypes = blockTypes.filter( + (blockType) => !blockType.includes('stepper_') || blockType.includes('--' + printerKinematics) + ) + } + return blockTypes.map((blockType) => ({ + label: blockType.includes('--') ? blockType.split('-')[0] : blockType, + type: 'keyword', + })) +} + +//Known Issues: secondary stepper/extruder-names are not suggested (only stepper_z1/extruder1) diff --git a/src/plugins/Codemirror/KlipperCfgLang/lang/klipperCfg.ts b/src/plugins/Codemirror/KlipperCfgLang/lang/klipperCfg.ts new file mode 100644 index 000000000..6e83ed824 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/lang/klipperCfg.ts @@ -0,0 +1,45 @@ +import { parser } from '../dist/klipperCfgParser.es.js' +import { LRLanguage, LanguageSupport, StreamLanguage, foldNodeProp } from '@codemirror/language' +import { parseMixed } from '@lezer/common' +import { klipper_config } from '../../../StreamParserKlipperConfig.js' +import { klipperCfgCompletionSource } from './complete.js' + + +const jinja2Parser = StreamLanguage.define(klipper_config).parser + +export const klipperCfgLang = LRLanguage.define({ + parser: parser.configure({ + props: [ + foldNodeProp.add({ + ConfigBlock(tree) { + const body = tree.lastChild + if (body == null) return null + let lastOption = body.lastChild + if (lastOption == null) return null + while (lastOption.name == 'Comment') { + lastOption = lastOption.prevSibling + if (lastOption == null) return null + } + return { from: body.from - 1, to: lastOption.to - 1 } + }, + }), + ], + wrap: parseMixed((node) => { + return node.name == 'Jinja2' ? { parser: jinja2Parser } : null + }), + }), + languageData: { + commentTokens: { line: '#' }, + }, +}) + +export function klipperCfg() { + return new LanguageSupport(klipperCfgLang, [ + klipperCfgLang.data.of({ autocomplete: klipperCfgCompletionSource }), + ]) +} + +/* +to generate the parser run: +npx lezer-generator klipperCfg.grammar -o klipperCfgParser.js + */ diff --git a/src/plugins/Codemirror/KlipperCfgLang/lang/lint.ts b/src/plugins/Codemirror/KlipperCfgLang/lang/lint.ts new file mode 100644 index 000000000..61b2efe87 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/lang/lint.ts @@ -0,0 +1,297 @@ +import { syntaxTree } from '@codemirror/language' +import { linter, Diagnostic } from '@codemirror/lint' +import { EditorState } from '@codemirror/state' +import { SyntaxNode } from '@lezer/common' +import { exampleText } from '../parserCfgMd/ref.js' +import { parseCfgMd, Parameter } from '../parserCfgMd/parserCfgMd.js' +import { EditorView } from 'codemirror' + +// Parse Cfg Reference +const [mdCfgBlockMap, mdDepParamBlockMap] = parseCfgMd(exampleText) + +export const klipperCfgLint = linter(lintSource) + +export function lintSource(view: EditorView) { + const diagnostics: Diagnostic[] = [] + const programmNode = syntaxTree(view.state).topNode + const importNodes = programmNode.getChildren('Import') + const cfgBlockNodes = getAllUsedBlockNodes(programmNode, view.state, diagnostics) // also adds diagnostics for duplicate BlockTypes + const autoGenBlockMap = getAllUsedAutoGenBlocks(view.state, programmNode) + + // check imports + importNodes.forEach((importNode) => { + const pathNode = importNode.getChild('FilePath') + if (!pathNode) { + addToDiagnostics(diagnostics, importNode, 'Import must be a file or file path') + } + }) + + // check all cfg blocks + const printerKinematics = getPrinterKinematics(view.state, programmNode) + const allPossibleBlockTypes = getAllPossibleBlockTypes(view.state, printerKinematics) + + cfgBlockNodes.forEach((cfgBlockNode, blockTypeIdent) => { + const blockTypeNode = cfgBlockNode.getChild('BlockType') + if (!blockTypeNode) return + let [blockType, identifier] = blockTypeIdent.split(' ') + if (/[^0-9][2-9]$/.test(blockType)) blockType = blockType.slice(0, -1) + '1' // e.g. extruder2 -> extruder1 to find options in mdCfgBlockMap + + // check if BlockType is valid + if (!allPossibleBlockTypes.has(blockType)) { + let msg = 'Invalid BlockType: ' + blockType + const possibleAlternatives = findClosestMatches(blockType, allPossibleBlockTypes) + if (possibleAlternatives.length > 0) { + msg += '\nDid you mean: ' + possibleAlternatives.map((item) => `"${item}"`).join(', ') + ' ?' + } + msg += '\n(forther linting in this block is not possible)' + addToDiagnostics(diagnostics, blockTypeNode, msg) + return + } + + // check if BlockName/identifier is given if required + if (!identifier && mdCfgBlockMap.get(blockType)?.requiresName) { + addToDiagnostics(diagnostics, blockTypeNode, 'Identifier required!\nLike [' + blockType + ' myName]') + } + + const usedOptions = getAllUsedOptionsForBlock(cfgBlockNode, view.state, diagnostics, autoGenBlockMap) // also add diagnostics for duplicate Parameters + if (usedOptions.size == 0) return + const allPossibleOptions = getAllPossibleOptionsForBlock(blockType, usedOptions) + if (allPossibleOptions.size == 0) return + + // check if all required options are given + allPossibleOptions.forEach((option, parameter) => { + if (!option.isOptional && !usedOptions.has(parameter)) { + addToDiagnostics(diagnostics, blockTypeNode, 'Missing required Parameter: ' + parameter) + } + }) + + usedOptions.forEach(({ paramValue, optionNode }, parameter) => { + // check if used option is valid in this blocktype + if (/^screw\d/.test(parameter)) parameter = parameter.replace(/\d/, '1') // e.g. screw4 -> screw1 to find options in mdCfgBlockMap + if (!allPossibleOptions.has(parameter)) { + addToDiagnostics(diagnostics, optionNode, 'Invalid Parameter in this Block!') + return + } + + // check if used option has correct value type + if (paramValue.includes('gcode:')) return // because the current use of the old Jinja2 parser there is no good way to check the value + const valueNode = optionNode.getChild('Value') ?? optionNode.getChild('AutoGenValue') + const valueType = valueNode?.firstChild?.name ?? '⚠' + if (!valueNode || !valueType || valueType === '⚠') { + addToDiagnostics(diagnostics, optionNode, 'Missing value for Parameter: ' + parameter) + return + } + const refParam = allPossibleOptions.get(parameter) + if (!refParam) return + if (refParam.valueType !== 'any' && !valueType.includes(refParam.valueType)) { + addToDiagnostics( + diagnostics, + optionNode, + 'Wrong value-type (' + + valueType + + ') for Parameter: ' + + parameter + + '! Expected: ' + + refParam.valueType + ) + return + } + }) + }) + + return diagnostics +} + +function addToDiagnostics(diagnostics: Diagnostic[], node: SyntaxNode, message: string) { + diagnostics.push({ + from: node.from, + to: node.to, + severity: 'error', + message: message, + }) +} + +function findPrinterNode(programmNode: SyntaxNode, state: EditorState) { + const printerNode = + programmNode.getChildren('ConfigBlock')?.find((cfgBlockNode) => { + const blockTypeNode = cfgBlockNode.getChild('BlockType') + if (!blockTypeNode) return false + return state.sliceDoc(blockTypeNode.from, blockTypeNode.to).trim().toLowerCase() === 'printer' + }) ?? null + return printerNode +} + +function getPrinterKinematics(state: EditorState, programmNode: SyntaxNode) { + const printerOptions = findPrinterNode(programmNode, state)?.getChild('Body')?.getChildren('Option') ?? [] + + for (const childNode of printerOptions) { + const parameter = childNode.getChild('Parameter') + const value = childNode.getChild('Value') + if (!parameter || !value) continue + const parameterName = state.sliceDoc(parameter.from, parameter.to).trim().toLowerCase() + if (parameterName !== 'kinematics') continue + const printerKinematics = state.sliceDoc(value.from, value.to).replace(/(\r\n|\n|\r)/gm, '') + return printerKinematics.split('#')[0].trim().toLowerCase() + } + + return '' +} + +function getAllPossibleBlockTypes(state: EditorState, printerKinematics: string) { + let blockTypes = Array.from(mdCfgBlockMap.keys()) + // if no printerKinematics is set, no filtering (all steppers_ possible) else filter steppers_ by printerKinematics + if (printerKinematics !== '') { + blockTypes = blockTypes.filter( + (blockType) => /^(?!stepper_\D*$).+/.test(blockType) || blockType.includes('--' + printerKinematics) + ) + } + blockTypes = blockTypes.map((blockType) => (blockType.includes('--') ? blockType.split('-')[0] : blockType)) + return new Set(blockTypes) +} + +function getAllUsedBlockNodes(programmNode: SyntaxNode, state: EditorState, diagnostics: Diagnostic[]) { + const cfgBlockNodes = programmNode.getChildren('ConfigBlock') + const cfgBlockNodeMap = new Map() + + cfgBlockNodes.forEach((cfgBlockNode) => { + const blockTypeNode = cfgBlockNode.getChild('BlockType') + if (!blockTypeNode) return + const blockType = state.sliceDoc(blockTypeNode.from, blockTypeNode.to).trim().toLowerCase() + + const identifierNode = cfgBlockNode.getChild('Identifier') + const identifierName = identifierNode + ? state.sliceDoc(identifierNode.from, identifierNode.to).trim().toLowerCase() + : '' + + const mapKey = blockType + ' ' + identifierName + if (cfgBlockNodeMap.has(mapKey)) addToDiagnostics(diagnostics, blockTypeNode, 'Duplicate BlockType') + else cfgBlockNodeMap.set(mapKey, cfgBlockNode) + }) + + return cfgBlockNodeMap +} + +function findClosestMatches(input: string, set: Set): string[] { + const matches = [] + let minErrors = Infinity + + for (const str of set) { + const errors = calculateErrors(input, str) + if (errors <= minErrors) { + minErrors = errors + if (errors === 0) { + matches.unshift(str) // Add exact matches at the beginning + } else { + matches.push(str) // Add other matches at the end + } + } + } + + return matches +} + +function calculateErrors(str1: string, str2: string): number { + const len1 = str1.length + const len2 = str2.length + const dp: number[][] = [] + + for (let i = 0; i <= len1; i++) { + dp[i] = [] + dp[i][0] = i + } + for (let j = 0; j <= len2; j++) { + dp[0][j] = j + } + for (let i = 1; i <= len1; i++) { + for (let j = 1; j <= len2; j++) { + const cost = str1[i - 1] === str2[j - 1] ? 0 : 1 + dp[i][j] = Math.min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost) + } + } + + return dp[len1][len2] +} + +function getAllUsedOptionsForBlock( + cfgBlockNode: SyntaxNode, + state: EditorState, + diagnostics: Diagnostic[], + autoGenBlockMap: Map +) { + const optionsNodeMap = new Map() + const optionNodes = cfgBlockNode.getChild('Body')?.getChildren('Option') ?? [] + const blockTypeNode = cfgBlockNode.getChild('BlockType') + if (!optionNodes || !blockTypeNode) return optionsNodeMap + const blockType = state.sliceDoc(blockTypeNode.from, blockTypeNode.to).trim().toLowerCase() + const autoGenParams = autoGenBlockMap.get(blockType) + if (autoGenParams && blockType !== 'bed_mesh') optionNodes.push(...autoGenParams) + + optionNodes.forEach((optionNode) => { + const parameterNode = optionNode.getChild('Parameter') + + if (!parameterNode) { + const gcodeNode = optionNode.getChild('GcodeKeyword') + if (!gcodeNode) return + const gcodeParam = state.sliceDoc(gcodeNode.from, gcodeNode.to).trim().toLowerCase() + if (gcodeParam === '') return + if (optionsNodeMap.has(gcodeParam)) addToDiagnostics(diagnostics, gcodeNode, 'Duplicate Parameter') + else optionsNodeMap.set(gcodeParam.split(':')[0], { paramValue: gcodeParam, optionNode: gcodeNode }) + return + } + + const parameter = state.sliceDoc(parameterNode.from, parameterNode.to).trim().toLowerCase() + const valueNode = optionNode.getChild('Value') ?? optionNode.getChild('AutoGenValue') + const value = valueNode ? state.sliceDoc(valueNode.from, valueNode.to).trim().toLowerCase() : '' + const paramValue = parameter + ':' + value + + if (optionsNodeMap.has(parameter)) addToDiagnostics(diagnostics, parameterNode, 'Duplicate Parameter') + else optionsNodeMap.set(parameter, { paramValue, optionNode }) + }) + + return optionsNodeMap +} + +function getAllPossibleOptionsForBlock( + blockType: string, + usedOptions: Map +) { + const allPossibleOptions = new Map() + const blockTypeOptions = mdCfgBlockMap.get(blockType)?.parameters ?? [] + blockTypeOptions.forEach((parameter) => { + allPossibleOptions.set(parameter.name, parameter) + }) + + if (blockType.includes('heater_')) { + const heaterOptions = mdCfgBlockMap.get('heater_generic')?.parameters ?? [] + heaterOptions.forEach((parameter) => { + if (!allPossibleOptions.has(parameter.name)) allPossibleOptions.set(parameter.name, parameter) + }) + } + + usedOptions.forEach(({ paramValue }) => { + const depParams = mdDepParamBlockMap.get(paramValue) + if (depParams) { + depParams.parameters.forEach((parameter) => { + allPossibleOptions.set(parameter.name, parameter) + }) + } + }) + + return allPossibleOptions +} + +function getAllUsedAutoGenBlocks(state: EditorState, programmNode: SyntaxNode) { + const autoGenParams = new Map() + const autoGenBlocks = programmNode.getChild('AutoGenSection')?.getChildren('AutoGenBlock') ?? [] + + autoGenBlocks.forEach((autoGenBlock) => { + const blockTypeNode = autoGenBlock.getChild('BlockType') + if (!blockTypeNode) return + const blockType = state.sliceDoc(blockTypeNode.from, blockTypeNode.to).trim().toLowerCase() + const autoGenOptionNodes = autoGenBlock.getChild('AutoGenBody')?.getChildren('AutoGenOption') + if (!autoGenOptionNodes) return + autoGenParams.set(blockType, autoGenOptionNodes) + }) + + return autoGenParams +} diff --git a/src/plugins/Codemirror/KlipperCfgLang/parser/highlight.js b/src/plugins/Codemirror/KlipperCfgLang/parser/highlight.js new file mode 100644 index 000000000..ae0eafe09 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/parser/highlight.js @@ -0,0 +1,31 @@ +import { styleTags, tags as t } from '@lezer/highlight' + +export const klipperConfigHighlighting = styleTags({ + Import: t.keyword, + ImportKeyword: t.keyword, + Parameter: t.variableName, + ConfigBlock: t.keyword, + AutoGenBlock: t.keyword, + BlockType: t.keyword, + Identifier: t.regexp, + + String: t.string, + Boolean: t.bool, + Number: t.number, + Cords: t.number, + Resolution: t.number, + Ratio: t.number, + Pin: t.namespace, + VirtualPin: t.namespace, + Path: t.string, + File: t.string, + FilePath: t.string, + Ipv4: t.number, + Ipv6: t.number, + + AutoGenLineStart: t.regexp, + AutoGenHeader: t.regexp, + AutoGenIndent: t.regexp, + + Comment: t.comment, +}) diff --git a/src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfg.grammar b/src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfg.grammar new file mode 100644 index 000000000..07a464bb0 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfg.grammar @@ -0,0 +1,85 @@ +@top Program { (Import | ConfigBlock)+ AutoGenSection? } + +@skip { space | blankLine | Comment newline? | AutoGenLineStart space* newline? } + +valueBlock { indent (content (newline | eof) | valueBlock)+ (dedent | eof) } +sep { content (seperator content)+ } + + +Import { "[" ImportKeyword FilePath "]" (newline | eof) } +ConfigBlock {"[" BlockType Identifier* "]" ( newline Body? | newline? eof ) } + +Body { Option+ eof? } +Option { Parameter ":" Value | GcodeKeyword Jinja2 } + +Value { value (newline | eof) | value? newline valueBlock } +Jinja2 { jinja2 (newline | eof) | jinja2? newline valueBlock } + +value { Pin | pins | VirtualPin | Cords | Number | String | Boolean | Path | FilePath | Resolution | Ratio | Ipv4 | Ipv6 } +pins { sep<(Pin | VirtualPin), ","> } +Cords { sep } +Number { number } + +AutoGenHeader { autoGenFirstLine newline autoGenSecondLine newline } +AutoGenSection { AutoGenHeader AutoGenBlock+ } +AutoGenBlock { "[" BlockType Identifier* "]" newline AutoGenBody } +AutoGenBody { AutoGenOption+ eof? } +AutoGenOption { Parameter "=" AutoGenValue } +AutoGenValue { (value | value? (newline AutoGenIndent value)+) (newline | eof) } + + +@context trackIndent from "./tokens.js" +@external tokens indentation from "./tokens.js" { indent, dedent } +@external tokens newlines from "./tokens.js" { newline, blankLine, eof } + +@tokens { + extAscii { $[a-zA-Z0-9_\-.] } + unixPath { ![/<>|:&{}\t\f #;\[\]\n\r] } + + ImportKeyword{ "include" } + GcodeKeyword{ extAscii* "gcode:" } + BlockType { extAscii+ } + Identifier { extAscii+ } + Parameter { extAscii+ } + Path { ("/"|"~/") unixPath+ ("/" unixPath+)* } + FilePath { (Path | unixPath+) "." unixPath+ } + Resolution { $[0-9]+ "x" $[0-9]+ } + Ratio { $[0-9]+ ":" $[0-9]+ } + Ipv4 { $[0-9]+ "." $[0-9]+ "." $[0-9]+ "." $[0-9]+ ((":"|"/") $[0-9]+)? } + hex { $[0-9a-fA-F] } + Ipv6 { (("::" (hex+ ":")* hex+) + | (hex+ (":" hex+)* "::") + | ((hex+ ":")+ (":" hex+)+) + | ((hex+ ":" hex+ ":" hex+ ":" hex+ ":" hex+ ":" hex+))) + ("/" $[0-9]+)?} + + String { ![#;\n\r]+ } + jinja2 { ![#;\n\r]+ } + number { "-"? $[0-9]+ ("." $[0-9]*)? } + Boolean { "True" | "False" | "true" | "false" } + Pin { ("^" | "~")? "!"? "P" $[A-Z]? $[0-9.]+ } + VirtualPin { ("^" | "~")? "!"? extAscii+ ":" extAscii+ } + + AutoGenLineStart { "#*#" } + AutoGenIndent { "#*# \t" } + autoGenFirstLine { "#*# <" "-"+ " SAVE_CONFIG " "-"+ ">" } + autoGenSecondLine { $[A-Za-z\-. ]+ } + + Comment { ("#"|";") ![\n\r]* } + + space { $[ \t\f]+ } + + @precedence { space, jinja2, String } // because space is used in jinja2/string rules + @precedence { autoGenFirstLine, autoGenSecondLine, AutoGenIndent, space } + @precedence { autoGenFirstLine, AutoGenIndent, AutoGenLineStart, Comment } // AutoGenerated also starts with a # + @precedence { Resolution, Ipv4, Ipv6, Ratio, number, Pin, VirtualPin, Boolean, ImportKeyword, FilePath, Path, String } + @precedence { ImportKeyword, BlockType }// because the ImportKeyword can be canerated with extAscii + @precedence { GcodeKeyword, Parameter } // because the GcodeKeyword can be canerated with extAscii +} + +@external propSource klipperConfigHighlighting from "./highlight" + +@detectDelim + +// to generate the parser run: +// npx lezer-generator klipperCfg.grammar -o klipperCfgParser.js \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/parser/tokens.js b/src/plugins/Codemirror/KlipperCfgLang/parser/tokens.js new file mode 100644 index 000000000..32da6ecec --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/parser/tokens.js @@ -0,0 +1,82 @@ +/* ref: https://github.com/lezer-parser/python/blob/main/src/tokens.js */ +import { ExternalTokenizer, ContextTracker } from '@lezer/lr' + +import { newline as newlineToken, eof, blankLine, indent, dedent } from '../parser/klipperCfgParser.terms.js' + +const newline = 10, + carriageReturn = 13, + space = 32, + tab = 9 + +function isLineBreak(ch) { + return ch == newline || ch == carriageReturn +} + +export const newlines = new ExternalTokenizer( + (input, stack) => { + let prev + if (input.next < 0) { + input.acceptToken(eof) + } else if ((prev = input.peek(-1)) < 0 || isLineBreak(prev)) { + while (input.next == space || input.next == tab) { + input.advance() + } + if (isLineBreak(input.next)) input.acceptToken(blankLine, 1) + } else if (isLineBreak(input.next)) { + input.acceptToken(newlineToken, 1) + } + }, + { contextual: true } +) + +export const indentation = new ExternalTokenizer((input, stack) => { + let cDepth = stack.context.depth + if (cDepth < 0) return + let prev = input.peek(-1), + depth + if (prev == newline || prev == carriageReturn) { + let depth = 0, + chars = 0 + for (;;) { + if (input.next == space) depth++ + else if (input.next == tab) depth += 8 - (depth % 8) + else break + input.advance() + chars++ + } + if (depth != cDepth && !isLineBreak(input.next)) { + if (depth < cDepth) input.acceptToken(dedent, -chars) + else input.acceptToken(indent) + } + } +}) + +function IndentLevel(parent, depth) { + this.parent = parent + // -1 means this is not an actual indent level but a set of brackets + this.depth = depth + this.hash = (parent ? (parent.hash + parent.hash) << 8 : 0) + depth + (depth << 4) +} + +const topIndent = new IndentLevel(null, 0) + +function countIndent(space) { + let depth = 0 + for (let i = 0; i < space.length; i++) depth += space.charCodeAt(i) == tab ? 8 - (depth % 8) : 1 + return depth +} + +export const trackIndent = new ContextTracker({ + start: topIndent, + reduce(context) { + return context.depth < 0 ? context.parent : context + }, + shift(context, term, stack, input) { + if (term == indent) return new IndentLevel(context, countIndent(input.read(input.pos, stack.pos)) >= 1 ? 1 : 0) + if (term == dedent) return context.parent + return context + }, + hash(context) { + return context.hash + }, +}) \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/parserCfgMd.ts b/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/parserCfgMd.ts new file mode 100644 index 000000000..0864ea99e --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/parserCfgMd.ts @@ -0,0 +1,197 @@ +export interface Parameter { + name: string + valueType: string + isOptional: boolean + tooltip: string +} + +interface CfgBlock { + type: string + requiresName: boolean + parameters: Parameter[] +} + +interface CondParamBlock { + triggerParameter: string + parameters: Parameter[] +} + +export function parseCfgMd(text: string): [Map, Map] { + const textLines = text.split('\n') + const cfgBlockMap: Map = new Map() + const depParamBlockMap: Map = new Map() + let currentCfgBlock: CfgBlock | null = null + let currentCondParamBlock: CondParamBlock | null = null + let isCodeSection = false + let printerKinematics = '' + let multipleTriggers: string[] = [] + + for (let lineIndex = 0; lineIndex < textLines.length; lineIndex++) { + const line = textLines[lineIndex] + const trimmedLine = line.trim() + + // Save current currentBlock if end of the codeBlock is reached or if new block is started + if ((trimmedLine === '```' && !isCodeSection) || /^#?\[.*\]$/.test(trimmedLine)) { + if (currentCfgBlock || currentCondParamBlock) { + if (currentCfgBlock) { + if ( + !cfgBlockMap.has(currentCfgBlock.type) || + (cfgBlockMap.get(currentCfgBlock.type)?.requiresName && !currentCfgBlock.requiresName) + ) { + cfgBlockMap.set(currentCfgBlock.type, currentCfgBlock) + currentCfgBlock = null + } + } else if (currentCondParamBlock) { + if (multipleTriggers.length > 0) { + for (const trigger of multipleTriggers) { + const condParamBlock: CondParamBlock = { + triggerParameter: 'sensor_type:' + trigger.replace(/"/g, ''), + parameters: currentCondParamBlock.parameters, + } + depParamBlockMap.set(condParamBlock.triggerParameter, condParamBlock) + } + multipleTriggers = [] + } else { + depParamBlockMap.set(currentCondParamBlock.triggerParameter, currentCondParamBlock) + } + currentCondParamBlock = null + } + } + if (trimmedLine === '```' && !isCodeSection) printerKinematics = '' + } + // Start new codeBlock or ends it + if (trimmedLine === '```') isCodeSection = !isCodeSection + + // Parse current cfg line + if (isCodeSection) { + // If [Block] + if (/^#?\[.*\]$/.test(trimmedLine)) { + const [type, name] = trimmedLine.replace(/\[|\]|#/g, '').split(' ') + // Because multiple [Blocks] exist which are spesific to the printer kinematics (printerKinematics only set if in same CodeSection as [printer]) + const newType = printerKinematics !== '' ? type + '--' + printerKinematics : type + currentCfgBlock = { + type: newType, + requiresName: !!name, + parameters: [], + } + // If under a [block] -> Parameter + } else if (currentCfgBlock) { + const parameterMatch = trimmedLine.match(/^(#?(\w+):)(.*)$/) + if (parameterMatch) { + const [, parameterWithColon, parameterName, value] = parameterMatch + const parameter: Parameter = { + name: (parameterName.includes('<') ? parameterName.split('<')[0] : parameterName).toLowerCase(), + valueType: parseValue(value.trim(), parameterName), + tooltip: findTooltip(textLines, lineIndex), + isOptional: parameterWithColon.startsWith('#'), + } + // For all [blocks] which only exists to specify dependent parameters + if ( + value.trim() !== '' && + (parameterName === 'kinematics' || + parameterName === 'lcd_type' || + (parameterName === 'type' && currentCfgBlock.type === 'menu')) + ) { + if (parameterName === 'kinematics') printerKinematics = value.trim() + currentCondParamBlock = { + triggerParameter: (parameterName + ':' + value.trim()).toLowerCase(), + parameters: [], + } + currentCfgBlock = null + } else { + currentCfgBlock.parameters.push(parameter) + } + } + // If no [block] but Parameter -> dependent Parameter + } else { + const parameterMatch = trimmedLine.match(/^(#?(\w+):)(.*)$/) + if (parameterMatch) { + const [, parameterWithColon, parameterName, value] = parameterMatch + const tooltip = findTooltip(textLines, lineIndex) + const parameter: Parameter = { + name: parameterName.toLowerCase(), + valueType: parseValue(value.trim(), parameterName), + tooltip: tooltip, + isOptional: parameterWithColon.startsWith('#'), + } + if (currentCondParamBlock == null) { + const match = tooltip.match(/One of\s+(.+)/) + if (match && match[1]) { + const values = match[1].match(/"([^"]+)"/g) ?? [] + multipleTriggers = values + } + currentCondParamBlock = { + triggerParameter: (parameterName + ':' + value.trim()).toLowerCase(), + parameters: [parameter], + } + } else { + currentCondParamBlock.parameters.push(parameter) + } + } + } + } + } + + return [cfgBlockMap, depParamBlockMap] +} + +function parseValue(valueType: string, parameterName: string): string { + if (['true', 'false', 'True', 'False'].includes(valueType)) { + return 'Boolean' + } else if (parameterName.includes('gear_ratio')) { + return 'Ratio' + } else if (/^-?\d+(?:\.\d+)?(,\s*-?\d+(?:\.\d+)?)+$/.test(valueType)) { + return 'Cords' + } else if (parameterName.includes('gcode')) { + return 'Jinja2' + } else if (parameterName.includes('pin') || valueType.match(/^(\^?!?PE\d\d?)|([^\s:]*:[^\s:]*)$/)) { + return 'Pin' + } else if (/^-?\d+(?:\.\d+)?$/.test(valueType)) { + return 'Number' + } else if (valueType === '') { + return 'any' + } else { + return 'String' + } +} + +function findTooltip(textLines: string[], currentLineIndex: number): string { + const tooltipLines: string[] = [] + for (let i = currentLineIndex + 1; i < textLines.length; i++) { + const trimmedNextLine = textLines[i].trim() + if (trimmedNextLine.startsWith('# ')) { + tooltipLines.push(trimmedNextLine.substring(3).trim()) + } else { + break + } + } + return tooltipLines.join(' ').trim() +} + +export function printCfgMd(text: string) { + const [parsedMd, CondParamBlock] = parseCfgMd(text) + parsedMd.forEach((cfgBlock) => { + let msg = '' + msg += `[${cfgBlock.type}] ${cfgBlock.requiresName}\n` + cfgBlock.parameters.forEach((parameter) => { + if (parameter.isOptional) { + msg += `|- ?${parameter.name}: ${parameter.valueType}\n` + } else { + msg += `|- ${parameter.name}: ${parameter.valueType}\n` + } + }) + console.log(msg) + }) + CondParamBlock.forEach((dependentParameter) => { + let msg = '' + msg += `${dependentParameter.triggerParameter}\n` + dependentParameter.parameters.forEach((parameter) => { + if (parameter.isOptional) { + msg += `|- ?${parameter.name}: ${parameter.valueType}\n` + } else { + msg += `|- ${parameter.name}: ${parameter.valueType}\n` + } + }) + console.log(msg) + }) +} diff --git a/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/ref.ts b/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/ref.ts new file mode 100644 index 000000000..526ddf414 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/parserCfgMd/ref.ts @@ -0,0 +1,4575 @@ +export const exampleText = ` +# Cfguration reference + +This document is a reference for options available in the Klipper +cfg file. + +The descriptions in this document are formatted so that it is possible +to cut-and-paste them into a printer cfg file. See the +[installation document](Installation.md) for information on setting up +Klipper and choosing an initial cfg file. + +## Micro-controller cfguration + +### Format of micro-controller pin names + +Many cfg options require the name of a micro-controller pin. +Klipper uses the hardware names for these pins - for example \`PA4\`. + +Pin names may be preceded by \`!\` to indicate that a reverse polarity +should be used (eg, trigger on low instead of high). + +Input pins may be preceded by \`^\` to indicate that a hardware pull-up +resistor should be enabled for the pin. If the micro-controller +supports pull-down resistors then an input pin may alternatively be +preceded by \`~\`. + +Note, some cfg sections may "create" additional pins. Where this +occurs, the cfg section defining the pins must be listed in the +cfg file before any sections using those pins. + +### [mcu] + +Cfguration of the primary micro-controller. + +\`\`\` +[mcu] +serial: +# The serial port to connect to the MCU. If unsure (or if it +# changes) see the "Where's my serial port?" section of the FAQ. +# This parameter must be provided when using a serial port. +#baud: 250000 +# The baud rate to use. The default is 250000. +#canbus_uuid: +# If using a device connected to a CAN bus then this sets the unique +# chip identifier to connect to. This value must be provided when using +# CAN bus for communication. +#canbus_interface: +# If using a device connected to a CAN bus then this sets the CAN +# network interface to use. The default is 'can0'. +#restart_method: +# This controls the mechanism the host will use to reset the +# micro-controller. The choices are 'arduino', 'cheetah', 'rpi_usb', +# and 'command'. The 'arduino' method (toggle DTR) is common on +# Arduino boards and clones. The 'cheetah' method is a special +# method needed for some Fysetc Cheetah boards. The 'rpi_usb' method +# is useful on Raspberry Pi boards with micro-controllers powered +# over USB - it briefly disables power to all USB ports to +# accomplish a micro-controller reset. The 'command' method involves +# sending a Klipper command to the micro-controller so that it can +# reset itself. The default is 'arduino' if the micro-controller +# communicates over a serial port, 'command' otherwise. +\`\`\` + +### [mcu my_extra_mcu] + +Additional micro-controllers (one may define any number of sections +with an "mcu" prefix). Additional micro-controllers introduce +additional pins that may be cfgured as heaters, steppers, fans, +etc.. For example, if an "[mcu extra_mcu]" section is introduced, then +pins such as "extra_mcu:ar9" may then be used elsewhere in the cfg +(where "ar9" is a hardware pin name or alias name on the given mcu). + +\`\`\` +[mcu my_extra_mcu] +# See the "mcu" section for cfguration parameters. +\`\`\` + +## Common kinematic settings + +### [printer] + +The printer section controls high level printer settings. + +\`\`\` +[printer] +kinematics: +# The type of printer in use. This option may be one of: cartesian, +# corexy, corexz, hybrid_corexy, hybrid_corexz, rotary_delta, delta, +# deltesian, polar, winch, or none. This parameter must be specified. +max_velocity: +# Maximum velocity (in mm/s) of the toolhead (relative to the +# print). This parameter must be specified. +max_accel: +# Maximum acceleration (in mm/s^2) of the toolhead (relative to the +# print). This parameter must be specified. +#max_accel_to_decel: +# A pseudo acceleration (in mm/s^2) controlling how fast the +# toolhead may go from acceleration to deceleration. It is used to +# reduce the top speed of short zig-zag moves (and thus reduce +# printer vibration from these moves). The default is half of +# max_accel. +#square_corner_velocity: 5.0 +# The maximum velocity (in mm/s) that the toolhead may travel a 90 +# degree corner at. A non-zero value can reduce changes in extruder +# flow rates by enabling instantaneous velocity changes of the +# toolhead during cornering. This value cfgures the internal +# centripetal velocity cornering algorithm; corners with angles +# larger than 90 degrees will have a higher cornering velocity while +# corners with angles less than 90 degrees will have a lower +# cornering velocity. If this is set to zero then the toolhead will +# decelerate to zero at each corner. The default is 5mm/s. +\`\`\` + +### [stepper] + +Stepper motor definitions. Different printer types (as specified by +the "kinematics" option in the [printer] cfg section) require +different names for the stepper (eg, \`stepper_x\` vs \`stepper_a\`). +Below are common stepper definitions. + +See the [rotation distance document](Rotation_Distance.md) for +information on calculating the \`rotation_distance\` parameter. See the +[Multi-MCU homing](Multi_MCU_Homing.md) document for information on +homing using multiple micro-controllers. + +\`\`\` +[stepper_x] +step_pin: +# Step GPIO pin (triggered high). This parameter must be provided. +dir_pin: +# Direction GPIO pin (high indicates positive direction). This +# parameter must be provided. +enable_pin: +# Enable pin (default is enable high; use ! to indicate enable +# low). If this parameter is not provided then the stepper motor +# driver must always be enabled. +rotation_distance: +# Distance (in mm) that the axis travels with one full rotation of +# the stepper motor (or final gear if gear_ratio is specified). +# This parameter must be provided. +microsteps: +# The number of microsteps the stepper motor driver uses. This +# parameter must be provided. +#full_steps_per_rotation: 200 +# The number of full steps for one rotation of the stepper motor. +# Set this to 200 for a 1.8 degree stepper motor or set to 400 for a +# 0.9 degree motor. The default is 200. +#gear_ratio: +# The gear ratio if the stepper motor is connected to the axis via a +# gearbox. For example, one may specify "5:1" if a 5 to 1 gearbox is +# in use. If the axis has multiple gearboxes one may specify a comma +# separated list of gear ratios (for example, "57:11, 2:1"). If a +# gear_ratio is specified then rotation_distance specifies the +# distance the axis travels for one full rotation of the final gear. +# The default is to not use a gear ratio. +#step_pulse_duration: +# The minimum time between the step pulse signal edge and the +# following "unstep" signal edge. This is also used to set the +# minimum time between a step pulse and a direction change signal. +# The default is 0.000000100 (100ns) for TMC steppers that are +# cfgured in UART or SPI mode, and the default is 0.000002 (which +# is 2us) for all other steppers. +endstop_pin: +# Endstop switch detection pin. If this endstop pin is on a +# different mcu than the stepper motor then it enables "multi-mcu +# homing". This parameter must be provided for the X, Y, and Z +# steppers on cartesian style printers. +#position_min: 0 +# Minimum valid distance (in mm) the user may command the stepper to +# move to. The default is 0mm. +position_endstop: +# Location of the endstop (in mm). This parameter must be provided +# for the X, Y, and Z steppers on cartesian style printers. +position_max: +# Maximum valid distance (in mm) the user may command the stepper to +# move to. This parameter must be provided for the X, Y, and Z +# steppers on cartesian style printers. +#homing_speed: 5.0 +# Maximum velocity (in mm/s) of the stepper when homing. The default +# is 5mm/s. +#homing_retract_dist: 5.0 +# Distance to backoff (in mm) before homing a second time during +# homing. Set this to zero to disable the second home. The default +# is 5mm. +#homing_retract_speed: +# Speed to use on the retract move after homing in case this should +# be different from the homing speed, which is the default for this +# parameter +#second_homing_speed: +# Velocity (in mm/s) of the stepper when performing the second home. +# The default is homing_speed/2. +#homing_positive_dir: +# If true, homing will cause the stepper to move in a positive +# direction (away from zero); if false, home towards zero. It is +# better to use the default than to specify this parameter. The +# default is true if position_endstop is near position_max and false +# if near position_min. +\`\`\` + +### Cartesian Kinematics + +See [example-cartesian.cfg](../cfg/example-cartesian.cfg) for an +example cartesian kinematics cfg file. + +Only parameters specific to cartesian printers are described here - +see [common kinematic settings](#common-kinematic-settings) for +available parameters. + +\`\`\` +[printer] +kinematics: cartesian +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. This setting can be used to restrict the maximum speed of +# the z stepper motor. The default is to use max_velocity for +# max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. It limits the acceleration of the z stepper motor. The +# default is to use max_accel for max_z_accel. + +# The stepper_x section is used to describe the stepper controlling +# the X axis in a cartesian robot. +[stepper_x] + +# The stepper_y section is used to describe the stepper controlling +# the Y axis in a cartesian robot. +[stepper_y] + +# The stepper_z section is used to describe the stepper controlling +# the Z axis in a cartesian robot. +[stepper_z] +\`\`\` + +### Linear Delta Kinematics + +See [example-delta.cfg](../cfg/example-delta.cfg) for an example +linear delta kinematics cfg file. See the +[delta calibrate guide](Delta_Calibrate.md) for information on +calibration. + +Only parameters specific to linear delta printers are described here - +see [common kinematic settings](#common-kinematic-settings) for +available parameters. + +\`\`\` +[printer] +kinematics: delta +max_z_velocity: +# For delta printers this limits the maximum velocity (in mm/s) of +# moves with z axis movement. This setting can be used to reduce the +# maximum speed of up/down moves (which require a higher step rate +# than other moves on a delta printer). The default is to use +# max_velocity for max_z_velocity. +#max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. Setting this may be useful if the printer can reach higher +# acceleration on XY moves than Z moves (eg, when using input shaper). +# The default is to use max_accel for max_z_accel. +#minimum_z_position: 0 +# The minimum Z position that the user may command the head to move +# to. The default is 0. +delta_radius: +# Radius (in mm) of the horizontal circle formed by the three linear +# axis towers. This parameter may also be calculated as: +# delta_radius = smooth_rod_offset - effector_offset - carriage_offset +# This parameter must be provided. +#print_radius: +# The radius (in mm) of valid toolhead XY coordinates. One may use +# this setting to customize the range checking of toolhead moves. If +# a large value is specified here then it may be possible to command +# the toolhead into a collision with a tower. The default is to use +# delta_radius for print_radius (which would normally prevent a +# tower collision). + +# The stepper_a section describes the stepper controlling the front +# left tower (at 210 degrees). This section also controls the homing +# parameters (homing_speed, homing_retract_dist) for all towers. +[stepper_a] +position_endstop: +# Distance (in mm) between the nozzle and the bed when the nozzle is +# in the center of the build area and the endstop triggers. This +# parameter must be provided for stepper_a; for stepper_b and +# stepper_c this parameter defaults to the value specified for +# stepper_a. +arm_length: +# Length (in mm) of the diagonal rod that connects this tower to the +# print head. This parameter must be provided for stepper_a; for +# stepper_b and stepper_c this parameter defaults to the value +# specified for stepper_a. +#angle: +# This option specifies the angle (in degrees) that the tower is +# at. The default is 210 for stepper_a, 330 for stepper_b, and 90 +# for stepper_c. + +# The stepper_b section describes the stepper controlling the front +# right tower (at 330 degrees). +[stepper_b] + +# The stepper_c section describes the stepper controlling the rear +# tower (at 90 degrees). +[stepper_c] + +# The delta_calibrate section enables a DELTA_CALIBRATE extended +# g-code command that can calibrate the tower endstop positions and +# angles. +[delta_calibrate] +radius: +# Radius (in mm) of the area that may be probed. This is the radius +# of nozzle coordinates to be probed; if using an automatic probe +# with an XY offset then choose a radius small enough so that the +# probe always fits over the bed. This parameter must be provided. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +\`\`\` + +### Deltesian Kinematics + +See [example-deltesian.cfg](../cfg/example-deltesian.cfg) for an +example deltesian kinematics cfg file. + +Only parameters specific to deltesian printers are described here - see +[common kinematic settings](#common-kinematic-settings) for available + parameters. + +\`\`\` +[printer] +kinematics: deltesian +max_z_velocity: +# For deltesian printers, this limits the maximum velocity (in mm/s) of +# moves with z axis movement. This setting can be used to reduce the +# maximum speed of up/down moves (which require a higher step rate +# than other moves on a deltesian printer). The default is to use +# max_velocity for max_z_velocity. +#max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. Setting this may be useful if the printer can reach higher +# acceleration on XY moves than Z moves (eg, when using input shaper). +# The default is to use max_accel for max_z_accel. +#minimum_z_position: 0 +# The minimum Z position that the user may command the head to move +# to. The default is 0. +#min_angle: 5 +# This represents the minimum angle (in degrees) relative to horizontal +# that the deltesian arms are allowed to achieve. This parameter is +# intended to restrict the arms from becoming completely horizontal, +# which would risk accidental inversion of the XZ axis. The default is 5. +#print_width: +# The distance (in mm) of valid toolhead X coordinates. One may use +# this setting to customize the range checking of toolhead moves. If +# a large value is specified here then it may be possible to command +# the toolhead into a collision with a tower. This setting usually +# corresponds to bed width (in mm). +#slow_ratio: 3 +# The ratio used to limit velocity and acceleration on moves near the +# extremes of the X axis. If vertical distance divided by horizontal +# distance exceeds the value of slow_ratio, then velocity and +# acceleration are limited to half their nominal values. If vertical +# distance divided by horizontal distance exceeds twice the value of +# the slow_ratio, then velocity and acceleration are limited to one +# quarter of their nominal values. The default is 3. + +# The stepper_left section is used to describe the stepper controlling +# the left tower. This section also controls the homing parameters +# (homing_speed, homing_retract_dist) for all towers. +[stepper_left] +position_endstop: +# Distance (in mm) between the nozzle and the bed when the nozzle is +# in the center of the build area and the endstops are triggered. This +# parameter must be provided for stepper_left; for stepper_right this +# parameter defaults to the value specified for stepper_left. +arm_length: +# Length (in mm) of the diagonal rod that connects the tower carriage to +# the print head. This parameter must be provided for stepper_left; for +# stepper_right, this parameter defaults to the value specified for +# stepper_left. +arm_x_length: +# Horizontal distance between the print head and the tower when the +# printers is homed. This parameter must be provided for stepper_left; +# for stepper_right, this parameter defaults to the value specified for +# stepper_left. + +# The stepper_right section is used to describe the stepper controlling the +# right tower. +[stepper_right] + +# The stepper_y section is used to describe the stepper controlling +# the Y axis in a deltesian robot. +[stepper_y] +\`\`\` + +### CoreXY Kinematics + +See [example-corexy.cfg](../cfg/example-corexy.cfg) for an example +corexy (and h-bot) kinematics file. + +Only parameters specific to corexy printers are described here - see +[common kinematic settings](#common-kinematic-settings) for available +parameters. + +\`\`\` +[printer] +kinematics: corexy +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. This setting can be used to restrict the maximum speed of +# the z stepper motor. The default is to use max_velocity for +# max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. It limits the acceleration of the z stepper motor. The +# default is to use max_accel for max_z_accel. + +# The stepper_x section is used to describe the X axis as well as the +# stepper controlling the X+Y movement. +[stepper_x] + +# The stepper_y section is used to describe the Y axis as well as the +# stepper controlling the X-Y movement. +[stepper_y] + +# The stepper_z section is used to describe the stepper controlling +# the Z axis. +[stepper_z] +\`\`\` + +### CoreXZ Kinematics + +See [example-corexz.cfg](../cfg/example-corexz.cfg) for an example +corexz kinematics cfg file. + +Only parameters specific to corexz printers are described here - see +[common kinematic settings](#common-kinematic-settings) for available +parameters. + +\`\`\` +[printer] +kinematics: corexz +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. The default is to use max_velocity for max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. The default is to use max_accel for max_z_accel. + +# The stepper_x section is used to describe the X axis as well as the +# stepper controlling the X+Z movement. +[stepper_x] + +# The stepper_y section is used to describe the stepper controlling +# the Y axis. +[stepper_y] + +# The stepper_z section is used to describe the Z axis as well as the +# stepper controlling the X-Z movement. +[stepper_z] +\`\`\` + +### Hybrid-CoreXY Kinematics + +See [example-hybrid-corexy.cfg](../cfg/example-hybrid-corexy.cfg) +for an example hybrid corexy kinematics cfg file. + +This kinematic is also known as Markforged kinematic. + +Only parameters specific to hybrid corexy printers are described here +see [common kinematic settings](#common-kinematic-settings) for available +parameters. + +\`\`\` +[printer] +kinematics: hybrid_corexy +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. The default is to use max_velocity for max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. The default is to use max_accel for max_z_accel. + +# The stepper_x section is used to describe the X axis as well as the +# stepper controlling the X-Y movement. +[stepper_x] + +# The stepper_y section is used to describe the stepper controlling +# the Y axis. +[stepper_y] + +# The stepper_z section is used to describe the stepper controlling +# the Z axis. +[stepper_z] +\`\`\` + +### Hybrid-CoreXZ Kinematics + +See [example-hybrid-corexz.cfg](../cfg/example-hybrid-corexz.cfg) +for an example hybrid corexz kinematics cfg file. + +This kinematic is also known as Markforged kinematic. + +Only parameters specific to hybrid corexy printers are described here +see [common kinematic settings](#common-kinematic-settings) for available +parameters. + +\`\`\` +[printer] +kinematics: hybrid_corexz +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. The default is to use max_velocity for max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. The default is to use max_accel for max_z_accel. + +# The stepper_x section is used to describe the X axis as well as the +# stepper controlling the X-Z movement. +[stepper_x] + +# The stepper_y section is used to describe the stepper controlling +# the Y axis. +[stepper_y] + +# The stepper_z section is used to describe the stepper controlling +# the Z axis. +[stepper_z] +\`\`\` + +### Polar Kinematics + +See [example-polar.cfg](../cfg/example-polar.cfg) for an example +polar kinematics cfg file. + +Only parameters specific to polar printers are described here - see +[common kinematic settings](#common-kinematic-settings) for available +parameters. + +POLAR KINEMATICS ARE A WORK IN PROGRESS. Moves around the 0, 0 +position are known to not work properly. + +\`\`\` +[printer] +kinematics: polar +max_z_velocity: +# This sets the maximum velocity (in mm/s) of movement along the z +# axis. This setting can be used to restrict the maximum speed of +# the z stepper motor. The default is to use max_velocity for +# max_z_velocity. +max_z_accel: +# This sets the maximum acceleration (in mm/s^2) of movement along +# the z axis. It limits the acceleration of the z stepper motor. The +# default is to use max_accel for max_z_accel. + +# The stepper_bed section is used to describe the stepper controlling +# the bed. +[stepper_bed] +gear_ratio: +# A gear_ratio must be specified and rotation_distance may not be +# specified. For example, if the bed has an 80 toothed pulley driven +# by a stepper with a 16 toothed pulley then one would specify a +# gear ratio of "80:16". This parameter must be provided. + +# The stepper_arm section is used to describe the stepper controlling +# the carriage on the arm. +[stepper_arm] + +# The stepper_z section is used to describe the stepper controlling +# the Z axis. +[stepper_z] +\`\`\` + +### Rotary delta Kinematics + +See [example-rotary-delta.cfg](../cfg/example-rotary-delta.cfg) for +an example rotary delta kinematics cfg file. + +Only parameters specific to rotary delta printers are described here - +see [common kinematic settings](#common-kinematic-settings) for +available parameters. + +ROTARY DELTA KINEMATICS ARE A WORK IN PROGRESS. Homing moves may +timeout and some boundary checks are not implemented. + +\`\`\` +[printer] +kinematics: rotary_delta +max_z_velocity: +# For delta printers this limits the maximum velocity (in mm/s) of +# moves with z axis movement. This setting can be used to reduce the +# maximum speed of up/down moves (which require a higher step rate +# than other moves on a delta printer). The default is to use +# max_velocity for max_z_velocity. +#minimum_z_position: 0 +# The minimum Z position that the user may command the head to move +# to. The default is 0. +shoulder_radius: +# Radius (in mm) of the horizontal circle formed by the three +# shoulder joints, minus the radius of the circle formed by the +# effector joints. This parameter may also be calculated as: +# shoulder_radius = (delta_f - delta_e) / sqrt(12) +# This parameter must be provided. +shoulder_height: +# Distance (in mm) of the shoulder joints from the bed, minus the +# effector toolhead height. This parameter must be provided. + +# The stepper_a section describes the stepper controlling the rear +# right arm (at 30 degrees). This section also controls the homing +# parameters (homing_speed, homing_retract_dist) for all arms. +[stepper_a] +gear_ratio: +# A gear_ratio must be specified and rotation_distance may not be +# specified. For example, if the arm has an 80 toothed pulley driven +# by a pulley with 16 teeth, which is in turn connected to a 60 +# toothed pulley driven by a stepper with a 16 toothed pulley, then +# one would specify a gear ratio of "80:16, 60:16". This parameter +# must be provided. +position_endstop: +# Distance (in mm) between the nozzle and the bed when the nozzle is +# in the center of the build area and the endstop triggers. This +# parameter must be provided for stepper_a; for stepper_b and +# stepper_c this parameter defaults to the value specified for +# stepper_a. +upper_arm_length: +# Length (in mm) of the arm connecting the "shoulder joint" to the +# "elbow joint". This parameter must be provided for stepper_a; for +# stepper_b and stepper_c this parameter defaults to the value +# specified for stepper_a. +lower_arm_length: +# Length (in mm) of the arm connecting the "elbow joint" to the +# "effector joint". This parameter must be provided for stepper_a; +# for stepper_b and stepper_c this parameter defaults to the value +# specified for stepper_a. +#angle: +# This option specifies the angle (in degrees) that the arm is at. +# The default is 30 for stepper_a, 150 for stepper_b, and 270 for +# stepper_c. + +# The stepper_b section describes the stepper controlling the rear +# left arm (at 150 degrees). +[stepper_b] + +# The stepper_c section describes the stepper controlling the front +# arm (at 270 degrees). +[stepper_c] + +# The delta_calibrate section enables a DELTA_CALIBRATE extended +# g-code command that can calibrate the shoulder endstop positions. +[delta_calibrate] +radius: +# Radius (in mm) of the area that may be probed. This is the radius +# of nozzle coordinates to be probed; if using an automatic probe +# with an XY offset then choose a radius small enough so that the +# probe always fits over the bed. This parameter must be provided. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +\`\`\` + +### Cable winch Kinematics + +See the [example-winch.cfg](../cfg/example-winch.cfg) for an +example cable winch kinematics cfg file. + +Only parameters specific to cable winch printers are described here - +see [common kinematic settings](#common-kinematic-settings) for +available parameters. + +CABLE WINCH SUPPORT IS EXPERIMENTAL. Homing is not implemented on +cable winch kinematics. In order to home the printer, manually send +movement commands until the toolhead is at 0, 0, 0 and then issue a +\`G28\` command. + +\`\`\` +[printer] +kinematics: winch + +# The stepper_a section describes the stepper connected to the first +# cable winch. A minimum of 3 and a maximum of 26 cable winches may be +# defined (stepper_a to stepper_z) though it is common to define 4. +[stepper_a] +rotation_distance: +# The rotation_distance is the nominal distance (in mm) the toolhead +# moves towards the cable winch for each full rotation of the +# stepper motor. This parameter must be provided. +anchor_x: +anchor_y: +anchor_z: +# The X, Y, and Z position of the cable winch in cartesian space. +# These parameters must be provided. +\`\`\` + +### None Kinematics + +It is possible to define a special "none" kinematics to disable +kinematic support in Klipper. This may be useful for controlling +devices that are not typical 3d-printers or for debugging purposes. + +\`\`\` +[printer] +kinematics: none +max_velocity: 1 +max_accel: 1 +# The max_velocity and max_accel parameters must be defined. The +# values are not used for "none" kinematics. +\`\`\` + +## Common extruder and heated bed support + +### [extruder] + +The extruder section is used to describe the heater parameters for the +nozzle hotend along with the stepper controlling the extruder. See the +[command reference](G-Codes.md#extruder) for additional information. +See the [pressure advance guide](Pressure_Advance.md) for information +on tuning pressure advance. + +\`\`\` +[extruder] +step_pin: +dir_pin: +enable_pin: +microsteps: +rotation_distance: +#full_steps_per_rotation: +#gear_ratio: +# See the "stepper" section for a description of the above +# parameters. If none of the above parameters are specified then no +# stepper will be associated with the nozzle hotend (though a +# SYNC_EXTRUDER_MOTION command may associate one at run-time). +nozzle_diameter: +# Diameter of the nozzle orifice (in mm). This parameter must be +# provided. +filament_diameter: +# The nominal diameter of the raw filament (in mm) as it enters the +# extruder. This parameter must be provided. +#max_extrude_cross_section: +# Maximum area (in mm^2) of an extrusion cross section (eg, +# extrusion width multiplied by layer height). This setting prevents +# excessive amounts of extrusion during relatively small XY moves. +# If a move requests an extrusion rate that would exceed this value +# it will cause an error to be returned. The default is: 4.0 * +# nozzle_diameter^2 +#instantaneous_corner_velocity: 1.000 +# The maximum instantaneous velocity change (in mm/s) of the +# extruder during the junction of two moves. The default is 1mm/s. +#max_extrude_only_distance: 50.0 +# Maximum length (in mm of raw filament) that a retraction or +# extrude-only move may have. If a retraction or extrude-only move +# requests a distance greater than this value it will cause an error +# to be returned. The default is 50mm. +#max_extrude_only_velocity: +#max_extrude_only_accel: +# Maximum velocity (in mm/s) and acceleration (in mm/s^2) of the +# extruder motor for retractions and extrude-only moves. These +# settings do not have any impact on normal printing moves. If not +# specified then they are calculated to match the limit an XY +# printing move with a cross section of 4.0*nozzle_diameter^2 would +# have. +#pressure_advance: 0.0 +# The amount of raw filament to push into the extruder during +# extruder acceleration. An equal amount of filament is retracted +# during deceleration. It is measured in millimeters per +# millimeter/second. The default is 0, which disables pressure +# advance. +#pressure_advance_smooth_time: 0.040 +# A time range (in seconds) to use when calculating the average +# extruder velocity for pressure advance. A larger value results in +# smoother extruder movements. This parameter may not exceed 200ms. +# This setting only applies if pressure_advance is non-zero. The +# default is 0.040 (40 milliseconds). +# +# The remaining variables describe the extruder heater. +heater_pin: +# PWM output pin controlling the heater. This parameter must be +# provided. +#max_power: 1.0 +# The maximum power (expressed as a value from 0.0 to 1.0) that the +# heater_pin may be set to. The value 1.0 allows the pin to be set +# fully enabled for extended periods, while a value of 0.5 would +# allow the pin to be enabled for no more than half the time. This +# setting may be used to limit the total power output (over extended +# periods) to the heater. The default is 1.0. +sensor_type: +# Type of sensor - common thermistors are "EPCOS 100K B57560G104F", +# "ATC Semitec 104GT-2", "ATC Semitec 104NT-4-R025H42G", "Generic +# 3950","Honeywell 100K 135-104LAG-J01", "NTC 100K MGB18-104F39050L32", +# "SliceEngineering 450", and "TDK NTCG104LH104JT1". See the +# "Temperature sensors" section for other sensors. This parameter +# must be provided. +sensor_pin: +# Analog input pin connected to the sensor. This parameter must be +# provided. +#pullup_resistor: 4700 +# The resistance (in ohms) of the pullup attached to the thermistor. +# This parameter is only valid when the sensor is a thermistor. The +# default is 4700 ohms. +#smooth_time: 1.0 +# A time value (in seconds) over which temperature measurements will +# be smoothed to reduce the impact of measurement noise. The default +# is 1 seconds. +control: +# Control algorithm (either pid or watermark). This parameter must +# be provided. +pid_Kp: +pid_Ki: +pid_Kd: +# The proportional (pid_Kp), integral (pid_Ki), and derivative +# (pid_Kd) settings for the PID feedback control system. Klipper +# evaluates the PID settings with the following general formula: +# heater_pwm = (Kp*error + Ki*integral(error) - Kd*derivative(error)) / 255 +# Where "error" is "requested_temperature - measured_temperature" +# and "heater_pwm" is the requested heating rate with 0.0 being full +# off and 1.0 being full on. Consider using the PID_CALIBRATE +# command to obtain these parameters. The pid_Kp, pid_Ki, and pid_Kd +# parameters must be provided for PID heaters. +#max_delta: 2.0 +# On 'watermark' controlled heaters this is the number of degrees in +# Celsius above the target temperature before disabling the heater +# as well as the number of degrees below the target before +# re-enabling the heater. The default is 2 degrees Celsius. +#pwm_cycle_time: 0.100 +# Time in seconds for each software PWM cycle of the heater. It is +# not recommended to set this unless there is an electrical +# requirement to switch the heater faster than 10 times a second. +# The default is 0.100 seconds. +#min_extrude_temp: 170 +# The minimum temperature (in Celsius) at which extruder move +# commands may be issued. The default is 170 Celsius. +min_temp: +max_temp: +# The maximum range of valid temperatures (in Celsius) that the +# heater must remain within. This controls a safety feature +# implemented in the micro-controller code - should the measured +# temperature ever fall outside this range then the micro-controller +# will go into a shutdown state. This check can help detect some +# heater and sensor hardware failures. Set this range just wide +# enough so that reasonable temperatures do not result in an error. +# These parameters must be provided. +\`\`\` + +### [heater_bed] + +The heater_bed section describes a heated bed. It uses the same heater +settings described in the "extruder" section. + +\`\`\` +[heater_bed] +heater_pin: +sensor_type: +sensor_pin: +control: +min_temp: +max_temp: +# See the "extruder" section for a description of the above parameters. +\`\`\` + +## Bed level support + +### [bed_mesh] + +Mesh Bed Leveling. One may define a bed_mesh cfg section to enable +move transformations that offset the z axis based on a mesh generated +from probed points. When using a probe to home the z-axis, it is +recommended to define a safe_z_home section in printer.cfg to home +toward the center of the print area. + +See the [bed mesh guide](Bed_Mesh.md) and +[command reference](G-Codes.md#bed_mesh) for additional information. + +Visual Examples: +\`\`\` + rectangular bed, probe_count = 3, 3: + x---x---x (max_point) + | + x---x---x + | + (min_point) x---x---x + + round bed, round_probe_count = 5, bed_radius = r: + x (0, r) end + / + x---x---x + \ + (-r, 0) x---x---x---x---x (r, 0) + \ + x---x---x + / + x (0, -r) start +\`\`\` + +\`\`\` +[bed_mesh] +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +#mesh_radius: +# Defines the radius of the mesh to probe for round beds. Note that +# the radius is relative to the coordinate specified by the +# mesh_origin option. This parameter must be provided for round beds +# and omitted for rectangular beds. +#mesh_origin: +# Defines the center X, Y coordinate of the mesh for round beds. This +# coordinate is relative to the probe's location. It may be useful +# to adjust the mesh_origin in an effort to maximize the size of the +# mesh radius. Default is 0, 0. This parameter must be omitted for +# rectangular beds. +#mesh_min: +# Defines the minimum X, Y coordinate of the mesh for rectangular +# beds. This coordinate is relative to the probe's location. This +# will be the first point probed, nearest to the origin. This +# parameter must be provided for rectangular beds. +#mesh_max: +# Defines the maximum X, Y coordinate of the mesh for rectangular +# beds. Adheres to the same principle as mesh_min, however this will +# be the furthest point probed from the bed's origin. This parameter +# must be provided for rectangular beds. +#probe_count: 3, 3 +# For rectangular beds, this is a comma separate pair of integer +# values X, Y defining the number of points to probe along each +# axis. A single value is also valid, in which case that value will +# be applied to both axes. Default is 3, 3. +#round_probe_count: 5 +# For round beds, this integer value defines the maximum number of +# points to probe along each axis. This value must be an odd number. +# Default is 5. +#fade_start: 1.0 +# The gcode z position in which to start phasing out z-adjustment +# when fade is enabled. Default is 1.0. +#fade_end: 0.0 +# The gcode z position in which phasing out completes. When set to a +# value below fade_start, fade is disabled. It should be noted that +# fade may add unwanted scaling along the z-axis of a print. If a +# user wishes to enable fade, a value of 10.0 is recommended. +# Default is 0.0, which disables fade. +#fade_target: +# The z position in which fade should converge. When this value is +# set to a non-zero value it must be within the range of z-values in +# the mesh. Users that wish to converge to the z homing position +# should set this to 0. Default is the average z value of the mesh. +#split_delta_z: .025 +# The amount of Z difference (in mm) along a move that will trigger +# a split. Default is .025. +#move_check_distance: 5.0 +# The distance (in mm) along a move to check for split_delta_z. +# This is also the minimum length that a move can be split. Default +# is 5.0. +#mesh_pps: 2, 2 +# A comma separated pair of integers X, Y defining the number of +# points per segment to interpolate in the mesh along each axis. A +# "segment" can be defined as the space between each probed point. +# The user may enter a single value which will be applied to both +# axes. Default is 2, 2. +#algorithm: lagrange +# The interpolation algorithm to use. May be either "lagrange" or +# "bicubic". This option will not affect 3x3 grids, which are forced +# to use lagrange sampling. Default is lagrange. +#bicubic_tension: .2 +# When using the bicubic algorithm the tension parameter above may +# be applied to change the amount of slope interpolated. Larger +# numbers will increase the amount of slope, which results in more +# curvature in the mesh. Default is .2. +#relative_reference_index: +# A point index in the mesh to reference all z values to. Enabling +# this parameter produces a mesh relative to the probed z position +# at the provided index. +#faulty_region_1_min: +#faulty_region_1_max: +# Optional points that define a faulty region. See docs/Bed_Mesh.md +# for details on faulty regions. Up to 99 faulty regions may be added. +# By default no faulty regions are set. +\`\`\` + +### [bed_tilt] + +Bed tilt compensation. One may define a bed_tilt cfg section to +enable move transformations that account for a tilted bed. Note that +bed_mesh and bed_tilt are incompatible; both cannot be defined. + +See the [command reference](G-Codes.md#bed_tilt) for additional +information. + +\`\`\` +[bed_tilt] +#x_adjust: 0 +# The amount to add to each move's Z height for each mm on the X +# axis. The default is 0. +#y_adjust: 0 +# The amount to add to each move's Z height for each mm on the Y +# axis. The default is 0. +#z_adjust: 0 +# The amount to add to the Z height when the nozzle is nominally at +# 0, 0. The default is 0. +# The remaining parameters control a BED_TILT_CALIBRATE extended +# g-code command that may be used to calibrate appropriate x and y +# adjustment parameters. +#points: +# A list of X, Y coordinates (one per line; subsequent lines +# indented) that should be probed during a BED_TILT_CALIBRATE +# command. Specify coordinates of the nozzle and be sure the probe +# is above the bed at the given nozzle coordinates. The default is +# to not enable the command. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +\`\`\` + +### [bed_screws] + +Tool to help adjust bed leveling screws. One may define a [bed_screws] +cfg section to enable a BED_SCREWS_ADJUST g-code command. + +See the +[leveling guide](Manual_Level.md#adjusting-bed-leveling-screws) and +[command reference](G-Codes.md#bed_screws) for additional information. + +\`\`\` +[bed_screws] +#screw1: +# The X, Y coordinate of the first bed leveling screw. This is a +# position to command the nozzle to that is directly above the bed +# screw (or as close as possible while still being above the bed). +# This parameter must be provided. +#screw1_name: +# An arbitrary name for the given screw. This name is displayed when +# the helper script runs. The default is to use a name based upon +# the screw XY location. +#screw1_fine_adjust: +# An X, Y coordinate to command the nozzle to so that one can fine +# tune the bed leveling screw. The default is to not perform fine +# adjustments on the bed screw. +#screw2: +#screw2_name: +#screw2_fine_adjust: +#... +# Additional bed leveling screws. At least three screws must be +# defined. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# when moving from one screw location to the next. The default is 5. +#probe_height: 0 +# The height of the probe (in mm) after adjusting for the thermal +# expansion of bed and nozzle. The default is zero. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#probe_speed: 5 +# The speed (in mm/s) when moving from a horizontal_move_z position +# to a probe_height position. The default is 5. +\`\`\` + +### [screws_tilt_adjust] + +Tool to help adjust bed screws tilt using Z probe. One may define a +screws_tilt_adjust cfg section to enable a SCREWS_TILT_CALCULATE +g-code command. + +See the +[leveling guide](Manual_Level.md#adjusting-bed-leveling-screws-using-the-bed-probe) +and [command reference](G-Codes.md#screws_tilt_adjust) for additional +information. + +\`\`\` +[screws_tilt_adjust] +#screw1: +# The (X, Y) coordinate of the first bed leveling screw. This is a +# position to command the nozzle to so that the probe is directly +# above the bed screw (or as close as possible while still being +# above the bed). This is the base screw used in calculations. This +# parameter must be provided. +#screw1_name: +# An arbitrary name for the given screw. This name is displayed when +# the helper script runs. The default is to use a name based upon +# the screw XY location. +#screw2: +#screw2_name: +#... +# Additional bed leveling screws. At least two screws must be +# defined. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +#screw_thread: CW-M3 +# The type of screw used for bed leveling, M3, M4, or M5, and the +# rotation direction of the knob that is used to level the bed. +# Accepted values: CW-M3, CCW-M3, CW-M4, CCW-M4, CW-M5, CCW-M5. +# Default value is CW-M3 which most printers use. A clockwise +# rotation of the knob decreases the gap between the nozzle and the +# bed. Conversely, a counter-clockwise rotation increases the gap. +\`\`\` + +### [z_tilt] + +Multiple Z stepper tilt adjustment. This feature enables independent +adjustment of multiple z steppers (see the "stepper_z1" section) to +adjust for tilt. If this section is present then a Z_TILT_ADJUST +extended [G-Code command](G-Codes.md#z_tilt) becomes available. + +\`\`\` +[z_tilt] +#z_positions: +# A list of X, Y coordinates (one per line; subsequent lines +# indented) describing the location of each bed "pivot point". The +# "pivot point" is the point where the bed attaches to the given Z +# stepper. It is described using nozzle coordinates (the X, Y position +# of the nozzle if it could move directly above the point). The +# first entry corresponds to stepper_z, the second to stepper_z1, +# the third to stepper_z2, etc. This parameter must be provided. +#points: +# A list of X, Y coordinates (one per line; subsequent lines +# indented) that should be probed during a Z_TILT_ADJUST command. +# Specify coordinates of the nozzle and be sure the probe is above +# the bed at the given nozzle coordinates. This parameter must be +# provided. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +#retries: 0 +# Number of times to retry if the probed points aren't within +# tolerance. +#retry_tolerance: 0 +# If retries are enabled then retry if largest and smallest probed +# points differ more than retry_tolerance. Note the smallest unit of +# change here would be a single step. However if you are probing +# more points than steppers then you will likely have a fixed +# minimum value for the range of probed points which you can learn +# by observing command output. +\`\`\` + +### [quad_gantry_level] + +Moving gantry leveling using 4 independently controlled Z motors. +Corrects hyperbolic parabola effects (potato chip) on moving gantry +which is more flexible. +WARNING: Using this on a moving bed may lead to undesirable results. +If this section is present then a QUAD_GANTRY_LEVEL extended G-Code +command becomes available. This routine assumes the following Z motor +cfguration: +\`\`\` + ---------------- + |Z1 Z2| + | --------- | + | | | | + | | | | + | x-------- | + |Z Z3| + ---------------- +\`\`\` +Where x is the 0, 0 point on the bed + +\`\`\` +[quad_gantry_level] +#gantry_corners: +# A newline separated list of X, Y coordinates describing the two +# opposing corners of the gantry. The first entry corresponds to Z, +# the second to Z2. This parameter must be provided. +#points: +# A newline separated list of four X, Y points that should be probed +# during a QUAD_GANTRY_LEVEL command. Order of the locations is +# important, and should correspond to Z, Z1, Z2, and Z3 location in +# order. This parameter must be provided. For maximum accuracy, +# ensure your probe offsets are cfgured. +#speed: 50 +# The speed (in mm/s) of non-probing moves during the calibration. +# The default is 50. +#horizontal_move_z: 5 +# The height (in mm) that the head should be commanded to move to +# just prior to starting a probe operation. The default is 5. +#max_adjust: 4 +# Safety limit if an adjustment greater than this value is requested +# quad_gantry_level will abort. +#retries: 0 +# Number of times to retry if the probed points aren't within +# tolerance. +#retry_tolerance: 0 +# If retries are enabled then retry if largest and smallest probed +# points differ more than retry_tolerance. +\`\`\` + +### [skew_correction] + +Printer Skew Correction. It is possible to use software to correct +printer skew across 3 planes, xy, xz, yz. This is done by printing a +calibration model along a plane and measuring three lengths. Due to +the nature of skew correction these lengths are set via gcode. See +[Skew Correction](Skew_Correction.md) and +[Command Reference](G-Codes.md#skew_correction) for details. + +\`\`\` +[skew_correction] +\`\`\` + +### [z_thermal_adjust] + +Temperature-dependant toolhead Z position adjustment. Compensate for vertical +toolhead movement caused by thermal expansion of the printer's frame in +real-time using a temperature sensor (typically coupled to a vertical section +of frame). + +See also: [extended g-code commands](G-Codes.md#z_thermal_adjust). + +\`\`\` +[z_thermal_adjust] +#temp_coeff: +# The temperature coefficient of expansion, in mm/degC. For example, a +# temp_coeff of 0.01 mm/degC will move the Z axis downwards by 0.01 mm for +# every degree Celsius that the temperature sensor increases. Defaults to +# 0.0 mm/degC, which applies no adjustment. +#smooth_time: +# Smoothing window applied to the temperature sensor, in seconds. Can reduce +# motor noise from excessive small corrections in response to sensor noise. +# The default is 2.0 seconds. +#z_adjust_off_above: +# Disables adjustments above this Z height [mm]. The last computed correction +# will remain applied until the toolhead moves below the specified Z height +# again. The default is 99999999.0 mm (always on). +#max_z_adjustment: +# Maximum absolute adjustment that can be applied to the Z axis [mm]. The +# default is 99999999.0 mm (unlimited). +#sensor_type: +#sensor_pin: +#min_temp: +#max_temp: +# Temperature sensor cfguration. +# See the "extruder" section for the definition of the above +# parameters. +#gcode_id: +# See the "heater_generic" section for the definition of this +# parameter. +\`\`\` + +## Customized homing + +### [safe_z_home] + +Safe Z homing. One may use this mechanism to home the Z axis at a +specific X, Y coordinate. This is useful if the toolhead, for example +has to move to the center of the bed before Z can be homed. + +\`\`\` +[safe_z_home] +home_xy_position: +# A X, Y coordinate (e.g. 100, 100) where the Z homing should be +# performed. This parameter must be provided. +#speed: 50.0 +# Speed at which the toolhead is moved to the safe Z home +# coordinate. The default is 50 mm/s +#z_hop: +# Distance (in mm) to lift the Z axis prior to homing. This is +# applied to any homing command, even if it doesn't home the Z axis. +# If the Z axis is already homed and the current Z position is less +# than z_hop, then this will lift the head to a height of z_hop. If +# the Z axis is not already homed the head is lifted by z_hop. +# The default is to not implement Z hop. +#z_hop_speed: 15.0 +# Speed (in mm/s) at which the Z axis is lifted prior to homing. The +# default is 15 mm/s. +#move_to_previous: False +# When set to True, the X and Y axes are reset to their previous +# positions after Z axis homing. The default is False. +\`\`\` + +### [homing_override] + +Homing override. One may use this mechanism to run a series of g-code +commands in place of a G28 found in the normal g-code input. This may +be useful on printers that require a specific procedure to home the +machine. + +\`\`\` +[homing_override] +gcode: +# A list of G-Code commands to execute in place of G28 commands +# found in the normal g-code input. See docs/Command_Templates.md +# for G-Code format. If a G28 is contained in this list of commands +# then it will invoke the normal homing procedure for the printer. +# The commands listed here must home all axes. This parameter must +# be provided. +#axes: xyz +# The axes to override. For example, if this is set to "z" then the +# override script will only be run when the z axis is homed (eg, via +# a "G28" or "G28 Z0" command). Note, the override script should +# still home all axes. The default is "xyz" which causes the +# override script to be run in place of all G28 commands. +#set_position_x: +#set_position_y: +#set_position_z: +# If specified, the printer will assume the axis is at the specified +# position prior to running the above g-code commands. Setting this +# disables homing checks for that axis. This may be useful if the +# head must move prior to invoking the normal G28 mechanism for an +# axis. The default is to not force a position for an axis. +\`\`\` + +### [endstop_phase] + +Stepper phase adjusted endstops. To use this feature, define a cfg +section with an "endstop_phase" prefix followed by the name of the +corresponding stepper cfg section (for example, +"[endstop_phase stepper_z]"). This feature can improve the accuracy of +endstop switches. Add a bare "[endstop_phase]" declaration to enable +the ENDSTOP_PHASE_CALIBRATE command. + +See the [endstop phases guide](Endstop_Phase.md) and +[command reference](G-Codes.md#endstop_phase) for additional +information. + +\`\`\` +[endstop_phase stepper_z] +#endstop_accuracy: +# Sets the expected accuracy (in mm) of the endstop. This represents +# the maximum error distance the endstop may trigger (eg, if an +# endstop may occasionally trigger 100um early or up to 100um late +# then set this to 0.200 for 200um). The default is +# 4*rotation_distance/full_steps_per_rotation. +#trigger_phase: +# This specifies the phase of the stepper motor driver to expect +# when hitting the endstop. It is composed of two numbers separated +# by a forward slash character - the phase and the total number of +# phases (eg, "7/64"). Only set this value if one is sure the +# stepper motor driver is reset every time the mcu is reset. If this +# is not set, then the stepper phase will be detected on the first +# home and that phase will be used on all subsequent homes. +#endstop_align_zero: False +# If true then the position_endstop of the axis will effectively be +# modified so that the zero position for the axis occurs at a full +# step on the stepper motor. (If used on the Z axis and the print +# layer height is a multiple of a full step distance then every +# layer will occur on a full step.) The default is False. +\`\`\` + +## G-Code macros and events + +### [gcode_macro] + +G-Code macros (one may define any number of sections with a +"gcode_macro" prefix). See the +[command template guide](Command_Templates.md) for more information. + +\`\`\` +[gcode_macro my_cmd] +#gcode: +# A list of G-Code commands to execute in place of "my_cmd". See +# docs/Command_Templates.md for G-Code format. This parameter must +# be provided. +#variable_: +# One may specify any number of options with a "variable_" prefix. +# The given variable name will be assigned the given value (parsed +# as a Python literal) and will be available during macro expansion. +# For example, a cfg with "variable_fan_speed = 75" might have +# gcode commands containing "M106 S{ fan_speed * 255 }". Variables +# can be changed at run-time using the SET_GCODE_VARIABLE command +# (see docs/Command_Templates.md for details). Variable names may +# not use upper case characters. +#rename_existing: +# This option will cause the macro to override an existing G-Code +# command and provide the previous definition of the command via the +# name provided here. This can be used to override builtin G-Code +# commands. Care should be taken when overriding commands as it can +# cause complex and unexpected results. The default is to not +# override an existing G-Code command. +#description: G-Code macro +# This will add a short description used at the HELP command or while +# using the auto completion feature. Default "G-Code macro" +\`\`\` + +### [delayed_gcode] + +Execute a gcode on a set delay. See the +[command template guide](Command_Templates.md#delayed-gcodes) and +[command reference](G-Codes.md#delayed_gcode) for more information. + +\`\`\` +[delayed_gcode my_delayed_gcode] +gcode: +# A list of G-Code commands to execute when the delay duration has +# elapsed. G-Code templates are supported. This parameter must be +# provided. +#initial_duration: 0.0 +# The duration of the initial delay (in seconds). If set to a +# non-zero value the delayed_gcode will execute the specified number +# of seconds after the printer enters the "ready" state. This can be +# useful for initialization procedures or a repeating delayed_gcode. +# If set to 0 the delayed_gcode will not execute on startup. +# Default is 0. +\`\`\` + +### [save_variables] + +Support saving variables to disk so that they are retained across +restarts. See +[command templates](Command_Templates.md#save-variables-to-disk) and +[G-Code reference](G-Codes.md#save_variables) for further information. + +\`\`\` +[save_variables] +filename: +# Required - provide a filename that would be used to save the +# variables to disk e.g. ~/variables.cfg +\`\`\` + +### [idle_timeout] + +Idle timeout. An idle timeout is automatically enabled - add an +explicit idle_timeout cfg section to change the default settings. + +\`\`\` +[idle_timeout] +#gcode: +# A list of G-Code commands to execute on an idle timeout. See +# docs/Command_Templates.md for G-Code format. The default is to run +# "TURN_OFF_HEATERS" and "M84". +#timeout: 600 +# Idle time (in seconds) to wait before running the above G-Code +# commands. The default is 600 seconds. +\`\`\` + +## Optional G-Code features + +### [virtual_sdcard] + +A virtual sdcard may be useful if the host machine is not fast enough +to run OctoPrint well. It allows the Klipper host software to directly +print gcode files stored in a directory on the host using standard +sdcard G-Code commands (eg, M24). + +\`\`\` +[virtual_sdcard] +path: +# The path of the local directory on the host machine to look for +# g-code files. This is a read-only directory (sdcard file writes +# are not supported). One may point this to OctoPrint's upload +# directory (generally ~/.octoprint/uploads/ ). This parameter must +# be provided. +#on_error_gcode: +# A list of G-Code commands to execute when an error is reported. + +\`\`\` + +### [sdcard_loop] + +Some printers with stage-clearing features, such as a part ejector or +a belt printer, can find use in looping sections of the sdcard file. +(For example, to print the same part over and over, or repeat the +a section of a part for a chain or other repeated pattern). + +See the [command reference](G-Codes.md#sdcard_loop) for supported +commands. See the [sample-macros.cfg](../cfg/sample-macros.cfg) +file for a Marlin compatible M808 G-Code macro. + +\`\`\` +[sdcard_loop] +\`\`\` + +### [force_move] + +Support manually moving stepper motors for diagnostic purposes. Note, +using this feature may place the printer in an invalid state - see the +[command reference](G-Codes.md#force_move) for important details. + +\`\`\` +[force_move] +#enable_force_move: False +# Set to true to enable FORCE_MOVE and SET_KINEMATIC_POSITION +# extended G-Code commands. The default is false. +\`\`\` + +### [pause_resume] + +Pause/Resume functionality with support of position capture and +restore. See the [command reference](G-Codes.md#pause_resume) for more +information. + +\`\`\` +[pause_resume] +#recover_velocity: 50. +# When capture/restore is enabled, the speed at which to return to +# the captured position (in mm/s). Default is 50.0 mm/s. +\`\`\` + +### [firmware_retraction] + +Firmware filament retraction. This enables G10 (retract) and G11 +(unretract) GCODE commands issued by many slicers. The parameters +below provide startup defaults, although the values can be adjusted +via the SET_RETRACTION [command](G-Codes.md#firmware_retraction)), +allowing per-filament settings and runtime tuning. + +\`\`\` +[firmware_retraction] +#retract_length: 0 +# The length of filament (in mm) to retract when G10 is activated, +# and to unretract when G11 is activated (but see +# unretract_extra_length below). The default is 0 mm. +#retract_speed: 20 +# The speed of retraction, in mm/s. The default is 20 mm/s. +#unretract_extra_length: 0 +# The length (in mm) of *additional* filament to add when +# unretracting. +#unretract_speed: 10 +# The speed of unretraction, in mm/s. The default is 10 mm/s. +\`\`\` + +### [gcode_arcs] + +Support for gcode arc (G2/G3) commands. + +\`\`\` +[gcode_arcs] +#resolution: 1.0 +# An arc will be split into segments. Each segment's length will +# equal the resolution in mm set above. Lower values will produce a +# finer arc, but also more work for your machine. Arcs smaller than +# the cfgured value will become straight lines. The default is +# 1mm. +\`\`\` + +### [respond] + +Enable the "M118" and "RESPOND" extended +[commands](G-Codes.md#respond). + +\`\`\` +[respond] +#default_type: echo +# Sets the default prefix of the "M118" and "RESPOND" output to one +# of the following: +# echo: "echo: " (This is the default) +# command: "// " +# error: "!! " +#default_prefix: echo: +# Directly sets the default prefix. If present, this value will +# override the "default_type". +\`\`\` + +### [exclude_object] +Enables support to exclude or cancel individual objects during the printing +process. + +See the [exclude objects guide](Exclude_Object.md) and +[command reference](G-Codes.md#excludeobject) +for additional information. See the +[sample-macros.cfg](../cfg/sample-macros.cfg) file for a +Marlin/RepRapFirmware compatible M486 G-Code macro. + +\`\`\` +[exclude_object] +\`\`\` + +## Resonance compensation + +### [input_shaper] + +Enables [resonance compensation](Resonance_Compensation.md). Also see +the [command reference](G-Codes.md#input_shaper). + +\`\`\` +[input_shaper] +#shaper_freq_x: 0 +# A frequency (in Hz) of the input shaper for X axis. This is +# usually a resonance frequency of X axis that the input shaper +# should suppress. For more complex shapers, like 2- and 3-hump EI +# input shapers, this parameter can be set from different +# considerations. The default value is 0, which disables input +# shaping for X axis. +#shaper_freq_y: 0 +# A frequency (in Hz) of the input shaper for Y axis. This is +# usually a resonance frequency of Y axis that the input shaper +# should suppress. For more complex shapers, like 2- and 3-hump EI +# input shapers, this parameter can be set from different +# considerations. The default value is 0, which disables input +# shaping for Y axis. +#shaper_type: mzv +# A type of the input shaper to use for both X and Y axes. Supported +# shapers are zv, mzv, zvd, ei, 2hump_ei, and 3hump_ei. The default +# is mzv input shaper. +#shaper_type_x: +#shaper_type_y: +# If shaper_type is not set, these two parameters can be used to +# cfgure different input shapers for X and Y axes. The same +# values are supported as for shaper_type parameter. +#damping_ratio_x: 0.1 +#damping_ratio_y: 0.1 +# Damping ratios of vibrations of X and Y axes used by input shapers +# to improve vibration suppression. Default value is 0.1 which is a +# good all-round value for most printers. In most circumstances this +# parameter requires no tuning and should not be changed. +\`\`\` + +### [adxl345] + +Support for ADXL345 accelerometers. This support allows one to query +accelerometer measurements from the sensor. This enables an +ACCELEROMETER_MEASURE command (see [G-Codes](G-Codes.md#adxl345) for +more information). The default chip name is "default", but one may +specify an explicit name (eg, [adxl345 my_chip_name]). + +\`\`\` +[adxl345] +cs_pin: +# The SPI enable pin for the sensor. This parameter must be provided. +#spi_speed: 5000000 +# The SPI speed (in hz) to use when communicating with the chip. +# The default is 5000000. +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#axes_map: x, y, z +# The accelerometer axis for each of the printer's X, Y, and Z axes. +# This may be useful if the accelerometer is mounted in an +# orientation that does not match the printer orientation. For +# example, one could set this to "y, x, z" to swap the X and Y axes. +# It is also possible to negate an axis if the accelerometer +# direction is reversed (eg, "x, z, -y"). The default is "x, y, z". +#rate: 3200 +# Output data rate for ADXL345. ADXL345 supports the following data +# rates: 3200, 1600, 800, 400, 200, 100, 50, and 25. Note that it is +# not recommended to change this rate from the default 3200, and +# rates below 800 will considerably affect the quality of resonance +# measurements. +\`\`\` + +### [mpu9250] + +Support for MPU-9250, MPU-9255, MPU-6515, MPU-6050, and MPU-6500 +accelerometers (one may define any number of sections with an +"mpu9250" prefix). + +\`\`\` +[mpu9250 my_accelerometer] +#i2c_address: +# Default is 104 (0x68). If AD0 is high, it would be 0x69 instead. +#i2c_mcu: +#i2c_bus: +#i2c_speed: 400000 +# See the "common I2C settings" section for a description of the +# above parameters. The default "i2c_speed" is 400000. +#axes_map: x, y, z +# See the "adxl345" section for information on this parameter. +\`\`\` + +### [resonance_tester] + +Support for resonance testing and automatic input shaper calibration. +In order to use most of the functionality of this module, additional +software dependencies must be installed; refer to +[Measuring Resonances](Measuring_Resonances.md) and the +[command reference](G-Codes.md#resonance_tester) for more +information. See the [Max smoothing](Measuring_Resonances.md#max-smoothing) +section of the measuring resonances guide for more information on +\`max_smoothing\` parameter and its use. + +\`\`\` +[resonance_tester] +#probe_points: +# A list of X, Y, Z coordinates of points (one point per line) to test +# resonances at. At least one point is required. Make sure that all +# points with some safety margin in XY plane (~a few centimeters) +# are reachable by the toolhead. +#accel_chip: +# A name of the accelerometer chip to use for measurements. If +# adxl345 chip was defined without an explicit name, this parameter +# can simply reference it as "accel_chip: adxl345", otherwise an +# explicit name must be supplied as well, e.g. "accel_chip: adxl345 +# my_chip_name". Either this, or the next two parameters must be +# set. +#accel_chip_x: +#accel_chip_y: +# Names of the accelerometer chips to use for measurements for each +# of the axis. Can be useful, for instance, on bed slinger printer, +# if two separate accelerometers are mounted on the bed (for Y axis) +# and on the toolhead (for X axis). These parameters have the same +# format as 'accel_chip' parameter. Only 'accel_chip' or these two +# parameters must be provided. +#max_smoothing: +# Maximum input shaper smoothing to allow for each axis during shaper +# auto-calibration (with 'SHAPER_CALIBRATE' command). By default no +# maximum smoothing is specified. Refer to Measuring_Resonances guide +# for more details on using this feature. +#min_freq: 5 +# Minimum frequency to test for resonances. The default is 5 Hz. +#max_freq: 133.33 +# Maximum frequency to test for resonances. The default is 133.33 Hz. +#accel_per_hz: 75 +# This parameter is used to determine which acceleration to use to +# test a specific frequency: accel = accel_per_hz * freq. Higher the +# value, the higher is the energy of the oscillations. Can be set to +# a lower than the default value if the resonances get too strong on +# the printer. However, lower values make measurements of +# high-frequency resonances less precise. The default value is 75 +# (mm/sec). +#hz_per_sec: 1 +# Determines the speed of the test. When testing all frequencies in +# range [min_freq, max_freq], each second the frequency increases by +# hz_per_sec. Small values make the test slow, and the large values +# will decrease the precision of the test. The default value is 1.0 +# (Hz/sec == sec^-2). +\`\`\` + +## Cfg file helpers + +### [board_pins] + +Board pin aliases (one may define any number of sections with a +"board_pins" prefix). Use this to define aliases for the pins on a +micro-controller. + +\`\`\` +[board_pins my_aliases] +mcu: mcu +# A comma separated list of micro-controllers that may use the +# aliases. The default is to apply the aliases to the main "mcu". +aliases: +aliases_: +# A comma separated list of "name=value" aliases to create for the +# given micro-controller. For example, "EXP1_1=PE6" would create an +# "EXP1_1" alias for the "PE6" pin. However, if "value" is enclosed +# in "<>" then "name" is created as a reserved pin (for example, +# "EXP1_9=" would reserve "EXP1_9"). Any number of options +# starting with "aliases_" may be specified. +\`\`\` + +### [include] + +Include file support. One may include additional cfg file from the +main printer cfg file. Wildcards may also be used (eg, +"cfgs/*.cfg"). + +\`\`\` +[include my_other_cfg.cfg] +\`\`\` + +### [duplicate_pin_override] + +This tool allows a single micro-controller pin to be defined multiple +times in a cfg file without normal error checking. This is intended +for diagnostic and debugging purposes. This section is not needed +where Klipper supports using the same pin multiple times, and using +this override may cause confusing and unexpected results. + +\`\`\` +[duplicate_pin_override] +pins: +# A comma separated list of pins that may be used multiple times in +# a cfg file without normal error checks. This parameter must be +# provided. +\`\`\` + +## Bed probing hardware + +### [probe] + +Z height probe. One may define this section to enable Z height probing +hardware. When this section is enabled, PROBE and QUERY_PROBE extended +[g-code commands](G-Codes.md#probe) become available. Also, see the +[probe calibrate guide](Probe_Calibrate.md). The probe section also +creates a virtual "probe:z_virtual_endstop" pin. One may set the +stepper_z endstop_pin to this virtual pin on cartesian style printers +that use the probe in place of a z endstop. If using +"probe:z_virtual_endstop" then do not define a position_endstop in the +stepper_z cfg section. + +\`\`\` +[probe] +pin: +# Probe detection pin. If the pin is on a different microcontroller +# than the Z steppers then it enables "multi-mcu homing". This +# parameter must be provided. +#deactivate_on_each_sample: True +# This determines if Klipper should execute deactivation gcode +# between each probe attempt when performing a multiple probe +# sequence. The default is True. +#x_offset: 0.0 +# The distance (in mm) between the probe and the nozzle along the +# x-axis. The default is 0. +#y_offset: 0.0 +# The distance (in mm) between the probe and the nozzle along the +# y-axis. The default is 0. +z_offset: +# The distance (in mm) between the bed and the nozzle when the probe +# triggers. This parameter must be provided. +#speed: 5.0 +# Speed (in mm/s) of the Z axis when probing. The default is 5mm/s. +#samples: 1 +# The number of times to probe each point. The probed z-values will +# be averaged. The default is to probe 1 time. +#sample_retract_dist: 2.0 +# The distance (in mm) to lift the toolhead between each sample (if +# sampling more than once). The default is 2mm. +#lift_speed: +# Speed (in mm/s) of the Z axis when lifting the probe between +# samples. The default is to use the same value as the 'speed' +# parameter. +#samples_result: average +# The calculation method when sampling more than once - either +# "median" or "average". The default is average. +#samples_tolerance: 0.100 +# The maximum Z distance (in mm) that a sample may differ from other +# samples. If this tolerance is exceeded then either an error is +# reported or the attempt is restarted (see +# samples_tolerance_retries). The default is 0.100mm. +#samples_tolerance_retries: 0 +# The number of times to retry if a sample is found that exceeds +# samples_tolerance. On a retry, all current samples are discarded +# and the probe attempt is restarted. If a valid set of samples are +# not obtained in the given number of retries then an error is +# reported. The default is zero which causes an error to be reported +# on the first sample that exceeds samples_tolerance. +#activate_gcode: +# A list of G-Code commands to execute prior to each probe attempt. +# See docs/Command_Templates.md for G-Code format. This may be +# useful if the probe needs to be activated in some way. Do not +# issue any commands here that move the toolhead (eg, G1). The +# default is to not run any special G-Code commands on activation. +#deactivate_gcode: +# A list of G-Code commands to execute after each probe attempt +# completes. See docs/Command_Templates.md for G-Code format. Do not +# issue any commands here that move the toolhead. The default is to +# not run any special G-Code commands on deactivation. +\`\`\` + +### [bltouch] + +BLTouch probe. One may define this section (instead of a probe +section) to enable a BLTouch probe. See [BL-Touch guide](BLTouch.md) +and [command reference](G-Codes.md#bltouch) for further information. A +virtual "probe:z_virtual_endstop" pin is also created (see the "probe" +section for the details). + +\`\`\` +[bltouch] +sensor_pin: +# Pin connected to the BLTouch sensor pin. Most BLTouch devices +# require a pullup on the sensor pin (prefix the pin name with "^"). +# This parameter must be provided. +control_pin: +# Pin connected to the BLTouch control pin. This parameter must be +# provided. +#pin_move_time: 0.680 +# The amount of time (in seconds) to wait for the BLTouch pin to +# move up or down. The default is 0.680 seconds. +#stow_on_each_sample: True +# This determines if Klipper should command the pin to move up +# between each probe attempt when performing a multiple probe +# sequence. Read the directions in docs/BLTouch.md before setting +# this to False. The default is True. +#probe_with_touch_mode: False +# If this is set to True then Klipper will probe with the device in +# "touch_mode". The default is False (probing in "pin_down" mode). +#pin_up_reports_not_triggered: True +# Set if the BLTouch consistently reports the probe in a "not +# triggered" state after a successful "pin_up" command. This should +# be True for all genuine BLTouch devices. Read the directions in +# docs/BLTouch.md before setting this to False. The default is True. +#pin_up_touch_mode_reports_triggered: True +# Set if the BLTouch consistently reports a "triggered" state after +# the commands "pin_up" followed by "touch_mode". This should be +# True for all genuine BLTouch devices. Read the directions in +# docs/BLTouch.md before setting this to False. The default is True. +#set_output_mode: +# Request a specific sensor pin output mode on the BLTouch V3.0 (and +# later). This setting should not be used on other types of probes. +# Set to "5V" to request a sensor pin output of 5 Volts (only use if +# the controller board needs 5V mode and is 5V tolerant on its input +# signal line). Set to "OD" to request the sensor pin output use +# open drain mode. The default is to not request an output mode. +#x_offset: +#y_offset: +#z_offset: +#speed: +#lift_speed: +#samples: +#sample_retract_dist: +#samples_result: +#samples_tolerance: +#samples_tolerance_retries: +# See the "probe" section for information on these parameters. +\`\`\` + +### [smart_effector] + +The "Smart Effector" from Duet3d implements a Z probe using a force +sensor. One may define this section instead of \`[probe]\` to enable the +Smart Effector specific features. This also enables +[runtime commands](G-Codes.md#smart_effector) to adjust the parameters +of the Smart Effector at run time. + +\`\`\` +[smart_effector] +pin: +# Pin connected to the Smart Effector Z Probe output pin (pin 5). Note that +# pullup resistor on the board is generally not required. However, if the +# output pin is connected to the board pin with a pullup resistor, that +# resistor must be high value (e.g. 10K Ohm or more). Some boards have a low +# value pullup resistor on the Z probe input, which will likely result in an +# always-triggered probe state. In this case, connect the Smart Effector to +# a different pin on the board. This parameter is required. +#control_pin: +# Pin connected to the Smart Effector control input pin (pin 7). If provided, +# Smart Effector sensitivity programming commands become available. +#probe_accel: +# If set, limits the acceleration of the probing moves (in mm/sec^2). +# A sudden large acceleration at the beginning of the probing move may +# cause spurious probe triggering, especially if the hotend is heavy. +# To prevent that, it may be necessary to reduce the acceleration of +# the probing moves via this parameter. +#recovery_time: 0.4 +# A delay between the travel moves and the probing moves in seconds. A fast +# travel move prior to probing may result in a spurious probe triggering. +# This may cause 'Probe triggered prior to movement' errors if no delay +# is set. Value 0 disables the recovery delay. +# Default value is 0.4. +#x_offset: +#y_offset: +# Should be left unset (or set to 0). +z_offset: +# Trigger height of the probe. Start with -0.1 (mm), and adjust later using +# \`PROBE_CALIBRATE\` command. This parameter must be provided. +#speed: +# Speed (in mm/s) of the Z axis when probing. It is recommended to start +# with the probing speed of 20 mm/s and adjust it as necessary to improve +# the accuracy and repeatability of the probe triggering. +#samples: +#sample_retract_dist: +#samples_result: +#samples_tolerance: +#samples_tolerance_retries: +#activate_gcode: +#deactivate_gcode: +#deactivate_on_each_sample: +# See the "probe" section for more information on the parameters above. +\`\`\` + +## Additional stepper motors and extruders + +### [stepper_z1] + +Multi-stepper axes. On a cartesian style printer, the stepper +controlling a given axis may have additional cfg blocks defining +steppers that should be stepped in concert with the primary stepper. +One may define any number of sections with a numeric suffix starting +at 1 (for example, "stepper_z1", "stepper_z2", etc.). + +\`\`\` +[stepper_z1] +#step_pin: +#dir_pin: +#enable_pin: +#microsteps: +#rotation_distance: +# See the "stepper" section for the definition of the above parameters. +#endstop_pin: +# If an endstop_pin is defined for the additional stepper then the +# stepper will home until the endstop is triggered. Otherwise, the +# stepper will home until the endstop on the primary stepper for the +# axis is triggered. +\`\`\` + +### [extruder1] + +In a multi-extruder printer add an additional extruder section for +each additional extruder. The additional extruder sections should be +named "extruder1", "extruder2", "extruder3", and so on. See the +"extruder" section for a description of available parameters. + +See [sample-multi-extruder.cfg](../cfg/sample-multi-extruder.cfg) +for an example cfguration. + +\`\`\` +[extruder1] +#step_pin: +#dir_pin: +#... +# See the "extruder" section for available stepper and heater +# parameters. +#shared_heater: +# This option is deprecated and should no longer be specified. +\`\`\` + +### [dual_carriage] + +Support for cartesian printers with dual carriages on a single +axis. The active carriage is set via the SET_DUAL_CARRIAGE extended +g-code command. The "SET_DUAL_CARRIAGE CARRIAGE=1" command will +activate the carriage defined in this section (CARRIAGE=0 will return +activation to the primary carriage). Dual carriage support is +typically combined with extra extruders - the SET_DUAL_CARRIAGE +command is often called at the same time as the ACTIVATE_EXTRUDER +command. Be sure to park the carriages during deactivation. + +See [sample-idex.cfg](../cfg/sample-idex.cfg) for an example +cfguration. + +\`\`\` +[dual_carriage] +axis: +# The axis this extra carriage is on (either x or y). This parameter +# must be provided. +#step_pin: +#dir_pin: +#enable_pin: +#microsteps: +#rotation_distance: +#endstop_pin: +#position_endstop: +#position_min: +#position_max: +# See the "stepper" section for the definition of the above parameters. +\`\`\` + +### [extruder_stepper] + +Support for additional steppers synchronized to the movement of an +extruder (one may define any number of sections with an +"extruder_stepper" prefix). + +See the [command reference](G-Codes.md#extruder) for more information. + +\`\`\` +[extruder_stepper my_extra_stepper] +extruder: +# The extruder this stepper is synchronized to. If this is set to an +# empty string then the stepper will not be synchronized to an +# extruder. This parameter must be provided. +#step_pin: +#dir_pin: +#enable_pin: +#microsteps: +#rotation_distance: +# See the "stepper" section for the definition of the above +# parameters. +\`\`\` + +### [manual_stepper] + +Manual steppers (one may define any number of sections with a +"manual_stepper" prefix). These are steppers that are controlled by +the MANUAL_STEPPER g-code command. For example: "MANUAL_STEPPER +STEPPER=my_stepper MOVE=10 SPEED=5". See +[G-Codes](G-Codes.md#manual_stepper) file for a description of the +MANUAL_STEPPER command. The steppers are not connected to the normal +printer kinematics. + +\`\`\` +[manual_stepper my_stepper] +#step_pin: +#dir_pin: +#enable_pin: +#microsteps: +#rotation_distance: +# See the "stepper" section for a description of these parameters. +#velocity: +# Set the default velocity (in mm/s) for the stepper. This value +# will be used if a MANUAL_STEPPER command does not specify a SPEED +# parameter. The default is 5mm/s. +#accel: +# Set the default acceleration (in mm/s^2) for the stepper. An +# acceleration of zero will result in no acceleration. This value +# will be used if a MANUAL_STEPPER command does not specify an ACCEL +# parameter. The default is zero. +#endstop_pin: +# Endstop switch detection pin. If specified, then one may perform +# "homing moves" by adding a STOP_ON_ENDSTOP parameter to +# MANUAL_STEPPER movement commands. +\`\`\` + +## Custom heaters and sensors + +### [verify_heater] + +Heater and temperature sensor verification. Heater verification is +automatically enabled for each heater that is cfgured on the +printer. Use verify_heater sections to change the default settings. + +\`\`\` +[verify_heater heater_cfg_name] +#max_error: 120 +# The maximum "cumulative temperature error" before raising an +# error. Smaller values result in stricter checking and larger +# values allow for more time before an error is reported. +# Specifically, the temperature is inspected once a second and if it +# is close to the target temperature then an internal "error +# counter" is reset; otherwise, if the temperature is below the +# target range then the counter is increased by the amount the +# reported temperature differs from that range. Should the counter +# exceed this "max_error" then an error is raised. The default is +# 120. +#check_gain_time: +# This controls heater verification during initial heating. Smaller +# values result in stricter checking and larger values allow for +# more time before an error is reported. Specifically, during +# initial heating, as long as the heater increases in temperature +# within this time frame (specified in seconds) then the internal +# "error counter" is reset. The default is 20 seconds for extruders +# and 60 seconds for heater_bed. +#hysteresis: 5 +# The maximum temperature difference (in Celsius) to a target +# temperature that is considered in range of the target. This +# controls the max_error range check. It is rare to customize this +# value. The default is 5. +#heating_gain: 2 +# The minimum temperature (in Celsius) that the heater must increase +# by during the check_gain_time check. It is rare to customize this +# value. The default is 2. +\`\`\` + +### [homing_heaters] + +Tool to disable heaters when homing or probing an axis. + +\`\`\` +[homing_heaters] +#steppers: +# A comma separated list of steppers that should cause heaters to be +# disabled. The default is to disable heaters for any homing/probing +# move. +# Typical example: stepper_z +#heaters: +# A comma separated list of heaters to disable during homing/probing +# moves. The default is to disable all heaters. +# Typical example: extruder, heater_bed +\`\`\` + +### [thermistor] + +Custom thermistors (one may define any number of sections with a +"thermistor" prefix). A custom thermistor may be used in the +sensor_type field of a heater cfg section. (For example, if one +defines a "[thermistor my_thermistor]" section then one may use a +"sensor_type: my_thermistor" when defining a heater.) Be sure to place +the thermistor section in the cfg file above its first use in a +heater section. + +\`\`\` +[thermistor my_thermistor] +#temperature1: +#resistance1: +#temperature2: +#resistance2: +#temperature3: +#resistance3: +# Three resistance measurements (in Ohms) at the given temperatures +# (in Celsius). The three measurements will be used to calculate the +# Steinhart-Hart coefficients for the thermistor. These parameters +# must be provided when using Steinhart-Hart to define the +# thermistor. +#beta: +# Alternatively, one may define temperature1, resistance1, and beta +# to define the thermistor parameters. This parameter must be +# provided when using "beta" to define the thermistor. +\`\`\` + +### [adc_temperature] + +Custom ADC temperature sensors (one may define any number of sections +with an "adc_temperature" prefix). This allows one to define a custom +temperature sensor that measures a voltage on an Analog to Digital +Converter (ADC) pin and uses linear interpolation between a set of +cfgured temperature/voltage (or temperature/resistance) +measurements to determine the temperature. The resulting sensor can be +used as a sensor_type in a heater section. (For example, if one +defines a "[adc_temperature my_sensor]" section then one may use a +"sensor_type: my_sensor" when defining a heater.) Be sure to place the +sensor section in the cfg file above its first use in a heater +section. + +\`\`\` +[adc_temperature my_sensor] +#temperature1: +#voltage1: +#temperature2: +#voltage2: +#... +# A set of temperatures (in Celsius) and voltages (in Volts) to use +# as reference when converting a temperature. A heater section using +# this sensor may also specify adc_voltage and voltage_offset +# parameters to define the ADC voltage (see "Common temperature +# amplifiers" section for details). At least two measurements must +# be provided. +#temperature1: +#resistance1: +#temperature2: +#resistance2: +#... +# Alternatively one may specify a set of temperatures (in Celsius) +# and resistance (in Ohms) to use as reference when converting a +# temperature. A heater section using this sensor may also specify a +# pullup_resistor parameter (see "extruder" section for details). At +# least two measurements must be provided. +\`\`\` + +### [heater_generic] + +Generic heaters (one may define any number of sections with a +"heater_generic" prefix). These heaters behave similarly to standard +heaters (extruders, heated beds). Use the SET_HEATER_TEMPERATURE +command (see [G-Codes](G-Codes.md#heaters) for details) to set the +target temperature. + +\`\`\` +[heater_generic my_generic_heater] +#gcode_id: +# The id to use when reporting the temperature in the M105 command. +# This parameter must be provided. +#heater_pin: +#max_power: +#sensor_type: +#sensor_pin: +#smooth_time: +#control: +#pid_Kp: +#pid_Ki: +#pid_Kd: +#pwm_cycle_time: +#min_temp: +#max_temp: +# See the "extruder" section for the definition of the above +# parameters. +\`\`\` + +### [temperature_sensor] + +Generic temperature sensors. One can define any number of additional +temperature sensors that are reported via the M105 command. + +\`\`\` +[temperature_sensor my_sensor] +#sensor_type: +#sensor_pin: +#min_temp: +#max_temp: +# See the "extruder" section for the definition of the above +# parameters. +#gcode_id: +# See the "heater_generic" section for the definition of this +# parameter. +\`\`\` + +## Temperature sensors + +Klipper includes definitions for many types of temperature sensors. +These sensors may be used in any cfg section that requires a +temperature sensor (such as an \`[extruder]\` or \`[heater_bed]\` +section). + +### Common thermistors + +Common thermistors. The following parameters are available in heater +sections that use one of these sensors. + +\`\`\` +sensor_type: +# One of "EPCOS 100K B57560G104F", "ATC Semitec 104GT-2", +# "ATC Semitec 104NT-4-R025H42G", "Generic 3950", +# "Honeywell 100K 135-104LAG-J01", "NTC 100K MGB18-104F39050L32", +# "SliceEngineering 450", or "TDK NTCG104LH104JT1" +sensor_pin: +# Analog input pin connected to the thermistor. This parameter must +# be provided. +#pullup_resistor: 4700 +# The resistance (in ohms) of the pullup attached to the thermistor. +# The default is 4700 ohms. +#inline_resistor: 0 +# The resistance (in ohms) of an extra (not heat varying) resistor +# that is placed inline with the thermistor. It is rare to set this. +# The default is 0 ohms. +\`\`\` + +### Common temperature amplifiers + +Common temperature amplifiers. The following parameters are available +in heater sections that use one of these sensors. + +\`\`\` +sensor_type: +# One of "PT100 INA826", "AD595", "AD597", "AD8494", "AD8495", +# "AD8496", or "AD8497". +sensor_pin: +# Analog input pin connected to the sensor. This parameter must be +# provided. +#adc_voltage: 5.0 +# The ADC comparison voltage (in Volts). The default is 5 volts. +#voltage_offset: 0 +# The ADC voltage offset (in Volts). The default is 0. +\`\`\` + +### Directly connected PT1000 sensor + +Directly connected PT1000 sensor. The following parameters are +available in heater sections that use one of these sensors. + +\`\`\` +sensor_type: PT1000 +sensor_pin: +# Analog input pin connected to the sensor. This parameter must be +# provided. +#pullup_resistor: 4700 +# The resistance (in ohms) of the pullup attached to the sensor. The +# default is 4700 ohms. +\`\`\` + +### MAXxxxxx temperature sensors + +MAXxxxxx serial peripheral interface (SPI) temperature based +sensors. The following parameters are available in heater sections +that use one of these sensor types. + +\`\`\` +sensor_type: +# One of "MAX6675", "MAX31855", "MAX31856", or "MAX31865". +sensor_pin: +# The chip select line for the sensor chip. This parameter must be +# provided. +#spi_speed: 4000000 +# The SPI speed (in hz) to use when communicating with the chip. +# The default is 4000000. +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#tc_type: K +#tc_use_50Hz_filter: False +#tc_averaging_count: 1 +# The above parameters control the sensor parameters of MAX31856 +# chips. The defaults for each parameter are next to the parameter +# name in the above list. +#rtd_nominal_r: 100 +#rtd_reference_r: 430 +#rtd_num_of_wires: 2 +#rtd_use_50Hz_filter: False +# The above parameters control the sensor parameters of MAX31865 +# chips. The defaults for each parameter are next to the parameter +# name in the above list. +\`\`\` + +### BMP280/BME280/BME680 temperature sensor + +BMP280/BME280/BME680 two wire interface (I2C) environmental sensors. +Note that these sensors are not intended for use with extruders and +heater beds, but rather for monitoring ambient temperature (C), +pressure (hPa), relative humidity and in case of the BME680 gas level. +See [sample-macros.cfg](../cfg/sample-macros.cfg) for a gcode_macro +that may be used to report pressure and humidity in addition to +temperature. + +\`\`\` +sensor_type: BME280 +#i2c_address: +# Default is 118 (0x76). Some BME280 sensors have an address of 119 +# (0x77). +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +\`\`\` + +### AHT10/AHT20/AHT21 temperature sensor + +AHT10/AHT20/AHT21 two wire interface (I2C) environmental sensors. +Note that these sensors are not intended for use with extruders and +heater beds, but rather for monitoring ambient temperature (C) and +relative humidity. See +[sample-macros.cfg](../cfg/sample-macros.cfg) for a gcode_macro +that may be used to report humidity in addition to temperature. + +\`\`\` +sensor_type: AHT10 +# Also use AHT10 for AHT20 and AHT21 sensors. +#i2c_address: +# Default is 56 (0x38). Some AHT10 sensors give the option to use +# 57 (0x39) by moving a resistor. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#aht10_report_time: +# Interval in seconds between readings. Default is 30, minimum is 5 +\`\`\` + +### HTU21D sensor + +HTU21D family two wire interface (I2C) environmental sensor. Note that +this sensor is not intended for use with extruders and heater beds, +but rather for monitoring ambient temperature (C) and relative +humidity. See [sample-macros.cfg](../cfg/sample-macros.cfg) for a +gcode_macro that may be used to report humidity in addition to +temperature. + +\`\`\` +sensor_type: +# Must be "HTU21D" , "SI7013", "SI7020", "SI7021" or "SHT21" +#i2c_address: +# Default is 64 (0x40). +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#htu21d_hold_master: +# If the sensor can hold the I2C buf while reading. If True no other +# bus communication can be performed while reading is in progress. +# Default is False. +#htu21d_resolution: +# The resolution of temperature and humidity reading. +# Valid values are: +# 'TEMP14_HUM12' -> 14bit for Temp and 12bit for humidity +# 'TEMP13_HUM10' -> 13bit for Temp and 10bit for humidity +# 'TEMP12_HUM08' -> 12bit for Temp and 08bit for humidity +# 'TEMP11_HUM11' -> 11bit for Temp and 11bit for humidity +# Default is: "TEMP11_HUM11" +#htu21d_report_time: +# Interval in seconds between readings. Default is 30 +\`\`\` + +### LM75 temperature sensor + +LM75/LM75A two wire (I2C) connected temperature sensors. These sensors +have a range of -55~125 C, so are usable for e.g. chamber temperature +monitoring. They can also function as simple fan/heater controllers. + +\`\`\` +sensor_type: LM75 +#i2c_address: +# Default is 72 (0x48). Normal range is 72-79 (0x48-0x4F) and the 3 +# low bits of the address are cfgured via pins on the chip +# (usually with jumpers or hard wired). +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#lm75_report_time: +# Interval in seconds between readings. Default is 0.8, with minimum +# 0.5. +\`\`\` + +### Builtin micro-controller temperature sensor + +The atsam, atsamd, and stm32 micro-controllers contain an internal +temperature sensor. One can use the "temperature_mcu" sensor to +monitor these temperatures. + +\`\`\` +sensor_type: temperature_mcu +#sensor_mcu: mcu +# The micro-controller to read from. The default is "mcu". +#sensor_temperature1: +#sensor_adc1: +# Specify the above two parameters (a temperature in Celsius and an +# ADC value as a float between 0.0 and 1.0) to calibrate the +# micro-controller temperature. This may improve the reported +# temperature accuracy on some chips. A typical way to obtain this +# calibration information is to completely remove power from the +# printer for a few hours (to ensure it is at the ambient +# temperature), then power it up and use the QUERY_ADC command to +# obtain an ADC measurement. Use some other temperature sensor on +# the printer to find the corresponding ambient temperature. The +# default is to use the factory calibration data on the +# micro-controller (if applicable) or the nominal values from the +# micro-controller specification. +#sensor_temperature2: +#sensor_adc2: +# If sensor_temperature1/sensor_adc1 is specified then one may also +# specify sensor_temperature2/sensor_adc2 calibration data. Doing so +# may provide calibrated "temperature slope" information. The +# default is to use the factory calibration data on the +# micro-controller (if applicable) or the nominal values from the +# micro-controller specification. +\`\`\` + +### Host temperature sensor + +Temperature from the machine (eg Raspberry Pi) running the host software. + +\`\`\` +sensor_type: temperature_host +#sensor_path: +# The path to temperature system file. The default is +# "/sys/class/thermal/thermal_zone0/temp" which is the temperature +# system file on a Raspberry Pi computer. +\`\`\` + +### DS18B20 temperature sensor + +DS18B20 is a 1-wire (w1) digital temperature sensor. Note that this sensor is not intended for use with extruders and heater beds, but rather for monitoring ambient temperature (C). These sensors have range up to 125 C, so are usable for e.g. chamber temperature monitoring. They can also function as simple fan/heater controllers. DS18B20 sensors are only supported on the "host mcu", e.g. the Raspberry Pi. The w1-gpio Linux kernel module must be installed. + +\`\`\` +sensor_type: DS18B20 +serial_no: +# Each 1-wire device has a unique serial number used to identify the device, +# usually in the format 28-031674b175ff. This parameter must be provided. +# Attached 1-wire devices can be listed using the following Linux command: +# ls /sys/bus/w1/devices/ +#ds18_report_time: +# Interval in seconds between readings. Default is 3.0, with a minimum of 1.0 +#sensor_mcu: +# The micro-controller to read from. Must be the host_mcu +\`\`\` + +## Fans + +### [fan] + +Print cooling fan. + +\`\`\` +[fan] +pin: +# Output pin controlling the fan. This parameter must be provided. +#max_power: 1.0 +# The maximum power (expressed as a value from 0.0 to 1.0) that the +# pin may be set to. The value 1.0 allows the pin to be set fully +# enabled for extended periods, while a value of 0.5 would allow the +# pin to be enabled for no more than half the time. This setting may +# be used to limit the total power output (over extended periods) to +# the fan. If this value is less than 1.0 then fan speed requests +# will be scaled between zero and max_power (for example, if +# max_power is .9 and a fan speed of 80% is requested then the fan +# power will be set to 72%). The default is 1.0. +#shutdown_speed: 0 +# The desired fan speed (expressed as a value from 0.0 to 1.0) if +# the micro-controller software enters an error state. The default +# is 0. +#cycle_time: 0.010 +# The amount of time (in seconds) for each PWM power cycle to the +# fan. It is recommended this be 10 milliseconds or greater when +# using software based PWM. The default is 0.010 seconds. +#hardware_pwm: False +# Enable this to use hardware PWM instead of software PWM. Most fans +# do not work well with hardware PWM, so it is not recommended to +# enable this unless there is an electrical requirement to switch at +# very high speeds. When using hardware PWM the actual cycle time is +# constrained by the implementation and may be significantly +# different than the requested cycle_time. The default is False. +#kick_start_time: 0.100 +# Time (in seconds) to run the fan at full speed when either first +# enabling or increasing it by more than 50% (helps get the fan +# spinning). The default is 0.100 seconds. +#off_below: 0.0 +# The minimum input speed which will power the fan (expressed as a +# value from 0.0 to 1.0). When a speed lower than off_below is +# requested the fan will instead be turned off. This setting may be +# used to prevent fan stalls and to ensure kick starts are +# effective. The default is 0.0. +# +# This setting should be recalibrated whenever max_power is adjusted. +# To calibrate this setting, start with off_below set to 0.0 and the +# fan spinning. Gradually lower the fan speed to determine the lowest +# input speed which reliably drives the fan without stalls. Set +# off_below to the duty cycle corresponding to this value (for +# example, 12% -> 0.12) or slightly higher. +#tachometer_pin: +# Tachometer input pin for monitoring fan speed. A pullup is generally +# required. This parameter is optional. +#tachometer_ppr: 2 +# When tachometer_pin is specified, this is the number of pulses per +# revolution of the tachometer signal. For a BLDC fan this is +# normally half the number of poles. The default is 2. +#tachometer_poll_interval: 0.0015 +# When tachometer_pin is specified, this is the polling period of the +# tachometer pin, in seconds. The default is 0.0015, which is fast +# enough for fans below 10000 RPM at 2 PPR. This must be smaller than +# 30/(tachometer_ppr*rpm), with some margin, where rpm is the +# maximum speed (in RPM) of the fan. +#enable_pin: +# Optional pin to enable power to the fan. This can be useful for fans +# with dedicated PWM inputs. Some of these fans stay on even at 0% PWM +# input. In such a case, the PWM pin can be used normally, and e.g. a +# ground-switched FET(standard fan pin) can be used to control power to +# the fan. +\`\`\` + +### [heater_fan] + +Heater cooling fans (one may define any number of sections with a +"heater_fan" prefix). A "heater fan" is a fan that will be enabled +whenever its associated heater is active. By default, a heater_fan has +a shutdown_speed equal to max_power. + +\`\`\` +[heater_fan my_nozzle_fan] +#pin: +#max_power: +#shutdown_speed: +#cycle_time: +#hardware_pwm: +#kick_start_time: +#off_below: +#tachometer_pin: +#tachometer_ppr: +#tachometer_poll_interval: +#enable_pin: +# See the "fan" section for a description of the above parameters. +#heater: extruder +# Name of the cfg section defining the heater that this fan is +# associated with. If a comma separated list of heater names is +# provided here, then the fan will be enabled when any of the given +# heaters are enabled. The default is "extruder". +#heater_temp: 50.0 +# A temperature (in Celsius) that the heater must drop below before +# the fan is disabled. The default is 50 Celsius. +#fan_speed: 1.0 +# The fan speed (expressed as a value from 0.0 to 1.0) that the fan +# will be set to when its associated heater is enabled. The default +# is 1.0 +\`\`\` + +### [controller_fan] + +Controller cooling fan (one may define any number of sections with a +"controller_fan" prefix). A "controller fan" is a fan that will be +enabled whenever its associated heater or its associated stepper +driver is active. The fan will stop whenever an idle_timeout is +reached to ensure no overheating will occur after deactivating a +watched component. + +\`\`\` +[controller_fan my_controller_fan] +#pin: +#max_power: +#shutdown_speed: +#cycle_time: +#hardware_pwm: +#kick_start_time: +#off_below: +#tachometer_pin: +#tachometer_ppr: +#tachometer_poll_interval: +#enable_pin: +# See the "fan" section for a description of the above parameters. +#fan_speed: 1.0 +# The fan speed (expressed as a value from 0.0 to 1.0) that the fan +# will be set to when a heater or stepper driver is active. +# The default is 1.0 +#idle_timeout: +# The amount of time (in seconds) after a stepper driver or heater +# was active and the fan should be kept running. The default +# is 30 seconds. +#idle_speed: +# The fan speed (expressed as a value from 0.0 to 1.0) that the fan +# will be set to when a heater or stepper driver was active and +# before the idle_timeout is reached. The default is fan_speed. +#heater: +#stepper: +# Name of the cfg section defining the heater/stepper that this fan +# is associated with. If a comma separated list of heater/stepper names +# is provided here, then the fan will be enabled when any of the given +# heaters/steppers are enabled. The default heater is "extruder", the +# default stepper is all of them. +\`\`\` + +### [temperature_fan] + +Temperature-triggered cooling fans (one may define any number of +sections with a "temperature_fan" prefix). A "temperature fan" is a +fan that will be enabled whenever its associated sensor is above a set +temperature. By default, a temperature_fan has a shutdown_speed equal +to max_power. + +See the [command reference](G-Codes.md#temperature_fan) for additional +information. + +\`\`\` +[temperature_fan my_temp_fan] +#pin: +#max_power: +#shutdown_speed: +#cycle_time: +#hardware_pwm: +#kick_start_time: +#off_below: +#tachometer_pin: +#tachometer_ppr: +#tachometer_poll_interval: +#enable_pin: +# See the "fan" section for a description of the above parameters. +#sensor_type: +#sensor_pin: +#control: +#max_delta: +#min_temp: +#max_temp: +# See the "extruder" section for a description of the above parameters. +#pid_Kp: +#pid_Ki: +#pid_Kd: +# The proportional (pid_Kp), integral (pid_Ki), and derivative +# (pid_Kd) settings for the PID feedback control system. Klipper +# evaluates the PID settings with the following general formula: +# fan_pwm = max_power - (Kp*e + Ki*integral(e) - Kd*derivative(e)) / 255 +# Where "e" is "target_temperature - measured_temperature" and +# "fan_pwm" is the requested fan rate with 0.0 being full off and +# 1.0 being full on. The pid_Kp, pid_Ki, and pid_Kd parameters must +# be provided when the PID control algorithm is enabled. +#pid_deriv_time: 2.0 +# A time value (in seconds) over which temperature measurements will +# be smoothed when using the PID control algorithm. This may reduce +# the impact of measurement noise. The default is 2 seconds. +#target_temp: 40.0 +# A temperature (in Celsius) that will be the target temperature. +# The default is 40 degrees. +#max_speed: 1.0 +# The fan speed (expressed as a value from 0.0 to 1.0) that the fan +# will be set to when the sensor temperature exceeds the set value. +# The default is 1.0. +#min_speed: 0.3 +# The minimum fan speed (expressed as a value from 0.0 to 1.0) that +# the fan will be set to for PID temperature fans. +# The default is 0.3. +#gcode_id: +# If set, the temperature will be reported in M105 queries using the +# given id. The default is to not report the temperature via M105. +\`\`\` + +### [fan_generic] + +Manually controlled fan (one may define any number of sections with a +"fan_generic" prefix). The speed of a manually controlled fan is set +with the SET_FAN_SPEED [gcode command](G-Codes.md#fan_generic). + +\`\`\` +[fan_generic extruder_partfan] +#pin: +#max_power: +#shutdown_speed: +#cycle_time: +#hardware_pwm: +#kick_start_time: +#off_below: +#tachometer_pin: +#tachometer_ppr: +#tachometer_poll_interval: +#enable_pin: +# See the "fan" section for a description of the above parameters. +\`\`\` + +## LEDs + +### [led] + +Support for LEDs (and LED strips) controlled via micro-controller PWM +pins (one may define any number of sections with an "led" prefix). See +the [command reference](G-Codes.md#led) for more information. + +\`\`\` +[led my_led] +#red_pin: +#green_pin: +#blue_pin: +#white_pin: +# The pin controlling the given LED color. At least one of the above +# parameters must be provided. +#cycle_time: 0.010 +# The amount of time (in seconds) per PWM cycle. It is recommended +# this be 10 milliseconds or greater when using software based PWM. +# The default is 0.010 seconds. +#hardware_pwm: False +# Enable this to use hardware PWM instead of software PWM. When +# using hardware PWM the actual cycle time is constrained by the +# implementation and may be significantly different than the +# requested cycle_time. The default is False. +#initial_RED: 0.0 +#initial_GREEN: 0.0 +#initial_BLUE: 0.0 +#initial_WHITE: 0.0 +# Sets the initial LED color. Each value should be between 0.0 and +# 1.0. The default for each color is 0. +\`\`\` + +### [neopixel] + +Neopixel (aka WS2812) LED support (one may define any number of +sections with a "neopixel" prefix). See the +[command reference](G-Codes.md#led) for more information. + +Note that the [linux mcu](RPi_microcontroller.md) implementation does +not currently support directly connected neopixels. The current design +using the Linux kernel interface does not allow this scenario because +the kernel GPIO interface is not fast enough to provide the required +pulse rates. + +\`\`\` +[neopixel my_neopixel] +pin: +# The pin connected to the neopixel. This parameter must be +# provided. +#chain_count: +# The number of Neopixel chips that are "daisy chained" to the +# provided pin. The default is 1 (which indicates only a single +# Neopixel is connected to the pin). +#color_order: GRB +# Set the pixel order required by the LED hardware (using a string +# containing the letters R, G, B, W with W optional). Alternatively, +# this may be a comma separated list of pixel orders - one for each +# LED in the chain. The default is GRB. +#initial_RED: 0.0 +#initial_GREEN: 0.0 +#initial_BLUE: 0.0 +#initial_WHITE: 0.0 +# See the "led" section for information on these parameters. +\`\`\` + +### [dotstar] + +Dotstar (aka APA102) LED support (one may define any number of +sections with a "dotstar" prefix). See the +[command reference](G-Codes.md#led) for more information. + +\`\`\` +[dotstar my_dotstar] +data_pin: +# The pin connected to the data line of the dotstar. This parameter +# must be provided. +clock_pin: +# The pin connected to the clock line of the dotstar. This parameter +# must be provided. +#chain_count: +# See the "neopixel" section for information on this parameter. +#initial_RED: 0.0 +#initial_GREEN: 0.0 +#initial_BLUE: 0.0 +# See the "led" section for information on these parameters. +\`\`\` + +### [pca9533] + +PCA9533 LED support. The PCA9533 is used on the mightyboard. + +\`\`\` +[pca9533 my_pca9533] +#i2c_address: 98 +# The i2c address that the chip is using on the i2c bus. Use 98 for +# the PCA9533/1, 99 for the PCA9533/2. The default is 98. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#initial_RED: 0.0 +#initial_GREEN: 0.0 +#initial_BLUE: 0.0 +#initial_WHITE: 0.0 +# See the "led" section for information on these parameters. +\`\`\` + +### [pca9632] + +PCA9632 LED support. The PCA9632 is used on the FlashForge Dreamer. + +\`\`\` +[pca9632 my_pca9632] +#i2c_address: 98 +# The i2c address that the chip is using on the i2c bus. This may be +# 96, 97, 98, or 99. The default is 98. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#scl_pin: +#sda_pin: +# Alternatively, if the pca9632 is not connected to a hardware I2C +# bus, then one may specify the "clock" (scl_pin) and "data" +# (sda_pin) pins. The default is to use hardware I2C. +#color_order: RGBW +# Set the pixel order of the LED (using a string containing the +# letters R, G, B, W). The default is RGBW. +#initial_RED: 0.0 +#initial_GREEN: 0.0 +#initial_BLUE: 0.0 +#initial_WHITE: 0.0 +# See the "led" section for information on these parameters. +\`\`\` + +## Additional servos, buttons, and other pins + +### [servo] + +Servos (one may define any number of sections with a "servo" +prefix). The servos may be controlled using the SET_SERVO +[g-code command](G-Codes.md#servo). For example: SET_SERVO +SERVO=my_servo ANGLE=180 + +\`\`\` +[servo my_servo] +pin: +# PWM output pin controlling the servo. This parameter must be +# provided. +#maximum_servo_angle: 180 +# The maximum angle (in degrees) that this servo can be set to. The +# default is 180 degrees. +#minimum_pulse_width: 0.001 +# The minimum pulse width time (in seconds). This should correspond +# with an angle of 0 degrees. The default is 0.001 seconds. +#maximum_pulse_width: 0.002 +# The maximum pulse width time (in seconds). This should correspond +# with an angle of maximum_servo_angle. The default is 0.002 +# seconds. +#initial_angle: +# Initial angle (in degrees) to set the servo to. The default is to +# not send any signal at startup. +#initial_pulse_width: +# Initial pulse width time (in seconds) to set the servo to. (This +# is only valid if initial_angle is not set.) The default is to not +# send any signal at startup. +\`\`\` + +### [gcode_button] + +Execute gcode when a button is pressed or released (or when a pin +changes state). You can check the state of the button by using +\`QUERY_BUTTON button=my_gcode_button\`. + +\`\`\` +[gcode_button my_gcode_button] +pin: +# The pin on which the button is connected. This parameter must be +# provided. +#analog_range: +# Two comma separated resistances (in Ohms) specifying the minimum +# and maximum resistance range for the button. If analog_range is +# provided then the pin must be an analog capable pin. The default +# is to use digital gpio for the button. +#analog_pullup_resistor: +# The pullup resistance (in Ohms) when analog_range is specified. +# The default is 4700 ohms. +#press_gcode: +# A list of G-Code commands to execute when the button is pressed. +# G-Code templates are supported. This parameter must be provided. +#release_gcode: +# A list of G-Code commands to execute when the button is released. +# G-Code templates are supported. The default is to not run any +# commands on a button release. +\`\`\` + +### [output_pin] + +Run-time cfgurable output pins (one may define any number of +sections with an "output_pin" prefix). Pins cfgured here will be +setup as output pins and one may modify them at run-time using +"SET_PIN PIN=my_pin VALUE=.1" type extended +[g-code commands](G-Codes.md#output_pin). + +\`\`\` +[output_pin my_pin] +pin: +# The pin to cfgure as an output. This parameter must be +# provided. +#pwm: False +# Set if the output pin should be capable of pulse-width-modulation. +# If this is true, the value fields should be between 0 and 1; if it +# is false the value fields should be either 0 or 1. The default is +# False. +#static_value: +# If this is set, then the pin is assigned to this value at startup +# and the pin can not be changed during runtime. A static pin uses +# slightly less ram in the micro-controller. The default is to use +# runtime cfguration of pins. +#value: +# The value to initially set the pin to during MCU cfguration. +# The default is 0 (for low voltage). +#shutdown_value: +# The value to set the pin to on an MCU shutdown event. The default +# is 0 (for low voltage). +#maximum_mcu_duration: +# The maximum duration a non-shutdown value may be driven by the MCU +# without an acknowledge from the host. +# If host can not keep up with an update, the MCU will shutdown +# and set all pins to their respective shutdown values. +# Default: 0 (disabled) +# Usual values are around 5 seconds. +#cycle_time: 0.100 +# The amount of time (in seconds) per PWM cycle. It is recommended +# this be 10 milliseconds or greater when using software based PWM. +# The default is 0.100 seconds for pwm pins. +#hardware_pwm: False +# Enable this to use hardware PWM instead of software PWM. When +# using hardware PWM the actual cycle time is constrained by the +# implementation and may be significantly different than the +# requested cycle_time. The default is False. +#scale: +# This parameter can be used to alter how the 'value' and +# 'shutdown_value' parameters are interpreted for pwm pins. If +# provided, then the 'value' parameter should be between 0.0 and +# 'scale'. This may be useful when cfguring a PWM pin that +# controls a stepper voltage reference. The 'scale' can be set to +# the equivalent stepper amperage if the PWM were fully enabled, and +# then the 'value' parameter can be specified using the desired +# amperage for the stepper. The default is to not scale the 'value' +# parameter. +\`\`\` + +### [static_digital_output] + +Statically cfgured digital output pins (one may define any number +of sections with a "static_digital_output" prefix). Pins cfgured +here will be setup as a GPIO output during MCU cfguration. They can +not be changed at run-time. + +\`\`\` +[static_digital_output my_output_pins] +pins: +# A comma separated list of pins to be set as GPIO output pins. The +# pin will be set to a high level unless the pin name is prefaced +# with "!". This parameter must be provided. +\`\`\` + +### [multi_pin] + +Multiple pin outputs (one may define any number of sections with a +"multi_pin" prefix). A multi_pin output creates an internal pin alias +that can modify multiple output pins each time the alias pin is +set. For example, one could define a "[multi_pin my_fan]" object +containing two pins and then set "pin=multi_pin:my_fan" in the "[fan]" +section - on each fan change both output pins would be updated. These +aliases may not be used with stepper motor pins. + +\`\`\` +[multi_pin my_multi_pin] +pins: +# A comma separated list of pins associated with this alias. This +# parameter must be provided. +\`\`\` + +## TMC stepper driver cfguration + +Cfguration of Trinamic stepper motor drivers in UART/SPI mode. +Additional information is in the [TMC Drivers guide](TMC_Drivers.md) +and in the [command reference](G-Codes.md#tmcxxxx). + +### [tmc2130] + +Cfgure a TMC2130 stepper motor driver via SPI bus. To use this +feature, define a cfg section with a "tmc2130" prefix followed by +the name of the corresponding stepper cfg section (for example, +"[tmc2130 stepper_x]"). + +\`\`\` +[tmc2130 stepper_x] +cs_pin: +# The pin corresponding to the TMC2130 chip select line. This pin +# will be set to low at the start of SPI messages and raised to high +# after the message completes. This parameter must be provided. +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#chain_position: +#chain_length: +# These parameters cfgure an SPI daisy chain. The two parameters +# define the stepper position in the chain and the total chain length. +# Position 1 corresponds to the stepper that connects to the MOSI signal. +# The default is to not use an SPI daisy chain. +#interpolate: True +# If true, enable step interpolation (the driver will internally +# step at a rate of 256 micro-steps). This interpolation does +# introduce a small systemic positional deviation - see +# TMC_Drivers.md for details. The default is True. +run_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# during stepper movement. This parameter must be provided. +#hold_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# when the stepper is not moving. Setting a hold_current is not +# recommended (see TMC_Drivers.md for details). The default is to +# not reduce the current. +#sense_resistor: 0.110 +# The resistance (in ohms) of the motor sense resistor. The default +# is 0.110 ohms. +#stealthchop_threshold: 0 +# The velocity (in mm/s) to set the "stealthChop" threshold to. When +# set, "stealthChop" mode will be enabled if the stepper motor +# velocity is below this value. The default is 0, which disables +# "stealthChop" mode. +#driver_MSLUT0: 2863314260 +#driver_MSLUT1: 1251300522 +#driver_MSLUT2: 608774441 +#driver_MSLUT3: 269500962 +#driver_MSLUT4: 4227858431 +#driver_MSLUT5: 3048961917 +#driver_MSLUT6: 1227445590 +#driver_MSLUT7: 4211234 +#driver_W0: 2 +#driver_W1: 1 +#driver_W2: 1 +#driver_W3: 1 +#driver_X1: 128 +#driver_X2: 255 +#driver_X3: 255 +#driver_START_SIN: 0 +#driver_START_SIN90: 247 +# These fields control the Microstep Table registers directly. The optimal +# wave table is specific to each motor and might vary with current. An +# optimal cfguration will have minimal print artifacts caused by +# non-linear stepper movement. The values specified above are the default +# values used by the driver. The value must be specified as a decimal integer +# (hex form is not supported). In order to compute the wave table fields, +# see the tmc2130 "Calculation Sheet" from the Trinamic website. +#driver_IHOLDDELAY: 8 +#driver_TPOWERDOWN: 0 +#driver_TBL: 1 +#driver_TOFF: 4 +#driver_HEND: 7 +#driver_HSTRT: 0 +#driver_PWM_AUTOSCALE: True +#driver_PWM_FREQ: 1 +#driver_PWM_GRAD: 4 +#driver_PWM_AMPL: 128 +#driver_SGT: 0 +# Set the given register during the cfguration of the TMC2130 +# chip. This may be used to set custom motor parameters. The +# defaults for each parameter are next to the parameter name in the +# above list. +#diag0_pin: +#diag1_pin: +# The micro-controller pin attached to one of the DIAG lines of the +# TMC2130 chip. Only a single diag pin should be specified. The pin +# is "active low" and is thus normally prefaced with "^!". Setting +# this creates a "tmc2130_stepper_x:virtual_endstop" virtual pin +# which may be used as the stepper's endstop_pin. Doing this enables +# "sensorless homing". (Be sure to also set driver_SGT to an +# appropriate sensitivity value.) The default is to not enable +# sensorless homing. +\`\`\` + +### [tmc2208] + +Cfgure a TMC2208 (or TMC2224) stepper motor driver via single wire +UART. To use this feature, define a cfg section with a "tmc2208" +prefix followed by the name of the corresponding stepper cfg +section (for example, "[tmc2208 stepper_x]"). + +\`\`\` +[tmc2208 stepper_x] +uart_pin: +# The pin connected to the TMC2208 PDN_UART line. This parameter +# must be provided. +#tx_pin: +# If using separate receive and transmit lines to communicate with +# the driver then set uart_pin to the receive pin and tx_pin to the +# transmit pin. The default is to use uart_pin for both reading and +# writing. +#select_pins: +# A comma separated list of pins to set prior to accessing the +# tmc2208 UART. This may be useful for cfguring an analog mux for +# UART communication. The default is to not cfgure any pins. +#interpolate: True +# If true, enable step interpolation (the driver will internally +# step at a rate of 256 micro-steps). This interpolation does +# introduce a small systemic positional deviation - see +# TMC_Drivers.md for details. The default is True. +run_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# during stepper movement. This parameter must be provided. +#hold_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# when the stepper is not moving. Setting a hold_current is not +# recommended (see TMC_Drivers.md for details). The default is to +# not reduce the current. +#sense_resistor: 0.110 +# The resistance (in ohms) of the motor sense resistor. The default +# is 0.110 ohms. +#stealthchop_threshold: 0 +# The velocity (in mm/s) to set the "stealthChop" threshold to. When +# set, "stealthChop" mode will be enabled if the stepper motor +# velocity is below this value. The default is 0, which disables +# "stealthChop" mode. +#driver_IHOLDDELAY: 8 +#driver_TPOWERDOWN: 20 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 0 +#driver_HSTRT: 5 +#driver_PWM_AUTOGRAD: True +#driver_PWM_AUTOSCALE: True +#driver_PWM_LIM: 12 +#driver_PWM_REG: 8 +#driver_PWM_FREQ: 1 +#driver_PWM_GRAD: 14 +#driver_PWM_OFS: 36 +# Set the given register during the cfguration of the TMC2208 +# chip. This may be used to set custom motor parameters. The +# defaults for each parameter are next to the parameter name in the +# above list. +\`\`\` + +### [tmc2209] + +Cfgure a TMC2209 stepper motor driver via single wire UART. To use +this feature, define a cfg section with a "tmc2209" prefix followed +by the name of the corresponding stepper cfg section (for example, +"[tmc2209 stepper_x]"). + +\`\`\` +[tmc2209 stepper_x] +uart_pin: +#tx_pin: +#select_pins: +#interpolate: True +run_current: +#hold_current: +#sense_resistor: 0.110 +#stealthchop_threshold: 0 +# See the "tmc2208" section for the definition of these parameters. +#uart_address: +# The address of the TMC2209 chip for UART messages (an integer +# between 0 and 3). This is typically used when multiple TMC2209 +# chips are connected to the same UART pin. The default is zero. +#driver_IHOLDDELAY: 8 +#driver_TPOWERDOWN: 20 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 0 +#driver_HSTRT: 5 +#driver_PWM_AUTOGRAD: True +#driver_PWM_AUTOSCALE: True +#driver_PWM_LIM: 12 +#driver_PWM_REG: 8 +#driver_PWM_FREQ: 1 +#driver_PWM_GRAD: 14 +#driver_PWM_OFS: 36 +#driver_SGTHRS: 0 +# Set the given register during the cfguration of the TMC2209 +# chip. This may be used to set custom motor parameters. The +# defaults for each parameter are next to the parameter name in the +# above list. +#diag_pin: +# The micro-controller pin attached to the DIAG line of the TMC2209 +# chip. The pin is normally prefaced with "^" to enable a pullup. +# Setting this creates a "tmc2209_stepper_x:virtual_endstop" virtual +# pin which may be used as the stepper's endstop_pin. Doing this +# enables "sensorless homing". (Be sure to also set driver_SGTHRS to +# an appropriate sensitivity value.) The default is to not enable +# sensorless homing. +\`\`\` + +### [tmc2660] + +Cfgure a TMC2660 stepper motor driver via SPI bus. To use this +feature, define a cfg section with a tmc2660 prefix followed by the +name of the corresponding stepper cfg section (for example, +"[tmc2660 stepper_x]"). + +\`\`\` +[tmc2660 stepper_x] +cs_pin: +# The pin corresponding to the TMC2660 chip select line. This pin +# will be set to low at the start of SPI messages and set to high +# after the message transfer completes. This parameter must be +# provided. +#spi_speed: 4000000 +# SPI bus frequency used to communicate with the TMC2660 stepper +# driver. The default is 4000000. +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#interpolate: True +# If true, enable step interpolation (the driver will internally +# step at a rate of 256 micro-steps). This only works if microsteps +# is set to 16. Interpolation does introduce a small systemic +# positional deviation - see TMC_Drivers.md for details. The default +# is True. +run_current: +# The amount of current (in amps RMS) used by the driver during +# stepper movement. This parameter must be provided. +#sense_resistor: +# The resistance (in ohms) of the motor sense resistor. This +# parameter must be provided. +#idle_current_percent: 100 +# The percentage of the run_current the stepper driver will be +# lowered to when the idle timeout expires (you need to set up the +# timeout using a [idle_timeout] cfg section). The current will +# be raised again once the stepper has to move again. Make sure to +# set this to a high enough value such that the steppers do not lose +# their position. There is also small delay until the current is +# raised again, so take this into account when commanding fast moves +# while the stepper is idling. The default is 100 (no reduction). +#driver_TBL: 2 +#driver_RNDTF: 0 +#driver_HDEC: 0 +#driver_CHM: 0 +#driver_HEND: 3 +#driver_HSTRT: 3 +#driver_TOFF: 4 +#driver_SEIMIN: 0 +#driver_SEDN: 0 +#driver_SEMAX: 0 +#driver_SEUP: 0 +#driver_SEMIN: 0 +#driver_SFILT: 0 +#driver_SGT: 0 +#driver_SLPH: 0 +#driver_SLPL: 0 +#driver_DISS2G: 0 +#driver_TS2G: 3 +# Set the given parameter during the cfguration of the TMC2660 +# chip. This may be used to set custom driver parameters. The +# defaults for each parameter are next to the parameter name in the +# list above. See the TMC2660 datasheet about what each parameter +# does and what the restrictions on parameter combinations are. Be +# especially aware of the CHOPCONF register, where setting CHM to +# either zero or one will lead to layout changes (the first bit of +# HDEC) is interpreted as the MSB of HSTRT in this case). +\`\`\` + +### [tmc2240] + +Cfgure a TMC2240 stepper motor driver via SPI bus. To use this +feature, define a cfg section with a "tmc2240" prefix followed by +the name of the corresponding stepper cfg section (for example, +"[tmc2240 stepper_x]"). + +\`\`\` +[tmc2240 stepper_x] +cs_pin: +# The pin corresponding to the TMC2240 chip select line. This pin +# will be set to low at the start of SPI messages and raised to high +# after the message completes. This parameter must be provided. +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#chain_position: +#chain_length: +# These parameters cfgure an SPI daisy chain. The two parameters +# define the stepper position in the chain and the total chain length. +# Position 1 corresponds to the stepper that connects to the MOSI signal. +# The default is to not use an SPI daisy chain. +#interpolate: True +# If true, enable step interpolation (the driver will internally +# step at a rate of 256 micro-steps). The default is True. +run_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# during stepper movement. This parameter must be provided. +#hold_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# when the stepper is not moving. Setting a hold_current is not +# recommended (see TMC_Drivers.md for details). The default is to +# not reduce the current. +#rref: 12000 +# The resistance (in ohms) of the resistor between IREF and GND. The +# default is 12000. +#stealthchop_threshold: 0 +# The velocity (in mm/s) to set the "stealthChop" threshold to. When +# set, "stealthChop" mode will be enabled if the stepper motor +# velocity is below this value. The default is 0, which disables +# "stealthChop" mode. +#driver_MSLUT0: 2863314260 +#driver_MSLUT1: 1251300522 +#driver_MSLUT2: 608774441 +#driver_MSLUT3: 269500962 +#driver_MSLUT4: 4227858431 +#driver_MSLUT5: 3048961917 +#driver_MSLUT6: 1227445590 +#driver_MSLUT7: 4211234 +#driver_W0: 2 +#driver_W1: 1 +#driver_W2: 1 +#driver_W3: 1 +#driver_X1: 128 +#driver_X2: 255 +#driver_X3: 255 +#driver_START_SIN: 0 +#driver_START_SIN90: 247 +#driver_OFFSET_SIN90: 0 +# These fields control the Microstep Table registers directly. The optimal +# wave table is specific to each motor and might vary with current. An +# optimal cfguration will have minimal print artifacts caused by +# non-linear stepper movement. The values specified above are the default +# values used by the driver. The value must be specified as a decimal integer +# (hex form is not supported). In order to compute the wave table fields, +# see the tmc2130 "Calculation Sheet" from the Trinamic website. +# Additionally, this driver also has the OFFSET_SIN90 field which can be used +# to tune a motor with unbalanced coils. See the \`Sine Wave Lookup Table\` +# section in the datasheet for information about this field and how to tune +# it. +#driver_IHOLDDELAY: 6 +#driver_IRUNDELAY: 4 +#driver_TPOWERDOWN: 10 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 2 +#driver_HSTRT: 5 +#driver_FD3: 0 +#driver_TPFD: 4 +#driver_CHM: 0 +#driver_VHIGHFS: 0 +#driver_VHIGHCHM: 0 +#driver_DISS2G: 0 +#driver_DISS2VS: 0 +#driver_PWM_AUTOSCALE: True +#driver_PWM_AUTOGRAD: True +#driver_PWM_FREQ: 0 +#driver_FREEWHEEL: 0 +#driver_PWM_GRAD: 0 +#driver_PWM_OFS: 29 +#driver_PWM_REG: 4 +#driver_PWM_LIM: 12 +#driver_SGT: 0 +#driver_SEMIN: 0 +#driver_SEUP: 0 +#driver_SEMAX: 0 +#driver_SEDN: 0 +#driver_SEIMIN: 0 +#driver_SFILT: 0 +#driver_SG4_ANGLE_OFFSET: 1 +# Set the given register during the cfguration of the TMC2240 +# chip. This may be used to set custom motor parameters. The +# defaults for each parameter are next to the parameter name in the +# above list. +#diag0_pin: +#diag1_pin: +# The micro-controller pin attached to one of the DIAG lines of the +# TMC2240 chip. Only a single diag pin should be specified. The pin +# is "active low" and is thus normally prefaced with "^!". Setting +# this creates a "tmc2240_stepper_x:virtual_endstop" virtual pin +# which may be used as the stepper's endstop_pin. Doing this enables +# "sensorless homing". (Be sure to also set driver_SGT to an +# appropriate sensitivity value.) The default is to not enable +# sensorless homing. +\`\`\` + +### [tmc5160] + +Cfgure a TMC5160 stepper motor driver via SPI bus. To use this +feature, define a cfg section with a "tmc5160" prefix followed by +the name of the corresponding stepper cfg section (for example, +"[tmc5160 stepper_x]"). + +\`\`\` +[tmc5160 stepper_x] +cs_pin: +# The pin corresponding to the TMC5160 chip select line. This pin +# will be set to low at the start of SPI messages and raised to high +# after the message completes. This parameter must be provided. +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#chain_position: +#chain_length: +# These parameters cfgure an SPI daisy chain. The two parameters +# define the stepper position in the chain and the total chain length. +# Position 1 corresponds to the stepper that connects to the MOSI signal. +# The default is to not use an SPI daisy chain. +#interpolate: True +# If true, enable step interpolation (the driver will internally +# step at a rate of 256 micro-steps). The default is True. +run_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# during stepper movement. This parameter must be provided. +#hold_current: +# The amount of current (in amps RMS) to cfgure the driver to use +# when the stepper is not moving. Setting a hold_current is not +# recommended (see TMC_Drivers.md for details). The default is to +# not reduce the current. +#sense_resistor: 0.075 +# The resistance (in ohms) of the motor sense resistor. The default +# is 0.075 ohms. +#stealthchop_threshold: 0 +# The velocity (in mm/s) to set the "stealthChop" threshold to. When +# set, "stealthChop" mode will be enabled if the stepper motor +# velocity is below this value. The default is 0, which disables +# "stealthChop" mode. +#driver_MSLUT0: 2863314260 +#driver_MSLUT1: 1251300522 +#driver_MSLUT2: 608774441 +#driver_MSLUT3: 269500962 +#driver_MSLUT4: 4227858431 +#driver_MSLUT5: 3048961917 +#driver_MSLUT6: 1227445590 +#driver_MSLUT7: 4211234 +#driver_W0: 2 +#driver_W1: 1 +#driver_W2: 1 +#driver_W3: 1 +#driver_X1: 128 +#driver_X2: 255 +#driver_X3: 255 +#driver_START_SIN: 0 +#driver_START_SIN90: 247 +# These fields control the Microstep Table registers directly. The optimal +# wave table is specific to each motor and might vary with current. An +# optimal cfguration will have minimal print artifacts caused by +# non-linear stepper movement. The values specified above are the default +# values used by the driver. The value must be specified as a decimal integer +# (hex form is not supported). In order to compute the wave table fields, +# see the tmc2130 "Calculation Sheet" from the Trinamic website. +#driver_IHOLDDELAY: 6 +#driver_TPOWERDOWN: 10 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 2 +#driver_HSTRT: 5 +#driver_FD3: 0 +#driver_TPFD: 4 +#driver_CHM: 0 +#driver_VHIGHFS: 0 +#driver_VHIGHCHM: 0 +#driver_DISS2G: 0 +#driver_DISS2VS: 0 +#driver_PWM_AUTOSCALE: True +#driver_PWM_AUTOGRAD: True +#driver_PWM_FREQ: 0 +#driver_FREEWHEEL: 0 +#driver_PWM_GRAD: 0 +#driver_PWM_OFS: 30 +#driver_PWM_REG: 4 +#driver_PWM_LIM: 12 +#driver_SGT: 0 +#driver_SEMIN: 0 +#driver_SEUP: 0 +#driver_SEMAX: 0 +#driver_SEDN: 0 +#driver_SEIMIN: 0 +#driver_SFILT: 0 +#driver_DRVSTRENGTH: 0 +#driver_BBMCLKS: 4 +#driver_BBMTIME: 0 +#driver_FILT_ISENSE: 0 +# Set the given register during the cfguration of the TMC5160 +# chip. This may be used to set custom motor parameters. The +# defaults for each parameter are next to the parameter name in the +# above list. +#diag0_pin: +#diag1_pin: +# The micro-controller pin attached to one of the DIAG lines of the +# TMC5160 chip. Only a single diag pin should be specified. The pin +# is "active low" and is thus normally prefaced with "^!". Setting +# this creates a "tmc5160_stepper_x:virtual_endstop" virtual pin +# which may be used as the stepper's endstop_pin. Doing this enables +# "sensorless homing". (Be sure to also set driver_SGT to an +# appropriate sensitivity value.) The default is to not enable +# sensorless homing. +\`\`\` + +## Run-time stepper motor current cfguration + +### [ad5206] + +Statically cfgured AD5206 digipots connected via SPI bus (one may +define any number of sections with an "ad5206" prefix). + +\`\`\` +[ad5206 my_digipot] +enable_pin: +# The pin corresponding to the AD5206 chip select line. This pin +# will be set to low at the start of SPI messages and raised to high +# after the message completes. This parameter must be provided. +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +#channel_1: +#channel_2: +#channel_3: +#channel_4: +#channel_5: +#channel_6: +# The value to statically set the given AD5206 channel to. This is +# typically set to a number between 0.0 and 1.0 with 1.0 being the +# highest resistance and 0.0 being the lowest resistance. However, +# the range may be changed with the 'scale' parameter (see below). +# If a channel is not specified then it is left uncfgured. +#scale: +# This parameter can be used to alter how the 'channel_x' parameters +# are interpreted. If provided, then the 'channel_x' parameters +# should be between 0.0 and 'scale'. This may be useful when the +# AD5206 is used to set stepper voltage references. The 'scale' can +# be set to the equivalent stepper amperage if the AD5206 were at +# its highest resistance, and then the 'channel_x' parameters can be +# specified using the desired amperage value for the stepper. The +# default is to not scale the 'channel_x' parameters. +\`\`\` + +### [mcp4451] + +Statically cfgured MCP4451 digipot connected via I2C bus (one may +define any number of sections with an "mcp4451" prefix). + +\`\`\` +[mcp4451 my_digipot] +i2c_address: +# The i2c address that the chip is using on the i2c bus. This +# parameter must be provided. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#wiper_0: +#wiper_1: +#wiper_2: +#wiper_3: +# The value to statically set the given MCP4451 "wiper" to. This is +# typically set to a number between 0.0 and 1.0 with 1.0 being the +# highest resistance and 0.0 being the lowest resistance. However, +# the range may be changed with the 'scale' parameter (see below). +# If a wiper is not specified then it is left uncfgured. +#scale: +# This parameter can be used to alter how the 'wiper_x' parameters +# are interpreted. If provided, then the 'wiper_x' parameters should +# be between 0.0 and 'scale'. This may be useful when the MCP4451 is +# used to set stepper voltage references. The 'scale' can be set to +# the equivalent stepper amperage if the MCP4451 were at its highest +# resistance, and then the 'wiper_x' parameters can be specified +# using the desired amperage value for the stepper. The default is +# to not scale the 'wiper_x' parameters. +\`\`\` + +### [mcp4728] + +Statically cfgured MCP4728 digital-to-analog converter connected +via I2C bus (one may define any number of sections with an "mcp4728" +prefix). + +\`\`\` +[mcp4728 my_dac] +#i2c_address: 96 +# The i2c address that the chip is using on the i2c bus. The default +# is 96. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#channel_a: +#channel_b: +#channel_c: +#channel_d: +# The value to statically set the given MCP4728 channel to. This is +# typically set to a number between 0.0 and 1.0 with 1.0 being the +# highest voltage (2.048V) and 0.0 being the lowest voltage. +# However, the range may be changed with the 'scale' parameter (see +# below). If a channel is not specified then it is left +# uncfgured. +#scale: +# This parameter can be used to alter how the 'channel_x' parameters +# are interpreted. If provided, then the 'channel_x' parameters +# should be between 0.0 and 'scale'. This may be useful when the +# MCP4728 is used to set stepper voltage references. The 'scale' can +# be set to the equivalent stepper amperage if the MCP4728 were at +# its highest voltage (2.048V), and then the 'channel_x' parameters +# can be specified using the desired amperage value for the +# stepper. The default is to not scale the 'channel_x' parameters. +\`\`\` + +### [mcp4018] + +Statically cfgured MCP4018 digipot connected via two gpio "bit +banging" pins (one may define any number of sections with an "mcp4018" +prefix). + +\`\`\` +[mcp4018 my_digipot] +scl_pin: +# The SCL "clock" pin. This parameter must be provided. +sda_pin: +# The SDA "data" pin. This parameter must be provided. +wiper: +# The value to statically set the given MCP4018 "wiper" to. This is +# typically set to a number between 0.0 and 1.0 with 1.0 being the +# highest resistance and 0.0 being the lowest resistance. However, +# the range may be changed with the 'scale' parameter (see below). +# This parameter must be provided. +#scale: +# This parameter can be used to alter how the 'wiper' parameter is +# interpreted. If provided, then the 'wiper' parameter should be +# between 0.0 and 'scale'. This may be useful when the MCP4018 is +# used to set stepper voltage references. The 'scale' can be set to +# the equivalent stepper amperage if the MCP4018 is at its highest +# resistance, and then the 'wiper' parameter can be specified using +# the desired amperage value for the stepper. The default is to not +# scale the 'wiper' parameter. +\`\`\` + +## Display support + +### [display] + +Support for a display attached to the micro-controller. + +\`\`\` +[display] +lcd_type: +# The type of LCD chip in use. This may be "hd44780", "hd44780_spi", +# "st7920", "emulated_st7920", "uc1701", "ssd1306", or "sh1106". +# See the display sections below for information on each type and +# additional parameters they provide. This parameter must be +# provided. +#display_group: +# The name of the display_data group to show on the display. This +# controls the content of the screen (see the "display_data" section +# for more information). The default is _default_20x4 for hd44780 +# displays and _default_16x4 for other displays. +#menu_timeout: +# Timeout for menu. Being inactive this amount of seconds will +# trigger menu exit or return to root menu when having autorun +# enabled. The default is 0 seconds (disabled) +#menu_root: +# Name of the main menu section to show when clicking the encoder +# on the home screen. The defaults is __main, and this shows the +# the default menus as defined in klippy/extras/display/menu.cfg +#menu_reverse_navigation: +# When enabled it will reverse up and down directions for list +# navigation. The default is False. This parameter is optional. +#encoder_pins: +# The pins connected to encoder. 2 pins must be provided when using +# encoder. This parameter must be provided when using menu. +#encoder_steps_per_detent: +# How many steps the encoder emits per detent ("click"). If the +# encoder takes two detents to move between entries or moves two +# entries from one detent, try changing this. Allowed values are 2 +# (half-stepping) or 4 (full-stepping). The default is 4. +#click_pin: +# The pin connected to 'enter' button or encoder 'click'. This +# parameter must be provided when using menu. The presence of an +# 'analog_range_click_pin' cfg parameter turns this parameter +# from digital to analog. +#back_pin: +# The pin connected to 'back' button. This parameter is optional, +# menu can be used without it. The presence of an +# 'analog_range_back_pin' cfg parameter turns this parameter from +# digital to analog. +#up_pin: +# The pin connected to 'up' button. This parameter must be provided +# when using menu without encoder. The presence of an +# 'analog_range_up_pin' cfg parameter turns this parameter from +# digital to analog. +#down_pin: +# The pin connected to 'down' button. This parameter must be +# provided when using menu without encoder. The presence of an +# 'analog_range_down_pin' cfg parameter turns this parameter from +# digital to analog. +#kill_pin: +# The pin connected to 'kill' button. This button will call +# emergency stop. The presence of an 'analog_range_kill_pin' cfg +# parameter turns this parameter from digital to analog. +#analog_pullup_resistor: 4700 +# The resistance (in ohms) of the pullup attached to the analog +# button. The default is 4700 ohms. +#analog_range_click_pin: +# The resistance range for a 'enter' button. Range minimum and +# maximum comma-separated values must be provided when using analog +# button. +#analog_range_back_pin: +# The resistance range for a 'back' button. Range minimum and +# maximum comma-separated values must be provided when using analog +# button. +#analog_range_up_pin: +# The resistance range for a 'up' button. Range minimum and maximum +# comma-separated values must be provided when using analog button. +#analog_range_down_pin: +# The resistance range for a 'down' button. Range minimum and +# maximum comma-separated values must be provided when using analog +# button. +#analog_range_kill_pin: +# The resistance range for a 'kill' button. Range minimum and +# maximum comma-separated values must be provided when using analog +# button. +\`\`\` + +#### hd44780 display + +Information on cfguring hd44780 displays (which is used in +"RepRapDiscount 2004 Smart Controller" type displays). + +\`\`\` +[display] +lcd_type: hd44780 +# Set to "hd44780" for hd44780 displays. +rs_pin: +e_pin: +d4_pin: +d5_pin: +d6_pin: +d7_pin: +# The pins connected to an hd44780 type lcd. These parameters must +# be provided. +#hd44780_protocol_init: True +# Perform 8-bit/4-bit protocol initialization on an hd44780 display. +# This is necessary on real hd44780 devices. However, one may need +# to disable this on some "clone" devices. The default is True. +#line_length: +# Set the number of characters per line for an hd44780 type lcd. +# Possible values are 20 (default) and 16. The number of lines is +# fixed to 4. +... +\`\`\` + +#### hd44780_spi display + +Information on cfguring an hd44780_spi display - a 20x04 display +controlled via a hardware "shift register" (which is used in +mightyboard based printers). + +\`\`\` +[display] +lcd_type: hd44780_spi +# Set to "hd44780_spi" for hd44780_spi displays. +latch_pin: +spi_software_sclk_pin: +spi_software_mosi_pin: +spi_software_miso_pin: +# The pins connected to the shift register controlling the display. +# The spi_software_miso_pin needs to be set to an unused pin of the +# printer mainboard as the shift register does not have a MISO pin, +# but the software spi implementation requires this pin to be +# cfgured. +#hd44780_protocol_init: True +# Perform 8-bit/4-bit protocol initialization on an hd44780 display. +# This is necessary on real hd44780 devices. However, one may need +# to disable this on some "clone" devices. The default is True. +#line_length: +# Set the number of characters per line for an hd44780 type lcd. +# Possible values are 20 (default) and 16. The number of lines is +# fixed to 4. +... +\`\`\` + +#### st7920 display + +Information on cfguring st7920 displays (which is used in +"RepRapDiscount 12864 Full Graphic Smart Controller" type displays). + +\`\`\` +[display] +lcd_type: st7920 +# Set to "st7920" for st7920 displays. +cs_pin: +sclk_pin: +sid_pin: +# The pins connected to an st7920 type lcd. These parameters must be +# provided. +... +\`\`\` + +#### emulated_st7920 display + +Information on cfguring an emulated st7920 display - found in some +"2.4 inch touchscreen devices" and similar. + +\`\`\` +[display] +lcd_type: emulated_st7920 +# Set to "emulated_st7920" for emulated_st7920 displays. +en_pin: +spi_software_sclk_pin: +spi_software_mosi_pin: +spi_software_miso_pin: +# The pins connected to an emulated_st7920 type lcd. The en_pin +# corresponds to the cs_pin of the st7920 type lcd, +# spi_software_sclk_pin corresponds to sclk_pin and +# spi_software_mosi_pin corresponds to sid_pin. The +# spi_software_miso_pin needs to be set to an unused pin of the +# printer mainboard as the st7920 as no MISO pin but the software +# spi implementation requires this pin to be cfgured. +... +\`\`\` + +#### uc1701 display + +Information on cfguring uc1701 displays (which is used in "MKS Mini +12864" type displays). + +\`\`\` +[display] +lcd_type: uc1701 +# Set to "uc1701" for uc1701 displays. +cs_pin: +a0_pin: +# The pins connected to a uc1701 type lcd. These parameters must be +# provided. +#rst_pin: +# The pin connected to the "rst" pin on the lcd. If it is not +# specified then the hardware must have a pull-up on the +# corresponding lcd line. +#contrast: +# The contrast to set. The value may range from 0 to 63 and the +# default is 40. +... +\`\`\` + +#### ssd1306 and sh1106 displays + +Information on cfguring ssd1306 and sh1106 displays. + +\`\`\` +[display] +lcd_type: +# Set to either "ssd1306" or "sh1106" for the given display type. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# Optional parameters available for displays connected via an i2c +# bus. See the "common I2C settings" section for a description of +# the above parameters. +#cs_pin: +#dc_pin: +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# The pins connected to the lcd when in "4-wire" spi mode. See the +# "common SPI settings" section for a description of the parameters +# that start with "spi_". The default is to use i2c mode for the +# display. +#reset_pin: +# A reset pin may be specified on the display. If it is not +# specified then the hardware must have a pull-up on the +# corresponding lcd line. +#contrast: +# The contrast to set. The value may range from 0 to 256 and the +# default is 239. +#vcomh: 0 +# Set the Vcomh value on the display. This value is associated with +# a "smearing" effect on some OLED displays. The value may range +# from 0 to 63. Default is 0. +#invert: False +# TRUE inverts the pixels on certain OLED displays. The default is +# False. +#x_offset: 0 +# Set the horizontal offset value on SH1106 displays. The default is +# 0. +... +\`\`\` + +### [display_data] + +Support for displaying custom data on an lcd screen. One may create +any number of display groups and any number of data items under those +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 +cfg file. + +\`\`\` +[display_data my_group_name my_data_name] +position: +# Comma separated row and column of the display position that should +# be used to display the information. This parameter must be +# provided. +text: +# The text to show at the given position. This field is evaluated +# using command templates (see docs/Command_Templates.md). This +# parameter must be provided. +\`\`\` + +### [display_template] + +Display data text "macros" (one may define any number of sections with +a display_template prefix). See the +[command templates](Command_Templates.md) document for information on +template evaluation. + +This feature allows one to reduce repetitive definitions in +display_data sections. One may use the builtin \`render()\` function in +display_data sections to evaluate a template. For example, if one were +to define \`[display_template my_template]\` then one could use \`{ +render('my_template') }\` in a display_data section. + +This feature can also be used for continuous LED updates using the +[SET_LED_TEMPLATE](G-Codes.md#set_led_template) command. + +\`\`\` +[display_template my_template_name] +#param_: +# One may specify any number of options with a "param_" prefix. The +# given name will be assigned the given value (parsed as a Python +# literal) and will be available during macro expansion. If the +# parameter is passed in the call to render() then that value will +# be used during macro expansion. For example, a cfg with +# "param_speed = 75" might have a caller with +# "render('my_template_name', param_speed=80)". Parameter names may +# not use upper case characters. +text: +# The text to return when the this template is rendered. This field +# is evaluated using command templates (see +# docs/Command_Templates.md). This parameter must be provided. +\`\`\` + +### [display_glyph] + +Display a custom glyph on displays that support it. The given name +will be assigned the given display data which can then be referenced +in the display templates by their name surrounded by two "tilde" +symbols i.e. \`~my_display_glyph~\` + +See [sample-glyphs.cfg](../cfg/sample-glyphs.cfg) for some +examples. + +\`\`\` +[display_glyph my_display_glyph] +#data: +# The display data, stored as 16 lines consisting of 16 bits (1 per +# pixel) where '.' is a blank pixel and '*' is an on pixel (e.g., +# "****************" to display a solid horizontal line). +# Alternatively, one can use '0' for a blank pixel and '1' for an on +# pixel. Put each display line into a separate cfg line. The +# glyph must consist of exactly 16 lines with 16 bits each. This +# parameter is optional. +#hd44780_data: +# Glyph to use on 20x4 hd44780 displays. The glyph must consist of +# exactly 8 lines with 5 bits each. This parameter is optional. +#hd44780_slot: +# The hd44780 hardware index (0..7) to store the glyph at. If +# multiple distinct images use the same slot then make sure to only +# use one of those images in any given screen. This parameter is +# required if hd44780_data is specified. +\`\`\` + +### [display my_extra_display] + +If a primary [display] section has been defined in printer.cfg as +shown above it is possible to define multiple auxiliary displays. Note +that auxiliary displays do not currently support menu functionality, +thus they do not support the "menu" options or button cfguration. + +\`\`\` +[display my_extra_display] +# See the "display" section for available parameters. +\`\`\` + +### [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 cfg file. + +See the +[command template document](Command_Templates.md#menu-templates) for +information on menu attributes available during template rendering. + +\`\`\` +# Common parameters available for all menu cfg sections. +#[menu __some_list __some_name] +#type: disabled +# Permanently disabled menu element, only required attribute is 'type'. +# Allows you to easily disable/hide existing menu items. + +#[menu some_name] +#type: +# One of command, input, list, text: +# command - basic menu element with various script triggers +# input - same like 'command' but has value changing capabilities. +# Press will start/stop edit mode. +# list - it allows for menu items to be grouped together in a +# scrollable list. Add to the list by creating menu +# cfgurations using "some_list" as a prefix - for +# example: [menu some_list some_item_in_the_list] +# vsdlist - same as 'list' but will append files from virtual sdcard +# (will be removed in the future) +#name: +# Name of menu item - evaluated as a template. +#enable: +# Template that evaluates to True or False. +#index: +# Position where an item needs to be inserted in list. By default +# the item is added at the end. + +#[menu some_list] +#type: list +#name: +#enable: +# See above for a description of these parameters. + +#[menu some_list some_command] +#type: command +#name: +#enable: +# See above for a description of these parameters. +#gcode: +# Script to run on button click or long click. Evaluated as a +# template. + +#[menu some_list some_input] +#type: input +#name: +#enable: +# See above for a description of these parameters. +#input: +# Initial value to use when editing - evaluated as a template. +# Result must be float. +#input_min: +# Minimum value of range - evaluated as a template. Default -99999. +#input_max: +# Maximum value of range - evaluated as a template. Default 99999. +#input_step: +# Editing step - Must be a positive integer or float value. It has +# internal fast rate step. When "(input_max - input_min) / +# input_step > 100" then fast rate step is 10 * input_step else fast +# rate step is same input_step. +#realtime: +# This attribute accepts static boolean value. When enabled then +# gcode script is run after each value change. The default is False. +#gcode: +# Script to run on button click, long click or value change. +# Evaluated as a template. The button click will trigger the edit +# mode start or end. +\`\`\` + +## Filament sensors + +### [filament_switch_sensor] + +Filament Switch Sensor. Support for filament insert and runout +detection using a switch sensor, such as an endstop switch. + +See the [command reference](G-Codes.md#filament_switch_sensor) for +more information. + +\`\`\` +[filament_switch_sensor my_sensor] +#pause_on_runout: True +# When set to True, a PAUSE will execute immediately after a runout +# is detected. Note that if pause_on_runout is False and the +# runout_gcode is omitted then runout detection is disabled. Default +# is True. +#runout_gcode: +# A list of G-Code commands to execute after a filament runout is +# detected. See docs/Command_Templates.md for G-Code format. If +# pause_on_runout is set to True this G-Code will run after the +# PAUSE is complete. The default is not to run any G-Code commands. +#insert_gcode: +# A list of G-Code commands to execute after a filament insert is +# detected. See docs/Command_Templates.md for G-Code format. The +# default is not to run any G-Code commands, which disables insert +# detection. +#event_delay: 3.0 +# The minimum amount of time in seconds to delay between events. +# Events triggered during this time period will be silently +# ignored. The default is 3 seconds. +#pause_delay: 0.5 +# The amount of time to delay, in seconds, between the pause command +# dispatch and execution of the runout_gcode. It may be useful to +# increase this delay if OctoPrint exhibits strange pause behavior. +# Default is 0.5 seconds. +#switch_pin: +# The pin on which the switch is connected. This parameter must be +# provided. +\`\`\` + +### [filament_motion_sensor] + +Filament Motion Sensor. Support for filament insert and runout +detection using an encoder that toggles the output pin during filament +movement through the sensor. + +See the [command reference](G-Codes.md#filament_switch_sensor) for +more information. + +\`\`\` +[filament_motion_sensor my_sensor] +detection_length: 7.0 +# The minimum length of filament pulled through the sensor to trigger +# a state change on the switch_pin +# Default is 7 mm. +extruder: +# The name of the extruder section this sensor is associated with. +# This parameter must be provided. +switch_pin: +#pause_on_runout: +#runout_gcode: +#insert_gcode: +#event_delay: +#pause_delay: +# See the "filament_switch_sensor" section for a description of the +# above parameters. +\`\`\` + +### [tsl1401cl_filament_width_sensor] + +TSLl401CL Based Filament Width Sensor. See the +[guide](TSL1401CL_Filament_Width_Sensor.md) for more information. + +\`\`\` +[tsl1401cl_filament_width_sensor] +#pin: +#default_nominal_filament_diameter: 1.75 # (mm) +# Maximum allowed filament diameter difference as mm. +#max_difference: 0.2 +# The distance from sensor to the melting chamber as mm. +#measurement_delay: 100 +\`\`\` + +### [hall_filament_width_sensor] + +Hall filament width sensor (see +[Hall Filament Width Sensor](Hall_Filament_Width_Sensor.md)). + +\`\`\` +[hall_filament_width_sensor] +adc1: +adc2: +# Analog input pins connected to the sensor. These parameters must +# be provided. +#cal_dia1: 1.50 +#cal_dia2: 2.00 +# The calibration values (in mm) for the sensors. The default is +# 1.50 for cal_dia1 and 2.00 for cal_dia2. +#raw_dia1: 9500 +#raw_dia2: 10500 +# The raw calibration values for the sensors. The default is 9500 +# for raw_dia1 and 10500 for raw_dia2. +#default_nominal_filament_diameter: 1.75 +# The nominal filament diameter. This parameter must be provided. +#max_difference: 0.200 +# Maximum allowed filament diameter difference in millimeters (mm). +# If difference between nominal filament diameter and sensor output +# is more than +- max_difference, extrusion multiplier is set back +# to %100. The default is 0.200. +#measurement_delay: 70 +# The distance from sensor to the melting chamber/hot-end in +# millimeters (mm). The filament between the sensor and the hot-end +# will be treated as the default_nominal_filament_diameter. Host +# module works with FIFO logic. It keeps each sensor value and +# position in an array and POP them back in correct position. This +# parameter must be provided. +#enable: False +# Sensor enabled or disabled after power on. The default is to +# disable. +#measurement_interval: 10 +# The approximate distance (in mm) between sensor readings. The +# default is 10mm. +#logging: False +# Out diameter to terminal and klipper.log can be turn on|of by +# command. +#min_diameter: 1.0 +# Minimal diameter for trigger virtual filament_switch_sensor. +#use_current_dia_while_delay: False +# Use the current diameter instead of the nominal diameter while +# the measurement delay has not run through. +#pause_on_runout: +#runout_gcode: +#insert_gcode: +#event_delay: +#pause_delay: +# See the "filament_switch_sensor" section for a description of the +# above parameters. +\`\`\` + +## Board specific hardware support + +### [sx1509] + +Cfgure an SX1509 I2C to GPIO expander. Due to the delay incurred by +I2C communication you should NOT use SX1509 pins as stepper enable, +step or dir pins or any other pin that requires fast bit-banging. They +are best used as static or gcode controlled digital outputs or +hardware-pwm pins for e.g. fans. One may define any number of sections +with an "sx1509" prefix. Each expander provides a set of 16 pins +(sx1509_my_sx1509:PIN_0 to sx1509_my_sx1509:PIN_15) which can be used +in the printer cfguration. + +See the [generic-duet2-duex.cfg](../cfg/generic-duet2-duex.cfg) +file for an example. + +\`\`\` +[sx1509 my_sx1509] +i2c_address: +# I2C address used by this expander. Depending on the hardware +# jumpers this is one out of the following addresses: 62 63 112 +# 113. This parameter must be provided. +#i2c_mcu: +#i2c_bus: +#i2c_speed: +# See the "common I2C settings" section for a description of the +# above parameters. +#i2c_bus: +# If the I2C implementation of your micro-controller supports +# multiple I2C busses, you may specify the bus name here. The +# default is to use the default micro-controller i2c bus. +\`\`\` + +### [samd_sercom] + +SAMD SERCOM cfguration to specify which pins to use on a given +SERCOM. One may define any number of sections with a "samd_sercom" +prefix. Each SERCOM must be cfgured prior to using it as SPI or I2C +peripheral. Place this cfg section above any other section that +makes use of SPI or I2C buses. + +\`\`\` +[samd_sercom my_sercom] +sercom: +# The name of the sercom bus to cfgure in the micro-controller. +# Available names are "sercom0", "sercom1", etc.. This parameter +# must be provided. +tx_pin: +# MOSI pin for SPI communication, or SDA (data) pin for I2C +# communication. The pin must have a valid pinmux cfguration +# for the given SERCOM peripheral. This parameter must be provided. +#rx_pin: +# MISO pin for SPI communication. This pin is not used for I2C +# communication (I2C uses tx_pin for both sending and receiving). +# The pin must have a valid pinmux cfguration for the given +# SERCOM peripheral. This parameter is optional. +clk_pin: +# CLK pin for SPI communication, or SCL (clock) pin for I2C +# communication. The pin must have a valid pinmux cfguration +# for the given SERCOM peripheral. This parameter must be provided. +\`\`\` + +### [adc_scaled] + +Duet2 Maestro analog scaling by vref and vssa readings. Defining an +adc_scaled section enables virtual adc pins (such as "my_name:PB0") +that are automatically adjusted by the board's vref and vssa +monitoring pins. Be sure to define this cfg section above any +cfg sections that use one these virtual pins. + +See the +[generic-duet2-maestro.cfg](../cfg/generic-duet2-maestro.cfg) file +for an example. + +\`\`\` +[adc_scaled my_name] +vref_pin: +# The ADC pin to use for VREF monitoring. This parameter must be +# provided. +vssa_pin: +# The ADC pin to use for VSSA monitoring. This parameter must be +# provided. +#smooth_time: 2.0 +# A time value (in seconds) over which the vref and vssa +# measurements will be smoothed to reduce the impact of measurement +# noise. The default is 2 seconds. +\`\`\` + +### [replicape] + +Replicape support - see the [beaglebone guide](Beaglebone.md) and the +[generic-replicape.cfg](../cfg/generic-replicape.cfg) file for an +example. + +\`\`\` +# The "replicape" cfg section adds "replicape:stepper_x_enable" +# virtual stepper enable pins (for steppers X, Y, Z, E, and H) and +# "replicape:power_x" PWM output pins (for hotbed, e, h, fan0, fan1, +# fan2, and fan3) that may then be used elsewhere in the cfg file. +[replicape] +revision: +# The replicape hardware revision. Currently only revision "B3" is +# supported. This parameter must be provided. +#enable_pin: !gpio0_20 +# The replicape global enable pin. The default is !gpio0_20 (aka +# P9_41). +host_mcu: +# The name of the mcu cfg section that communicates with the +# Klipper "linux process" mcu instance. This parameter must be +# provided. +#standstill_power_down: False +# This parameter controls the CFG6_ENN line on all stepper +# motors. True sets the enable lines to "open". The default is +# False. +#stepper_x_microstep_mode: +#stepper_y_microstep_mode: +#stepper_z_microstep_mode: +#stepper_e_microstep_mode: +#stepper_h_microstep_mode: +# This parameter controls the CFG1 and CFG2 pins of the given +# stepper motor driver. Available options are: disable, 1, 2, +# spread2, 4, 16, spread4, spread16, stealth4, and stealth16. The +# default is disable. +#stepper_x_current: +#stepper_y_current: +#stepper_z_current: +#stepper_e_current: +#stepper_h_current: +# The cfgured maximum current (in Amps) of the stepper motor +# driver. This parameter must be provided if the stepper is not in a +# disable mode. +#stepper_x_chopper_off_time_high: +#stepper_y_chopper_off_time_high: +#stepper_z_chopper_off_time_high: +#stepper_e_chopper_off_time_high: +#stepper_h_chopper_off_time_high: +# This parameter controls the CFG0 pin of the stepper motor driver +# (True sets CFG0 high, False sets it low). The default is False. +#stepper_x_chopper_hysteresis_high: +#stepper_y_chopper_hysteresis_high: +#stepper_z_chopper_hysteresis_high: +#stepper_e_chopper_hysteresis_high: +#stepper_h_chopper_hysteresis_high: +# This parameter controls the CFG4 pin of the stepper motor driver +# (True sets CFG4 high, False sets it low). The default is False. +#stepper_x_chopper_blank_time_high: +#stepper_y_chopper_blank_time_high: +#stepper_z_chopper_blank_time_high: +#stepper_e_chopper_blank_time_high: +#stepper_h_chopper_blank_time_high: +# This parameter controls the CFG5 pin of the stepper motor driver +# (True sets CFG5 high, False sets it low). The default is True. +\`\`\` + +## Other Custom Modules + +### [palette2] + +Palette 2 multimaterial support - provides a tighter integration +supporting Palette 2 devices in connected mode. + +This modules also requires \`[virtual_sdcard]\` and \`[pause_resume]\` +for full functionality. + +If you use this module, do not use the Palette 2 plugin for +Octoprint as they will conflict, and 1 will fail to initialize +properly likely aborting your print. + +If you use Octoprint and stream gcode over the serial port instead of +printing from virtual_sd, then remo **M1** and **M0** from *Pausing commands* +in *Settings > Serial Connection > Firmware & protocol* will prevent +the need to start print on the Palette 2 and unpausing in Octoprint +for your print to begin. + +\`\`\` +[palette2] +serial: +# The serial port to connect to the Palette 2. +#baud: 115200 +# The baud rate to use. The default is 115200. +#feedrate_splice: 0.8 +# The feedrate to use when splicing, default is 0.8 +#feedrate_normal: 1.0 +# The feedrate to use after splicing, default is 1.0 +#auto_load_speed: 2 +# Extrude feedrate when autoloading, default is 2 (mm/s) +#auto_cancel_variation: 0.1 +# Auto cancel print when ping variation is above this threshold +\`\`\` + +### [angle] + +Magnetic hall angle sensor support for reading stepper motor angle +shaft measurements using a1333, as5047d, or tle5012b SPI chips. The +measurements are available via the [API Server](API_Server.md) and +[motion analysis tool](Debugging.md#motion-analysis-and-data-logging). +See the [G-Code reference](G-Codes.md#angle) for available commands. + +\`\`\` +[angle my_angle_sensor] +sensor_type: +# The type of the magnetic hall sensor chip. Available choices are +# "a1333", "as5047d", and "tle5012b". This parameter must be +# specified. +#sample_period: 0.000400 +# The query period (in seconds) to use during measurements. The +# default is 0.000400 (which is 2500 samples per second). +#stepper: +# The name of the stepper that the angle sensor is attached to (eg, +# "stepper_x"). Setting this value enables an angle calibration +# tool. To use this feature, the Python "numpy" package must be +# installed. The default is to not enable angle calibration for the +# angle sensor. +cs_pin: +# The SPI enable pin for the sensor. This parameter must be provided. +#spi_speed: +#spi_bus: +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# See the "common SPI settings" section for a description of the +# above parameters. +\`\`\` + +## Common bus parameters + +### Common SPI settings + +The following parameters are generally available for devices using an +SPI bus. + +\`\`\` +#spi_speed: +# The SPI speed (in hz) to use when communicating with the device. +# The default depends on the type of device. +#spi_bus: +# If the micro-controller supports multiple SPI busses then one may +# specify the micro-controller bus name here. The default depends on +# the type of micro-controller. +#spi_software_sclk_pin: +#spi_software_mosi_pin: +#spi_software_miso_pin: +# Specify the above parameters to use "software based SPI". This +# mode does not require micro-controller hardware support (typically +# any general purpose pins may be used). The default is to not use +# "software spi". +\`\`\` + +### Common I2C settings + +The following parameters are generally available for devices using an +I2C bus. + +Note that Klipper's current micro-controller support for I2C is +generally not tolerant to line noise. Unexpected errors on the I2C +wires may result in Klipper raising a run-time error. Klipper's +support for error recovery varies between each micro-controller type. +It is generally recommended to only use I2C devices that are on the +same printed circuit board as the micro-controller. + +Most Klipper micro-controller implementations only support an +\`i2c_speed\` of 100000 (*standard mode*, 100kbit/s). The Klipper "Linux" +micro-controller supports a 400000 speed (*fast mode*, 400kbit/s), but it must be +[set in the operating system](RPi_microcontroller.md#optional-enabling-i2c) +and the \`i2c_speed\` parameter is otherwise ignored. The Klipper +"RP2040" micro-controller and ATmega AVR family support a rate of 400000 +via the \`i2c_speed\` parameter. All other Klipper micro-controllers use a +100000 rate and ignore the \`i2c_speed\` parameter. + +\`\`\` +#i2c_address: +# The i2c address of the device. This must specified as a decimal +# number (not in hex). The default depends on the type of device. +#i2c_mcu: +# The name of the micro-controller that the chip is connected to. +# The default is "mcu". +#i2c_bus: +# If the micro-controller supports multiple I2C busses then one may +# specify the micro-controller bus name here. The default depends on +# the type of micro-controller. +#i2c_speed: +# The I2C speed (in Hz) to use when communicating with the device. +# The Klipper implementation on most micro-controllers is hard-coded +# to 100000 and changing this value has no effect. The default is +# 100000. Linux, RP2040 and ATmega support 400000. +\`\`\` + +` diff --git a/src/plugins/Codemirror/KlipperCfgLang/rollup.config.js b/src/plugins/Codemirror/KlipperCfgLang/rollup.config.js new file mode 100644 index 000000000..306f7eeb3 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/rollup.config.js @@ -0,0 +1,19 @@ +import { nodeResolve } from '@rollup/plugin-node-resolve' + +export default { + input: 'src/plugins/Codemirror/KlipperCfgLang/parser/klipperCfgParser.js', + output: [ + { + format: 'cjs', + file: 'src/plugins/Codemirror/KlipperCfgLang/dist/klipperCfgParser.cjs', + }, + { + format: 'es', + file: 'src/plugins/Codemirror/KlipperCfgLang/dist/klipperCfgParser.es.js', + }, + ], + external(id) { + return !/^[\.\/]/.test(id) + }, + plugins: [nodeResolve()], +} diff --git a/src/plugins/Codemirror/KlipperCfgLang/testLint/testKlipperCfgLint.js b/src/plugins/Codemirror/KlipperCfgLang/testLint/testKlipperCfgLint.js new file mode 100644 index 000000000..83dd4f989 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testLint/testKlipperCfgLint.js @@ -0,0 +1,9 @@ +import { lintSource } from '../lang/lint.js' +import { valueTests } from './testValues.js' + +describe('Variable Types', () => { + for (let test of valueTests) { + console.log( lintSource(test.input)) + it(test.name, () => lintSource(test.input) === test.output) + } +}) diff --git a/src/plugins/Codemirror/KlipperCfgLang/testLint/testValues.ts b/src/plugins/Codemirror/KlipperCfgLang/testLint/testValues.ts new file mode 100644 index 000000000..5ec435186 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testLint/testValues.ts @@ -0,0 +1,11 @@ +import { LintTest, createEditorView } from '../../mochaFileTests.js' + +export const valueTests: LintTest[] = [] + +valueTests.push({ + name: 'very simple config with no errors', + input: createEditorView(` + [mcu] + Serial: /dev/ttyAMA0`), + expected: [], +}) diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/blocktype.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/blocktype.txt new file mode 100644 index 000000000..ead029e1c --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/blocktype.txt @@ -0,0 +1,25 @@ +# 1) block type with special characters +[test_-2a] +==> +Program(ConfigBlock(BlockType)) + + + +# 2) block type with non valid characters +[mcu123.:%=] +==> +error + + + +# 3) block type and identifier with special characters +[mcu test123_-4] +==> +Program(ConfigBlock(BlockType,Identifier)) + + + +# 4) block type and identifier with non valid characters +[mcu test123.:%=] +==> +error \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/commentBlankline.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/commentBlankline.txt new file mode 100644 index 000000000..3d9bf3996 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/commentBlankline.txt @@ -0,0 +1,121 @@ +# 1) Comment lines at the beginning with configuration underneath +# test comment +# test comment +[include test.cfg] +[include test2.cfg] +==> +Program( + Comment, + Comment, + Import(ImportKeyword,FilePath), + Import(ImportKeyword,FilePath)) + + + +# 2) blank lines at the beginning with configuration underneath + + +[include test.cfg] +[include test2.cfg] +==> +Program( + Import(ImportKeyword,FilePath), + Import(ImportKeyword,FilePath)) + + + +# 3) comment + blank line as first line with configuration underneath +# test comment + +[include test.cfg] +[include test2.cfg] +==> +Program( + Comment, + Import(ImportKeyword,FilePath), + Import(ImportKeyword,FilePath)) + + + +# 4) Comment line between config blocks / parameters +[mcu] +serial: /dev/ttyAMA0 +# test comment +restart_method: command +# test comment +[adxl345] +cs_pin: rpi:None +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Path)), + Comment, + Option(Parameter,Value(String)))), + Comment, + ConfigBlock(BlockType,Body( + Option(Parameter,Value(VirtualPin))))) + + + +# 5) blank line between config blocks / parameters +[mcu] +serial: /dev/ttyAMA0 + +restart_method: command + +[adxl345] +cs_pin: rpi:None +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Path)), + Option(Parameter,Value(String)))), + ConfigBlock(BlockType,Body( + Option(Parameter,Value(VirtualPin))))) + + + +# 6) Comment after a [Block], a parameter, and after a value +[mcu] # test comment +serial: /dev/ttyAMA0 # test comment +restart_method: # test comment + command # test comment +==> +Program( + ConfigBlock(BlockType,Comment,Body( + Option(Parameter,Value(Path,Comment)), + Option(Parameter,Comment,Value(String,Comment))))) + + + + +# 7) Comment after all value types +[test] +path: /dev/ttyAMA0 # test comment +filepath: /dev/test.txt # test comment +string: command # test comment +number: 1 # test comment +cords: 1,2 # test comment +pin: PE3 # test comment +pins: PE3,PE4 # test comment +virtualPin: rpi:None # test comment +boolean: true # test comment +resolution: 1x2 # test comment +ipv4: 10.22.22.2 # test comment +ipv6: ::1/128 # test comment +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Path,Comment)), + Option(Parameter,Value(FilePath,Comment)), + Option(Parameter,Value(String,Comment)), + Option(Parameter,Value(Number,Comment)), + Option(Parameter,Value(Cords,Comment)), + Option(Parameter,Value(Pin,Comment)), + Option(Parameter,Value(Pin,Pin,Comment)), + Option(Parameter,Value(VirtualPin,Comment)), + Option(Parameter,Value(Boolean,Comment)), + Option(Parameter,Value(Resolution,Comment)), + Option(Parameter,Value(Ipv4,Comment)), + Option(Parameter,Value(Ipv6,Comment)) + ))) \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/import.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/import.txt new file mode 100644 index 000000000..d86802eb4 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/import.txt @@ -0,0 +1,25 @@ +# 1) import with wrong syntax (missing bracket) +[include test.cfg +==> +error + + + +# 2) import with wrong syntax (missing file path) +[include ] +==> +error + + + +# 3) import with wrong syntax (wrong keyword) +[includ test.cfg] +==> +Program(ConfigBlock(BlockType,Identifier)) + + + +# 4) korrect import +[include test.cfg] +==> +Program(Import(ImportKeyword,FilePath)) \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/parameter.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/parameter.txt new file mode 100644 index 000000000..ecfa52ecd --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/parameter.txt @@ -0,0 +1,86 @@ +# 1) parameter at non valid positions +speed: 50 +[mcu] +serial: /dev/ttyAMA0 +[include test.cfg] +restart_method: command +==> +Program( + ConfigBlock(⚠,BlockType,⚠,Identifier,⚠), + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Path)))), + Import(ImportKeyword,FilePath), + ConfigBlock(⚠,BlockType,⚠,Identifier,⚠)) + + + +# 2) parameter without following ":" + value/valueBlock +[mcu] +serial +[adxl345] +==> +error + + + +# 3) parameter-name with special characters +[mcu] +serial_tem-3: 1 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Number))))) + + + +# 4) parameter-name with non-valid characters +[mcu] +serial@: /dev/ttyAMA0 +==> +error + + + +# 5) parameter with normal value +[mcu] +num: 100 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Number))))) + + + +# 6) parameter with valueBlock +[mcu] +cords: + 10, 20 + 220, 210 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Cords,Cords))))) + + + +# 7) parameter ending on "gcode" + value +[commands] +start_gcode: M106 S0 +==> +Program( + ConfigBlock(BlockType,Body( + Option(GcodeKeyword,Jinja2)))) + + + +# 8) parameter ending on "gcode" + valueBlock +[commands] +end_gcode: + M104 S0 + M140 S0 +# comment +==> +Program( + ConfigBlock(BlockType, + Body(Option(GcodeKeyword,Jinja2))), + Comment) \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/structure.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/structure.txt new file mode 100644 index 000000000..eb2f9e95d --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/structure.txt @@ -0,0 +1,186 @@ +# 1) only import +[include test.cfg] +==> +Program(Import(ImportKeyword,FilePath)) + + + +# 2) only empty config block +[mcu] +==> +Program(ConfigBlock(BlockType)) + + + +# 3) only config block +[mcu] +serial: /dev/ttyAMA0 +restart_method: command +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(Path)), + Option(Parameter,Value(String))))) + + + +# 4) import between config blocks +[mcu] +serial: /dev/ttyAMA0 +[include test.cfg] +[adxl345] +cs_pin: rpi:None +==> +Program( + ConfigBlock(BlockType,Body(Option(Parameter,Value(Path)))), + Import(ImportKeyword,FilePath), + ConfigBlock(BlockType,Body(Option(Parameter,Value(VirtualPin))))) + + + +# 5) import + eof +[include test.cfg]==> +Program(Import(ImportKeyword,FilePath)) + + + +# 6) empty config block + eof +[mcu]==> +Program(ConfigBlock(BlockType)) + + + +# 7) config block + value + eof +[mcu] +restart_method: command==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 8) config block + valueBlock + eof +[mcu] +restart_method: + command==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 9) config block + comment + eof +[mcu] +restart_method: command +# test==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String)))),Comment) + + + +# 10) config block + value + comment + eof +[mcu] +restart_method: command # test==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String)))),Comment) + + + +# 11) config with AutoGenSection +[printer] +kinematics: corexy + +#*# <---------------------- SAVE_CONFIG ----------------------> +#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. +#*# +#*# [input_shaper] +#*# shaper_type_x = mzv +#*# shaper_freq_x = 90.4 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(String)))), + AutoGenSection( + AutoGenHeader(AutoGenLineStart),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(String)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))))) + + + +# 12) config with AutoGenSection + eof +[printer] +kinematics: corexy + +#*# <---------------------- SAVE_CONFIG ----------------------> +#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. +#*# +#*# [input_shaper] +#*# shaper_type_x = mzv +#*# shaper_freq_x = 90.4==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(String)))), + AutoGenSection( + AutoGenHeader(AutoGenLineStart),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(String)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))))) + + + +# 13) AutoGenSection with multiple configBlocks +[printer] +kinematics: corexy + +#*# <---------------------- SAVE_CONFIG ----------------------> +#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. +#*# +#*# [input_shaper] +#*# shaper_type_x = mzv +#*# shaper_freq_x = 90.4 +#*# +#*# [heater_bed] +#*# control = pid +#*# pid_kp = 52.053 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(String)))), + AutoGenSection( + AutoGenHeader(AutoGenLineStart),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(String)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(String)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))))) + + + +# 14) config with AutoGenSection + valueBlock +[printer] +kinematics: corexy + +#*# <---------------------- SAVE_CONFIG ----------------------> +#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. +#*# +#*# [bed_mesh 20221215] +#*# version = 1 +#*# points = +#*# 0.062838, -0.005912 +#*# 0.027838, -0.025912 +#*# tension = 0.2 +#*# min_x = 15.0 +#*# +#*# [input_shaper] +#*# shaper_type_x = mzv +#*# shaper_freq_x = 90.4 +==> +Program( + ConfigBlock(BlockType,Body( + Option(Parameter,Value(String)))), + AutoGenSection( + AutoGenHeader(AutoGenLineStart),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,Identifier,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(Number)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(AutoGenIndent,Cords,AutoGenIndent,Cords)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))),AutoGenLineStart,AutoGenLineStart, + AutoGenBlock(BlockType,AutoGenLineStart,AutoGenBody( + AutoGenOption(Parameter,AutoGenValue(String)),AutoGenLineStart, + AutoGenOption(Parameter,AutoGenValue(Number)))))) diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/value.txt b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/value.txt new file mode 100644 index 000000000..8d7891134 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases/value.txt @@ -0,0 +1,296 @@ +# 1) normal Pin +[stepper] +pin: PE1 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Pin))))) + + + +# 2) inverted Pin +[stepper] +pin: !PE1 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Pin))))) + + + +# 3) pullup/low Pin +[stepper] +pin: ^PE1 +pin: ~PE2 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Pin)),Option(Parameter,Value(Pin))))) + + + +# 4) combination of iverted and pullup/low pin +[stepper] +pin: ^!PE1 +pin: ~!PE2 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Pin)),Option(Parameter,Value(Pin))))) + + + +# 5) wrong combination of iverted and pullup/low pin +[stepper] +pin: !^PE1 +pin: !+PE1 +pin: ~^PE2 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String)),Option(Parameter,Value(String)),Option(Parameter,Value(String))))) + + + +# 6) lowercase Pin +[stepper] +pin: pe1 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 7) pins +[stepper] +pin: PE1, PE2 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Pin,Pin))))) + + + +# 8) virtual pin +[stepper] +pin: rpi:None +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(VirtualPin))))) + + + +# 9) virtual pin with non valid characters +[stepper] +pin: rpi!:None* +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 10) number +[stepper] +microsteps: 32 +homing_speed: 30.3 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Number)),Option(Parameter,Value(Number))))) + + + +# 11) negativ number +[stepper] +microsteps: -32 +homing_speed: -30.3 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Number)),Option(Parameter,Value(Number))))) + + + +# 12) float but "," instead of "." +[stepper] +homing_speed: -30,3 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Cords))))) + + + +# 13) cords +[resonance_tester] +points3d: 110,110,20 +points2d: 110,-110 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Cords)),Option(Parameter,Value(Cords))))) + + + +# 14) mixing float/int in cords +[resonance_tester] +points3d: 110,110.23,20.6 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Cords))))) + + + +# 15) normal string +[printer] +kinematics: coreXY123 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 16) string with whitespaces +[printer] +kinematics: core xy +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 17) string with special characters +[printer] +kinematics: corexy!_:/-gtX +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 18) string with special characters 2 +[printer] +kinematics: {'%05.1f' % (printer.toolhead)} +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String))))) + + + +# 19) boolean +[tmc] +interpolate: True +interpolate: true +interpolate: False +interpolate: false +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Boolean)),Option(Parameter,Value(Boolean)),Option(Parameter,Value(Boolean)),Option(Parameter,Value(Boolean))))) + + + +# 20) Path +[mcu] +serial: /tmp/klipper_host_mcu +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Path))))) + + + +# 21) FilePath +[mcu] +serial: /tmp/test.txt +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(FilePath))))) + + + +# 22) path of a file in same directory +[mcu] +serial: test.txt +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(FilePath))))) + + + +# 23) parth starting with "./", "../", "~/" or without "/" +[mcu] +serial: ./tmp/test.txt +serial: ../tmp/test.txt +serial: ~/tmp/test.txt +serial: tmp/test.txt +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(String)),Option(Parameter,Value(String)),Option(Parameter,Value(FilePath)),Option(Parameter,Value(String))))) + + + +# 24) Resolution +[display] +resolution: 1280x720 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Resolution))))) + + + +# 25) non valid Resolution +[display] +resolution: 1280x720.8 +==> +error + + + +# 26) Ipv4 +[server] +host: 0.0.0.0 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Ipv4))))) + + + +# 27) Ipv4 with port +[server] +host: 0.0.0.0:8123 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Ipv4))))) + + + +# 28) ipv4 with subnetsize +[server] +host: 0.0.0.0/24 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Ipv4))))) + + + +# 29) Ipv4 with wrong syntax +[server] +host: 0.0.0/24 +==> +error + + + +# 30) Ipv6 +[server] +host: ::1 +host: FE80:: +host: FE80::1 +host: FE80:1::1:1 +host: 1:1:1:1:1:1 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Ipv6)),Option(Parameter,Value(Ipv6)),Option(Parameter,Value(Ipv6)),Option(Parameter,Value(Ipv6)),Option(Parameter,Value(Ipv6))))) + + + +# 31) ipv6 with subnetsize +[server] +host: ::1/128 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Ipv6))))) + + + +# 32) Ipv6 with wrong syntax +[server] +host: 1:1/128 +==> +error + + + +# 33) Empty value: +[server] +host: +restart_method: command +==> +error + + + +# 35) Empty value with whitespaces: +[server] +host: +restart_method: command +==> +error + + + +# 36) Value with leading and trailing whitespaces: +[mcu] +serial: 16x16 +==> +Program(ConfigBlock(BlockType,Body(Option(Parameter,Value(Resolution))))) \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/KlipperScreen.conf b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/KlipperScreen.conf new file mode 100644 index 000000000..9f150dc5c --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/KlipperScreen.conf @@ -0,0 +1,101 @@ +[main] +# Invert axis in move panel. Default is False. Change to true to invert +invert_x: False +invert_y: False +invert_z: False +# Time (seconds) before the Job Status page reverts to main menu after a successful job +job_complete_timeout: 30 +# Time (seconds) before the Job Status page reverts to main menu after a successful job. +# If this option is 0, the user must click on a button to go back to the main menu. +job_error_timeout: 0 +# Specify the language +# The language can be specified here instead of using the system default language. +language: en +# Allows the cursor to be displayed on the screen +show_cursor: False + +[printer Voron V2.660] +# Define the moonraker host/port if different from 127.0.0.1 and 7125 +moonraker_host: 127.0.0.1 +moonraker_port: 7125 +# Moonraker API key if this is not connecting from a trusted client IP +moonraker_api_key: False +# Define the z_babystep intervals in a CSV list. Currently only 2 are supported +z_babystep_values: 0.1, 0.05 + +#~# --- Do not edit below this line. This section is auto generated --- #~# + +#~# +#~# [main] +#~# language = en +#~# print_sort_dir = date_desc +#~# screen_blanking = 300 +#~# theme = colorized +#~# side_macro_shortcut = False +#~# +#~# [displayed_macros Printer] +#~# bed_mesh_calibrate = False +#~# cancel_print = False +#~# dump_parameters = False +#~# dump_config = False +#~# dump_settings = False +#~# mesh_load = False +#~# m204 = False +#~# m141 = False +#~# man_resonances = False +#~# m600 = False +#~# mesh_store = False +#~# prime_line = False +#~# m300 = False +#~# _caselight_off = False +#~# pause = False +#~# resume = False +#~# _display_plate = False +#~# rst_service = False +#~# rst_filter = False +#~# print_end = False +#~# _extruder_on = False +#~# _display_on = False +#~# _filament_ball = False +#~# test_probe_accuracy = False +#~# quad_gantry_level = False +#~# _list_plates = False +#~# _lcd_knob = False +#~# _add_new_plate = False +#~# _filter_info = False +#~# print_start = False +#~# _runout_info = False +#~# _display_state = False +#~# _add_print_time = False +#~# _extruder_off = False +#~# _set_filter = False +#~# _bed_off = False +#~# _caselight_on = False +#~# _psu_off = False +#~# _vent_info = False +#~# _g32 = False +#~# _bed_on = False +#~# _print_info1 = False +#~# _set_plate_offset = False +#~# _print_info2 = False +#~# _print_ar = False +#~# _filter_on = False +#~# _display_print_time = False +#~# _set_caselight = False +#~# _cg28 = False +#~# _heater_on = False +#~# _display_off = False +#~# _change_plate_name = False +#~# _change_plate_offset = False +#~# _set_z_current = False +#~# _sd_printer_stats = False +#~# _sd_print_stats = False +#~# _wipe = False +#~# _remove_plate = False +#~# _init_plate_array = False +#~# _print_time = False +#~# _set_acc = False +#~# _set_plate = False +#~# _select_pa = False +#~# _shutdown_pi = False +#~# diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/basic_macro.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/basic_macro.cfg new file mode 100644 index 000000000..484d2b15e --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/basic_macro.cfg @@ -0,0 +1,54 @@ +##################################################################### +# Macro +##################################################################### +# +# This section contains basic macros that needed in several other +# files. Getting them all to a single place should help to only +# use what needed without hunting down several other files. +# +##################################################################### +## Clear display output after Duration in seconds +## Use: UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 +[delayed_gcode _CLEAR_DISPLAY] +gcode: + M117 + +## Reset SD File after Print_END or CANCEL_PRINT +## This will avoid the reprint option in Mainsail after a print is done +[delayed_gcode _DELAY_SDCARD_RESET_FILE] +gcode: + SDCARD_RESET_FILE + +[gcode_macro DIRECT_MOVE] +gcode: + {% set out_param = ["G0"] %} + {% set _dummy = out_param.append("X%s" % params.X) if params.X %} + {% set _dummy = out_param.append("Y%s" % params.Y) if params.Y %} + {% set _dummy = out_param.append("Z%s" % params.Z) if params.Z %} + {% set _dummy = out_param.append("E%s" % params.E) if params.E %} + {% set _dummy = out_param.append("F%s" % params.F) if params.F %} + {out_param|join(" ")} + +## action_respond_info will be always executed at the beginning of an macro evaluation. +## Use _PRINT_AR if you need the order of several console outputs in the order given by the macro +## Use: _PRINT_AR T="QGL forced by PRINT_START" +[gcode_macro _PRINT_AR] +description: Helper: Action response +gcode: + {% if params.SHOW_LCD|default('false') == 'true' %} M117 {params.T} {% endif %} + {action_respond_info(params.T)} + +[gcode_macro M115] +description: Print host and mcu version +rename_existing: M115.1 +gcode: + {% set out = ['mcu build version:'] %} + {% for name1 in printer %} + {% for name2 in printer[name1] %} + {% if name2 is in ['mcu_version'] %} + {% set _dummy = out.append("%s: %s" % (name1, printer[name1][name2])) %} + {% endif %} + {% endfor %} + {% endfor %} + {action_respond_info(out|join("\n"))} + M115.1 diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/bed_mesh.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/bed_mesh.cfg new file mode 100644 index 000000000..a30d7e44e --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/bed_mesh.cfg @@ -0,0 +1,133 @@ +##################################################################### +# Bed Mesh Definition +##################################################################### +[bed_mesh] +## Start end end point of mesh +mesh_min: 30,30 +mesh_max: 320,320 +speed: 1000 +## The height (in mm) that the head should be commanded to move to +## just prior to starting a probe operation. The default is 5. +horizontal_move_z: 7.5 ; MagProbe Klicky +#horizontal_move_z: 4 ; Vinda or Omron +probe_count: 9,9 +## The interpolation algorithm to use. May be either "lagrange" +## or "bicubic". This option will not affect 3x3 grids, which +## are forced to use lagrange sampling. Default is lagrange. +algorithm: bicubic +##[(7x7)-1] / 2 = 24 +##[(5x5)-1] / 2 = 12 +relative_reference_index: 40 +## The gcode z position in which to start phasing out z-adjustment +## when fade is enabled. Default is 1.0. +#fade_start: 1 +## The gcode z position in which phasing out completes. When set +## to a value below fade_start, fade is disabled. It should be +## noted that fade may add unwanted scaling along the z-axis of a +## print. If a user wishes to enable fade, a value of 10.0 is +## recommended. Default is 0.0, which disables fade. +#fade_end: 10 +## The z position in which fade should converge. When this value is set +## to a non-zero value it must be within the range of z-values in the mesh. +## Users that wish to converge to the z homing position should set this to 0. +## Default is the average z value of the mesh. +#fade_target: 0 +## The distance (in mm) along a move to check for split_delta_z. +## This is also the minimum length that a move can be split. Default +## is 5.0. +move_check_distance: 3 +## The amount of Z difference (in mm) along a move that will +## trigger a split. Default is .025. +split_delta_z: 0.0125 +## A comma separated pair of integers (X,Y) defining the number of +## points per segment to interpolate in the mesh along each axis. A +## "segment" can be defined as the space between each probed +## point. The user may enter a single value which will be applied +## to both axes. Default is 2,2. +mesh_pps: 2,2 +## When using the bicubic algorithm the tension parameter above +## may be applied to change the amount of slope interpolated. +## Larger numbers will increase the amount of slope, which +## results in more curvature in the mesh. Default is .2. +#bicubic_tension: 0.2 + +##################################################################### +# Macros +##################################################################### +# +# Warning: If you use the flexplate names insight your stored mesh's than: +# - insure that it does not contain spaces +# - insure that it does not contain special charakters +# - insure that it does not contain german "umlaut" (äöü and ß) +# +# All macros are writen in the way that they will work without a [save_variables] +# block and also without the flexplate.cfg +# +##################################################################### +[gcode_macro BED_MESH_CALIBRATE] +description: Perform QGL and bed mesh leveling +rename_existing: BED_MESH_CALIBRATE_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% if "xyz" not in printer.toolhead.homed_axes %} G28 {% endif %} + BED_MESH_CLEAR + {% if not printer.quad_gantry_level.applied %} QUAD_GANTRY_LEVEL PARK=false {% endif %} + {% if user.hw.mag_probe.ena %} ATTACH_PROBE {% endif %} + BED_MESH_CALIBRATE_BASE {rawparams} + {% if user.hw.mag_probe.ena %} DETACH_PROBE {% endif %} + +## use BED_MESH_STORE -> generate MESH and park in the middle +## use BED_MESH_STORE SAVE=now -> generate MESH and park in the middle and save immediately +## use BED_MESH_STORE PARK=false -> generate MESH +## use BED_MESH_STORE SAVE=later -> generate MESH and park in the middle and save it later +[gcode_macro BED_MESH_STORE] +description: Generate a mesh, name it and run save_config if requested +variable_save_at_end: False +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set name = '' if printer.save_variables.variables.plates is not defined + else printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name + '-' %} + {% set mesh_name = name + "Bed_Temp-" + printer.heater_bed.target|int|string + "C" %} + {action_respond_info("BED_MESH: Generate \"%s\"" % mesh_name)} + BED_MESH_CALIBRATE PROFILE={mesh_name} + {% if params.PARK|default('true')|lower == 'true' %} + G90 ; set absolute + G0 Z{user.park.bed.z} F{user.speed.z_hop} ; lift first + G0 X{user.park.bed.x} Y{user.park.bed.y} F{user.speed.travel} ; park toolhead + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set it back to relative + {% endif %} + {% if params.SAVE|default('none')|lower == 'now' %} + _PRINT_AR T="BED_MESH: Save Config!" + SAVE_CONFIG + {% elif params.SAVE|default('none')|lower == 'later' %} + _PRINT_AR T="BED_MESH: Save Config after print done" + SET_GCODE_VARIABLE MACRO=BED_MESH_STORE VARIABLE=save_at_end VALUE=True + {% endif %} + +## use BED_MESH_LOAD -> load an existing MESH +## use BED_MESH_LOAD AUTO=true -> load an existing MESH or generate a new one and prepare it to be saved after print end +[gcode_macro BED_MESH_LOAD] +description: Load an existing mesh or generate a new one +gcode: + {% set name = '' if printer.save_variables.variables.plates is not defined + else printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name + '-' %} + {% set mesh_name = name + "Bed_Temp-" + printer.heater_bed.target|int|string + "C" %} + {% if printer.configfile.config["bed_mesh " + mesh_name] is defined %} + {action_respond_info("BED_MESH: \"%s\" loaded" % mesh_name)} + BED_MESH_CLEAR + BED_MESH_PROFILE LOAD={mesh_name} + {% elif params.AUTO|default('false')|lower == 'true' %} + {action_respond_info("BED_MESH: \"%s\" needs to be generated" % mesh_name)} + BED_MESH_STORE SAVE=none PARK=false + {% else %} + {action_respond_info("BED_MESH: ERROR \"%s\" not defined" % mesh_name)} + {% endif %} + +## add this to your PRINT_END to save a mesh if needed 10 seconds after print ended +## UPDATE_DELAYED_GCODE ID=_BED_MESH_SAVE DURATION=10 +[delayed_gcode _BED_MESH_SAVE] +gcode: + {% if printer["gcode_macro MESH_STORE"].save_at_end %} + {action_respond_info("BED_MESH: Save Config!")} + SAVE_CONFIG + {% endif %} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/caselight.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/caselight.cfg new file mode 100644 index 000000000..2faeda0b0 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/caselight.cfg @@ -0,0 +1,29 @@ +##################################################################### +# Caselight pin Definition +##################################################################### +## Caselight - XYE board, HB Connector +[output_pin caselight] +pin: P2.5 +pwm: true +hardware_pwm: true +shutdown_value: 0 +cycle_time: 0.0001 + +##################################################################### +# Macros +##################################################################### +[gcode_macro _CASELIGHT_ON] +description: Helper: Light on +gcode: + SET_PIN PIN=caselight VALUE={printer['gcode_macro _USER_VARIABLE'].peripheral.caselight.on_val} + {action_respond_info("Caselight on")} + +[gcode_macro _CASELIGHT_OFF] +description: Helper: Light off +gcode: + SET_PIN PIN=caselight VALUE=0.0 + {action_respond_info("Caselight off")} + +[gcode_macro CASELIGHT] +description: Toggle light +gcode: {% if printer['output_pin caselight'].value == 0 %} _CASELIGHT_ON {% else %} _CASELIGHT_OFF {% endif %} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/crowsnest.conf b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/crowsnest.conf new file mode 100644 index 000000000..f233bf84d --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/crowsnest.conf @@ -0,0 +1,41 @@ +#### crowsnest.conf +#### This is mainsail / MainsailOS default config. +#### See: +#### https://github.com/mainsail-crew/crowsnest/blob/master/README.md +#### for details to configure to your needs. + + +##################################################################### +#### ##### +#### Information about ports and according URL's ##### +#### ##### +##################################################################### +#### ##### +#### Port 8080 equals /webcam/?action=[stream/snapshot] ##### +#### Port 8081 equals /webcam2/?action=[stream/snapshot] ##### +#### Port 8082 equals /webcam3/?action=[stream/snapshot] ##### +#### Port 8083 equals /webcam4/?action=[stream/snapshot] ##### +#### ##### +##################################################################### +[crowsnest] +log_path: ~/klipper_logs/crowsnest.log # Default logfile in ~/klipper_logs/crowsnest.log +log_level: verbose # Valid Options are quiet/verbose/debug +delete_log: false # Deletes log on every restart, if set to true + +[cam Main] +mode: mjpg # mjpg/rtsp +port: 8080 # Port +device: /dev/v4l/by-id/usb-046d_HD_Pro_Webcam_C920_BAB4B21F-video-index0 +resolution: 1920x1080 # widthxheight format +max_fps: 30 # If Hardware Supports this it will be forced, ohterwise ignored/coerced. +v4l2ctl: focus_auto=0,focus_absolute=30 +#custom_flags: # You can run the Stream Services with custom flags. + +#[cam test] +#streamer: mjpg +#port: 8081 +#device: /dev/v4l/by-id/usb-HD_USB_Camera_HD_USB_Camera_2020042508-video-index0 +#resolution: 1280x960 +#max_fps: 15 +#custom_flags: -pl 50hz -ex 300 -co 40 --gain 2 + diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/debug_macro.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/debug_macro.cfg new file mode 100644 index 000000000..f9df81228 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/debug_macro.cfg @@ -0,0 +1,67 @@ +# Use: +# - DUMP_PARAMETER print all parameter expect configfile +# - DUMP_PARAMETER P='gcode_macro _TEST' print the defined parameter group +# - DUMP_PARAMETER C='printer' print the defined config values +# - DUMP_PARAMETER S='printer' print the defined settings values +[gcode_macro DUMP_PARAMETER] +description: Debug: Print entries of the printer object +gcode: + {% set config = True if params.C or params.S else False %} + {% set path = 'config' if params.C + else 'settings' if params.S %} + {% set search = params.C if params.C + else params.S if params.S + else params.P if params.P %} + {% set out = [] %} + {% for name1 in printer|sort %} + {% if config %} ; print the searched printer.configfile[path] parameter + {% if name1 is in ['configfile'] %} + {% for name2 in printer[name1][path]|sort %} + {% if name2 is in [search] %} + {% for name3, value in printer[name1][path][name2].items()|sort %} + {% set _dummy = out.append("printer.configfile.%s['%s'].%s = %s" % + (path, name2, name3, value)) %} + {% endfor %} + {% endif %} + {% endfor %} + {% endif %} + {% else %} + {% for name2, value in printer[name1].items()|sort %} ; search for anything expext printer.configfile + {% if search is not defined and name1 is not in ['configfile'] %} ; print all printer. parameter + {% set _dummy = out.append("printer['%s'].%s = %s" % (name1, name2, value)) %} + {% elif search is defined and name1 is in [search] %} ; print the searched printer. parameter + {% set _dummy = out.append("printer['%s'].%s = %s" % (name1, name2, value)) %} + {% endif %} + {% endfor %} + {% endif %} + {% endfor %} + {% if out|length > 0 %} + {action_respond_info(out|join("\n"))} + {% else %} + {action_respond_info("Nothing found for \"DUMP_PARAMETER %s\"" % rawparams)} + {% endif %} + +[gcode_macro DUMP_PRINT_AREA_LIMITS] +description: Debug: Print information about print volume and probeable area +gcode: + {% set min = printer.toolhead.axis_minimum %} + {% set max = printer.toolhead.axis_maximum %} + {% set probe_offset = {'x' : printer.configfile.settings.probe.x_offset, + 'y' : printer.configfile.settings.probe.y_offset} %} + {% set probe_area = {'min' : {'x' : [min.x,(min.x-probe_offset.x)]|max, + 'y' : [min.y,(min.y-probe_offset.y)]|max}, + 'max' : {'x' : [max.x,(max.x-probe_offset.x)]|min, + 'y' : [max.y,(max.y-probe_offset.y)]|min}} %} + {action_respond_info("Print Volume Limits: + Min X:%7.1f, Y:%7.1f, Z:%7.1f + Max X:%7.1f, Y:%7.1f, Z:%7.1f + Probe Area Limits: + Min X:%7.1f, Y:%7.1f + Max X:%7.1f, Y:%7.1f" % + (min.x,min.y,min.z,max.x,max.y,max.z,probe_area.min.x,probe_area.min.y, probe_area.max.x,probe_area.max.y))} + +##################################################################### +# Macros needed for several debug activities +##################################################################### + + diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/display_menu.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/display_menu.cfg new file mode 100644 index 000000000..292f177ef --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/display_menu.cfg @@ -0,0 +1,527 @@ +# Main +# + Power Off +# + Flexplate +# + Set Name +# + Offset 0.0 +# + Tune +# + Speed: 0% +# + Flow: 0% +# + Offset Z:0.0 +# + SD Card +# + Show loaded file +# + Load File +# + Unload File +# + Start printing +# + Pause printing +# + Resume printing +# + Cancel printing +# + Control +# + Fan +# + Cooling +# + Toggle: OFF +# + Speed: 0% +# + Chamber +# + Toggle: OFF +# + Temp: 0C +# + Filter +# + Toggle: OFF +# + Speed: 0% +# + Lights +# + Toggle: OFF +# + Dim: 0% +# + Runout +# + Runout: ON +# + Toolhead: ON +# + Home [ALL / Z / X Y] +# + Park +# + Move +# + Move Step: 0 +# + Move X: 0.0 +# + Move Y: 0.0 +# + Move Z: 0.0 +# + Move E: +0.0 +# + Steppers off +# + Temperature +# + E0: 0.0 (0.0) +# + Bed: 0.0 (0.0) +# + Filament +# + Load +# + Unload +# + Feed: 0.0 +# + Satistic +# + Time of Operation +# + Total Filament used +# + Time since Filter change +# + Time since Service +# + Reset Filter time +# + Reset Service time + +[gcode_macro _MENU_LIMITS] +variable_move: {} +gcode: + {% set list = [0.1,0.5,1,5,10,50,100] %} ; define your input list + {% set max = printer.toolhead.axis_maximum %} + {% set min = printer.toolhead.axis_minimum %} + {% set index = params.INDEX|int if params.INDEX is defined and params.INDEX|int < list|length else 0 %} + {% set move = {'index': {'i': index, 'list': list }, + 'step' : list[index], + 'max' : {'x': ((max.x - min.x) / list[index])|int, + 'y': ((max.y - min.y) / list[index])|int, + 'z': ( max.z / list[index])|int, + 'e': (printer.configfile.settings.extruder.max_extrude_only_distance / list[index])|int}} %} + SET_GCODE_VARIABLE MACRO=_MENU_LIMITS VARIABLE=move VALUE="{move}" + +[menu __voron_main] +type: list +name: Main + +[menu __voron_main __power_off] +type: command +enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused") and + 'gcode_macro PRINTER_OFF' in printer} +name: Power Off +gcode: {menu.exit()} PRINTER_OFF + +[menu __voron_main __flexplate] +type: list +name: Flexplate: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name} +enable: {'plates' in printer.save_variables.variables and + not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} + +[menu __voron_main __flexplate __set] +type: input +name: Set: {printer.save_variables.variables.plates.array[menu.input|int].name} +input: {printer.save_variables.variables.plates.index} +input_min: 0 +input_max: {printer.save_variables.variables.plates.array|length - 1} +gcode: SET_PLATE INDEX={menu.input|int} + +[menu __voron_main __flexplate __offset] +type: input +name: Offset:{'%01.3f' % menu.input} +input: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset} +input_min: -1.0 +input_max: 1.0 +input_step: 0.001 +gcode: CHANGE_PLATE_VALUE OFFSET={menu.input|float} + +[menu __voron_main __tune] +type: list +enable: {printer.print_stats.state == "printing" or printer.print_stats.state == "paused"} +name: Tune + +[menu __voron_main __tune __speed] +type: input +name: Speed: {'%3d' % (menu.input*100)}% +input: {printer.gcode_move.speed_factor} +input_min: 0.01 +input_max: 5 +input_step: 0.01 +realtime: True +gcode: M220 S{'%d' % (menu.input*100)} + +[menu __voron_main __tune __flow] +type: input +name: Flow: {'%3d' % (menu.input*100)}% +input: {printer.gcode_move.extrude_factor} +input_min: 0.01 +input_max: 2 +input_step: 0.01 +realtime: True +gcode: M221 S{'%d' % (menu.input*100)} + +[menu __voron_main __tune __offsetz] +type: input +name: Offset Z:{'%05.3f' % menu.input} +input: {printer.gcode_move.homing_origin.z} +input_min: -5 +input_max: 5 +input_step: 0.005 +realtime: True +gcode: SET_GCODE_OFFSET Z={'%.3f' % menu.input} MOVE=1 + +[menu __voron_main __sdcard] +type: list +enable: {'virtual_sdcard' in printer} +name: SD Card + +[menu __voron_main __sdcard __file] +type: command +name: File: {printer.print_stats.filename} + +[menu __voron_main __sdcard __load] +type: vsdlist +enable: {not printer.virtual_sdcard.file_path and not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +name: Load file + +[menu __voron_main __sdcard __unload] +type: command +enable: {printer.virtual_sdcard.file_path and not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +name: Unload file +gcode: + {menu.back()} SDCARD_RESET_FILE + +[menu __voron_main __sdcard __start] +type: command +enable: {printer.virtual_sdcard.file_path and not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +name: Start print +gcode: + {menu.exit()} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + M24 + +[menu __voron_main __sdcard __pause] +type: command +enable: {printer.print_stats.state == "printing"} +name: Pause print +gcode: + {menu.back()} PAUSE + +[menu __voron_main __sdcard __resume] +type: command +enable: {printer.print_stats.state == "paused"} +name: Resume print +gcode: + {menu.exit()} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + RESUME + +[menu __voron_main __sdcard __cancel] +type: command +enable: {printer.print_stats.state == "paused"} +name: Cancel print +gcode: + {menu.exit()} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + CANCEL_PRINT + +[menu __voron_main __control] +type: list +name: Control + +[menu __voron_main __control __fan] +type: list +name: Fan + +[menu __voron_main __control __fan __partcooling] +type: list +enable: {'fan' in printer} +name: Cooling {'%3d%s' % (printer.fan.speed*100,'%') if printer.fan.speed else 'OFF'} + +[menu __voron_main __control __fan __partcooling __fanonoff] +type: input +name: Toggle: {'ON' if menu.input else 'OFF'} +input: {printer.fan.speed} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: M106 S{255 if menu.input else 0} + +[menu __voron_main __control __fan __partcooling __fanspeed] +type: input +name: Speed: {'%3d%s' % (menu.input*100,'%') if menu.input else 'OFF'} +input: {printer.fan.speed} +input_min: 0 +input_max: 1 +input_step: 0.01 +gcode: M106 S{'%d' % (menu.input*255)} + +[menu __voron_main __control __fan __chamber] +type: list +enable: {'temperature_fan chamber' in printer} +name: Chamber {'%2dC' % (printer['temperature_fan chamber'].target) if printer['temperature_fan chamber'].target else 'OFF'} + +[menu __voron_main __control __fan __chamber __chamberonoff] +type: input +name: Toggle: {'ON' if menu.input else 'OFF'} +input: {printer['temperature_fan chamber'].target} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: M141 S{printer["gcode_macro _USER_VARIABLE"].vent_on if menu.input else 0} + +[menu __voron_main __control __fan __chamber __chamberfanspeed] +type: input +name: Temp: {'%2dC' % (menu.input) if menu.input else 'OFF'} +input: {printer['temperature_fan chamber'].target} +input_min: {printer.configfile.settings['temperature_fan chamber'].min_temp|int} +input_max: {printer.configfile.settings['temperature_fan chamber'].max_temp|int} +input_step: 1 +gcode: M141 S{'%d' % (menu.input)} + +[menu __voron_main __control __fan __filter] +type: list +enable: {'fan_generic filter' in printer} +name: Filter {'%3d%s' % (printer['fan_generic filter'].speed*100,'%') if printer['fan_generic filter'].speed else 'OFF'} + +[menu __voron_main __control __fan __filter __filteronoff] +type: input +name: Toggle: {'ON ' if menu.input else 'OFF'} +input: {printer['fan_generic filter'].speed} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: {% if menu.input %} _FILTER_ON {% else %} _SET_FILTER S=0.0 {% endif %} + +[menu __voron_main __control __fan __filter __filterspeed] +type: input +name: Speed: {'%3d%s' % (menu.input*100,'%') if menu.input else 'OFF'} +input: {printer['fan_generic filter'].speed} +input_min: 0 +input_max: 1 +input_step: 0.01 +gcode: _SET_FILTER S={menu.input} + +[menu __voron_main __control __lights] +type: list +enable: {'output_pin caselight' in printer} +name: Lights {'ON' if printer['output_pin caselight'].value != 0 else 'OFF'} + +[menu __voron_main __control __lights __caselightonoff] +type: input +enable: {'output_pin caselight' in printer} +name: Toggle: {'ON ' if menu.input else 'OFF'} +input: {printer['output_pin caselight'].value} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: {% if menu.input %} _CASELIGHT_ON {% else %} _CASELIGHT_OFF {% endif %} + +[menu __voron_main __control __lights __caselightpwm] +type: input +enable: {'output_pin caselight' in printer} +name: Dim: {'%3d%s' % (menu.input*100,'%') if menu.input else 'OFF'} +input: {printer['output_pin caselight'].value} +input_min: 0.0 +input_max: 1.0 +input_step: 0.01 +gcode: SET_PIN PIN=caselight VALUE={menu.input} + +[menu __voron_main __control __runout] +type: list +enable: {printer['gcode_macro _USER_VARIABLE'].hw.runout.sensor or + 'filament_switch_sensor toolhead_runout' in printer.configfile.settings} +name: Runout + +[menu __voron_main __control __runout __runoutonoff] +type: input +enable: {printer['gcode_macro _USER_VARIABLE'].hw.runout.sensor} +name: Runout: {'ON ' if menu.input else 'OFF'} +input: {printer["filament_" + printer['gcode_macro _USER_VARIABLE'].hw.runout.type + "_sensor runout"].enabled} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: SET_FILAMENT_SENSOR SENSOR=runout ENABLE={menu.input|int} + +[menu __voron_main __control __runout __toolhead_runoitonoff] +type: input +enable: {'filament_switch_sensor toolhead_runout' in printer.configfile.settings} +name: Toolhead: {'ON ' if menu.input else 'OFF'} +input: {printer['filament_switch_sensor toolhead_runout'].enabled} +input_min: 0 +input_max: 1 +input_step: 1 +gcode: SET_FILAMENT_SENSOR SENSOR=toolhead_runout ENABLE={menu.input|int} + +[menu __voron_main __control __home] +type: input +enable: {not printer.print_stats.state == "printing" } +name: Home: {['ALL','Z','X Y'][menu.input|int]} +input: 0 +input_min: 0 +input_max: 2 +gcode: {['G28','G28 Z','G28 X Y'][menu.input|int]} + +[menu __voron_main __control __park_pos] +type: input +enable: {not printer.print_stats.state == "printing" } +name: Park: {['Bed','Center','Rear','Front','FrontLow'][menu.input|int]} +input: 0 +input_min: 0 +input_max: 4 +gcode: PARK P={['BED','CENTER','REAR','FRONT', 'FRONTLOW'][menu.input|int]} + +[menu __voron_main __control __move] +type: list +enable: {not printer.print_stats.state == "printing"} +name: Move + +[menu __voron_main __control __move __move_select] +type: input +name: Move Step: {printer['gcode_macro _MENU_LIMITS'].move.index.list[menu.input|int]} +input: {printer['gcode_macro _MENU_LIMITS'].move.index.i} +input_min: 0 +input_max: {printer['gcode_macro _MENU_LIMITS'].move.index.list|length - 1} +input_step: 1 +gcode: _MENU_LIMITS INDEX={menu.input|int} + +[menu __voron_main __control __move __move_x] +type: input +name: Move X: {'%05.1f' % (printer.toolhead.axis_minimum.x + menu.input * printer['gcode_macro _MENU_LIMITS'].move.step) if 'x' in printer.toolhead.homed_axes else 'unhomed' } +input: {((printer.gcode_move.gcode_position.x - printer.toolhead.axis_minimum.x) / printer['gcode_macro _MENU_LIMITS'].move.step)|int} +input_min: 0 +input_max: {printer['gcode_macro _MENU_LIMITS'].move.max.x} +input_step: 1 +realtime: True +gcode: + SAVE_GCODE_STATE NAME=__move__axis + G90 + G1 X{printer.toolhead.axis_minimum.x + menu.input * printer['gcode_macro _MENU_LIMITS'].move.step} F6000 + RESTORE_GCODE_STATE NAME=__move__axis + +[menu __voron_main __control __move __move_y] +type: input +name: Move Y: {'%05.1f' % (printer.toolhead.axis_minimum.y + menu.input * printer['gcode_macro _MENU_LIMITS'].move.step) if 'y' in printer.toolhead.homed_axes else 'unhomed' } +input: {((printer.gcode_move.gcode_position.y - printer.toolhead.axis_minimum.y) / printer['gcode_macro _MENU_LIMITS'].move.step)|int} +input_min: 0 +input_max: {printer['gcode_macro _MENU_LIMITS'].move.max.y} +input_step: 1 +realtime: True +gcode: + SAVE_GCODE_STATE NAME=__move__axis + G90 + G1 Y{printer.toolhead.axis_minimum.y + menu.input * printer['gcode_macro _MENU_LIMITS'].move.step} F6000 + RESTORE_GCODE_STATE NAME=__move__axis + +[menu __voron_main __control __move __move_z] +type: input +name: Move Z: {'%05.1f' % (menu.input * printer['gcode_macro _MENU_LIMITS'].move.step) if 'z' in printer.toolhead.homed_axes else 'unhomed' } +input: {((printer.gcode_move.gcode_position.z - printer.toolhead.axis_minimum.z) / printer['gcode_macro _MENU_LIMITS'].move.step)|int} +input_min: 0 +input_max: {printer['gcode_macro _MENU_LIMITS'].move.max.z} +input_step: 1 +realtime: True +gcode: + SAVE_GCODE_STATE NAME=__move__axis + G90 + G1 Z{printer.toolhead.axis_minimum.z + menu.input * printer['gcode_macro _MENU_LIMITS'].move.step} F900 + RESTORE_GCODE_STATE NAME=__move__axis + +[menu __voron_main __control __move __move_e] +type: input +name: Move E: {'%+06.1f' % (menu.input * printer['gcode_macro _MENU_LIMITS'].move.step) if printer.extruder.can_extrude else 'to cold'} +input: 0 +input_min: -{printer['gcode_macro _MENU_LIMITS'].move.max.e} +input_max: {printer['gcode_macro _MENU_LIMITS'].move.max.e} +input_step: 1 +gcode: + SAVE_GCODE_STATE NAME=__move__axis + M83 + G1 E{menu.input * printer['gcode_macro _MENU_LIMITS'].move.step} F240 + RESTORE_GCODE_STATE NAME=__move__axis + +[menu __voron_main __control __disable] +type: command +name: Steppers off +enable: {not printer.print_stats.state == "printing"} +gcode: M84 + +[menu __voron_main __temp] +type: list +name: Temperature + +[menu __voron_main __temp __hotend0_target] +type: input +enable: {('extruder' in printer) and ('extruder' in printer.heaters.available_heaters)} +name: {"E0: %3.0f (%4.0f)" % (menu.input, printer.extruder.temperature)} +input: {printer.extruder.target} +input_min: 0 +input_max: {printer.configfile.config.extruder.max_temp} +input_step: 1 +gcode: M104 T0 S{'%.0f' % menu.input} + +[menu __voron_main __temp __hotbed_target] +type: input +enable: {'heater_bed' in printer} +name: {"Bed:%3.0f (%4.0f)" % (menu.input, printer.heater_bed.temperature)} +input: {printer.heater_bed.target} +input_min: 0 +input_max: {printer.configfile.config.heater_bed.max_temp} +input_step: 1 +gcode: M140 S{'%.0f' % menu.input} + +[menu __voron_main __filament] +type: list +name: Filament + +[menu __voron_main __filament __load] +type: command +name: Load +gcode: FILAMENT_LOAD + +[menu __voron_main __filament __unload] +type: command +name: Unload +gcode: FILAMENT_UNLOAD + +[menu __voron_main __filament __feed] +type: input +name: Feed: {'%.1f' % menu.input if printer.extruder.can_extrude else 'to cold'} +input: 5 +input_min: -{printer.configfile.settings.extruder.max_extrude_only_distance} +input_max: {printer.configfile.settings.extruder.max_extrude_only_distance} +input_step: 0.1 +gcode: + SAVE_GCODE_STATE NAME=__filament__load + M83 + G1 E{'%.1f' % menu.input} F60 + RESTORE_GCODE_STATE NAME=__filament__load + +[menu __voron_main __statistic] +type: list +enable: {'print_stats' in printer.save_variables.variables} +name: Satistic + +[menu __voron_main __statistic __totaltime] +type: command +name: Time of Operation +gcode: + {menu.exit()} + _DISPLAY_PRINT_TIME PREFIX=Total SECONDS={printer.save_variables.variables.print_stats.time.total} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +[menu __voron_main __statistic __filament] +type: command +name: Total Filament used +gcode: + {menu.exit()} + M117 Filerment {'%.4f' % (printer.save_variables.variables.print_stats.filament|float / 1000.0)}m + {action_respond_info("Total Filament printed: %.4fm" % (printer.save_variables.variables.print_stats.filament|float / 1000.0))} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +[menu __voron_main __statistic __filtertime] +type: command +name: Time since Filter change +gcode: + {menu.exit()} + _DISPLAY_PRINT_TIME PREFIX=Filter SECONDS={printer.save_variables.variables.print_stats.time.filter} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +[menu __voron_main __statistic __servicetime] +type: command +name: Time since Service +gcode: + {menu.exit()} + _DISPLAY_PRINT_TIME PREFIX=Service SECONDS={printer.save_variables.variables.print_stats.time.service} + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + + +[menu __voron_main __statistic __rst_filter] +type: command +enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +name: Reset Filter time +gcode: + {menu.exit()} + RST_FILTER + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + + +[menu __voron_main __statistic __rst_service] +type: command +enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +name: Reset Service time +gcode: + {menu.exit()} + RST_SERVICE + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/fan.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/fan.cfg new file mode 100644 index 000000000..80c837a9a --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/fan.cfg @@ -0,0 +1,167 @@ +##################################################################### +# Fan Control +##################################################################### +## Hotend Fan - XYE board, E1 Connector +[heater_fan hotend_fan] +pin: P2.4 +max_power: 1.0 +fan_speed: 1 +kick_start_time: 0 +heater: extruder +heater_temp: 50.0 + +## Print Cooling Fan (24V Fan 4 wire) +## Z board, X Endstop (PWM) +## Z board, E1det (Tacho) +[fan] +pin: z:P1.29 +cycle_time: 0.0001 #10 kHz PWM signal +hardware_pwm: False +kick_start_time: 0 +off_below: 0.05 +tachometer_pin: z:P1.25 +tachometer_ppr: 2 + +## Controller fan (5V Fan 4 wire) +## Z board, NeoPixel Connector (PWM) +## Z board, Y Endstop (Tacho) +[heater_fan controller_fan] +pin: z:P1.24 +max_power: 1.0 +shutdown_speed: 1.0 +cycle_time: 0.0001 #10 kHz PWM signal +hardware_pwm: False +kick_start_time: 0 +fan_speed: 0.9 +heater: heater_bed +heater_temp: 45.0 +tachometer_pin: z:P1.28 +tachometer_ppr: 2 + +## Chamber temp / Exhaust fan (24V Fan 4 wire) +## XYE board, NeoPixel Connector (PWM) +## XYE board, TH1 Connector +## XYE board, Z Endstop (Tacho) +[temperature_fan chamber] +pin: P1.24 +max_power: 1.0 +shutdown_speed: 0.0 +cycle_time: 0.0005 #2 kHz PWM signal +hardware_pwm: False +kick_start_time: 0 +sensor_type: ATC Semitec 104GT-2 +sensor_pin: P0.23 +min_temp: 0 +max_temp: 70 +target_temp: 0 +max_speed: 0.7 +min_speed: 0.1 +control: pid +pid_Kp: 2.0 ;40 +pid_Ki: 5.0 ;0.2 +pid_Kd: 0.5 ;0.1 +pid_deriv_time: 2.0 +gcode_id: C +tachometer_pin: P1.27 +tachometer_ppr: 2 + +## Nevermore Micro filter +## - Z board, E1 Connector +[fan_generic filter] +pin: z:P2.4 +max_power: 1.0 +kick_start_time: 0.5 +off_below: 0.10 + +[temperature_sensor RPi] +sensor_type: temperature_host +min_temp: 10 +max_temp: 100 +gcode_id: PI + +## Z board, TH1 Connector +[temperature_sensor endstop] +sensor_type: Generic 3950 +sensor_pin: z:P0.23 +min_temp: 10 +max_temp: 100 +gcode_id: E + +## dummy output to get an switch in Mainsail +## any unused mcu pin can be defined you will not connect anything +## as I use the rPi as mcu I will use a pin from it +## Off -> M106 will update fan +## On -> M106 can not uodate fan +[output_pin lock_M106] +pin: rpi: gpio16 +value:0 + +##################################################################### +# Macros +##################################################################### +# M106 with lock and manual set feature +# M106 S128 M1 will update the fan in any case +[gcode_macro M106] +description: set fan with manual override and lock option +rename_existing: M106.1 +gcode: + {% if printer['output_pin lock_M106'].value|int == 0 or params.M|default(0) == '1' %} + M106.1 {rawparams} + {% else %} + {action_respond_info("M106 update is locked")} + {% endif %} + +[gcode_macro M141] +description: Set temperature of chamber fan +gcode: SET_TEMPERATURE_FAN_TARGET temperature_fan=chamber target={params.S|default(0)} + +[gcode_macro _SET_FILTER] +description: Helper: Set Nevermore filter speed +gcode: SET_FAN_SPEED FAN=filter SPEED={params.S|default(0)} + +[gcode_macro _FILTER_ON] +description: Helper: Nevermore on +gcode: _SET_FILTER S={printer['gcode_macro _USER_VARIABLE'].peripheral.filter.on_val} + +[gcode_macro FILTER] +description: Toggle Nevermore fan +gcode: + {% if printer['fan_generic filter'].speed|float > 0.0 %} _SET_FILTER {% else %} _FILTER_ON {% endif %} + _FILTER_INFO + +[delayed_gcode _DELAY_FILTER_OFF] +gcode: + {% if printer.print_stats.state|lower != "paused" and printer.print_stats.state|lower != "printing" %} + _SET_FILTER + _FILTER_INFO + {% endif %} + +## Chamber Ventilation Control in Mainsail +[gcode_macro VENT] +description: Toggle Chamber fan +gcode: + {% if printer['temperature_fan chamber'].target|float > 0 and + printer['temperature_fan chamber'].target|float <= printer['gcode_macro _USER_VARIABLE'].peripheral.vent.on_val|float %} + M141 + {% else %} + M141 S{printer['gcode_macro _USER_VARIABLE'].peripheral.vent.on_val} + {% endif %} + _VENT_INFO + +[delayed_gcode _DELAY_VENT_OFF] +gcode: + {% if printer.print_stats.state|lower != "paused" and printer.print_stats.state|lower != "printing" %} + M141 + _VENT_INFO + {% endif %} + +[gcode_macro _VENT_INFO] +description: Helper: Print chamber fan temperature +gcode: + {% set txt = "off" if printer['temperature_fan chamber'].target == 0 + else "target temp: %2dC" % printer['temperature_fan chamber'].target %} + {action_respond_info("Chamber fan %s" % txt)} + +[gcode_macro _FILTER_INFO] +description: Helper: Print Nevermore speed +gcode: {action_respond_info("Filter fan %s" % 'on' if printer['fan_generic filter'].speed|float > 0.0 else 'off')} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/filament.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/filament.cfg new file mode 100644 index 000000000..2c2dd27f3 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/filament.cfg @@ -0,0 +1,176 @@ +[firmware_retraction] +retract_length: 0.75 ; length of filament (in mm) at G10/G11 +unretract_extra_length: 0 ; length of additional filament (in mm) at G11 +retract_speed: 50 +unretract_speed: 30 + +##################################################################### +# Macro +##################################################################### +[gcode_macro _FILAMENT_BALL] +description: Helper: Round the filament tip +gcode: + G92 E0 ; zero the extruder + M83 ; relative extrusion + G1 E2 F{printer['gcode_macro _USER_VARIABLE'].speed.retract * 2} + G1 E-2 + G1 E4 + G1 E-4 + G1 E8 + G1 E-8 + G1 E-25 + G4 P{params.WAIT|default(0)|int * 1000} + +[gcode_macro FILAMENT_LOAD] +description: Load filament and disable rounout while running +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set pos = printer['gcode_macro _USER_VARIABLE'].purge.purge %} + {% set move_z = [user.z_hop,printer.toolhead.position.z]|max %} ; calc movement high + {% if printer.idle_timeout.state != "Printing" or printer.pause_resume.is_paused|lower == "true" %} + {% if user.hw.runout.type == 'motion' %} SET_FILAMENT_SENSOR SENSOR=runout ENABLE=0 {% endif %} + _CG28 ; home if not already homed + G90 ; absolute positioning + G1 Z{move_z} F{user.speed.z_hop} ; move head to minimum + G1 X{pos.x} Y{pos.y} F{user.speed.travel} ; move to purge bucket location + {% if user.hw.display.ena %} _LCD_KNOB COLOR=BLUE {% endif %} + {% if not printer.extruder.can_extrude %} + {action_respond_info("Extruder Temp to low heat to %3.1f°C" % printer.configfile.settings.extruder.min_extrude_temp)} + M109 S{printer.configfile.settings.extruder.min_extrude_temp} + {% endif %} + {% if user.hw.display.ena %} _LCD_KNOB {% endif %} + G1 Z{pos.z} F{user.speed.z_hop} + M83 ; set extruder to relative + G1 E{user.filament.load_distance} F{user.speed.load} ; quickly load filament + {% if user.hw.runout.type == 'motion' %} + _PRINT_AR T="RUNOUT Motion Sensor Enable: true" + SET_FILAMENT_SENSOR SENSOR=runout ENABLE=1 + {% endif %} + G1 E{user.filament.load_extrude} F{user.speed.retract} ; slower load filament + G1 E-{user.filament.retract.pause} + _WIPE ; clean nozzle + G1 Z{move_z} F{user.speed.z_hop} + G1 X{pos.x} Y{pos.y} F{user.speed.travel} ; move to purge bucket location + M109 S{printer.extruder.target} ; restore old extruder temperature + _PRINT_AR T="Filament loaded" + SAVE_VARIABLE VARIABLE=filament_loaded VALUE=True + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set it back to relativ + {% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; set it back to absolute + {% else %} + _PRINT_AR T="Filament loading disabled while printing!" + {% endif %} + +[gcode_macro FILAMENT_UNLOAD] +description: Unload filament and disable rounout while running +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% if printer.idle_timeout.state != "Printing" or printer.pause_resume.is_paused|lower == "true" %} + {% if user.hw.runout.type == 'motion' %} + _PRINT_AR T="RUNOUT Motion Sensor Enable: false" + SET_FILAMENT_SENSOR SENSOR=runout ENABLE=0 + {% endif %} + {% if user.hw.display.ena %} _LCD_KNOB COLOR=BLUE {% endif %} + {% if not printer.extruder.can_extrude %} + {action_respond_info("Extruder Temp to low heat to %3.1f°C" % printer.configfile.settings.extruder.min_extrude_temp)} + M109 S{printer.configfile.settings.extruder.min_extrude_temp} + {% endif %} + {% if user.hw.display.ena %} _LCD_KNOB {% endif %} + _FILAMENT_BALL WAIT=3 ; ball up the filament tip and retract out past the extruder gears + G1 E-{user.filament.unload_distance} F{user.speed.load} + M109 S{printer.extruder.target} ; restore old extruder temperature + _PRINT_AR T="Filament unloaded" + SAVE_VARIABLE VARIABLE=filament_loaded VALUE=False + {% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; set it back to absolute + {% else %} + _PRINT_AR T="Filament unloading disabled while printing!" + {% endif %} + +[gcode_macro NOZZLECLEAN] +description: Move to bucket and purge and scrub nozzle +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set pos = user.purge.purge %} + {% set move_z = [user.z_hop,printer.toolhead.position.z]|max %} ; calc movement high + SET_GCODE_OFFSET Z=0.0 + _PRINT_AR T="Clean Nozzle" SHOW_LCD=true + _CG28 ; home if not already homed + G90 ; absolute positioning + G1 Z{move_z} F{user.speed.z_hop} ; move head up + G1 X{pos.x} Y{pos.y} F{user.speed.travel} ; move to purge bucket location + G1 Z{pos.z} F{user.speed.z_hop} ; lower Z + {% if not printer.extruder.can_extrude %} + {action_respond_info("Extruder Temp to low heat to %3.1f°C" % printer.configfile.settings.extruder.min_extrude_temp)} + M109 S{printer.configfile.settings.extruder.min_extrude_temp} + {% endif %} + G92 E0 ; reset Extruder + M83 ; relative extrusion + G1 E2 F500 ; purge filament + G1 E2 F800 ; purge filament + G1 E-1 F800 ; retract filament + G4 P500 + _WIPE + M109 S{printer.extruder.target} ; restore old extruder temperature + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set it back to relative + {% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; set it back to absolute + SET_GCODE_OFFSET Z={printer.gcode_move.homing_origin.z} MOVE=1 + +[gcode_macro _WIPE] +description: Helper: Wipe nozzle at bucket +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set wipe = user.purge.wipe %} + G90 ; absolute positioning + G0 X{wipe.start.x} Y{wipe.start.y} Z{wipe.start.z} F{user.speed.wipe} + {% for moves in range(0, wipe.cnt) %} ; move head diagonal to brush + {% for coordinate in [wipe.start.x, wipe.end.x] %} + G0 X{coordinate} Y{wipe.start.y + wipe.offset * moves} + {% endfor %} + {% endfor %} + G0 X{wipe.end.x} Y{wipe.end.y} Z{wipe.end.z} + +[gcode_macro PRIME_LINE] +description: Purge nozzle at defined position +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set prime = user.prime %} + {% set prime_height = params.PRIME_HEIGHT|default(prime.pos.z) %} ; get parameter or set default + {% set move_z = [user.z_hop,printer.toolhead.position.z]|max %} ; calc movement high + {% if prime.dir|string == 'X+' %} + {% set first_line = 'X%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set second_line = 'X-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set move_to_side = 'Y%s' % prime.spacing %} + {% elif prime.dir|string == 'X-' %} + {% set first_line = 'X-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set second_line = 'X%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set move_to_side = 'Y%s' % prime.spacing %} + {% elif prime.dir|string == 'Y+' %} + {% set first_line = 'Y%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set second_line = 'Y-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set move_to_side = 'X%s' % prime.spacing %} + {% elif prime.dir|string == 'Y-' %} + {% set first_line = 'Y-%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set second_line = 'Y%s E%s F%s' % (prime.length_per_seg, prime.extrude_per_seg, user.speed.prime) %} + {% set move_to_side = 'X%s' % prime.spacing %} + {% else %} + {action_raise_error("_USER_VARIABLE.prime.dir is not spezified as X+, X-, Y+ or Y-")} + {% endif %} + _PRINT_AR T="Prime Line" SHOW_LCD=true + _CG28 ; home if not already homed + G92 E0 ; reset Extruder + G90 ; absolute positioning + G1 Z{move_z} F{user.speed.z_hop} ; move head up + G1 X{prime.pos.x} Y{prime.pos.y} F{user.speed.travel} ; move to start position + G1 Z{prime_height} F{user.speed.z_hop} ; move Z Axis down + G91 ; relative positioning + {% for segment in range(prime.seg|int) %} ; draw the first line + G1 {first_line} + {% endfor %} + G1 {move_to_side} ; move to side + {% for segment in range(prime.seg|int) %} ; draw the second line + G1 {second_line} + {% endfor %} + G92 E0 ; reset Extruder + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set it back to relative + {% if printer.gcode_move.absolute_extrude %} M82 {% endif %} ; set it back to absolute + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/flexplate.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/flexplate.cfg new file mode 100644 index 000000000..ce0b32b9c --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/flexplate.cfg @@ -0,0 +1,212 @@ +##################################################################### +# Preperation +##################################################################### +# copy this file in the same directory as your printer.cfg +# add +# [include flexplate.cfg] +# to your printer.cfg +# +# add +# _SET_PLATE_OFFSET +# to your print start gcode to apply the offset before you print the first line of filament +# +# A [save_variables] block is needed since a printer save variable needs to be used to have it available after power up. +# You can skip this if you already have an [save_variables] config block +# e.g: +# [save_variables] +# filename: /home/pi/klipper_config/.variables.stb +# I like to hide that file as there is nothing in that should be modified by the user. +# Do a klipper restart after adding the stuff above +# +# After klipper is back you need define your first plate e.g. +# ADD_NEW_PLATE NAME=Texture OFFSET=-0.010 +# +##################################################################### +# Macro for the print_start gcode section of your slicer +# or your print start macro +##################################################################### +# _SET_PLATE_OFFSET [MOVE=0|1] : Set the z offset +# Set the offset of the active flexplate as an Z_ADJUST offset. MOVE=0 (default) +# will add the offset with the next z move, MOVE=1 imitate change the z offset. +# +# !!! Caution: Insure that SET_GCODE_OFFSET Z=0 is set once at every +# print start. Please read also the desribtion of the gcode SET_GCODE_OFFSET +# at https://www.klipper3d.org/G-Codes.html#extended-g-code-commands !!! +# +##################################################################### +# Console ussage +##################################################################### +# LIST_PLATES: List all plates +# Use the index shown there for all other macros +# +# SET_PLATE INDEX=: Set the active flexplate +# The flexplate stored at index will be activated. +# +# ADD_PLATE [NAME=] [OFFSET=]: Add a new flexplate to the list +# If NAME or OFFSET is not defined than the defaults 'New' and 0.000 will be used. +# !!! Caution do not use special characters like äüö or anything else in the name !!! +# +# REMOVE_PLATE INDEX=: Remove a flexplate of the list +# Remove plate with INDEX from the list. Note the last or active plate can not be removed. +# +# CHANGE_PLATE_VALUE [INDEX=] [NAME=] [OFFSET=]: Change name or/and offset of an flexplate +# If INDEX is not defined the name and/or offset value of the active plate will be changed. +# !!! Caution do not use special characters like äüö or anything else in the name !!! +# +##################################################################### +# LCD menu usage +##################################################################### +# Change the active flexplate and the offset of that flexplate. +# +##################################################################### +# Get offset_z and name for own usage +##################################################################### +# {% set offset = printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset %} +# {% set name = printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name %} +# +##################################################################### +[gcode_macro _SET_PLATE_OFFSET] +description: Helper: Apply the z-offset of the active flexplate +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + SET_GCODE_OFFSET Z_ADJUST={plates.array[plates.index].offset} MOVE={params.MOVE|default(0)} + {% endif %} + +[gcode_macro LIST_PLATES] +description: List all flexplates +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% set out = ["FLEXPLATE: Defined Plates"] %} + {% for elem in range(plates.array|length) %} + {% set _dummy = out.append("INDEX: %d -> %s -> offset: %.3fmm" % + (elem, plates.array[elem].name, plates.array[elem].offset)) %} + {% endfor %} + {% set _dummy = out.append("\n Active Plate: %s" % plates.array[plates.index].name) %} + {action_respond_info(out|join("\n"))} + {% endif %} + +[gcode_macro SET_PLATE] +description: Set an flexplate +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% if 'INDEX' not in params|upper %} + {action_respond_info("FLEXPLATE: No INDEX defined, use SET_PLATE INDEX=index. ABORDED")} + {% elif params.INDEX|int < 0 or params.INDEX|int >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {% set _dummy = plates.update({'index' : params.INDEX|int}) %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + M117 Plate: {plates.array[plates.index].name} + {action_respond_info("FLEXPLATE: Set plate: %s with offset: %.3fmm" % ( + plates.array[plates.index].name,plates.array[plates.index].offset))} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + {% endif %} + {% endif %} + +[gcode_macro ADD_PLATE] +description: Add a flexplate to the list +gcode: + {% set name = params.NAME|default('New')|string %} + {% set offset = params.OFFSET|default(0.0)|float|round(3) %} + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: Initialize Plate Array + Add plate: %s with offset: %.3fmm at INDEX: 0" % (name,offset))} + {% set plates = {'array': [{'name': name, 'offset': offset}], 'index' : 0} %} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: Add plate: %s with offset: %.3fmm at INDEX: %d" % (name,offset,plates.array|length))} + {% set _dummy = plates.array.append({'name': name, 'offset': offset}) %} + {% endif %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + +[gcode_macro REMOVE_PLATE] +description: Remove a flexplate from the list +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% if 'INDEX' not in params|upper %} + {action_respond_info("FLEXPLATE: No INDEX defined, use REMOVE_PLATE INDEX=index. ABORDED")} + {% elif plates.array|length == 1 or params.INDEX|int == plates.index %} + {action_respond_info("FLEXPLATE: Last or active plate can not be removed. ABORDED")} + {% elif params.INDEX|int < 0 or params.INDEX|int >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {action_respond_info("FLEXPLATE: Remove plate with INDEX %d from list " % params.INDEX|int)} + {% set _dummy = plates.array.pop(params.INDEX|int) %} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + {% endif %} + {% endif %} + +[gcode_macro CHANGE_PLATE_VALUE] +description: Change name or offset of an flexplate in the list +gcode: + {% if not printer.save_variables.variables.plates %} + {action_respond_info("FLEXPLATE: No Plate Array defined. ABORDED")} + {% else %} + {% set plates = printer.save_variables.variables.plates %} + {% set index = params.INDEX|default(plates.index)|int %} + {% if index < 0 or index >= plates.array|length %} + {action_respond_info("FLEXPLATE: Index out of range [0..%d]. ABORDED" % (plates.array|length-1))} + {% else %} + {% set change_txt = [] %} + {% if 'NAME' in params|upper %} + {% set _dummy = change_txt.append("name to %s" % params.NAME|string) %} + {% set _dummy = plates.array[index].update({'name': params.NAME|string}) %} + {% endif %} + {% if 'OFFSET' in params|upper %} + {% set _dummy = change_txt.append("offset to %.3fmm" % params.OFFSET|float|round(3)) %} + {% set _dummy = plates.array[index].update({'offset': params.OFFSET|float|round(3)}) %} + {% endif %} + {% if change_txt|length > 0 %} + {action_respond_info("FLEXPLATE: Changed %s at plate with INDEX %d" % (change_txt|join(" and "),index))} + SAVE_VARIABLE VARIABLE=plates VALUE="{plates}" + {% else %} + {action_respond_info("FLEXPLATE: Nothing changed at plate with INDEX %d" % index)} + {% endif %} + {% endif %} + {% endif %} + +# Display Menu +# !!! Caution: I use my own menu root __voron_main !!! +# If you use a stock menu un comment this here +#[menu __main __flexplate] +#type: list +#name: Flexplate: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name} +#enable: {'plates' in printer.save_variables.variables} +#index: 1 + +#[menu __main __flexplate __set] +#type: input +#name: Set: {printer.save_variables.variables.plates.array[menu.input|int].name} +#enable: {printer.print_stats.state != "printing" and printer.print_stats.state != "paused"} +#input: {printer.save_variables.variables.plates.index} +#input_min: 0 +#input_max: {printer.save_variables.variables.plates.array|length - 1} +#gcode: +# {%- if menu.event == 'long_click' -%} +# SET_PLATE INDEX={menu.input|int} +# {%- endif -%} + +#[menu __main __flexplate __offset] +#type: input +#name: Offset:{'%01.3f' % menu.input} +#enable: {printer.print_stats.state != "printing" and printer.print_stats.state != "paused"} +#input: {printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset} +#input_min: -1.0 +#input_max: 1.0 +#input_step: 0.001 +#gcode: +# {%- if menu.event == 'long_click' -%} +# CHANGE_PLATE_VALUE OFFSET={menu.input|float} +# {%- endif -%} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/force_move.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/force_move.cfg new file mode 100644 index 000000000..8fded41d1 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/force_move.cfg @@ -0,0 +1,32 @@ +## This is an emergency fix if the gantry is at the max Z position what makes homing imposible +## 1) set enable_force_move: True +## 2) do an klipper restart +## 3) use a SET_KINEMATIC_POSITION e.g SET_KINEMATIC_POSITION X=50 Y=50 Z=100 +## that position does not need to be accurate as we only use it to get the head down +## 4) get the head down by at least the amount you have specified as z lift for homing e.g. 25 mm +## 5) set enable_force_move: False +## 6) do an klipper restart +## 7) now you can home normal again + +## Reference: +## Force move enabled will allow the following 2 debug commands. !!! Use them carefully !!! +## +## SET_KINEMATIC_POSITION [X=] [Y=] [Z=]: Force the low-level kinematic code to believe +## the toolhead is at the given cartesian position. This is a diagnostic and debugging command; use +## SET_GCODE_OFFSET and/or G92 for regular axis transformations. If an axis is not specified then it will +## default to the position that the head was last commanded to. Setting an incorrect or invalid position +## may lead to internal software errors. This command may invalidate future boundary checks; issue a G28 +## afterwards to reset the kinematics. +## +## FORCE_MOVE STEPPER= DISTANCE= VELOCITY= [ACCEL=]: This command will +## forcibly move the given stepper the given distance (in mm) at the given constant velocity (in mm/s). +## If ACCEL is specified and is greater than zero, then the given acceleration (in mm/s^2) will be used; +## otherwise no acceleration is performed. If acceleration is not performed then it can lead to the +## micro-controller reporting “No next step” errors (avoid these errors by specifying an ACCEL value or +## use a very low VELOCITY). No boundary checks are performed; no kinematic updates are made; other +## parallel steppers on an axis will not be moved. Use caution as an incorrect command could cause +## damage! Using this command will almost certainly place the low-level kinematics in an incorrect state; +## issue a G28 afterwards to reset the kinematics. This command is intended for low-level diagnostics and debugging. + +[force_move] +enable_force_move: False diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater.cfg new file mode 100644 index 000000000..4b02cd60f --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater.cfg @@ -0,0 +1,90 @@ +##################################################################### +# Extruder +##################################################################### +## XYE board, E0 Connector +## XYE board, TH0 Connector +[extruder] +##################### Standard Values ##################### +## BMG spec of extruder pully +## rotation_distence: 22.68 BMG 5mm axis +## rotation_distence: 33.00 BMG 8 mm axis +## gear ratios of different Extruders +## gear_ratio: 50:10 Voron V0.1 DD +## gear_ratio: 50:17 Voron Afterburner Clockworks +## gear_ratio: 80:20 Voron M4 +## gear_ratio: 7.5:1 Voron Afterburner Galileo +############### Different Clockworks Setups ############### +## Afterburner: Stepper Motor 0.9 step distance 0.00120 calibrated 0.001196 +## dir_pin: P0.11 +## full_steps_per_rotation: 400 +## microsteps: 16 +## rotation_distance: 7.6544 +############################################################ +## Galileo: Stepper Motor 1.8 step distance 0.00138 calibrated 0,001375 +## dir_pin: !P0.11 +## full_steps_per_rotation: 200 +## microsteps: 16 +## rotation_distance: 4.401 +############### Different Clockworks Setups ############### +## Update value below when you perform extruder calibration +## Higher value means less filament extruded +## If you ask for 100mm of filament, but in reality it is 98mm: +## step_distance = 98 / 100 * step_distance_old +############################################################ +step_pin: P2.13 +dir_pin: !P0.11 +enable_pin: !P2.12 +full_steps_per_rotation: 200 +microsteps: 16 +rotation_distance: 4.401 +nozzle_diameter: 0.4 +filament_diameter: 1.75 +heater_pin: P2.7 +sensor_type: SliceEngineering 450 +sensor_pin: P0.24 +min_temp: 10 +max_temp: 300 +max_power: 1.0 +# The minimum temperature (in Celsius) at which extruder move +# commands may be issued. The default is 170 Celsius. +min_extrude_temp: 210 +## Maximum length (in mm of raw filament) that a retraction or +## extrude-only move may have. If a retraction or extrude-only move +## requests a distance greater than this value it will cause an error +## to be returned. The default is 50mm. +max_extrude_only_distance: 100.0 +#control = pid +#pid_kp = 26.213 +#pid_ki = 1.304 +#pid_kd = 131.721 +## Try to keep pressure_advance below 1.0 +pressure_advance: 0.05 +## Default is 0.040, leave stock +pressure_advance_smooth_time: 0.040 + +##################################################################### +# Bed Heater +##################################################################### +## SSR - Z board, Fan0 Connector +## Z board, TB Connector +[heater_bed] +heater_pin: z:P2.3 +sensor_type: Generic 3950 +sensor_pin: z:P0.25 +max_power: 0.65 +min_temp: 10 +max_temp: 130 +#control: pid +#pid_kp: 58.437 +#pid_ki: 2.347 +#pid_kd: 363.769 + +## Sensor srewed in the bed +## Z board, TH0 Thermistor +## This only works as safety guard +[temperature_sensor bed] +sensor_type: Generic 3950 +sensor_pin: z:P0.24 +min_temp: 10 +max_temp: 120 +gcode_id: B1 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater_verify.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater_verify.cfg new file mode 100644 index 000000000..bffa83de4 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/heater_verify.cfg @@ -0,0 +1,14 @@ +##################################################################### +# Heater Verification +##################################################################### +[verify_heater heater_bed] +max_error: 120 +check_gain_time: 60 +hysteresis: 5 +heating_gain: 2 + +[verify_heater extruder] +max_error: 120 +check_gain_time: 20 +hysteresis: 5 +heating_gain: 2 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/homing.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/homing.cfg new file mode 100644 index 000000000..27922be3b --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/homing.cfg @@ -0,0 +1,107 @@ +##################################################################### +# Homing definition +##################################################################### +[homing_override] +axes: z +set_position_z: 0 +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set home_x, home_y, home_z = False, False, False %} ; define what axes need to be homed + {% if params.X is not defined and params.Y is not defined and params.Z is not defined %} ; G28 + {% set home_x, home_y, home_z = True, True, True %} + {% else %} + {% if params.X is defined %}{% set home_x = True %}{% endif %} + {% if params.Y is defined %}{% set home_y = True %}{% endif %} + {% if params.Z is defined %} + {% if 'x' not in printer.toolhead.homed_axes %}{% set home_x = True %}{% endif %} ; check if homed + {% if 'y' not in printer.toolhead.homed_axes %}{% set home_y = True %}{% endif %} ; check if homed + {% set home_z = True %} + {% endif %} + {% endif %} + {% if user.hw.mag_probe.ena %} _MAG_PROBE ACTION=GET_STATUS RESPOND=0 {% endif %} ; generate probe state + _SET_ACC VAL=HOME ; reduce accel and accel_to_decel + G0 Z{user.homing.z_endstop.hop} F{user.speed.z_hop} ; lift nozzle + {% if home_x %} G28 X {% endif %} ; home X + {% if home_y %} G28 Y {% endif %} ; home Y + {% if home_z %} _HOME_Z {% endif %} ; home Z + _SET_ACC ; set accel and accel_to_decel back to cfg value + +[gcode_macro _HOME_Z] +description: Helper: z homing +variable_calibrate_z_next: False +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + ; use -10 as default to insure it error out in case the variable is not existing + {% set z_endstop = user.homing.z_endstop|default({'x':-10,'y':-10,'z':0, 'hop':0}) %} + {% if user.hw.mag_probe.ena %} + {% set probe = printer['gcode_macro _MAG_PROBE'].state|default('unknown')|lower %} ; get probe state + {% set error = "run \"_MAG_PROBE ACTION=GET_STATUS\"" if probe == 'unknown' + else "last dock or undock failed" if probe == 'error' + else "not valid" if probe is not in ['docked','attached'] + else "" %} + {% if error|length > 0 %} + {action_raise_error("Home&Probe: MagProbe state %s %s" % (error,probe|upper))} + {% endif %} + {% endif %} + {% if user.hw.mag_probe.ena and probe == 'attached' %} + {action_respond_info("Home&Probe: Probe docked, remove probe first")} + DETACH_PROBE ; detach probe + {% endif %} + _SET_Z_CURRENT VAL=HOME ; reduce Z current + G90 ; absolute position + G0 X{z_endstop.x} Y{z_endstop.y} F{user.speed.travel} ; move to endstop position + G28 Z ; home Z + G0 Z{z_endstop.z} F{user.speed.z_hop/3} ; lift toolhead to stop pressing on the pin + {% if calibrate_z_next %} + SET_GCODE_VARIABLE MACRO=_HOME_Z VARIABLE=calibrate_z_next VALUE=False + {% else %} + _SET_Z_CURRENT ; set Z current back to cfg value + G0 Z{user.z_hop} F{user.speed.z_hop} ; lift toolhead + {% endif %} + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set it back to relative + +##################################################################### +# Macros +##################################################################### +## conditional home +[gcode_macro _CG28] +description: Helper: Conditional homing +gcode: + {% if "xyz" not in printer.toolhead.homed_axes %} G28 {% endif %} + +[gcode_macro _SET_Z_CURRENT] +description: Helper: Set Z-drive motor current +variable_last_val: 'CONFIG' +gcode: + {% set val = params.VAL|default('CONFIG') %} + {% set z_run = printer['gcode_macro _USER_VARIABLE'].homing.z_current if val == 'HOME' + else printer.configfile.settings['tmc2209 stepper_z'].run_current if 'tmc2209 stepper_z' in printer.configfile.settings + else printer.configfile.settings['tmc5160 stepper_z'].run_current if 'tmc5160 stepper_z' in printer.configfile.settings %} + {% if val != last_val %} + SET_GCODE_VARIABLE MACRO=_SET_Z_CURRENT VARIABLE=last_val VALUE='"{val}"' + {% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.z_current)|int == 1 %} + {action_respond_info("Home&Probe: RunCur %.2fA rms" % z_run|float)} + {% endif %} + SET_TMC_CURRENT STEPPER=stepper_z CURRENT={z_run} + SET_TMC_CURRENT STEPPER=stepper_z1 CURRENT={z_run} + SET_TMC_CURRENT STEPPER=stepper_z2 CURRENT={z_run} + SET_TMC_CURRENT STEPPER=stepper_z3 CURRENT={z_run} + M400 + {% endif %} + +[gcode_macro _SET_ACC] +description: Helper: Set accel and accel_to_decel value +variable_last_val: 'CONFIG' +gcode: + {% set val = params.VAL|default('CONFIG') %} + {% set accel = printer['gcode_macro _USER_VARIABLE'].homing.accel if val == 'HOME' + else printer.configfile.settings.printer.max_accel %} + {% set accel_to_decel = printer['gcode_macro _USER_VARIABLE'].homing.accel|int / 2 if val == 'HOME' + else printer.configfile.settings.printer.max_accel_to_decel %} + {% if val != last_val %} + SET_GCODE_VARIABLE MACRO=_SET_ACC VARIABLE=last_val VALUE='"{val}"' + {% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.acc)|int == 1 %} + {action_respond_info("Home&Probe: ACCEL: %d ACCEL_TO_DECEL: %d" % (accel|int, accel_to_decel|int))} + {% endif %} + SET_VELOCITY_LIMIT ACCEL={accel} ACCEL_TO_DECEL={accel_to_decel} + {% endif %} diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/input_shaper.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/input_shaper.cfg new file mode 100644 index 000000000..a7d1cd15e --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/input_shaper.cfg @@ -0,0 +1,151 @@ +##################################################################### +# G Sensor definition +##################################################################### +[adxl345] +cs_pin: rpi:None +## The SPI speed (in hz) to use when communicating with the chip. +## The default is 5000000. +#spi_speed: 5000000 +## Output data rate for ADXL345. ADXL345 supports the following data +## rates: 3200, 1600, 800, 400, 200, 100, 50, and 25. Note that it is +## not recommended to change this rate from the default 3200, and +## rates below 800 will considerably affect the quality of resonance +## measurements. +#rate: 3200 +## The accelerometer axis for each of the printer's x, y, and z axes. +## This may be useful if the accelerometer is mounted in an +## orientation that does not match the printer orientation. For +## example, one could set this to "y,x,z" to swap the x and y axes. +## It is also possible to negate an axis if the accelerometer +## direction is reversed (eg, "x,z,-y"). The default is "x,y,z". +## receck +axes_map: x,y,z + +##################################################################### +# resonance tester definition +##################################################################### +[resonance_tester] +accel_chip: adxl345 +## A list of X,Y,Z coordinates of points (one point per line) to test +## resonances at. At least one point is required. Make sure that all +## points with some safety margin in XY plane (~a few centimeters) +## are reachable by the toolhead. +probe_points: + 175,175,20 +# 175,175,160 +# 175,175,300 +## Maximum input shaper smoothing to allow for each axis during shaper +## auto-calibration (with 'SHAPER_CALIBRATE' command). By default no +## maximum smoothing is specified. Refer to Measuring_Resonances guide +## for more details on using this feature. +#max_smoothing: +## Minimum/Maximum frequency to test for resonances. +min_freq: 5 +max_freq: 133 +## This parameter is used to determine which acceleration to use to +## test a specific frequency: accel = accel_per_hz * freq. Higher the +## value, the higher is the energy of the oscillations. Can be set to +## a lower than the default value if the resonances get too strong on +## the printer. However, lower values make measurements of +## high-frequency resonances less precise. The default value is 75 +## (mm/sec). +accel_per_hz: 75 +## Determines the speed of the test. When testing all frequencies in +## range [min_freq, max_freq], each second the frequency increases by +## hz_per_sec. Small values make the test slow, and the large values +## will decrease the precision of the test. The default value is 1.0 +## (Hz/sec == sec^-2). +hz_per_sec: 1 + +##################################################################### +# input shaper definition +##################################################################### +[input_shaper] +## A frequency (in Hz) of the input shaper for X or Y axis. +shaper_freq_x: 61.4 +shaper_freq_y: 43.4 +## A type of the intput shaper for X or Y axia. +shaper_type_x: mzv +shaper_type_y: mzv +## Damping ratios of vibrations of X and Y axes used by input shapers +## to improve vibration suppression. Default value is 0.1 which is a +## good all-round value for most printers. In most circumstances this +## parameter requires no tuning and should not be changed. +#damping_ratio_x: 0.1 +#damping_ratio_y: 0.1 + +##################################################################### +# Macros +##################################################################### +# !!! This macro only works with the use of gcode_shell_command.py !!! +# you find both needed files at /klipper_config/script +# - gcode_shell_command.py -> klipper add on file +# - plot_graph.sh -> shell script that is executed +# +# Setup: +# - symlink or copy gcode_shell_command.py to /klipper/klippy/extra +# e.g ln -s /home/pi/klipper_config/script/gcode_shell_command.py /home/pi/klipper/klippy/extras/gcode_shell_command.py +# - klipper service restart +# +# Please inspect the shell script by yourself and use it at your own risk +# Functions: +# - Generate folder if needed. Default path is IS_FOLDER=~/klipper_config/input_shaper +# - Store a defined number of results for the RESONANCES_TEST/BELT_TEST. Default is STORE_RESULTS=5 +# - generate/store following files for RESONANCES_TEST: +# - resonances_x_YYYYMMDD_HHMMSS.csv +# - resonances_y_YYYYMMDD_HHMMSS.csv +# - resonances_x_YYYYMMDD_HHMMSS.png +# - resonances_y_YYYYMMDD_HHMMSS.png +# - generate/store following files for BELT_TEST: +# - raw_data_belt_a_YYYYMMDD_HHMMSS.csv +# - raw_data_belt_b_YYYYMMDD_HHMMSS.csv +# - resonances_belts_YYYYMMDD_HHMMSS.png +# - remove files from /tmp +##################################################################### +[gcode_macro RESONANCES_TEST] +description: Run input shaper test +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + _CG28 ; home if needed + TURN_OFF_HEATERS ; turn off heaters + M107 ; turn off fan + {% if user.hw.chamber.fan %} M141 {% endif %} ; exhaust fan off + {% if user.hw.filter.ena %} _SET_FILTER {% endif %} ; filter off + _PRINT_AR T="INPUT SHAPER: Noise values, check if sensor is installed" + MEASURE_AXES_NOISE ; get noise value in log + _PRINT_AR T="INPUT SHAPER: Resonance Tests starting" + _PRINT_AR T="INPUT SHAPER: Mesasure X axis" + TEST_RESONANCES AXIS=X ; measure X + _PRINT_AR T="INPUT SHAPER: Mesasure Y axis" + TEST_RESONANCES AXIS=Y ; measure Y + _PRINT_AR T="INPUT SHAPER: Resonance Tests done" + _PRINT_AR T="INPUT SHAPER: Generate graph in backround" + RUN_SHELL_COMMAND CMD=plot_graph PARAMS=SHAPER + +[gcode_macro BELT_TEST] +description: Run resonance test to analyze belts +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + _CG28 ; home if needed + TURN_OFF_HEATERS ; turn off heaters + M107 ; turn off fan + {% if user.hw.chamber.fan %} M141 {% endif %} ; exhaust fan off + {% if user.hw.filter.ena %} _SET_FILTER {% endif %} ; filter off + _PRINT_AR T="BELT TEST: Noise values, check if sensor is installed" + MEASURE_AXES_NOISE ; get noise value in log + _PRINT_AR T="BELT TEST: Resonance Tests starting ..." + _PRINT_AR T="BELT TEST: Mesasure B belt" + TEST_RESONANCES AXIS=1,1 OUTPUT=raw_data NAME=b + _PRINT_AR T="BELT TEST: Mesasure A belt" + TEST_RESONANCES AXIS=1,-1 OUTPUT=raw_data NAME=a + _PRINT_AR T="BELT TEST: Resonance Tests done" + _PRINT_AR T="BELT TEST: Generate graph in backround" + RUN_SHELL_COMMAND CMD=plot_graph PARAMS=BELT + +# Shell Comand is not supported by a default klipper installation +[gcode_shell_command plot_graph] +command: bash /home/pi/klipper_config/script/plot_graph.sh +timeout: 60.0 +verbose: True + + diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/lcd.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/lcd.cfg new file mode 100644 index 000000000..7374570c2 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/lcd.cfg @@ -0,0 +1,303 @@ +# Displays mini12864 LCD (Fystec) +[display] +lcd_type: uc1701 +cs_pin: z:P1.18 +a0_pin: z:P1.19 +encoder_pins: ^z:P3.25,^z:P3.26 +click_pin: ^!z:P0.28 +contrast: 63 +display_group: __voron_display +# Use either: +# __voron_main : that is a complete menu you need to [include display_menu.cfg] here. +# __voron_empty: only activates the backlight of the display for 10 sek if you +# hit the knob with no other function. In this case you can comment out +# [include display_menu.cfg] +# remove menu_root: ... if you want to use the stock menu +menu_root: __voron_empty + +# Display menu definitions +[menu __voron_empty] +type: command +name: Main +gcode: {menu.exit()} + +#[include display_menu.cfg] + +[neopixel neo_display] +# Fystec 1 backlight 2/3 knob +# BTT 3 backlight 1/2 knob +# the macros here are written for Fystec if you use BTT you need to change the index +pin: z:P1.21 +chain_count: 3 +color_order: RGB +initial_RED: 0.8 +initial_GREEN: 0.8 +initial_BLUE: 1.0 + +[output_pin _BEEPER] +pin: z:P1.30 +pwm: TRUE +value: 0 +shutdown_value: 0 +# PWM frequency : 0.001 = 1ms will give a base tone of 1kHz +cycle_time: 0.0024 + +# this solution is purly a workaround to switch on the display +# when pressing the menu button. It has the following limitaions: +# - As it is handled as normal gcode it can take a few sec to +# execute the gcode and light up +# - At blocking gcodes e.g M190 it will executed after that finished +# - You need to add 'UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10' +# manual to each menu item you execute with the menu.exit methode +# add this to use the click pin also to switch on display +[duplicate_pin_override] +pins: z:P0.28 + +[gcode_button click_button_display] +pin: ^!z:P0.28 +press_gcode: {% if not printer.menu.running %} _DISPLAY_ON {% endif %} +release_gcode: {% if not printer.menu.running %} UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 {% endif %} + +# Glyph definition +[display_glyph chamber] +data: + 0000000000000000 + 1111111111111111 + 1000010000100001 + 1000010000100001 + 1000011111100001 + 1000000000000001 + 1000000000000001 + 1000001111000001 + 1011101001011101 + 1000001111000001 + 1000000110000001 + 1000000000000001 + 1011111111111101 + 1000100000010001 + 1111111111111111 + 0000000000000000 + +[display_glyph voron] +data: + 1111111001111111 + 1111100000011111 + 1111000000001111 + 1100000000000011 + 1000001100110001 + 1000011001100001 + 1000110011000001 + 1001100110000001 + 1000000110011001 + 1000001100110001 + 1000011001100001 + 1000110011000001 + 1110000000000111 + 1111000000001111 + 1111100000011111 + 1111111001111111 + +[display_glyph voroninv] +data: + 0000001110000000 + 0000111111100000 + 0001111111110000 + 0111111111111100 + 1111100111001110 + 1111001110011110 + 1110011100111110 + 1100111001111110 + 1111110011100110 + 1111100111001110 + 1111001110011110 + 1110011100111110 + 0111111111111100 + 0001111111110000 + 0000111111100000 + 0000001110000000 + +# Display Data definition +[display_template _vheater_temperature] +param_heater: "extruder" +text: + {% if param_heater in printer %} + # Show glyph + {% if param_heater == "heater_bed" %} + {% if printer[param_heater].target %} + {% set frame = (printer.toolhead.estimated_print_time|int % 2) + 1 %} + ~bed_heat{frame}~ + {% else %} + ~bed~ + {% endif %} + {% else %} + ~extruder~ + {% endif %} + # Show temperature + { "%3.0f" % (printer[param_heater].temperature,) } + # Optionally show target + {% if printer[param_heater].target and (printer[param_heater].temperature - printer[param_heater].target)|abs > 2 %} + ~right_arrow~ + { "%0.0f" % (printer[param_heater].target,) } + {% endif %} + ~degrees~ + {% endif %} + +[display_data __voron_display extruder] +position: 0, 0 +text: { render("_vheater_temperature", param_heater="extruder") } + +[display_data __voron_display fan] +position: 0, 10 +text: + {% if 'fan' in printer %} + {% set speed = printer.fan.speed %} + {% if speed %} + {% set frame = (printer.toolhead.estimated_print_time|int % 2) + 1 %} + ~fan{frame}~ + {% else %} + ~fan1~ + {% endif %} + { "{:>4.0%}".format(speed) } + {% endif %} + +[display_data __voron_display bed] +position: 1, 0 +text: { render("_vheater_temperature", param_heater="heater_bed") } + +[display_data __voron_display progress_text] +position: 1, 10 +text: + {% set progress = printer.virtual_sdcard.progress %} + { "{:^6.0%}".format(progress) } + +[display_data __voron_display progress_text2] +position: 1, 10 +text: + {% set progress = printer.virtual_sdcard.progress %} + { draw_progress_bar(1, 10, 6, progress) } + +[display_data __voron_display chamber] +position: 2, 0 +text: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% if 'chamber' in user.hw and user.hw.chamber.ena %} + ~chamber~ + { "%3.0f" % printer["temperature_" + user.hw.chamber.type + " chamber"].temperature } + ~degrees~ + {% endif %} + +[display_data __voron_display printing_time] +position: 2, 10 +text: + {% set ptime = printer.print_stats.total_duration %} + { "%02d:%02d" % (ptime // (60 * 60), (ptime // 60) % 60) } + +[display_data __voron_display print_status] +position: 3, 0 +text: + {% if printer.display_status.message %} + { printer.display_status.message } + {% elif printer.idle_timeout.printing_time|int != 0 %} + {% set pos = printer.motion_report.live_position %} + { "X%-4.0fY%-4.0fZ%-5.2f" % (pos.x, pos.y, pos.z) } + {% else %} + { "V2.660 " } + ~voroninv~ + {% endif %} + +# Macro definition + +# M300 [P] [S] +# P is the tone duration, S the tone frequency. +# The frequency won't be pitch perfect. +# Volume can be adjusted with VALUE. Maximum volume is VALUE=0.5 on the 12864. +[gcode_macro M300] +description: Set Beeper value +gcode: + {% set freq = params.S|default(440)|float %} + {% if freq != 0 %} SET_PIN PIN=_BEEPER VALUE=0.3 CYCLE_TIME={1/freq} {% endif %} + G4 P{params.P|default(100)|int} + SET_PIN PIN=_BEEPER VALUE=0 + +[delayed_gcode _DISPLAY_INIT] +gcode: + {% if printer['gcode_macro _USER_VARIABLE'].hw.display.ena %} + _LCD_KNOB COLOR=GREEN SYNC=1 + UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + {% endif %} + +[gcode_macro _LCD_KNOB] +description: Helper: Set LCD Knob color +variable_knob: {'act' : {'pri':{'R':0.0, 'G':0.3, 'B':0.0}, + 'sec':{'R':0.0, 'G':0.0, 'B':0.0}}, + 'restore': {'pri':{'R':0.0, 'G':0.0, 'B':0.0}, + 'sec':{'R':0.0, 'G':0.0, 'B':0.0}}, + 'time' : 0, + 'sync' : 0} +variable_select: 1 ; used to select what neopixel is active while blinking +gcode: + ##### color definition ##### + {% set color_dic = {'OFF' :{'R':0.0, 'G':0.0, 'B':0.0}, + 'GREEN':{'R':0.0, 'G':0.3, 'B':0.0}, + 'RED' :{'R':0.5, 'G':0.0, 'B':0.0}, + 'BLUE' :{'R':0.0, 'G':0.0, 'B':0.5}} %} + ##### get PARAMETERS or use defaults values ##### + {% set _dummy = knob.update({'time': params.BLINK|default(0)|float}) %} + {% set _dummy = knob.update({'sync': params.SYNC|default(0)|int}) %} + {% if 'COLOR' in params|upper %} + {% set color = params.COLOR|upper %} + {% set _dummy = knob.restore.update({'pri':knob.act.pri}) %} + {% if color in color_dic %} + {% set _dummy = knob.act.update({'pri':color_dic[color]}) %} + {% else %} + {action_respond_info("LCD KNOB COLOR %s is not defined used default: GREEN" % color)} + {% set _dummy = knob.act.update({'pri':color_dic.GREEN}) %} + {% endif %} + {% else %} + {% set _dummy = knob.act.update({'pri':knob.restore.pri}) %} + {% endif %} + ##### store new variable values ##### + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=knob VALUE="{knob}" + ##### update to new color and start or stop blinking ##### + SET_LED LED=neo_display RED={knob.act.pri.R} GREEN={knob.act.pri.G} BLUE={knob.act.pri.B} INDEX=2 TRANSMIT=0 SYNC={knob.sync} + SET_LED LED=neo_display RED={knob.act.pri.R} GREEN={knob.act.pri.G} BLUE={knob.act.pri.B} INDEX=3 TRANSMIT=1 SYNC={knob.sync} + UPDATE_DELAYED_GCODE ID=_BLINK_DELAY DURATION={knob.time} + +[delayed_gcode _BLINK_DELAY] +gcode: + {% set knob = printer["gcode_macro _LCD_KNOB"].knob %} + {% set i = [2,3] if printer["gcode_macro _LCD_KNOB"].select|int == 1 else [3,2] %} + SET_GCODE_VARIABLE MACRO=_LCD_KNOB VARIABLE=select VALUE={(printer["gcode_macro _LCD_KNOB"].select|int * -1)} + SET_LED LED=neo_display RED={knob.act.pri.R} GREEN={knob.act.pri.G} BLUE={knob.act.pri.B} INDEX={i[0]} TRANSMIT=0 SYNC={knob.sync} + SET_LED LED=neo_display RED={knob.act.sec.R} GREEN={knob.act.sec.G} BLUE={knob.act.sec.B} INDEX={i[1]} TRANSMIT=1 SYNC={knob.sync} + UPDATE_DELAYED_GCODE ID=_BLINK_DELAY DURATION={knob.time} + +[gcode_macro DISPLAY] +description: Toggle Display backlight +variable_state: 'on' +gcode: + {% if state == 'on' %} _DISPLAY_OFF {% else %} _DISPLAY_ON {% endif %} + _DISPLAY_STATE + +[gcode_macro _DISPLAY_STATE] +description: Helper: Print display backlight state +gcode: {action_respond_info("LCD display %s" % (printer["gcode_macro DISPLAY"].state))} + +[gcode_macro _DISPLAY_OFF] +description: Helper: Display backlight off +gcode: + {% if not printer.menu.running and printer['gcode_macro _USER_VARIABLE'].hw.display.ena %} + SET_GCODE_VARIABLE MACRO=DISPLAY VARIABLE=state VALUE='"off"' + SET_LED LED=neo_display RED=0 GREEN=0 BLUE=0 INDEX=1 TRANSMIT=1 SYNC=0 + {% endif %} + +[gcode_macro _DISPLAY_ON] +description: Helper: Display backlight on +gcode: + {% if printer['gcode_macro _USER_VARIABLE'].hw.display.ena %} + SET_GCODE_VARIABLE MACRO=DISPLAY VARIABLE=state VALUE='"on"' + SET_LED LED=neo_display RED=0.8 GREEN=0.8 BLUE=1.0 INDEX=1 TRANSMIT=1 SYNC=0 + {% endif %} + +[delayed_gcode _DELAY_DISPLAY_OFF] +gcode: _DISPLAY_OFF \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/macro.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/macro.cfg new file mode 100644 index 000000000..93fdfea96 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/macro.cfg @@ -0,0 +1,356 @@ +## User Paramaters +## BED_TEMP : Target temperature for the Bed. Is also used to decide +## if heatsoak is needed +## EXTRUDER_TEMP : Target temperature for the Extruder +## CHAMBER_TEMP : Target temperature for the chamber fan controll +## SOAK : Soak time in minutes +## DELTA_B : Allowed delta between actual bed temperature and target +## temperature for the decision if heat soak is needed. +## DELTA_C : Allowed delta between actual chamber temperature and target +## will wait until target reached or time is zero +## CHAMBER_SOAK : Extra Soak time if Chamber is not on target - DELTA_C +## EXTRA_SOAK : Enables Chamber Soak ('true'/'false') +## LAYER_HEIGHT : Hight of prime_line should be set to layer_hight +## Z_ADJUST : Add extra z offset via slicer +## FILTER : Activate Nevermore 1 On 0 Off default On +[gcode_macro PRINT_START] +description: All cmd needed at print start +variable_var: {'temp' : {'extruder': 245.0, 'bed': 100.0, 'chamber': 40.0, 'endstop': 0.0}, + 'delta' : {'chamber': 5.0, 'bed': 10}, + 'time' : {'soak' : 1800, 'soak_extra': 900}, + 'redo_qgl' : True, + 'prime_height': 0.0, + 'z_adjust' : 0.0, + 'filter' : True} +## Valid state +## Prepare : Store Params +## HeatBed : heat up bed and decide if soak is needed +## HeatSoak : loop the time specified with SOAK +## Chamber : decide if extra soak is needed +## ChamberSoak: loop the time specified with EXTRA_SOAK or Chamber target reached +## Final : all what needs to be done after wait time +variable_state: 'Prepare' +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set actBed = printer['temperature_sensor bed'].temperature|float|round(1) if 'temperature_sensor bed' in printer + else printer.heater_bed.temperature|float|round(1) %} ; get actual temp from extra sensor or heater sensor + ############################## Prepare phase only done at the first exection of PRINT_START ############################## + {% if state == 'Prepare' %} + ############# Store input parameters ############# + {% set var = {'temp': {'extruder': params.EXTRUDER_TEMP|default(245)|float|round(1), + 'bed' : params.BED_TEMP|default(100)|float|round(1), + 'chamber' : params.CHAMBER_TEMP|default(50)|float|round(1), + 'endstop' : 0.0}, + 'delta': {'chamber': params.DELTA_C|default(5)|float|round(1), + 'bed' : params.DELTA_B|default(10)|float|round(1)}, + 'time' : {'soak' : params.SOAK|default(30)|int * 60, + 'soak_extra': params.CHAMBER_SOAK|default(15)|int * 60 if params.EXTRA_SOAK|default('true') == 'true' and + user.hw.chamber.ena + else 0}, + 'redo_qgl' : True, + 'prime_height': params.LAYER_HEIGHT|float * user.print_start.prime_mult|float if LAYER_HEIGHT in params + else user.prime.pos.z|float, + 'z_adjust' : params.Z_ADJUST|default(0.0)|float, + 'filter' : False if params.FILTER|default(1)|int == 0 else True} %} + {% if user.hw.relay.ena %} _HEATER_ON {% endif %} + {% if user.hw.caselight.ena %} _CASELIGHT_ON {% endif %} ; switch on light + {% if user.hw.display.ena %} _LCD_KNOB COLOR=RED BLINK=1 {% endif %} + {% if user.hw.chamber.fan %} M141 S0 {% endif %} ; exhaust fan off + {% if user.hw.filter.ena and var.filter %} _FILTER_ON {% endif %} ; activate filter + _CG28 ; home if needed + G90 ; absolute position + G0 Z{user.park.bed.z} F{user.speed.z_hop} ; move nozzle to z high first + G0 X{user.park.bed.x} Y{user.park.bed.y} F{user.speed.travel} ; home to get toolhead in the middle + PAUSE_BASE + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=var VALUE="{var}" + SET_GCODE_VARIABLE MACRO=CANCEL_PRINT VARIABLE=execute VALUE=False + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"HeatBed"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + ############################## HeatBed Phase heat up the bed ############################## + {% elif state == 'HeatBed' %} + # get max allow bed temp from config. Lower it by 5C to avoid shutdown + {% set cfg_bed_max = printer.configfile.settings.heater_bed.max_temp|float|round(1) - 5.0 %} + {% set targetBed = var.temp.bed - var.delta.bed %} + {% set soakBed = [(var.temp.bed + user.print_start.bed_up), cfg_bed_max]|min %} + {% if (var.time.soak <= 0) or (actBed >= targetBed) %} ; check if soak time is 0 or if the bed is still hot + M117 Heating Extruder + {% set text = 'heat soak disabled' if var.time.soak <= 0 else 'heat soak not needed' %} + _PRINT_AR T="{"Bed temp: act %3.1f°C min %3.1f°C (target(%3.1f°C) - delta(%2.1f°C)) %s" % + (actBed,targetBed,var.temp.bed,var.delta.bed,text)}" + {% set _dummy = var.update({'redo_qgl' : False}) %} + M140 S{var.temp.bed} ; heat bed + M109 S{var.temp.extruder} ; heat extruder and wait + M190 S{var.temp.bed} ; heat bed and wait + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Chamber"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + {% else %} + M117 Heating Bed + _PRINT_AR T="{"Bed temp: act %3.1f°C min %3.1f°C (target(%3.1f°C) - delta(%2.1f°C)) heat soak needed" % + (actBed,targetBed,var.temp.bed,var.delta.bed)}" + _PRINT_AR T="{"Set Bed temp to %3.1f°C instead of %3.1f°C for faster heat soak" % (soakBed,var.temp.bed)}" + M106 S90 ; switch part cooling ~35% to move air in chamber + M140 S{soakBed} ; heat bed + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"HeatSoak"' + {% set next_duration = user.print_start.ival if var.time.soak > user.print_start.ival else var.time.soak %} + {% set _dummy = var.time.update({'soak': var.time.soak - user.print_start.ival}) if var.time.soak > user.print_start.ival + else var.time.update({'soak': 0}) %} + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={next_duration} + {% endif%} + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=var VALUE="{var}" + _RUNOUT_INFO + ############################## Heatsoak Phase call the delay macro until time is over ############################## + {% elif state == 'HeatSoak' %} + ############# Get filament runout info ############# + {% if user.hw.runout.sensor %} + {% if printer["filament_" + user.hw.runout.type + "_sensor runout"].enabled|lower == 'true' %} + {% set filament_detected = printer["filament_" + user.hw.runout.type + "_sensor runout"].filament_detected %} + {% elif 'filament_loaded' in printer.save_variables.variables %} + {% set filament_detected = printer.save_variables.variables.filament_loaded %} + {% else %} + {% set filament_detected = True %} + {% endif %} + {% elif user.hw.runout.type == 'file' %} + {% set filament_detected = printer.save_variables.variables.filament_loaded %} + {% else %} + {% set filament_detected = True %} + {% endif %} + {% if filament_detected %} + {% if var.time.soak <= (user.print_start.time.extruder + var.temp.extruder - 240) and + var.temp.extruder != printer.extruder.target %} ; check time to start heating extruder + M104 S{var.temp.extruder} ; heat extruder + {% endif %} + {% if var.time.soak <= user.print_start.time.bed and bed != printer.heater_bed.target|int %} ; check time to reduce bed temp + M140 S{var.temp.bed} ; heat bed + {% endif %} + {% if var.time.soak > 0 %} ; check remaining time + {% set next_duration = var.time.soak if user.print_start.ival >= var.time.soak else user.print_start.ival %} + {% set _dummy = var.time.update({'soak': 0}) if user.print_start.ival >= var.time.soak + else var.time.update({'soak': var.time.soak - user.print_start.ival}) %}} + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={next_duration} + {% else %} + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Chamber"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + _PRINT_AR T="{"Bed act temp=%3.1fC heat soak done" % (actBed)}" + {% endif%} + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=var VALUE="{var}" + {% else %} + _PRINT_AR T="No Filament loaded, print aborded!" + CANCEL_PRINT PARK=1 ERROR=1 + {% endif %} + ############################## Decide if extended soaking is needed ############################## + {% elif state == 'Chamber' %} + {% set targetChamber = var.temp.chamber - var.delta.chamber %} + {% set actChamber = printer["temperature_" + user.hw.chamber.type + " chamber"].temperature|round(1) if user.hw.chamber.ena + else 0 %} + {% if var.time.soak_extra > 0 and actChamber < targetChamber %} + _PRINT_AR T="{"Chamber temp: act %2.1f°C min %2.1f°C (target(%2.1f°C) - delta(%2.1f°C)) extra heat soak needed" % + (actChamber,targetChamber,var.temp.chamber,var.delta.chamber)}" + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"ChamberSoak"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + {% else %} + {% set text = 'extra heat soak disabled' if var.time.soak_extra <= 0 else 'extra heat soak not needed' %} + _PRINT_AR T="{"Chamber temp: act %2.1f°C min %2.1f°C (target(%2.1f°C) - delta(%2.1f°C)) %s" % + (actChamber,targetChamber,var.temp.chamber,var.delta.chamber,text)}" + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Final"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + {% endif %} + ############################## extra Heat Soak terminated by chamber temp ############################## + {% elif state == 'ChamberSoak' %} + {% set targetChamber = var.temp.chamber - var.delta.chamber %} + {% set actChamber = printer["temperature_" + user.hw.chamber.type + " chamber"].temperature|round(1) if user.hw.chamber.ena + else 0 %} + {% if var.time.soak_extra > 0 and actChamber < targetChamber %} ; check remaining time and temp difference + {% set next_duration = var.time.soak_extra if user.print_start.ival >= var.time.soak_extra else user.print_start.ival %} + {% set _dummy = var.time.update({'soak_extra': 0}) if user.print_start.ival >= var.time.soak_extra + else var.time.update({'soak_extra': var.time.soak_extra - user.print_start.ival}) %}} + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION={next_duration} + {% else %} + {% set text = 'extra heat soak timed out' if var.time.soak_extra == 0 else 'chamber temp reached' %} + _PRINT_AR T="{"Chamber temp: act %2.1f°C min %2.1f°C (target(%2.1f°C) - delta(%2.1f°C)) %s" % + (actChamber,targetChamber,var.temp.chamber,var.delta.chamber,text)}" + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Final"' + UPDATE_DELAYED_GCODE ID=_START_PRINT_WAIT DURATION=0.5 + {% endif %} + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=var VALUE="{var}" + ############################## all whats need to run at the end ############################## + {% elif state == 'Final' %} + RESUME_BASE + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Prepare"' ; set state for next print + {% if user.hw.display.ena %} _LCD_KNOB COLOR=RED {% endif %} + M106 S0 ; turn off part cooling fan + G34 ; home & QGL + {% if user.hw.chamber.fan %} M141 S{var.temp.chamber} {% endif %} ; set target temp for exhaust fan + NOZZLECLEAN + SET_GCODE_VARIABLE MACRO=_HOME_Z VARIABLE=calibrate_z_next VALUE={user.hw.auto_z_offset.auto} + G28 Z + {% if user.hw.auto_z_offset.auto %} CALIBRATE_Z {% endif %} + {% if user.hw.auto_z_offset.manu %} _SET_PLATE_OFFSET {% endif %} + SET_GCODE_OFFSET Z_ADJUST={var.z_adjust} MOVE=1 + _PRINT_OFFSET + PRIME_LINE PRIME_HEIGHT={var.prime_height} + {% if user.hw.endstop_temp.ena %} + {% set _dummy = var.temp.update({'endstop': printer['temperature_sensor endstop'].temperature}) %} + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=var VALUE="{var}" + {% endif %} + G21 ; set units to millimeters + G90 ; use absolute coordinates + M83 ; use relative distances for extrusion + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 + {% endif %} + +[delayed_gcode _START_PRINT_WAIT] +gcode: + {% macro print_time(text, time) %} ; print remaining time + M117 {'%s' % text} {(time|int // 60)}:{'%02d' % (time|int % 60)} + {% endmacro %} + {% if printer['gcode_macro PRINT_START'].state == 'HeatSoak'%} + { print_time("HEAT SOAK", printer['gcode_macro PRINT_START'].var.time.soak) } + {% elif printer['gcode_macro PRINT_START'].state == 'ChamberSoak' %} + { print_time("SOAK", printer['gcode_macro PRINT_START'].var.time.soak_extra) } + {% endif %} + # Check CANCLE_PRINT was executed + {% if printer['gcode_macro CANCEL_PRINT'].execute|lower == 'false' %} + PRINT_START ; Junp back to PRINT_START + {% else %} ; break loop and insure state is correct for the next print start + SET_GCODE_VARIABLE MACRO=CANCEL_PRINT VARIABLE=execute VALUE=False + SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=state VALUE='"Prepare"' + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 + {% endif %} + +[gcode_macro PRINT_END] +description: All commands after the print +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set filter_off = user.peripheral.filter.run_after_print %} + {% set vent_on = user.peripheral.vent.on_val %} + {% set vent_off = user.peripheral.vent.run_after_print %} + # calculate save move + {% set max = printer.toolhead.axis_maximum %} + {% set act = printer.toolhead.position %} + {% set safe = {'x': 20.0 if act.x|float < (max.x|float - 20.0) else -20.0, + 'y': 20.0 if act.y|float < (max.y|float - 20.0) else -20.0, + 'z': 2.0 if act.z|float < (max.z|float - 2.0) else (max.z|float - act.z|float)} %} + M400 ; wait for buffer to clear + SAVE_GCODE_STATE NAME=STATE_PRINT_END + G92 E0 ; zero the extruder + M83 ; relative extrusion + G1 E-{user.filament.retract.end} F{user.speed.retract} ; retract filament + G91 ; relative positioning + G0 X{safe.x} Y{safe.y} Z{safe.z} F{user.speed.travel} ; move nozzle to remove stringing + TURN_OFF_HEATERS ; turn off heaters + M107 ; turn off fan + {% if user.hw.chamber.fan %} M141 S{vent_on} {% endif %} ; vent chamber (setting fan to below ambient) + G90 ; absolute positioning + G0 X{user.park.pause.x} Y{user.park.pause.y} F{user.speed.travel} ; park nozzle at brush bin + _ADD_PRINT_TIME + _SD_PRINT_STATS R='done' + _SD_PRINTER_STATS + {% if user.hw.display.ena %} _LCD_KNOB COLOR=GREEN {% endif %} + {% if user.hw.caselight.ena %} _CASELIGHT_OFF {% endif %} + {% if user.hw.chamber.fan %} UPDATE_DELAYED_GCODE ID=_DELAY_VENT_OFF DURATION={vent_off} {% endif %} + {% if user.hw.filter.ena %} UPDATE_DELAYED_GCODE ID=_DELAY_FILTER_OFF DURATION={filter_off} {% endif %} + {% if user.hw.endstop_temp.ena %} + {action_respond_info("PRINT_END + BED temp: act %3.1f°C + Endstop temp: start %3.1f°C end %3.1f°C" % (printer['temperature_sensor bed'].temperature if 'temperature_sensor bed' in printer + else printer.heater_bed.temperature, + printer['gcode_macro PRINT_START'].var.temp.endstop, + printer['temperature_sensor endstop'].temperature))} + {% endif %} + {% if user.unload_sd|lower == 'true' %} UPDATE_DELAYED_GCODE ID=_DELAY_SDCARD_RESET_FILE DURATION=10 {% endif %} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + RESTORE_GCODE_STATE NAME=STATE_PRINT_END + M220 S100 ; set feedrate percentage back to default + M221 S100 ; set speed percentage back to default + +[gcode_macro G34] +description: Reset bed mesh, offset and execute QGL +gcode: + _PRINT_AR T="Home & QGL" SHOW_LCD=true + BED_MESH_CLEAR + SET_GCODE_OFFSET Z=0 MOVE=1 + {% if printer['gcode_macro PRINT_START'].var.redo_qgl|lower == 'true' %} + _PRINT_AR T="QGL forced by PRINT_START" + QUAD_GANTRY_LEVEL PARK=false HOME=false + {% elif printer.quad_gantry_level.applied|lower == 'false' %} + _PRINT_AR T="QGL not executed yet" + QUAD_GANTRY_LEVEL PARK=false HOME=false + {% endif %} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=1 + +[gcode_macro M204] +description: Set and limit acceleration to cfg value +rename_existing: M204.1 +gcode: + {% set accel = params.S|float if 'S' in params and params.S|float > 0 + else [params.P|float,params.T|float]|min if 'P' in params and 'T' in params and + params.P|float > 0 and params.T|float > 0 %} + {% if accel is defined %} + {% set lim_accel = [accel, printer.configfile.settings.printer.max_accel ]|min %} + {% set lim_accel_to_decel = [accel / 2, printer.configfile.settings.printer.max_accel_to_decel]|min %} + SET_VELOCITY_LIMIT ACCEL={lim_accel} ACCEL_TO_DECEL={lim_accel_to_decel} + {% else %} + {action_respond_info("Invalid M204 command \"M204 %s\"" % rawparams)} + {% endif %} + +[gcode_macro M900] +description: Set pressure advance +gcode: + SET_PRESSURE_ADVANCE ADVANCE={params.K|default(0)} + +[gcode_macro _PRINT_OFFSET] +description: Helper: Print gcode offsets defined by script or user in PRINT_START +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set text = ["GCODE OFFSET for Z applied from:"] %} + {% if user.hw.auto_z_offset.manu %} + {% set _dummy = text.append("Plate %s %.3fmm" % + (printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].name, + printer.save_variables.variables.plates.array[printer.save_variables.variables.plates.index].offset)) %} + {% endif %} + {% if user.hw.auto_z_offset.auto %} + {% set _dummy = text.append("Z_CALIBRATE %.3fmm" % printer.z_calibration.last_z_offset) %} + {% endif %} + {% set _dummy = text.append("User %.3fmm" % printer['gcode_macro PRINT_START'].var.z_adjust) %} + {% set _dummy = text.append("Total %.3fmm" % printer.gcode_move.homing_origin.z) %} + {action_respond_info(text|join("\n"))} + +[gcode_macro _RUNOUT_INFO] +description: Helper: Print runout sensor status +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set out = ['RUNOUT: ' + user.hw.runout.type|capitalize + ' Sensor'] if user.hw.runout.sensor + else ['RUNOUT: Stored in file'] if user.hw.runout.type == 'file' + else ['RUNOUT: Not monitored'] %} + + {% set enable = printer["filament_" + user.hw.runout.type + "_sensor runout"].enabled if user.hw.runout.sensor + else False %} + {% set _dummy = out.append('Enabled: ' + enable|lower) if user.hw.runout.sensor %} + {% set detected = printer["filament_" + user.hw.runout.type + "_sensor runout"].filament_detected if enable + else printer.save_variables.variables.filament_loaded if user.hw.runout.type == 'file' %} + {% set _dummy = out.append('Detect Filament: ' + detected|lower) if detected is defined %} + {action_respond_info(out|join("\n"))} + +## PrusaSlicer/SuperSlicer: +## Add at the start gcode section +## _LAYER TOTAL=[total_layer_count] RESPOND=0 +## +## Add at the layer change gcode section +## _LAYER CURRENT={layer_num+1} +[gcode_macro _LAYER] +description: Pass the current layer and the total amount of layers by your Slicer. +variable_layer: {'current': 0, 'total':0} +gcode: + {% set _dummy = layer.update({'total':params.TOTAL|int}) if ('TOTAL' in params and params.TOTAL|int > 0) %} + {% set _dummy = layer.update({'current':params.CURRENT|default(0)|int}) %} + SET_GCODE_VARIABLE MACRO=_LAYER VARIABLE=layer VALUE="{layer}" + {% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.layer)|int == 1 %} + {action_respond_info("Layer %s of %s" % (layer.current, layer.total))} + {% endif %} + +[gcode_macro TOGGLE_LAYER_OUTPUT] +description: Enable/Disable Console output of _LAYER +gcode: + {% set respond = printer['gcode_macro _USER_VARIABLE'].respond %} + {% set _dummy = respond.update({'layer':1}) if respond.layer|int == 0 else respond.update({'layer':0}) %} + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=respond VALUE="{respond}" diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/magprobe.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/magprobe.cfg new file mode 100644 index 000000000..4de56e67b --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/magprobe.cfg @@ -0,0 +1,286 @@ +##################################################################### +# User Macros +##################################################################### +## Used the same names as in +## to make the switch easier after the PR is merged +[gcode_macro ATTACH_PROBE] +description: Attaching the MagProbe if not already attached +gcode: + _MAG_PROBE ACTION=ATTACH + _MAG_PROBE ACTION=CHECK_ATTACH + +[gcode_macro DETACH_PROBE] +description: Dock the MagProbe if not already docked +gcode: + _MAG_PROBE ACTION=DOCK + _MAG_PROBE ACTION=CHECK_DOCK + +[gcode_macro GET_PROBE_STATUS] +description: Prints the current MagProbe state, valid probe states are UNKNOWN, ATTACHED and DOCKED +gcode: + _MAG_PROBE ACTION=GET_STATUS RESPOND=1 + +[gcode_macro SET_PROBE_STATUS] +description: Manually specify MagProbe status, valid probe states are UNKNOWN, ATTACHED and DOCKED +gcode: + {% if not params.STATE or params.STATE|lower is not in ['unknown','attached','docked'] %} + {action_raise_error("Invalid probe state: %s. Valid probe states are [UNKNOWN, ATTACHED, DOCKED]" % params.STATE|default('none')|upper)} + {% endif %} + SET_GCODE_VARIABLE MACRO=_PROBE_ACTION VARIABLE=man_state VALUE='"{params.STATE|lower}"' + SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=state VALUE='"{params.STATE|lower}"' + +##################################################################### +# Helper Macros +##################################################################### +# QUERY_PROBE must run direct before _PROBE_ACTION +# that relation is insured by the caller id +[gcode_macro _MAG_PROBE] +description: Helper: Query MagProbe state and request action +variable_state: 'unknown' +variable_dock_state: 'unknown' +variable_id: 0 +gcode: + {% set id = 1 if id == 0 else id + 1 %} ; generate an id not equal to 0 + QUERY_PROBE ID={id} + _PROBE_ACTION ACTION={params.ACTION} ID={id} {"RESPOND=" + params.RESPOND if params.RESPOND is defined else ""} + SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=id VALUE={id} + +[gcode_macro _PROBE_ACTION] +description: Helper: Perform MagProbe action +variable_man_state: 'unknown' +gcode: + {% set action = params.ACTION|default('undefined')|lower %} + {% set id = params.ID|default(0)|int %} + {% set probe_id = printer['gcode_macro QUERY_PROBE'].id|default(0)|int %} + {% set probe = 'attached' if printer.probe.last_query|int == 0 + else 'docked' if printer.probe.last_query|int == 1 %} + {% set error_id = 1 if printer.probe.last_query|lower == 'false' + else 2 if id == 0 or id != probe_id + else 3 if action is not in ['attach','dock','check_attach','check_dock','get_status'] + else 4 if action == 'check_dock' and probe != 'docked' + else 5 if action == 'check_attach' and probe != 'attached' + else 0 %} + {% set state = 'error' if error_id != 0 + else man_state if man_state != 'unknown' + else probe %} + {% if params.RESPOND|default(printer['gcode_macro _USER_VARIABLE'].respond.probe_action)|int == 1 %} + {% set txt = [] %} + {% if man_state != 'unknown' %}{% set _dummy = txt.append("State was set to %s by SET_PROBE_STATUS" % man_state)%}{% endif %} + {% if action == 'attach' and state == 'docked' %}{% set _dummy = txt.append("Attach Probe")%}{% endif %} + {% if action == 'attach' and state == 'attached' %}{% set _dummy = txt.append("Already attached")%}{% endif %} + {% if action == 'dock' and state == 'attached' %}{% set _dummy = txt.append("Dock Probe")%}{% endif %} + {% if action == 'dock' and state == 'docked' %}{% set _dummy = txt.append("Already docked")%}{% endif %} + {% if action == 'get_status' %}{% set _dummy = txt.append("Status: %s" % state)%}{% endif %} + {% if txt|length > 0 %} {action_respond_info("MagProbe: %s" % txt|join("\n"))} {% endif %} + {% endif %} + {% if action == 'attach' and state == 'docked' %} _ATTACH_PROBE {% endif %} + {% if action == 'dock' and state == 'attached' %} _DOCK_PROBE {% endif %} + SET_GCODE_VARIABLE MACRO=_PROBE_ACTION VARIABLE=man_state VALUE='"unknown"' + SET_GCODE_VARIABLE MACRO=_MAG_PROBE VARIABLE=state VALUE='"{state}"' + SET_GCODE_VARIABLE MACRO=_CHECK_STATE VARIABLE=error_id VALUE={error_id} + _CHECK_STATE + +[gcode_macro _CHECK_STATE] +description: Helper: Perform MagProbe error check +variable_error_id: 0 +gcode: + {% set txt = "Please execute QUERY_PROBE first" if error_id == 1 + else "Call ID invalid or does not match QUERY_PROBE call ID" if error_id == 2 + else "action not defined" if error_id == 3 + else "docking failed" if error_id == 4 + else "attaching failed" if error_id == 5 %} + {% if error_id != 0 %} {action_raise_error("MagProbe: ERROR, %s" % txt)} {% endif %} + +## used probe: klicky probe +## the probe is fixed to the Gantry +## +## Gantry +## ======= +## | dock| x position: probe.store +## | arm| +## +## x position: probe.dock +## +## Attach: +## 1) Prepare : move toolhead next to of dock arm (left or right depending on mouting position) +## 2) Dock Probe : move toolhead in X direction on the dock +## 3) Finisch : slide toolhead from holder (Y direction) +## +## Detach: +## 1) Prepare : move toolhead infront of the dock arm +## 2) UnDock Probe : slide toolhead on holder (Y direction) +## 3) Finisch Dock : move toolhead from dock arm (left or right depending on mouting position) +[gcode_macro _ATTACH_PROBE] +description: Helper: Attach MagProbe +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set move_z = [user.z_hop, printer.toolhead.position.z]|max %} ; calc movement high + G90 ; absolute positioning + G0 Z{move_z} F{user.speed.z_hop} ; move head up + G0 X{user.probe.store.x} Y{user.probe.store.y} F{user.speed.travel} ; step 1 + G0 X{user.probe.dock.x} F{user.speed.dock} ; step 2 + G0 Y{user.probe.dock.y} F{user.speed.dock} ; step 3 + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + +[gcode_macro _DOCK_PROBE] +description: Helper: Dock MagProbe +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set move_z = [user.z_hop, printer.toolhead.position.z]|max %} ; calc movement high + G90 ; absolute positioning + G0 Z{move_z} F{user.speed.z_hop} ; move head up + G0 X{user.probe.dock.x} Y{user.probe.dock.y} F{user.speed.travel} ; step 1 + G0 Y{user.probe.store.y} F{user.speed.dock} ; step 2 + G0 X{user.probe.store.x} F{user.speed.dock} ; step 3 + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + +##################################################################### +# Customized standard macros +##################################################################### +# QUAD_GANTRY_LEVEL can be found in probe_qgl.cfg +# BED_MESH_CALIBRATE can be found in bed_mesh.cfg +##################################################################### +# +# !!! Caution !!! +# +# PROBE_CALIBRATE will attach the probe run the probe sequence and +# than detach the probe. After that use the normal paper test to find +# the right height. Use ACCEPT or ABOURT as usual. +# +##################################################################### +# +# If your probe needs a Z move for attach/detach use either +# G0 .... FORCE +# G1 .... FORCE +# +##################################################################### +[gcode_macro G0] +description: Move gcode that prevents moves lower than the limit when probe attached +rename_existing: G0.1 +gcode: + {% if params.FORCE is defined or printer['gcode_macro _MAG_PROBE'].state == 'docked' %} + G0.1 {rawparams} + {% else %} + {% set param = [] %} + {% for key in params %} ; get gcode input parameters + {% set _dummy = param.append(key + "=" + params[key]) if key is not in ['G', 'FORCE'] %} + {% endfor %} + _Z_MOVE_CHECK CALLER=G0 {param|join(" ")} + {% endif %} + +[gcode_macro G1] +description: Move gcode that prevents moves lower than the limit when probe attached +rename_existing: G1.1 +gcode: + {% if params.FORCE is defined or printer['gcode_macro _MAG_PROBE'].state == 'docked' %} + G1.1 {rawparams} + {% else %} + {% set param = [] %} + {% for key in params %} ; get gcode input parameters + {% set _dummy = param.append(key + "=" + params[key]) if key is not in ['G', 'FORCE'] %} + {% endfor %} + _Z_MOVE_CHECK CALLER=G1 {param|join(" ")} + {% endif %} + +[gcode_macro _Z_MOVE_CHECK] +description: Helper: Check limit and perform move +gcode: + {% set param = [] %} + {% for key in params %} ; generate base macro call + {% if key == 'Z' %} + {% set z_target = params.Z|float if printer.gcode_move.absolute_coordinates + else params.Z|float + printer.gcode_move.gcode_position.z %} + {% set z_move_ok = True if z_target >= printer['gcode_macro _USER_VARIABLE'].z_hop or + z_target >= printer.gcode_move.gcode_position.z + else False %} + {% if z_move_ok %} + {% set _dummy = param.append(key + params[key]) %} + {% else %} + {action_respond_info("%s: Z Move (%.3f mm -> %.3f mm) not allowed" % + (params.CALLER, printer.gcode_move.gcode_position.z, z_target))} + {% endif %} + {% elif key != 'CALLER' %} + {% set _dummy = param.append(key + params[key]) %} + {% endif %} + {% endfor %} + {params.CALLER}.1 {param|join(" ")} ; call G0 or G1 base macro with all parameters + +[gcode_macro QUERY_PROBE] +description: Return the status of the z-probe and store ID +rename_existing: QUERY_PROBE_BASE +variable_id: 0 +gcode: + QUERY_PROBE_BASE + SET_GCODE_VARIABLE MACRO=QUERY_PROBE VARIABLE=id VALUE={params.ID|default(0)} ; call id 0 means invalid + +[gcode_macro PROBE_ACCURACY] +description: Probe Z-height accuracy at current XY position and dock/undock MagProbe +rename_existing: PROBE_ACCURACY_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + # as we need to return to the position with the probe we need to be at least at z_hop + {% if user.hw.mag_probe.ena and printer.gcode_move.gcode_position.z < user.z_hop %} + {action_respond_info("PROBE_ACCURACY: High must be above %.2f" % user.z_hop)} + G90 ; absolute positioning + G0 Z{user.z_hop} F{user.speed.z_hop} ; move head up + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + {% endif %} + {% if user.hw.mag_probe.ena == 'true' %} + SAVE_GCODE_STATE NAME=STATE_PROBE_ACCURACY + ATTACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE_ACCURACY MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} + PROBE_ACCURACY_BASE {rawparams} + {% if user.hw.mag_probe.ena == 'true' and params.DOCK|default(1)|int == 1 %} ; use DOCK=0 to omit the probe docking + DETACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE_ACCURACY MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} + +[gcode_macro PROBE] +description: Probe Z-height at current XY position and dock/undock MagProbe +rename_existing: PROBE_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + # as we need to return to the position with the probe we need to be at least at z_hop + {% if user.hw.mag_probe.ena == 'true' and printer.gcode_move.gcode_position.z < user.z_hop %} + {action_respond_info("PROBE_ACCURACY: High must be above %.2f" % user.z_hop)} + G90 ; absolute positioning + G0 Z{user.z_hop} F{user.speed.z_hop} ; move head up + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + {% endif %} + {% if user.hw.mag_probe.ena == 'true' %} + SAVE_GCODE_STATE NAME=STATE_PROBE + ATTACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} + PROBE_BASE {rawparams} + G1 Z{user.z_hop} F{user.speed.z_hop} ; move head up to remove trigger + {% if user.hw.mag_probe.ena == 'true' and params.DOCK|default(1)|int == 1 %} ; use DOCK=0 to omit the probe docking + DETACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + +[gcode_macro PROBE_CALIBRATE] +description: Calibrate the probe's z_offset and undock MagProbe +rename_existing: PROBE_CALIBRATE_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + # as we need to return to the position with the probe we need to be at least at z_hop + {% if user.hw.mag_probe.ena == 'true' and printer.gcode_move.gcode_position.z < user.z_hop %} + {action_respond_info("PROBE_ACCURACY: High must be above %.2f" % user.z_hop)} + G90 ; absolute positioning + G0 Z{user.z_hop} F{user.speed.z_hop} ; move head up + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + {% endif %} + {% if user.hw.mag_probe.ena == 'true' %} + SAVE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE_ATTACH + ATTACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE_ATTACH MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} + PROBE_CALIBRATE_BASE {rawparams} + {% if user.hw.mag_probe.ena == 'true' %} + SAVE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE_DETACH + DETACH_PROBE + RESTORE_GCODE_STATE NAME=STATE_PROBE_CALIBRATE_DETACH MOVE=1 MOVE_SPEED={(user.speed.travel|float / 60)} + {% endif %} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/moonraker.conf b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/moonraker.conf new file mode 100644 index 000000000..6d59bdd25 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/moonraker.conf @@ -0,0 +1,187 @@ +[server] +host: 0.0.0.0 +port: 7125 +klippy_uds_address: /tmp/klippy_uds +enable_debug_logging: False +# The maximum size allowed for a file upload. Default is 1024 MiB. +max_upload_size: 1024 +# The port to listen on for SSL (HTTPS) connections. Note that the HTTPS +# server will only be started of the certificate and key options outlined +# below are provied. The default is 7130. +ssl_port: 7130 +# The path to a self signed ssl certificate. The default is no path, which +# disables HTTPS. +#ssl_certificate_path: +# The path to the private key used to signed the certificate. The default +# is no path, which disables HTTPS. +#ssl_key_path: + +[file_manager] +config_path: ~/klipper_config +log_path: ~/klipper_logs +# When set to True the file manager will add uploads to the job_queue when +# the `start_print` flag has been set. The default if False. +queue_gcode_uploads: False +# When set to True gcode files will be run through a "preprocessor" +# during metdata extraction if object tags are detected. This preprocessor +# replaces object tags with G-Code commands compatible with Klipper's +# "cancel object" functionality. Note that this process is file I/O intensive, +# it is not recommended for usage on low resource SBCs such as a Pi Zero. +# The default is False. +enable_object_processing: True + +[database] +database_path: ~/.moonraker_database +enable_database_debug: False + +[data_store] +# The maximum number of temperature values to store for each sensor. Note +# that this value also applies to the "target", "power", and "fan_speed" +# if the sensor reports them. The default is 1200, which is enough to +# store approximately 20 minutes of data at one value per second. +temperature_store_size: 1200 +# The maximum number "gcode lines" to store. The default is 1000. +gcode_store_size: 1000 + +[job_queue] +# When set to true the job queue will attempt to load the next +# pending job when Klipper reports as "Ready". If the queue has +# been paused it will automatically resume. Note that neither +# the job_transition_delay nor the job_transition_gcode are +# applied in this case. The default is False. +load_on_startup: False +# When set to True the queue will automatically transition to +# the next job in the queue after the current job is complete. +# This is useful for belt printers and other machines with the +# ability to automate clearing of the build area. When False +# the queue will be paused after each job is loaded, requiring +# that users manually resume to load the next print. The default +# is False. +automatic_transition: False +# The amount of time to delay after completion of a job before +# loading the next job on the queue. The default is no delay. +#job_transition_delay: +# A gcode to execute after the completion of a job before the next +# job is loaded. If a "job_transition_delay" has been configured +# this gcode will run after the delay. The default is no gcode. +#job_transition_gcode: + +[authorization] +# When set to True a user login is required for authorization if at least +# one user has been created, overriding the "trusted_clients" configuration. +# If no users have been created then trusted client checks will apply. +# The default is False. +force_logins: False +# The time, in days, after which a user is forced to re-enter their +# credentials to log in. This period begins when a logged out user +# first logs in. Successive logins without logging out will not +# renew the timeout. The default is 90 days. +#login_timeout: +cors_domains: + *.local + *://my.mainsail.xyz + *://app.fluidd.xyz + *://voron350 +trusted_clients: + 192.168.178.0/24 + 2a02:810d:9340:33f6::/64 + 172.29.199.0/25 + 127.0.0.1 + +[secrets] +secrets_path: ~/.moonraker_secret.json + +[octoprint_compat] + +[history] + +[timelapse] + +[update_manager] +channel: dev +enable_repo_debug: True +enable_auto_refresh: True +enable_system_updates: True +refresh_interval: 24 + +[update_manager mainsail] +type: web_beta +repo: mainsail-crew/mainsail +path: ~/mainsail + +[update_manager KlipperScreen] +type: git_repo +path: ~/KlipperScreen +env: /home/pi/.KlipperScreen-env/bin/python +origin: https://github.com/jordanruthe/KlipperScreen.git +requirements: scripts/KlipperScreen-requirements.txt +venv_args: -p python3 +install_script: scripts/KlipperScreen-install.sh + +[update_manager kiauh] +type: git_repo +path: ~/kiauh +origin: https://github.com/th33xitus/kiauh.git +is_system_service: False + +[update_manager z_calibration] +type: git_repo +path: ~/klipper_z_calibration +origin: https://github.com/protoloft/klipper_z_calibration.git + +[update_manager webcamd] +type: git_repo +path: ~/crowsnest +origin: https://github.com/mainsail-crew/crowsnest.git +primary_branch: nightly + +[update_manager timelapse] +type: git_repo +primary_branch: main +path: ~/moonraker-timelapse +origin: https://github.com/mainsail-crew/moonraker-timelapse.git + +[mqtt] +address: 192.168.178.200 +port: 1883 +username: {secrets.mqtt_credentials.username} +password: {secrets.mqtt_credentials.password} +# The protocol to use when connecting to the Broker. May be v3.1, +# v3.1.1, and v5. The default is v3.1.1 +mqtt_protocol: v3.1.1 +# If set to true the MQTT client will subscribe to API topic, ie: +# {instance_name}/moonraker/api/request +# This can be set to False if the user does not wish to allow API +# requests over MQTT. The default is True. +enable_moonraker_api: True +instance_name: printer/V2.660 +default_qos: 0 +# The QOS level to use for the API topics. If not provided, the +# value specified by "default_qos" will be used. +#api_qos: + +[power psu] +type: gpio +pin: !gpio14 +initial_state: on +bound_service: klipper +locked_while_printing: True + +[power bed] +type: gpio +pin: !gpio15 +initial_state: on +off_when_shutdown: True +locked_while_printing: True + +[power dryer] +type: mqtt +qos: 1 +command_topic: shellies/Schalten/OG/Arbeit/3dTrockner/relay/0/command +command_payload: {command} +retain_command_state: True +query_topic: shellies/Schalten/OG/Arbeit/3dTrockner/relay/0 +state_topic: shellies/Schalten/OG/Arbeit/3dTrockner/relay/0 +state_response_template: {payload} +query_after_command: False + diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/park_macro.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/park_macro.cfg new file mode 100644 index 000000000..494e4d39f --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/park_macro.cfg @@ -0,0 +1,20 @@ +# You can specify the park_pos variable manually if you do not want +# to use a _USER_VARIABLE macro, The set statement would look like: +# {% set park_pos = {'x': val, 'y': val, 'z': val} %} +# e.g. +# {% set park_pos = {'x': 175.0, 'y': 25.0, 'z': 30.0 } %} + +[gcode_macro PARK] +description: Park head depending on parameter P +gcode: + {% if params.P and params.P|lower is not in ['bed','center','front','frontlow','rear'] %} + {action_respond_info("\"PARK P=%s\" not valid use P=[BED,CENTER,FRONT,FRONTLOW,REAR] + Default position BED will be used" % params.P|upper)} + {% else %} + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set pos = params.P|default('bed')|lower %} + _CG28 ; home if not already homed + G90 ; absolute positioning + G0 X{user.park[pos].x} Y{user.park[pos].y} Z{user.park[pos].z} F{user.speed.travel} + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + {% endif %} \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/power.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/power.cfg new file mode 100644 index 000000000..1fc8c35dc --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/power.cfg @@ -0,0 +1,90 @@ +##################################################################### +# Idle Timeout +##################################################################### +[idle_timeout] +gcode: + {% if printer.webhooks.state|lower == 'ready' %} + {% if printer.pause_resume.is_paused|lower == 'false' %} + {action_respond_info("POWER: Execute Idle Timeout")} + TURN_OFF_HEATERS + {% if printer['gcode_macro _USER_VARIABLE'].hw.relay.ena %} + UPDATE_DELAYED_GCODE ID=_DELAY_HEATER_OFF DURATION=10 + {% endif %} + UPDATE_DELAYED_GCODE ID=_DELAY_PSU_OFF DURATION=20 + {% endif %} + {% endif %} +# 2h timeout +timeout: 7200 + +##################################################################### +# Safety Relay extruder +##################################################################### +## Use a pin to switch on a relay for the Extruder heater if klipper is active +## XYE board, UPWR_DET_PIN Connector +[output_pin extruder_relay] +## negativ logic +pin: !P1.0 +pwm: false +shutdown_value: 0 +value: 1 + +##################################################################### +# Safety Relay heater_bed +##################################################################### +## Use a pin to switch on a relay for the heater_bed if klipper is active +## Z board, UPWR_DET_PIN Connector +[output_pin heater_bed_relay] +## negativ logic +pin: !z:P1.0 +pwm: false +shutdown_value: 0 +value: 1 + +##################################################################### +# Macro +##################################################################### +[delayed_gcode _DELAY_PSU_OFF] +gcode: + {action_respond_info("POWER: 24V PS power off")} + {action_call_remote_method("set_device_power", device="psu", state="off")} + +[gcode_macro _HEATER_ON] +description: Helper: Power on BED and Extruder power +gcode: + {%if printer['output_pin heater_bed_relay'].value == 0 %} + {action_respond_info("POWER: heater_bed power on")} + SET_PIN PIN=heater_bed_relay VALUE=1 + {% endif %} + {action_call_remote_method("set_device_power", device="bed", state="on")} + {%if printer['output_pin extruder_relay'].value == 0 %} + {action_respond_info("POWER: extruder power on")} + SET_PIN PIN=extruder_relay VALUE=1 + {% endif %} + +[delayed_gcode _DELAY_HEATER_OFF] +gcode: + {%if printer['output_pin heater_bed_relay'].value == 1 %} + {action_respond_info("POWER: heater_bed power off")} + SET_PIN PIN=heater_bed_relay VALUE=0 + {% endif %} + {action_call_remote_method("set_device_power", device="bed", state="off")} + {%if printer['output_pin extruder_relay'].value == 1 %} + {action_respond_info("POWER: extruder power off")} + SET_PIN PIN=extruder_relay VALUE=0 + {% endif %} + +[gcode_macro _SHUTDOWN_PI] +description: Helper: Power down the rPi +gcode: {action_call_remote_method("shutdown_machine")} + +[gcode_macro PRINTER_OFF] +description: Park head and Power down the rPi +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + _CG28 ; home if not already homed + G90 ; absolute positioning + G0 X{user.park.bed.x} Y{user.park.bed.y} Z{user.park.bed.z} F{user.speed.travel} + M117 PI Off in 5 sec + G4 P5000 + M400 + _SHUTDOWN_PI \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/pressure_advance.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/pressure_advance.cfg new file mode 100644 index 000000000..d01420ad6 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/pressure_advance.cfg @@ -0,0 +1,185 @@ +##################################################################### +# Preperation +##################################################################### +# copy this file in the same directory as your printer.cfg +# add +# [include pressure_advance.cfg] +# to your printer.cfg +# +# A [save_variables] block is needed since a printer save variable needs to be used to have it available after power up. +# You can skip this if you already have an [save_variables] config block +# e.g: +# [save_variables] +# filename: /home/pi/klipper_config/.variables.stb +# I like to hide that file as there is nothing in that should be modified by the user. +# Do a klipper restart after adding the stuff above +# +# After klipper is back you need define your first filament id e.g. +# PRESSURE_ADVANCE_ADD FILAMENT=ABS +# +##################################################################### +# Macro for the print start or filament gcode section of your slicer +##################################################################### +# PRESSURE_ADVANCE_SELECT [FILAMENT=] [NOZZLE=] : Set pressure advanve and smooth +# time for the different filaments and nozzles combinations. If no combo is found +# the cfg values are used. +# +# For SuperSlicer/PrusaSlicer this could look like +# PRESSURE_ADVANCE_SELECT NOZZLE=[nozzle_diameter] FILAMENT=[filament_settings_id] +# +##################################################################### +# Console ussage +##################################################################### +# PRESSURE_ADVANCE_LIST: List all pressure advanve and smooth +# time for the different filaments and nozzles +# +# PRESSURE_ADVANCE_ADD FILAMENT= [NOZZLE=] [PRESSURE_ADVANCE=] [SMOOTH_TIME=]: +# Add new filaments, or nozzle to an existing filament or change pa settings for +# for an existing filament nozzle combination. +# Nozzle is defaulted to 0.4 and preasure advance/smoth time to the cfg values if not defined at the call +# !!! Caution do not use special characters like äüö or anything else in the name !!! +# +# PRESSURE_ADVANCE_REMOVE FILAMENT= [NOZZLE=]: Remove a definition +# If FILAMENT/NOZZLE is defined then only the coresponding nozzle setup will removed otherwise the complete +# filament. +# +##################################################################### +[gcode_macro PRESSURE_ADVANCE_LIST] +description: List all filament pressure advance settings +gcode: + {% if not printer.save_variables.variables.pressure_advance %} + {action_respond_info("PRESSURE ADVANCE: No filament defined ABORDED")} + {% else %} + {% set pa_dic = printer.save_variables.variables.pressure_advance %} + {% set out = ["PRESSURE ADVANCE: Defined filaments"] %} + {% for filament in pa_dic|sort(attribute='id') %} + {% set _dummy = out.append("%s" % filament.id) %} + {% for setup in filament.val|sort(attribute='nozzle') %} + {% set _dummy = out.append("Nozzle: %1.02f | Pressure Advance: %1.03f | Smooth Time: %1.03f" % + (setup.nozzle, setup.pa, setup.st)) %} + {% endfor %} + {% endfor %} + {action_respond_info(out|join("\n"))} + {% endif %} + +[gcode_macro PRESSURE_ADVANCE_ADD] +description: Add or change pressure advance settings +gcode: + {% if 'FILAMENT' not in params|upper %} + {action_respond_info("PRESSURE ADVANCE: FILAMENT must be defined use \"PRESSURE_ADVANCE_ADD FILAMENT=id\" as a minimum")} + {% else %} + {% set cfg = printer.configfile.settings.extruder %} + {% set id = params.FILAMENT|string %} + {% set nozzle = params.NOZZLE|default(0.40)|float|round(2) %} + {% if not printer.save_variables.variables.pressure_advance %} # add first entry + {action_respond_info("PRESSURE ADVANCE: Initialize with Filament %s" % (id))} + {% set pa_dic = [{'id' : id, + 'val': [{'nozzle': nozzle, + 'pa' : params.PRESSURE_ADVANCE|default(cfg.pressure_advance)|float|round(3), + 'st' : params.SMOOTH_TIME|default(cfg.pressure_advance_smooth_time)|float|round(3)}]}] %} + {% else %} + {% set pa_dic = printer.save_variables.variables.pressure_advance %} + {% for filament in pa_dic %} + {% if id == filament.id %} + {% set id_index = loop.index0 %} + {% for setup in filament.val %} + {% if nozzle == setup.nozzle %} # change value of an existing nozzle st an existing filament + {% set change_txt = [] %} + {% if 'PRESSURE_ADVANCE' in params|upper %} + {% set _dummy = change_txt.append("PRESSURE ADVANCE") %} + {% set _dummy = pa_dic[id_index].val[loop.index0].update({'pa': params.PRESSURE_ADVANCE|float|round(3)}) %} + {% endif %} + {% if 'SMOOTH_TIME' in params|upper %} + {% set _dummy = change_txt.append("SMOOTH TIME") %} + {% set _dummy = pa_dic[id_index].val[loop.index0].update({'st': params.SMOOTH_TIME|float|round(3)}) %} + {% endif %} + {% if change_txt|length > 0 %} + {action_respond_info("PRESSURE ADVANCE: Changed %s at Filament %s Nozzle %s" % (change_txt|join(" and "),id,nozzle))} + {% else %} + {action_respond_info("PRESSURE ADVANCE: Nothing changed at Filament %s Nozzle %s" % (id,nozzle))} + {% endif %} + {% elif loop.last %} # add a new nozzle to an existing filament + {action_respond_info("PRESSURE ADVANCE: Add setup for Nozzle %s at Filament %s" % (nozzle,id))} + {% set _dummy = pa_dic[id_index].val.append({'nozzle': nozzle, + 'pa' : params.PRESSURE_ADVANCE|default(cfg.pressure_advance)|float|round(3), + 'st' : params.SMOOTH_TIME|default(cfg.pressure_advance_smooth_time)|float|round(3)}) %} + {% endif%} + {% endfor %} + {% elif loop.last %} # add a new filament + {action_respond_info("PRESSURE ADVANCE: Add setup for Filament %s" % (id))} + {% set _dummy = pa_dic.append({'id' : id, + 'val': [{'nozzle': nozzle, + 'pa' : params.PRESSURE_ADVANCE|default(cfg.pressure_advance)|float|round(3), + 'st' : params.SMOOTH_TIME|default(cfg.pressure_advance_smooth_time)|float|round(3)}]}) %} + {% endif %} + {% endfor %} + {% endif %} + SAVE_VARIABLE VARIABLE=pressure_advance VALUE="{pa_dic}" + {% endif %} + +[gcode_macro PRESSURE_ADVANCE_REMOVE] +description: Remove a filament or a nezzle setup +gcode: + {% if 'FILAMENT' not in params|upper %} + {action_respond_info("PRESSURE ADVANCE: FILAMENT must be defined use \"PRESSURE_ADVANCE_REMOVE FILAMENT=id\" as a minimum")} + {% else %} + {% if not printer.save_variables.variables.pressure_advance %} # nothing setup'ed yet + {action_respond_info("PRESSURE ADVANCE: Nothing to remove, no save_variable defined yet")} + {% else %} + {% set id = params.FILAMENT|string %} + {% set pa_dic = printer.save_variables.variables.pressure_advance %} + {% for filament in pa_dic %} + {% if id == filament.id %} + {% if 'NOZZLE' in params|upper %} + {% set nozzle = params.NOZZLE|float|round(2) %} + {% set id_index = loop.index0 %} + {% for setup in filament.val %} + {% if nozzle == setup.nozzle %} # remove nozzle + {action_respond_info("PRESSURE ADVANCE: Remove Nozzle %s at Filament %s" % (nozzle,id))} + {% set _dummy = pa_dic[id_index].val.pop(loop.index0) %} + {% elif loop.last %} # nozzle not found + {action_respond_info("PRESSURE ADVANCE: Nothing to remove, Nozzle %s at Filament %s not defined" % (nozzle,id))} + {% endif%} + {% endfor %} + {% else %} # remove filament + {action_respond_info("PRESSURE ADVANCE: Remove Filament %s" % id)} + {% set _dummy = pa_dic.pop(loop.index0) %} + {% endif %} + {% elif loop.last %} # filament not found + {action_respond_info("PRESSURE ADVANCE: Nothing to remove, Filament %s not defined" % id)} + {% endif %} + {% endfor %} + {% endif %} + SAVE_VARIABLE VARIABLE=pressure_advance VALUE="{pa_dic}" + {% endif %} + +[gcode_macro PRESSURE_ADVANCE_SELECT] +description: Set PA depending on nozzle and filament +gcode: + {% if not printer.save_variables.variables.pressure_advance %} + {action_respond_info("PRESSURE ADVANCE: No filament defined ABORDED")} + {% else %} + {% set nozzle = params.NOZZLE|default(0.4)|float %} + {% set id = params.FILAMENT|default('None')|string %} + {% set pa_dic = printer.save_variables.variables.pressure_advance %} + {% set found = {'id' : 'default', + 'nozzle': 0.4, + 'pa' : printer.configfile.settings.extruder.pressure_advance, + 'st' : printer.configfile.settings.extruder.pressure_advance_smooth_time} %} + {% for filament in pa_dic %} + {% if id == filament.id %} + {% for setup in filament.val %} + {% if nozzle == setup.nozzle %} + {% set _dummy = found.update({'id': filament.id}) %} + {% set _dummy = found.update({'nozzle': setup.nozzle}) %} + {% set _dummy = found.update({'pa': setup.pa}) %} + {% set _dummy = found.update({'st': setup.st}) %} + {% endif %} + {% endfor %} + {% endif %} + {% endfor %} + SET_PRESSURE_ADVANCE ADVANCE={found.pa} SMOOTH_TIME={found.st} + {action_respond_info("PRESSURE ADVANCE: + Filament: %s Nozzle: %1.02f + Pressure Advance: %1.03f Smooth Time: %1.03f" % (found.id, found.nozzle, found.pa, found.st))} + {% endif %} diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printer.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printer.cfg new file mode 100644 index 000000000..086b5586e --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printer.cfg @@ -0,0 +1,465 @@ +##===================== SKR 1.4 Pin Definitions =================== +# +--------------+------+------+------+------+------+ +----+------+------+------+ +# | | X | Y | Z | E0 | E1 | | | 0 | 1 | BED | +# +--------------+------+------+------+------+------+ +----+------+------+------+ +# | STEP | 2.2 | 0.19 | 0.22 | 2.13 | 1.15 | | HE | 2.7 | 2.4 | 2.5 | +# +--------------+------+------+------+------+------+ +----+------+------+------+ +# | DIR | 2.6 | 0.20 | 2.11 | 0.11 | 1.14 | | TH | 0.24 | 0.23 | 0.25 | +# +--------------+------+------+------+------+------+ +----+------+------+------+ +# | ENABLE | 2.1 | 2.8 | 0.21 | 2.12 | 1.16 | +# +--------------+------+------+------+------+------+ +------+-------+-------+---------+ +# | DIAG/ENDSTOP | 1.29 | 1.28 | 1.27 | 1.26 | 1.25 | | FAN0 | SERVO | PROBE | PWR_DET | +# +--------------+------+------+------+------+------+ +------+-------+-------+---------+ +# | UART | 1.10 | 1.9 | 1.8 | 1.4 | 1.1 | | 2.3 | 2.0 | 0.10 | 1.0 | +# +--------------+------+------+------+------+------+ +------+-------+-------+---------+ + +# MCU definition +## MCU for X/Y/E steppers main MCU +## [X in X] - B Motor +## [Y in Y] - A Motor +## [E in E0] - Extruder +[mcu] +serial: /dev/serial/by-id/usb-Klipper_lpc1769_1840010F871C4AAF863E7C5DC32000F5-if00 +restart_method: command + +## MCU for Z steppers +## [Z in X] - Front Left +## [Z1 in Y] - Rear Left +## [Z2 in Z] - Rear Right +## [Z3 in E0] - Front Right +[mcu z] +serial: /dev/serial/by-id/usb-Klipper_lpc1769_07300110871C4AAFBF427C5DC72000F5-if00 +restart_method: command + +## MCU for adxl345 acelometer +[mcu rpi] +serial: /tmp/klipper_host_mcu + +# General Printer definition +[printer] +kinematics: corexy +max_velocity: 450 +max_accel: 7000 +max_accel_to_decel: 4000 +max_z_velocity: 30 +max_z_accel: 700 +square_corner_velocity: 5.0 + +# Stepper Settings +[include stepper.cfg] +[include tmc.cfg] + +# Extruder & Bed; Heater Verification (default values) +[include heater.cfg] +#[include heater_verify.cfg] + +# Probe and Gantry Adjustment Routines +[include probe_qgl.cfg] + +# Fan Control & Extra Thermistor +[include fan.cfg] + +# Caselight Control +[include caselight.cfg] + +# Homing Routines +[include homing.cfg] + +# Bed Mesh +[include bed_mesh.cfg] + +# Resonance compensation +[include input_shaper.cfg] + +# Display & Custom Menu +[include lcd.cfg] + +# Macros +[include basic_macro.cfg] +[include macro.cfg] +[include park_macro.cfg] +[include debug_macro.cfg] + +# moonraker/mainsail +[include webclient.cfg] + +# Power relays +[include power.cfg] + +# print and service time storage +[include printtime.cfg] + +# probe accuracy test +#[include test_probe_accuracy.cfg] + +# flexplate select menu +[include flexplate.cfg] + +# filament and pressure advance +[include filament.cfg] +[include pressure_advance.cfg] + +# filament runout sensor +[include runout.cfg] + +# force move used only if gantry is at z max +[include force_move.cfg] + +# MagProbe instead of Sensor +[include magprobe.cfg] + +# Z_calibration needs +[include z_calibration.cfg] + +# timelaps needs +[include timelapse.cfg] + +# Enable Execute Object (beta) use https://github.com/troy-jacobson/klipper/tree/exclude-object-pr +[exclude_object] + +# File location of stored varibales +[save_variables] +filename: /home/pi/klipper_config/.variables.stb + +# Virtual SD Card +[virtual_sdcard] +path: /home/pi/sdcard + +# macro that run at klipper start +[delayed_gcode _INIT] +initial_duration: 1 +gcode: + _USER_VARIABLE + _CHECK_CONSITENT + _EXECUTE_AT_INIT + +[gcode_macro _EXECUTE_AT_INIT] +description: Helper: Everything that should run at klipper start +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% if 'gcode_macro _MENU_LIMITS' is in printer %} _MENU_LIMITS INDEX=4 {% endif %} + {% if printer.save_variables.variables.filament_sensor %} _RESTORE_FILAMENT_SENSOR {% endif %} + {% if user.hw.filter.ena %} _CHECK_FILTER {% endif %} + {% if user.hw.relay.ena %} _HEATER_ON {% endif %} + {% if user.hw.display.ena %} UPDATE_DELAYED_GCODE ID=_DISPLAY_INIT DURATION=2 {% endif %} + _PRINT_AR T="Klipper INIT done" + +[gcode_macro _CHECK_CONSITENT] +description: Helper: Check that some criterias are meet in the printer.cfg +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set text = ["CONFIG: ERROR"] %} + {% if user.run is not defined %} + {% set _dummy = text.append("_USER_VARIABLE macro missing") %} + {% elif not user.run %} + {% set _dummy = text.append("_USER_VARIABLE macro not executed") %} + {% endif %} + {% if user.hw.auto_z_offset.auto and not user.hw.mag_probe.ena %} + {% set _dummy = text.append("[z_calibration] defined but no MagProbe\n") %} + {% endif %} + {% if 'save_variables' not in printer %} + {% set _dummy = text.append("[save_variables] missing") %} + {% endif %} + {% if 'virtual_sdcard' not in printer %} + {% set _dummy = text.append("[virtual_sdcard] missing") %} + {% endif %} + {% if text|length > 1 %} + {action_respond_info(text|join("\n"))} + {% endif %} + +[gcode_macro _USER_VARIABLE] +description: Helper: Contains User defined printer variables +##### see the readme for the variable definition ##### +variable_hw: {} +variable_homing: {} +variable_z_hop: 0 +variable_speed: {} +variable_probe: {} +variable_park: {} +variable_filament: {} +variable_purge: {} +variable_print_start: {} +variable_unload_sd: False +variable_prime: {} +variable_respond: {} +variable_peripheral: {} +variable_run: False +gcode: + ################################################################### + ## start of user defines ## + ## this needs to be changed for your printer ## + ################################################################### + #{% set user_z_endstop_xy = [232.0,355.0] %} ; z Endstop position insight right profil + {% set user_z_endstop_xy = [123.0,355.0] %} ; z Endstop position insight left profil + {% set user_z_endstop_hop = 7.5 %} ; z hop for moves e.g homimg + {% set user_z_home_current = 0.3 %} ; reduced homing curent for z + {% set user_home_accel = 1200 %} ; reduced ACCEL for homing + {% set user_bed_y_offset = 5 %} ; Endstop offset to bed max y + ##### all user defined speeds [mm/sec] ##### + {% set user_z_hop_speed = 15 %} ; default z_hop speed + {% set user_retract_speed = 30 %} ; default retract/extrude speed + {% set user_travel_speed = 300 %} ; travel speed e.g park, dock ... + {% set user_probe_dock_speed = 50 %} ; dock speed for attach/dock + {% set user_filament_load_speed = 50 %} ; load/unload speed + {% set user_wipe_speed = 60 %} ; wipe move speed + {% set user_prime_speed = 25 %} ; prime line speed + ##### Mag Probe ##### + {% set user_probe_dock_pos = [0,355] %} ; position of the dock + {% set user_probe_delta_x = 30 %} ; x offset for position before dock + {% set user_probe_delta_y = -30 %} ; y offset to move probe out of dock + {% set user_z_probe_hop = 15.5 %} ; z minimum heigh to avoid crash + ##### Park Position ##### + {% set user_park_xy_delta = 25 %} ; distance for x or y from the edge + {% set user_park_z_max_delta = 40 %} ; insure to do not hit cam in front + {% set user_park_z_min = 30 %} ; minimal z from bed + {% set user_park_pause_z_delta = 2.0 %} ; distance to increase head while PAUSE/CANCEL_PRINT + {% set user_park_at_cancel = False %} ; park head at CANCEL_PRINT if not paused [False/True] + ##### Filament ##### + {% set user_extruder_min_add = 30 %} ; Temperature add to min Extruder temp + {% set user_load_distance = 90 %} ; load distance while load filament + {% set user_load_extrude = 50 %} ; extrude distance while load filament + {% set user_unload_distance = 75 %} ; unload distance while unload filament + {% set user_retract_end = 2 %} ; retract distance at PRINT_END or CANCEL_PRINT + {% set user_retract_pause = 1 %} ; retract/extrude distance while PAUSE or RESUME + ##### Purge & Brush ##### + {% set user_brush_pos = 'right' %} ; left/right profile used + #{% set user_brush_x_middle = 100 %} ; mid point of brush at left profile + {% set user_brush_x_middle = 250 %} ; mid point of brush at right profil + {% set user_brush_x_width = 40 %} ; width of brush + {% set user_brush_y_start = 351 %} ; start point at y + {% set user_wipe_z = 1.0 %} ; z for wipe moves + {% set user_wipe_cnt = 5 %} ; number of full wipes + {% set user_z_purge = 2.5 %} ; z above purge bucket + ##### PRINT_START/STOP ##### + {% set user_print_start_bed_up = 10 %} ; bed temp raise for faster heat soak + {% set user_print_start_ival = 1 %} ; wait time per call in sec + {% set user_print_start_extruder_time = 3 %} ; time in minutes before soak end to start extruder heating + {% set user_print_start_bed_time = 3 %} ; time in minutes before soak end to set bed target temp + {% set user_print_start_prime_mult = 2 %} ; multiplier for prime line hight + {% set user_unload_sd = True %} ; unload sd file at PRINT_END or CANCEL_PRINT [True,False] + ##### Prime Line ##### + {% set user_prime_start_xy = [5.0,30.0] %} ; x&y start coordinates of prime line + {% set user_prime_z = 0.34 %} ; default prime layer hight + {% set user_prime_dir = 'Y+' %} ; direction of prime line (X+, X-, Y+, Y-) + {% set user_prime_spacing = 0.4 %} ; distance between line, move will allways positive + {% set user_prime_lenght = 220 %} ; length of prime line + {% set user_prime_seg = 11 %} ; segments in that the prime line is splitted + {% set user_prime_extrude_per_seg = 2 %} ; amount of filament extruded per segment + ##### Respond defaults ##### + # Default behaivior for output messages of the macro 0: no output 1: console output + {% set user_respond_set_z_current = 0 %} ; Macro: _SET_Z_CURRENT + {% set user_respond_set_acc = 0 %} ; Macro: _SET_ACC + {% set user_respond_probe_action = 1 %} ; Macro: _PROBE_ACTION + {% set user_respond_layer = 0 %} ; Macro: _LAYER + ##### Peripheral ##### + {% set user_filter_on = 0.5 %} ; filter on value + {% set user_filter_use_time = 80 %} ; Nevermore change warning limit + {% set user_vent_on = 15 %} ; chamber fan on temperature + {% set user_caselight_on = 0.4 %} ; caselight on value + {% set user_fan_run_after_print = 30 %} ; time in min to run filter and chamber exhaust after print finsih + ################################################################### + ## end of user defines ## + ################################################################### + # get printer limits & cfg value + {% set min = printer.toolhead.axis_minimum %} + {% set max = printer.toolhead.axis_maximum %} + {% set cfg_endstop_z_offset = printer.configfile.settings.stepper_z.position_endstop|default(0.0)|float %} + # detect additional hardware + {% set hw_dic = {'display' : {'ena' : True if 'neopixel neo_display' in printer.configfile.settings + else False}, + 'chamber' : {'type': 'sensor' if 'temperature_sensor chamber' in printer.configfile.settings + else 'fan' if 'temperature_fan chamber' in printer.configfile.settings + else 'none'}, + 'caselight' : {'ena' : True if 'output_pin caselight' in printer.configfile.settings + else False}, + 'filter' : {'ena' : True if 'fan_generic filter' in printer.configfile.settings + else False}, + 'runout' : {'type': 'switch' if 'filament_switch_sensor runout' in printer.configfile.settings + else 'motion' if 'filament_motion_sensor runout' in printer.configfile.settings + else 'file' if 'save_variables' in printer and filament_loaded in printer.save_variables.variables + else 'none'}, + 'relay' : {'ena' : True if 'output_pin extruder_relay' in printer.configfile.settings and + 'output_pin heater_bed_relay' in printer.configfile.settings + else False}, + 'auto_z_offset' : {'type': 'z_calib+flexplate' if 'z_calibration' in printer and 'save_variables' in printer and 'plates' in printer.save_variables.variables + else 'z_calib' if 'z_calibration' in printer + else 'flexplate' if 'save_variables' in printer and 'plates' in printer.save_variables.variables + else 'none'}, + 'mag_probe' : {'ena' : True if printer['gcode_macro _MAG_PROBE'] is defined or 'dockable_probe' in printer + else False}, + 'endstop_temp' : {'ena' : True if 'temperature_sensor endstop' in printer.configfile.settings + else False}}%} + {% set _dummy = hw_dic.chamber.update({'ena': True if hw_dic.chamber.type != 'none' else False}) %} + {% set _dummy = hw_dic.chamber.update({'fan': True if hw_dic.chamber.type == 'fan' else False}) %} + {% set _dummy = hw_dic.runout.update({'ena': True if hw_dic.runout.type != 'none' else False}) %} + {% set _dummy = hw_dic.runout.update({'sensor': True if hw_dic.runout.type == 'switch' or hw_dic.runout.type == 'motion' + else False}) %} + {% set _dummy = hw_dic.auto_z_offset.update({'ena': True if hw_dic.auto_z_offset.type != 'none' else False}) %} + {% set _dummy = hw_dic.auto_z_offset.update({'auto': True if hw_dic.auto_z_offset.type == 'z_calib+flexplate' or + hw_dic.auto_z_offset.type == 'z_calib' + else False}) %} + {% set _dummy = hw_dic.auto_z_offset.update({'manu': True if hw_dic.auto_z_offset.type == 'z_calib+flexplate' or + hw_dic.auto_z_offset.type == 'flexplate' + else False}) %} + # calc needed values + {% set bed = {'min': {'x': min.x, 'y': min.y , 'z': 0 }, + 'max': {'x': max.x, 'y': max.y - user_bed_y_offset, 'z': max.z}} %} + {% set calc_center = {'x': (bed.max.x - bed.min.x) / 2, + 'y': (bed.max.y - bed.min.y) / 2, + 'z': (bed.max.z - bed.min.z) / 2} %} + {% set calc_park = {'min': {'x': bed.min.x + user_park_xy_delta, + 'y': bed.min.y + user_park_xy_delta, + 'z': bed.min.z + user_park_z_min}, + 'max': {'x': bed.max.x - user_park_xy_delta, + 'y': bed.max.y - user_park_xy_delta, + 'z': bed.max.z - user_park_z_max_delta}} %} + {% set calc_z_endstop_z = cfg_endstop_z_offset|round(0, 'ceil') + 1.0 if cfg_endstop_z_offset > 0 else 1.0 %} + {% set calc_z_hop = user_z_probe_hop if hw_dic.mag_probe.ena and user_z_probe_hop > user_z_endstop_hop + else user_z_endstop_hop %} + {% set calc_brush = {'start': user_brush_x_middle - user_brush_x_width / 2, + 'end' : user_brush_x_middle + user_brush_x_width / 2} %} + {% set calc_purge = {'x': (min.x + calc_brush.start) / 2 if user_brush_pos|lower == 'left' + else max.x - (max.x - calc_brush.end) / 2, + 'y': max.y} %} + {% set calc_wipe = {'start': {'x': calc_brush.start if user_brush_pos|lower == 'left' + else calc_brush.end, + 'y': user_brush_y_start}, + 'end' : {'x': calc_brush.end if user_brush_pos|lower == 'left' + else calc_brush.start, + 'y': max.y}} %} + # prepare dictonaries + {% set homing_dic = {'z_endstop': {'x':user_z_endstop_xy[0], 'y':user_z_endstop_xy[1], 'z':calc_z_endstop_z, 'hop':user_z_endstop_hop}, + 'z_current': user_z_home_current, + 'accel' : user_home_accel} %} + {% set purge_dic = {'purge' : {'x':calc_purge.x, 'y':calc_purge.y, 'z':user_z_purge}, + 'wipe' : {'start' : {'x': calc_wipe.start.x, 'y': calc_wipe.start.y, 'z':user_wipe_z}, + 'end' : {'x': calc_wipe.end.x, 'y': calc_wipe.end.y, 'z':user_wipe_z}, + 'offset' : (calc_wipe.end.y - calc_wipe.start.y) / user_wipe_cnt, + 'cnt' : user_wipe_cnt}} %} + {% set probe_dic = {'dock' : {'x' : user_probe_dock_pos[0], + 'y' : user_probe_dock_pos[1] + user_probe_delta_y}, + 'store' : {'x' : user_probe_dock_pos[0] + user_probe_delta_x, + 'y' : user_probe_dock_pos[1]}} %} + {% set speed_dic = {'z_hop' : (user_z_hop_speed * 60), + 'retract' : (user_retract_speed * 60), + 'travel' : (user_travel_speed * 60), + 'dock' : (user_probe_dock_speed * 60), + 'load' : (user_filament_load_speed * 60), + 'wipe' : (user_wipe_speed * 60), + 'prime' : (user_prime_speed * 60)} %} + {% set park_dic = {'bed' : {'x': calc_center.x, 'y': calc_center.y, 'z': calc_park.min.z}, + 'center' : {'x': calc_center.x, 'y': calc_center.y, 'z': calc_center.z}, + 'front' : {'x': calc_center.x, 'y': calc_park.min.y, 'z': calc_park.max.z}, + 'frontlow' : {'x': calc_center.x, 'y': calc_park.min.y, 'z': calc_park.min.z}, + 'rear' : {'x': calc_park.min.x, 'y': calc_park.max.y, 'z': calc_park.max.z}, + 'pause' : {'x': calc_purge.x, 'y': calc_purge.y, 'dz': user_park_pause_z_delta}, + 'park_at_cancel': user_park_at_cancel} %} + {% set filament_dic = {'load_distance' : user_load_distance, + 'load_extrude' : user_load_extrude, + 'unload_distance' : user_unload_distance, + 'retract' : {'end' : user_retract_end, + 'pause' : user_retract_pause, + 'cancel': user_retract_end - user_retract_pause}} %} + {% set prime_dic = {'pos' : {'x':user_prime_start_xy[0], 'y':user_prime_start_xy[1], 'z':user_prime_z}, + 'dir' : user_prime_dir, + 'spacing' : user_prime_spacing, + 'length_per_seg' : user_prime_lenght / user_prime_seg, + 'seg' : user_prime_seg, + 'extrude_per_seg' : user_prime_extrude_per_seg} %} + {% set print_start_dic = {'bed_up' : user_print_start_bed_up|float|round(1), + 'ival' : user_print_start_ival|int, + 'time' : {'extruder' : (user_print_start_extruder_time * 60)|int, + 'bed' : (user_print_start_bed_time * 60)|int}, + 'prime_mult' : user_print_start_prime_mult|float} %} + {% set respond_dic = {'z_current' : user_respond_set_z_current, + 'acc' : user_respond_set_acc, + 'probe_action' : user_respond_probe_action, + 'layer' : user_respond_layer} %} + {% set peripheral_dic = {'filter' : {'on_val' : user_filter_on, + 'warning' : user_filter_use_time, + 'run_after_print' : (user_fan_run_after_print * 60)}, + 'vent' : {'on_val' : user_vent_on, + 'run_after_print' : ((user_fan_run_after_print * 60) + 5)}, + 'caselight' : {'on_val' : user_caselight_on}} %} + # store results in variable + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=hw VALUE="{hw_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=homing VALUE="{homing_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=z_hop VALUE={calc_z_hop} + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=speed VALUE="{speed_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=probe VALUE="{probe_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=park VALUE="{park_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=filament VALUE="{filament_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=purge VALUE="{purge_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=print_start VALUE="{print_start_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=unload_sd VALUE={user_unload_sd} + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=prime VALUE="{prime_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=respond VALUE="{respond_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=peripheral VALUE="{peripheral_dic}" + SET_GCODE_VARIABLE MACRO=_USER_VARIABLE VARIABLE=run VALUE=True + +#*# <---------------------- SAVE_CONFIG ----------------------> +#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated. +#*# +#*# [extruder] +#*# control = pid +#*# pid_kp = 23.886 +#*# pid_ki = 1.254 +#*# pid_kd = 113.757 +#*# +#*# [heater_bed] +#*# control = pid +#*# pid_kp = 42.778 +#*# pid_ki = 1.501 +#*# pid_kd = 304.788 +#*# +#*# [stepper_z] +#*# position_endstop = 2.177 +#*# +#*# [probe] +#*# z_offset = 0 +#*# +#*# [bed_mesh En_Thick-Bed_Temp-0C] +#*# version = 1 +#*# points = +#*# -0.055625, -0.001562, 0.030000, 0.019375, 0.009063, 0.029375, 0.026875, 0.062500, 0.096875 +#*# -0.040625, 0.008125, 0.039375, 0.035313, 0.021250, 0.048125, 0.048750, 0.079375, 0.122813 +#*# -0.043437, -0.005625, 0.017500, 0.014063, 0.004063, 0.023438, 0.040938, 0.070313, 0.101250 +#*# -0.036250, -0.004062, 0.016563, 0.014688, 0.007188, 0.025625, 0.032813, 0.065000, 0.093750 +#*# -0.025312, -0.003750, 0.013438, 0.008438, 0.000000, 0.017500, 0.029375, 0.065000, 0.090312 +#*# -0.005313, 0.007812, 0.026250, 0.021875, 0.011875, 0.029375, 0.035625, 0.069062, 0.090000 +#*# 0.001562, 0.014375, 0.028125, 0.013125, 0.003750, 0.018125, 0.024687, 0.050000, 0.073125 +#*# 0.020625, 0.029375, 0.033125, 0.014062, 0.007187, 0.027187, 0.028125, 0.049375, 0.056250 +#*# 0.050937, 0.044375, 0.040000, 0.021875, 0.011875, 0.030937, 0.037812, 0.047500, 0.050625 +#*# tension = 0.2 +#*# min_x = 30.0 +#*# algo = bicubic +#*# y_count = 9 +#*# mesh_y_pps = 2 +#*# min_y = 30.0 +#*# x_count = 9 +#*# max_y = 320.0 +#*# mesh_x_pps = 2 +#*# max_x = 320.0 +#*# +#*# [bed_mesh Mueller-Bed_Temp-0C] +#*# version = 1 +#*# points = +#*# -0.015000, 0.021875, 0.030000, 0.021250, 0.016875, 0.028125, 0.031250, 0.030625, 0.032500 +#*# -0.017500, 0.021875, 0.036250, 0.031875, 0.026250, 0.046875, 0.048750, 0.034375, 0.045625 +#*# -0.016875, 0.011875, 0.015000, 0.003750, 0.006250, 0.025625, 0.030625, 0.026250, 0.022500 +#*# -0.008750, 0.018125, 0.029375, 0.005000, 0.010625, 0.021250, 0.030625, 0.030625, 0.026875 +#*# -0.003125, 0.005000, 0.013125, 0.000000, 0.000000, 0.015000, 0.028750, 0.036875, 0.032500 +#*# -0.001875, 0.008750, 0.015000, 0.001875, 0.005625, 0.018125, 0.030000, 0.031250, 0.037500 +#*# 0.003750, 0.016875, 0.028750, 0.006875, 0.006250, 0.026250, 0.030000, 0.035000, 0.028750 +#*# 0.023125, 0.036250, 0.036250, 0.013125, 0.018750, 0.032500, 0.041875, 0.036875, 0.034375 +#*# 0.062500, 0.062500, 0.061875, 0.031875, 0.031875, 0.054375, 0.070625, 0.061250, 0.044375 +#*# x_count = 9 +#*# y_count = 9 +#*# mesh_x_pps = 2 +#*# mesh_y_pps = 2 +#*# algo = bicubic +#*# tension = 0.2 +#*# min_x = 30.0 +#*# max_x = 320.0 +#*# min_y = 30.0 +#*# max_y = 320.0 diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printtime.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printtime.cfg new file mode 100644 index 000000000..19599b2b2 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/printtime.cfg @@ -0,0 +1,167 @@ +##################################################################### +# Macro +##################################################################### +## This macro stores the variables +## must be added to PRINT_END - CANCEL_PRINT Macro +## works only with the use of virtual sd card! +[gcode_macro _ADD_PRINT_TIME] +description: Helper: Store print time values in variables +gcode: + {% set time = printer.print_stats.total_duration %} + {% set filament = printer.print_stats.filament_used|float %} + {% set filtertime = time if printer['gcode_macro PRINT_START'].var.filter else 0 %} + # update saved dictornary or initiate if not exist + {% if not printer.save_variables.variables.print_stats %} + {% set print_stats = {'time': {'total': time, 'service': time, 'filter': filtertime}, 'filament': filament}%} + {% else %} + {% set print_stats = printer.save_variables.variables.print_stats %} + {% set _dummy = print_stats.time.update({'total':(print_stats.time.total + time)|int}) %} + {% set _dummy = print_stats.time.update({'service':(print_stats.time.service + time)|int}) %} + {% set _dummy = print_stats.time.update({'filter':(print_stats.time.filter + filtertime)|int}) %} + {% set _dummy = print_stats.update({'filament':(print_stats.filament + filament)|float}) %} + {% endif %} + SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}" + +[gcode_macro _DISPLAY_PRINT_TIME] +description: Helper: Print actual stored print time +gcode: + {% set totaltime = params.SECONDS|int if 'SECONDS' in params|upper + else printer.save_variables.variables.print_stats.time.total %} + {% set prefix = params.PREFIX|default('Total') %} + {% set h,m,s = (totaltime / 3600)|int, ((totaltime / 60) % 60)|int, (totaltime % 60)|int %} + {action_respond_info("Print time %s %d:%02d:%02d" % (prefix,h,m,s))} + M117 {prefix} {h}:{'%02d' % m}:{'%02d' % s} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + +## used at PRINT_END and CANCEL_PRINT +[gcode_macro _SD_PRINT_STATS] +description: Helper: Print statistic of last print +gcode: + {% set PT = printer.print_stats.print_duration %} + {% set Ph,Pm,Ps = (PT / 3600)|int, ((PT / 60) % 60)|int, (PT % 60)|int %} + {% set TT = printer.print_stats.total_duration %} + {% set Th,Tm,Ts = (TT / 3600)|int, ((TT / 60) % 60)|int, (TT % 60)|int %} + {% set Fil = printer.print_stats.filament_used|float / 1000.0 %} + {action_respond_info("Statistic of last Print (%s): + Name: %s + Filament: %.4fm + Print Time: %d:%02d:%02d + Total Time: %d:%02d:%02d" % + (params.R, printer.print_stats.filename, Fil, Ph, Pm, Ps, Th, Tm, Ts))} + + ## used at PRINT_END and CANCEL_PRINT +[gcode_macro _SD_PRINTER_STATS] +description: Helper: Print statistic of printer +gcode: + {% set ST = printer.save_variables.variables.print_stats.time.service %} + {% set Sh,Sm,Ss = (ST / 3600)|int, ((ST / 60) % 60)|int, (ST % 60)|int %} + {% set TT = printer.save_variables.variables.print_stats.time.total %} + {% set Th,Tm,Ts = (TT / 3600)|int, ((TT / 60) % 60)|int, (TT % 60)|int %} + {% set FT = printer.save_variables.variables.print_stats.time.filter %} + {% set Fh,Fm,Fs = (FT / 3600)|int, ((FT / 60) % 60)|int, (FT % 60)|int %} + {% set Fil = printer.save_variables.variables.print_stats.filament|float / 1000.0 %} + {action_respond_info("Printer Statistics: + Total Print Time: %d:%02d:%02d + Total Filament used: %.4fm + Filter use time: %d:%02d:%02d + Time since last Service: %d:%02d:%02d" % + (Th, Tm, Ts, Fil, Fh, Fm, Fs, Sh, Sm, Ss))} + _CHECK_FILTER + +[gcode_macro _CHECK_FILTER] +description: Helper: Print filter exchange warning +gcode: + {% if printer['gcode_macro _USER_VARIABLE'].hw.filter.ena and + printer.save_variables.variables.print_stats %} + {% set Fh = (printer.save_variables.variables.print_stats.time.filter / 3600)|int %} + {% if Fh >= printer['gcode_macro _USER_VARIABLE'].peripheral.filter.warning %} + M117 Change Filter! + {action_respond_info("Change Filter material at Micro!")} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + {% endif %} + {% endif %} + +[gcode_macro RST_FILTER] +description: Reset Nevermore interval time +gcode: + {% if printer.save_variables.variables.print_stats %} + {% set print_stats = printer.save_variables.variables.print_stats %} + {% set _dummy = print_stats.time.update({'filter': 0}) %} + SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}" + {action_respond_info("Flter used time reseted to zero")} + {% endif %} + +[gcode_macro RST_SERVICE] +description: Reset Service interval time +gcode: + {% if printer.save_variables.variables.print_stats %} + {% set print_stats = printer.save_variables.variables.print_stats %} + {% set _dummy = print_stats.time.update({'service': 0}) %} + SAVE_VARIABLE VARIABLE=print_stats VALUE="{print_stats}" + {action_respond_info("Time since last service reseted to zero")} + {% endif %} + +# Display Menu +# !!! Caution: I use my own menu root __voron_main !!! +# If you use a stock menu un comment this here +#[menu __main __statistic] +#type: list +#enable: {'print_stats' in printer.save_variables.variables} +#name: Satistic + +#[menu __main __statistic __totaltime] +#type: command + +#name: Time of Operation +#gcode: +# {menu.exit()} +# _DISPLAY_PRINT_TIME PREFIX=Total SECONDS={printer.save_variables.variables.print_stats.time.total} +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +#[menu __main __statistic __filament] +#type: command + +#name: Total Filament used +#gcode: +# {menu.exit()} +# M117 Filerment {'%.4f' % (printer.save_variables.variables.print_stats.filament|float / 1000.0)}m +# {action_respond_info("Total Filament printed: %.4fm" % (printer.save_variables.variables.print_stats.filament|float / 1000.0))} +# UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +#[menu __main __statistic __filtertime] +#type: command + +#name: Time since Filter change +#gcode: +# {menu.exit()} +# _DISPLAY_PRINT_TIME PREFIX=Filter SECONDS={printer.save_variables.variables.print_stats.time.filter} +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +#[menu __main __statistic __servicetime] +#type: command + +#name: Time since Service +#gcode: +# {menu.exit()} +# _DISPLAY_PRINT_TIME PREFIX=Service SECONDS={printer.save_variables.variables.print_stats.time.service} +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + + +#[menu __main __statistic __rst_filter] +#type: command +#enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +#name: Reset Filter time +#gcode: +# {menu.exit()} +# RST_FILTER +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 + +#[menu __main __statistic __rst_service] +#type: command +#enable: {not (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")} +#name: Reset Service time +#gcode: +# {menu.exit()} +# RST_SERVICE +# UPDATE_DELAYED_GCODE ID=_DELAY_DISPLAY_OFF DURATION=10 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/probe_qgl.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/probe_qgl.cfg new file mode 100644 index 000000000..ac0435dc8 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/probe_qgl.cfg @@ -0,0 +1,121 @@ +##################################################################### +# Probe +##################################################################### +############### Different Probe Settings ############### +## Omron: +## speed: 10.0 +## lift_speed: 30.0 +## samples: 9 +## samples_result: median +## sample_retract_dist: 0.5 +## samples_tolerance: 0.006 +## samples_tolerance_retries: 10 +## y_offset: 25.00 +######################################################## +## Super Pinda: +## speed: 7.5 +## lift_speed: 30.0 +## samples: 6 +## samples_result: median +## sample_retract_dist: 0.8 +## samples_tolerance: 0.005 +## samples_tolerance_retries: 10 +## y_offset: 25.00 +######################################################## +## MagProbe Klicky +## speed: 7.5 +## lift_speed: 30.0 +## sample: 5 +## samples_result: median +## sample_retract_dist: 0.8 +## samples_tolerance: 0.005 +## samples_tolerance_retries: 10 +## y_offset: 19.75 +## z_offset: 6.42 ;not needed since a Endstop is used +############### Different Probe Settings ############## +[probe] +## Inductive Probe / Mag Probe +## This probe is not used for Z height +pin: ^z:P0.10 +x_offset: 0 +y_offset: 19.75 +#z_offset: 0 +speed: 7.5 +lift_speed: 30.0 +samples: 5 +samples_result: median +sample_retract_dist: 0.8 +samples_tolerance: 0.005 +samples_tolerance_retries: 10 + +##################################################################### +# Disable Heater while probing +##################################################################### +#[homing_heaters] +#steppers: stepper_z, stepper_z1, stepper_z2, stepper_z3 +#heaters: extruder + +##################################################################### +# Gantry Adjustment Routines +##################################################################### +[quad_gantry_level] +## Min & Max gantry corners - measure from nozzle to respective belt positions +gantry_corners: + -56,-1 + 406,420 +## Probe points; this are nozzel positions we need to substract the probe offset +points: + 100,50 + 100,250 + 250,250 + 250,50 +speed: 200 +horizontal_move_z: 20 ; MagProbe 20, Vinda or Omron 5 +retries: 10 +retry_tolerance: 0.005 +max_adjust: 15 + +##################################################################### +# Macros +##################################################################### +[gcode_macro QUAD_GANTRY_LEVEL] +description: Conform a moving, twistable gantry to the shape of a stationary bed +rename_existing: QUAD_GANTRY_LEVEL_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set move_z = [user.z_hop, printer.toolhead.position.z]|max %} ; calc movement high + _SET_Z_CURRENT VAL=HOME + {% if "xyz" not in printer.toolhead.homed_axes %} G28 {% endif %} + {% if user.hw.mag_probe.ena %} + G90 + G0 Z{move_z} F{user.speed.z_hop} ; move head up to insure Probe is not triggered in error case + ATTACH_PROBE + {% endif %} + QUAD_GANTRY_LEVEL_BASE {rawparams} + {% if user.hw.mag_probe.ena %} DETACH_PROBE {% endif %} + {% if params.HOME|default('true')|lower == 'true' %} G28 Z {% endif %} + _SET_Z_CURRENT + {% if params.PARK|default('true')|lower == 'true' %} + G90 + G0 X{user.park.bed.x} Y{user.park.bed.y} Z{user.park.bed.z} F{user.speed.travel} + {% endif %} + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + +[gcode_macro CHECK_QGL] +description: Run after QUAD_GANTRY_LEVEL to insure it passes +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set probe_state = printer['gcode_macro _MAG_PROBE'].state|default('unknown')|lower %} ; get probe state + {% set probe_ok = False if user.hw.mag_probe.ena and (probe_state == 'error' or probe_state == 'unknown') + else True %} + {% if not printer.quad_gantry_level.applied or not probe_ok %} ; check QGL and probe status + {action_respond_info("QGL CHECK: Fail therefore cancel the print")} + PAUSE_BASE + G90 + G0 Z{user.z_hop} F{user.speed.z_hop} ; move nozzle to z high first + {% if not printer.gcode_move.absolute_coordinates %} G91 {% endif %} ; set back to relative + {% if user.hw.mag_probe.ena %} DETACH_PROBE {% endif %} + CANCEL_PRINT PARK=1 ERROR=1 + {% else %} + {action_respond_info("QGL CHECK: Pass")} + {% endif %} diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/runout.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/runout.cfg new file mode 100644 index 000000000..b7c50dc1a --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/runout.cfg @@ -0,0 +1,94 @@ +#[filament_switch_sensor runout] +## When set to True, a PAUSE will execute immediately after a runout +## is detected. Note that if pause_on_runout is False and the +## runout_gcode is omitted then runout detection is disabled. Default +## is True. +#pause_on_runout: FALSE +#runout_gcode: +# {action_respond_info("RUNOUT: Filament runout")} +# PAUSE +#insert_gcode: {action_respond_info("RUNOUT: Filament inserted")} +## The minimum amount of time in seconds to delay between events. +## Events triggered during this time period will be silently +## ignored. The default is 3 seconds. +##event_delay: 3.0 +## The amount of time to delay, in seconds, between the pause command +## dispatch and execution of the runout_gcode. It may be useful to +## increase this delay if OctoPrint exhibits strange pause behavior. +## Default is 0.5 seconds. +##pause_delay: 0.5 +## XYE mcu E0DET +#switch_pin: ^!P1.26 + +[filament_motion_sensor runout] +# The minimum length of filament pulled through the sensor to trigger +# a state change on the switch_pin +# Default is 7 mm. +detection_length: 14.0 +extruder: extruder +pause_on_runout: FALSE +runout_gcode: + {action_respond_info("RUNOUT: Filament runout")} + PAUSE +insert_gcode: {action_respond_info("RUNOUT: Filament inserted")} +# The minimum amount of time in seconds to delay between events. +# Events triggered during this time period will be silently +# ignored. The default is 3 seconds. +#event_delay: 3.0 +# The amount of time to delay, in seconds, between the pause command +# dispatch and execution of the runout_gcode. It may be useful to +# increase this delay if OctoPrint exhibits strange pause behavior. +# Default is 0.5 seconds. +#pause_delay: 0.5 +## XYE mcu E0DET +switch_pin: ^!P1.26 + +[filament_switch_sensor toolhead_runout] +## When set to True, a PAUSE will execute immediately after a runout +## is detected. Note that if pause_on_runout is False and the +## runout_gcode is omitted then runout detection is disabled. Default +## is True. +pause_on_runout: FALSE +runout_gcode: {action_respond_info("RUNOUT: Toolhead Filament runout")} +# PAUSE +insert_gcode: {action_respond_info("RUNOUT: Toolhead Filament inserted")} +## The minimum amount of time in seconds to delay between events. +## Events triggered during this time period will be silently +## ignored. The default is 3 seconds. +##event_delay: 3.0 +## The amount of time to delay, in seconds, between the pause command +## dispatch and execution of the runout_gcode. It may be useful to +## increase this delay if OctoPrint exhibits strange pause behavior. +## Default is 0.5 seconds. +##pause_delay: 0.5 +## XYE mcu E1DET +switch_pin: ^!P1.25 + +##################################################################### +# Macro +##################################################################### +[gcode_macro SET_FILAMENT_SENSOR] +description: Sets the filament sensor on/off and save value to file +rename_existing: SET_FILAMENT_SENSOR_BASE +gcode: + {% if printer.save_variables.variables.filament_sensor is not defined %} + {% set filament_sensor = {params.SENSOR|string: params.ENABLE|int} %} + {% else %} + {% set filament_sensor = printer.save_variables.variables.filament_sensor %} + {% set _dummy = filament_sensor.update({params.SENSOR|string: params.ENABLE|int}) %} + {% endif %} + SET_FILAMENT_SENSOR_BASE SENSOR={params.SENSOR} ENABLE={params.ENABLE} + SAVE_VARIABLE VARIABLE=filament_sensor VALUE="{filament_sensor}" + +[gcode_macro _RESTORE_FILAMENT_SENSOR] +description: Restore the filament sensor on/off state at klipper start +gcode: + {% if printer.save_variables.variables.filament_sensor is defined %} + {% for sensor in printer.save_variables.variables.filament_sensor %} + SET_FILAMENT_SENSOR_BASE SENSOR={sensor} ENABLE={printer.save_variables.variables.filament_sensor[sensor]} + {% endfor %} + {% endif %} + +[gcode_macro M600] +description: Filament change +gcode: PAUSE Y=10 ; everything needed is defined there \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/stepper.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/stepper.cfg new file mode 100644 index 000000000..e8e27ef0d --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/stepper.cfg @@ -0,0 +1,86 @@ +# MCU - X -> B Stepper - Left +[stepper_x] +step_pin: P2.2 +# TMC2209 dir_pin: !P2.6 +dir_pin: P2.6 +enable_pin: !P2.1 +full_steps_per_rotation: 400 +microsteps: 32 +rotation_distance: 40 +endstop_pin: ^!P1.29 +position_endstop: 350 +position_max: 350 +homing_speed: 100 +homing_retract_dist: 2 +second_homing_speed: 5 + +# MCU - Y -> A Stepper - Right +[stepper_y] +step_pin: P0.19 +# TMC2209 dir_pin: P0.20 +dir_pin: !P0.20 +enable_pin: !P2.8 +full_steps_per_rotation: 400 +microsteps: 32 +rotation_distance: 40 +endstop_pin: ^!P1.28 +position_endstop: 355 +position_max: 355 +homing_speed: 100 +homing_retract_dist: 2 +second_homing_speed: 5 + +# Z MCU - X -> Z0 Stepper - Front Left +[stepper_z] +step_pin: z:P2.2 +# TMC2209 dir_pin: !z:P2.6 +dir_pin: z:P2.6 +enable_pin: !z:P2.1 +full_steps_per_rotation: 400 +microsteps: 32 +gear_ratio: 80:16 +rotation_distance: 40 +endstop_pin: z:P1.27 +# Z-position of nozzle (in mm) to z-endstop trigger point relative to print surface (Z0) +# (+) value = endstop above Z0, (-) value = endstop below +# Increasing position_endstop brings nozzle closer to the bed +# After you run Z_ENDSTOP_CALIBRATE, position_endstop will be stored at the very end of your config +#position_endstop: -0.5 +position_max: 320 +position_min: -1 +homing_speed: 15.0 +second_homing_speed: 3.0 +homing_retract_dist: 2.0 + +# Z MCU - Y -> Z1 Stepper - Rear Left +[stepper_z1] +step_pin: z:P0.19 +# TMC2209 dir_pin: z:P0.20 +dir_pin: !z:P0.20 +enable_pin: !z:P2.8 +full_steps_per_rotation: 400 +microsteps: 32 +gear_ratio: 80:16 +rotation_distance: 40 + +# Z MCU - Z -> Z2 Stepper - Rear Right +[stepper_z2] +step_pin: z:P0.22 +# TMC2209 dir_pin: !z:P2.11 +dir_pin: z:P2.11 +enable_pin: !z:P0.21 +full_steps_per_rotation: 400 +microsteps: 32 +gear_ratio: 80:16 +rotation_distance: 40 + +# Z MCU - E0 -> Z3 Stepper - Front Right +[stepper_z3] +step_pin: z:P2.13 +# TMC2209 dir_pin: z:P0.11 +dir_pin: !z:P0.11 +enable_pin: !z:P2.12 +full_steps_per_rotation: 400 +microsteps: 32 +gear_ratio: 80:16 +rotation_distance: 40 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/tmc.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/tmc.cfg new file mode 100644 index 000000000..958c1bf87 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/tmc.cfg @@ -0,0 +1,163 @@ +##################################################################### +# TMC Definitions of all steppers +##################################################################### +[tmc5160 stepper_x] +cs_pin: P1.10 +spi_software_miso_pin: P0.5 +spi_software_mosi_pin: P1.17 +spi_software_sclk_pin: P0.4 +interpolate: true +run_current: 0.875 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +[tmc5160 stepper_y] +cs_pin: P1.9 +spi_software_miso_pin: P0.5 +spi_software_mosi_pin: P1.17 +spi_software_sclk_pin: P0.4 +interpolate: true +run_current: 0.875 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +[tmc5160 stepper_z] +cs_pin: z:P1.10 +spi_software_miso_pin: z:P0.5 +spi_software_mosi_pin: z:P1.17 +spi_software_sclk_pin: z:P0.4 +interpolate: true +run_current: 1.1 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +[tmc5160 stepper_z1] +cs_pin: z:P1.9 +spi_software_miso_pin: z:P0.5 +spi_software_mosi_pin: z:P1.17 +spi_software_sclk_pin: z:P0.4 +interpolate: true +run_current: 1.1 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +[tmc5160 stepper_z2] +cs_pin: z:P1.8 +spi_software_miso_pin: z:P0.5 +spi_software_mosi_pin: z:P1.17 +spi_software_sclk_pin: z:P0.4 +interpolate: true +run_current: 1.1 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +[tmc5160 stepper_z3] +cs_pin: z:P1.4 +spi_software_miso_pin: z:P0.5 +spi_software_mosi_pin: z:P1.17 +spi_software_sclk_pin: z:P0.4 +interpolate: true +run_current: 1.1 +sense_resistor: 0.075 +stealthchop_threshold: 0 + +#[tmc2209 stepper_x] +#uart_pin: P1.10 +#interpolate: true +#run_current: 0.875 +#hold_current: 0.7 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 3 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 9 + +#[tmc2209 stepper_y] +#uart_pin: P1.9 +#interpolate: true +#run_current: 0.875 +#hold_current: 0.7 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 2 +#driver_TOFF: 3 +#driver_HEND: 3 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 9 + +#[tmc2209 stepper_z] +#uart_pin: z:P1.10 +#interpolate: true +#run_current: 1.1 +#hold_current: 1.1 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 0 +#driver_TOFF: 7 +#driver_HEND: 2 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 10 + +#[tmc2209 stepper_z1] +#uart_pin: z:P1.9 +#interpolate: true +#run_current: 1.1 +#hold_current: 1.1 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 0 +#driver_TOFF: 7 +#driver_HEND: 3 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 10 + +#[tmc2209 stepper_z2] +#uart_pin: z:P1.8 +#interpolate: False +#interpolate: true +#run_current: 1.1 +#hold_current: 1.1 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 0 +#driver_TOFF: 7 +#driver_HEND: 2 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 10 + +#[tmc2209 stepper_z3] +#uart_pin: z:P1.4 +#interpolate: true +#run_current: 1.1 +#hold_current: 1.1 +#sense_resistor: 0.110 +#stealthchop_threshold: 1 +#driver_TBL: 0 +#driver_TOFF: 7 +#driver_HEND: 2 +#driver_HSTRT: 0 +#driver_PWM_GRAD: 8 +#driver_PWM_LIM: 10 + + +[tmc2209 extruder] +############### Different Clockworks Setups ############### +## Afterburner: Stepper Motor 0.9 step distance 0.00120 calibrated 0.001196 +## run_current: 0.6 +############################################################ +## Galileo: Stepper Motor 1.8 step distance 0.00132 calibrated 0,001320975 +## run_current: 0.25 +############### Different Clockworks Setups ############### +uart_pin: P1.4 +interpolate: false +run_current: 0.25 +hold_current: 0.1 +sense_resistor: 0.110 +stealthchop_threshold: 0 \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/webclient.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/webclient.cfg new file mode 100644 index 000000000..44216d3ed --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/webclient.cfg @@ -0,0 +1,109 @@ +[pause_resume] + +[display_status] + +[respond] +default_type: echo +# Sets the default prefix of the "M118" and "RESPOND" output to one +# of the following: +# echo: "echo: " (This is the default) +# command: "// " +# error: "!! " +#default_prefix: echo: +# Directly sets the default prefix. If present, this value will +# override the "default_type". + +##################################################################### +# Macros +##################################################################### +[gcode_macro CANCEL_PRINT] +description: Cancel the actual running print +rename_existing: CANCEL_PRINT_BASE +variable_execute: False +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set filter_off = user.peripheral.filter.run_after_print %} + {% set vent_on = user.peripheral.vent.on_val %} + {% set vent_off = user.peripheral.vent.run_after_print %} + {% set retract = user.filament.retract.end if not printer.pause_resume.is_paused + else user.filament.retract.cancel %} + SET_GCODE_VARIABLE MACRO=CANCEL_PRINT VARIABLE=execute VALUE=True + M117 Cancel + CANCEL_PRINT_BASE + {% if printer['gcode_macro PRINT_START'].state == 'Prepare' %} + {% if not printer.extruder.can_extrude %} + {action_respond_info("Extruder Temp to low heat to %3.1f°C" % printer.configfile.settings.extruder.min_extrude_temp)} + M109 S{printer.configfile.settings.extruder.min_extrude_temp} + {% endif %} + M83 + G1 E-{retract} F{user.speed.retract} + {% endif %} + TURN_OFF_HEATERS + {% if params.PARK|default(0)|int == 1 or (not printer.pause_resume.is_paused and user.park.park_at_cancel) %} + _TOOLHEAD_PARK P={params.PARK|default(0)} X={user.park.pause.x} Y={user.park.pause.y} + {% endif %} + M107 ; turn off fan + {% if user.hw.chamber.fan %} M141 S{vent_on} {% endif %} ; vent chamber (setting fan to below ambient) + _ADD_PRINT_TIME + {% if params.ERROR|default(0)|int == 1 %} + {% if user.hw.display.ena %} _LCD_KNOB COLOR=RED BLINK=0.2 {% endif %} + _SD_PRINT_STATS R='abort' + {% else %} + {% if user.hw.display.ena %} _LCD_KNOB COLOR=BLUE {% endif %} + _SD_PRINT_STATS R='canceled' + {% endif %} + _SD_PRINTER_STATS + {% if user.hw.caselight.ena %} _CASELIGHT_OFF {% endif %} + {% if user.hw.chamber.fan %} UPDATE_DELAYED_GCODE ID=_DELAY_VENT_OFF DURATION={vent_off} {% endif %} + {% if user.hw.filter.ena %} UPDATE_DELAYED_GCODE ID=_DELAY_FILTER_OFF DURATION={filter_off} {% endif %} + {% if user.unload_sd %} UPDATE_DELAYED_GCODE ID=_DELAY_SDCARD_RESET_FILE DURATION=10 {% endif %} + UPDATE_DELAYED_GCODE ID=_CLEAR_DISPLAY DURATION=10 + +[gcode_macro PAUSE] +description: Pause the actual running print +rename_existing: PAUSE_BASE +variable_restore: {'absolute': {'coordinates': True, 'extrude': True}, 'speed': 1500} +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + ##### store coordinates to restore them at resume ##### + {% set restore = {'absolute': {'coordinates': printer.gcode_move.absolute_coordinates, + 'extrude' : printer.gcode_move.absolute_extrude}, + 'speed' : printer.gcode_move.speed} %} + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=restore VALUE="{restore}" + {% if user.hw.display.ena %} _LCD_KNOB COLOR=BLUE BLINK=1 {% endif %} + {% if not printer.extruder.can_extrude %} + {action_respond_info("Extruder Temp to low heat to %3.1f°C" % printer.configfile.settings.extruder.min_extrude_temp)} + M109 S{printer.configfile.settings.extruder.min_extrude_temp} + {% endif %} + M83 + G0 E-{user.filament.retract.pause} F{user.speed.retract} + PAUSE_BASE + _TOOLHEAD_PARK P=0 X={params.X|default(user.park.pause.x)} Y={params.Y|default(user.park.pause.y)} + M104 S{printer.extruder.target} + +[gcode_macro _TOOLHEAD_PARK] +description: Helper: Park toolhead used in PAUSE and CANCEL_PRINT +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set pos = {'x': user.park.bed.x if params.P|int == 1 + else params.X, + 'y': user.park.bed.y if params.P|int == 1 + else params.Y, + 'z': user.park.bed.z if params.P|int == 1 + else [(printer.toolhead.position.z + user.park.pause.dz), printer.toolhead.axis_maximum.z]|min} %} + G90 + G0 Z{pos.z} F{user.speed.z_hop} + G0 X{pos.x} Y{pos.y} F{user.speed.travel} + +[gcode_macro RESUME] +description: Resume the actual running print +rename_existing: RESUME_BASE +gcode: + {% set user = printer['gcode_macro _USER_VARIABLE'] %} + {% set restore = printer["gcode_macro PAUSE"].restore %} + {% if user.hw.display.ena %} _LCD_KNOB COLOR=RED {% endif %} + RESUME_BASE VELOCITY={params.VELOCITY|default(user.speed.travel/60)} + G0 E{user.filament.retract.pause} F{user.speed.retract} + G0 F{restore.speed} + {% if restore.absolute.extrude %} M82 {% endif %} ; set back to absolute + {% if not restore.absolute.coordinates %} G91 {% endif %} ; set back to relative \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/z_calibration.cfg b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/z_calibration.cfg new file mode 100644 index 000000000..a58aeceed --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs/z_calibration.cfg @@ -0,0 +1,77 @@ +##################################################################### +# Z Calibration +##################################################################### +[z_calibration] +# The X and Y coordinates (in mm) for clicking the nozzle on the +# Z endstop. +nozzle_xy_position: 123,355 +# The X and Y coordinates (in mm) for clicking the probe's switch +# on the Z endstop. +switch_xy_position: 123,350 +# The X and Y coordinates (in mm) for probing on the print surface +# (e.g. the center point) These coordinates will be adapted by the +# probe's X and Y offsets. The default is the relative_reference_index +# of the configured bed_mesh. It will raise an error if there is no +# probe_bed site and no bed_mesh with a relative_reference_index +# configured. +bed_xy_position: 175,175 +# The trigger point offset of the used mag-probe switch. +# This needs to be fined out manually. +# A smaller value is more away from bed +switch_offset: 0.475 +# The maximum allowed deviation of the calculated offset. +# If the offset exceeds this value, it will stop! +# The default is 1.0 mm. +max_deviation: 2.0 +# The number of times to probe each point. The probed z-values +# will be averaged. The default is from the probe's configuration. +#samples: default from "probe:samples" section +# The maximum Z distance (in mm) that a sample may differ from other +# samples. The default is from the probe's configuration. +#samples_tolerance: default from "probe:samples_tolerance" section +# The number of times to retry if a sample is found that exceeds +# samples_tolerance. The default is from the probe's configuration. +#samples_tolerance_retries: default from "probe:samples_tolerance_retries" section +# The calculation method when sampling more than once - either +# "median" or "average". The default is from the probe's configuration. +#samples_result: default from "probe:samples_result" section +# The distance in mm to move up before moving to the next +# position. The default is two times the z_offset from the probe's +# configuration. +clearance: 2 +#position_min: default from "stepper_z:position_min" section. +# The moving speed in X and Y. The default is 50 mm/s. +speed: 300 +# Speed (in mm/s) of the Z axis when lifting the probe between +# samples and clearance moves. The default is from the probe's +# configuration. +#lift_speed: default from "probe:lift_speed" section +# The fast probing speed (in mm/s) used, when probing_first_fast +# is activated. The default is from the Z rail configuration. +#probing_speed: default from "stepper_z:homing_speed" section. +# The slower speed (in mm/s) for probing the recorded samples. +# The default is second_homing_speed of the Z rail configuration. +#probing_second_speed: default from "stepper_z:second_homing_speed" section. +# Distance to backoff (in mm) before probing the next sample. +# The default is homing_retract_dist from the Z rail configuration. +#probing_retract_dist: default from "stepper_z:homing_retract_dist" section. +# If true, the first probing is done faster by the probing speed. +# This is to get faster down and the result is not recorded as a +# probing sample. The default is false. +probing_first_fast: true +# A list of G-Code commands to execute prior to each calibration command. +# See docs/Command_Templates.md for G-Code format. This can be used to +# attach the probe. +start_gcode: _SET_Z_CURRENT VAL=HOME + DETACH_PROBE +# A list of G-Code commands to execute prior to each probing on the +# mag-probe. See docs/Command_Templates.md for G-Code format. This can be +# used to attach the probe after probing on the nozzle and before probing +# on the mag-probe. +before_switch_gcode: ATTACH_PROBE + G0 Z20 +# A list of G-Code commands to execute after each calibration command. +# See docs/Command_Templates.md for G-Code format. This can be used to +# detach the probe afterwards. +end_gcode: _SET_Z_CURRENT + DETACH_PROBE \ No newline at end of file diff --git a/src/plugins/Codemirror/KlipperCfgLang/testParser/testKlipperCfgParser.js b/src/plugins/Codemirror/KlipperCfgLang/testParser/testKlipperCfgParser.js new file mode 100644 index 000000000..03c388da5 --- /dev/null +++ b/src/plugins/Codemirror/KlipperCfgLang/testParser/testKlipperCfgParser.js @@ -0,0 +1,27 @@ +import { parser } from '../dist/klipperCfgParser.cjs' +import { fileTestsParser } from '../../mochaFileTests.js' +import * as fs from 'fs' +import * as path from 'path' + +const caseDir = 'src/plugins/Codemirror/KlipperCfgLang/testParser/test-cases' +const testConfigsDir = 'src/plugins/Codemirror/KlipperCfgLang/testParser/test-configs' + +for (let file of fs.readdirSync(caseDir)) { + if (!/\.txt$/.test(file)) continue + + let result = /^[^.]+/.exec(file) + let name = result ? result[0] : 'default-name' + describe(name, () => { + for (let { name, run } of fileTestsParser(fs.readFileSync(path.join(caseDir, file), 'utf8'), file)) + it(name, () => run(parser)) + }) +} + +for (let file of fs.readdirSync(testConfigsDir)) { + let result = /^[^.]+/.exec(file) + let name = result ? result[0] : 'default-name' + describe(name, () => { + for (let { name, run } of fileTestsParser(fs.readFileSync(path.join(testConfigsDir, file), 'utf8'), file, true)) + it(name, () => run(parser)) + }) +} diff --git a/src/plugins/Codemirror/mochaFileTests.ts b/src/plugins/Codemirror/mochaFileTests.ts new file mode 100644 index 000000000..40162fc81 --- /dev/null +++ b/src/plugins/Codemirror/mochaFileTests.ts @@ -0,0 +1,116 @@ +import { Parser } from '@lezer/common' +import { testTree } from '@lezer/generator/dist/test' +import { Diagnostic } from '@codemirror/lint' +import { EditorView } from '@codemirror/view' +import { EditorState } from '@codemirror/state' + +function toLineContext(file: string, index: number) { + const endEol = file.indexOf('\n', index + 80) + + const endIndex = endEol === -1 ? file.length : endEol + + return file + .substring(index, endIndex) + .split(/\n/) + .map((str) => ' | ' + str) + .join('\n') +} + +function getLineNumber(text: string, index: number) { + const substring = text.substring(0, index) + const newLineRegex = /\n/g + const lineCount = (substring.match(newLineRegex) || []).length + 1 + return lineCount +} + +export function fileTestsParser(file: string, fileName: string, onlyNoError = false) { + const caseExpr = /\s*#[ \t]*(.*)(?:\r\n|\r|\n)([^]*?)==+>([^]*?)(?:$|(?:\r\n|\r|\n)+(?=#))/gy + const tests: { + name: string + text: string + expected: string + run(parser: Parser): void + }[] = [] + let lastIndex = 0 + if (onlyNoError) { + tests.push({ + name: fileName, + text: file, + expected: 'no parsing errors', + run(parser: Parser) { + parser + .parse(file) + .cursor() + .iterate((node) => { + if (node.type.isError) { + let msg = 'Parse error at line ' + getLineNumber(file, node.from) + ': ' + const parseError = '"' + file.slice(node.from, node.to) + '" ' + if (parseError.length > 100) msg += parseError.slice(0, 100) + '...' + else msg += parseError + const context = + '\n\t(context: ' + JSON.stringify(file.slice(node.from - 10, node.to + 10)) + ')' + msg += context.length > 100 ? context.slice(0, 100) + '...' : context + throw new Error(msg) + } + }) + }, + }) + } else { + for (;;) { + const m = caseExpr.exec(file) + if (!m) throw new Error(`Unexpected file format in ${fileName} around\n\n${toLineContext(file, lastIndex)}`) + + const text = m[2] + const expected = m[3].trim() + const [, name] = /(.*?)(\{.*?\})?$/.exec(m[1])! + + if (expected == 'error') { + tests.push({ + name, + text, + expected: 'error while parsing', + run(parser: Parser) { + let parsingError = false + parser + .parse(text) + .cursor() + .iterate((node) => { + if (node.type.isError) parsingError = true + }) + if (!parsingError) throw new Error('Parsed without error, but error was expected!') + }, + }) + } else { + const strict = !/⚠|\.\.\./.test(expected) + tests.push({ + name, + text, + expected, + run(parser: Parser) { + if ((parser as any).configure && strict) parser = (parser as any).configure({ strict }) + testTree(parser.parse(text), expected) + }, + }) + } + lastIndex = m.index + m[0].length + if (lastIndex == file.length) break + } + } + return tests +} + +export interface LintTest { + name: string + input: EditorView + expected: Diagnostic[] +} + +export function createEditorView(inputText: string) { + const startState = EditorState.create({ + doc: inputText, + }) + return new EditorView({ + state: startState, + parent: document.body, + }) +} \ No newline at end of file diff --git a/src/plugins/Codemirror/package.json b/src/plugins/Codemirror/package.json new file mode 100644 index 000000000..94a2534f1 --- /dev/null +++ b/src/plugins/Codemirror/package.json @@ -0,0 +1,11 @@ +{ + "name": "@lezer/klippercfg", + "version": "1.0", + "description": "Lezer-based grammar for Klipper Configuration", + "main": "dist/klipperCfgParser.cjs", + "type": "module", + "exports": { + "import": "./dist/klipperCfgParser.es.js", + "require": "./dist/klipperCfgParser.cjs" + } +} diff --git a/src/plugins/Codemirror/parseErrorLint.ts b/src/plugins/Codemirror/parseErrorLint.ts new file mode 100644 index 000000000..ae717f6f5 --- /dev/null +++ b/src/plugins/Codemirror/parseErrorLint.ts @@ -0,0 +1,19 @@ +import { syntaxTree } from '@codemirror/language' +import { linter, Diagnostic } from '@codemirror/lint' + +export const parseErrorLint = linter((view) => { + const diagnostics: Diagnostic[] = [] + syntaxTree(view.state) + .cursor() + .iterate((node) => { + if (node.type.isError) { + diagnostics.push({ + from: node.from, + to: node.to, + severity: 'error', + message: 'Parse error: ' + JSON.stringify(view.state.sliceDoc(node.from, node.to)), + }) + } + }) + return diagnostics +}) diff --git a/src/plugins/Codemirror/printLezerTree.ts b/src/plugins/Codemirror/printLezerTree.ts new file mode 100644 index 000000000..dd486e9de --- /dev/null +++ b/src/plugins/Codemirror/printLezerTree.ts @@ -0,0 +1,231 @@ +// MIT License +// +// Copyright (c) 2021 Matthijs Steen +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +import { Text } from '@codemirror/state' +import { Input, NodeType, SyntaxNode, Tree, TreeCursor } from '@lezer/common' + +class StringInput implements Input { + constructor(private readonly input: string) {} + + get length() { + return this.input.length + } + + chunk(from: number): string { + return this.input.slice(from) + } + + lineChunks = false + + read(from: number, to: number): string { + return this.input.slice(from, to) + } +} + +export function sliceType(cursor: TreeCursor, input: Input, type: number): string | null { + if (cursor.type.id === type) { + const s = input.read(cursor.from, cursor.to) + cursor.nextSibling() + return s + } + return null +} + +export function isType(cursor: TreeCursor, type: number): boolean { + const cond = cursor.type.id === type + if (cond) cursor.nextSibling() + return cond +} + +export type CursorNode = { type: NodeType; from: number; to: number; isLeaf: boolean } + +function cursorNode({ type, from, to }: TreeCursor, isLeaf = false): CursorNode { + return { type, from, to, isLeaf } +} + +export type TreeTraversal = { + beforeEnter?: (cursor: TreeCursor) => void + onEnter: (node: CursorNode) => false | void + onLeave?: (node: CursorNode) => false | void +} + +type TreeTraversalOptions = { + from?: number + to?: number + includeParents?: boolean +} & TreeTraversal + +export function traverseTree( + cursor: TreeCursor | Tree | SyntaxNode, + { from = -Infinity, to = Infinity, includeParents = false, beforeEnter, onEnter, onLeave }: TreeTraversalOptions +): void { + if (!(cursor instanceof TreeCursor)) cursor = cursor instanceof Tree ? cursor.cursor() : cursor.cursor + if (!(cursor instanceof TreeCursor)) return + for (;;) { + let node = cursorNode(cursor) + let leave = false + if (node.from <= to && node.to >= from) { + const enter = !node.type.isAnonymous && (includeParents || (node.from >= from && node.to <= to)) + if (enter && beforeEnter) beforeEnter(cursor) + node.isLeaf = !cursor.firstChild() + if (enter) { + leave = true + if (onEnter(node) === false) return + } + if (!node.isLeaf) continue + } + for (;;) { + node = cursorNode(cursor, node.isLeaf) + if (leave && onLeave) if (onLeave(node) === false) return + leave = cursor.type.isAnonymous + node.isLeaf = false + if (cursor.nextSibling()) break + if (!cursor.parent()) return + leave = true + } + } +} + +function isChildOf(child: CursorNode, parent: CursorNode): boolean { + return child.from >= parent.from && child.from <= parent.to && child.to <= parent.to && child.to >= parent.from +} + +export function validatorTraversal(input: Input | string, { fullMatch = true }: { fullMatch?: boolean } = {}) { + if (typeof input === 'string') input = new StringInput(input) + const state = { + valid: true, + parentNodes: [] as CursorNode[], + lastLeafTo: 0, + } + return { + state, + traversal: { + onEnter(node) { + state.valid = true + if (!node.isLeaf) state.parentNodes.unshift(node) + if (node.from > node.to || node.from < state.lastLeafTo) { + state.valid = false + } else if (node.isLeaf) { + if (state.parentNodes.length && !isChildOf(node, state.parentNodes[0])) state.valid = false + state.lastLeafTo = node.to + } else { + if (state.parentNodes.length) { + if (!isChildOf(node, state.parentNodes[0])) state.valid = false + } else if (fullMatch && (node.from !== 0 || node.to !== input.length)) { + state.valid = false + } + } + }, + onLeave(node) { + if (!node.isLeaf) state.parentNodes.shift() + }, + } as TreeTraversal, + } +} + +export function validateTree( + tree: TreeCursor | Tree | SyntaxNode, + input: Input | string, + options?: { fullMatch?: boolean } +): boolean { + const { state, traversal } = validatorTraversal(input, options) + traverseTree(tree, traversal) + return state.valid +} + +enum Color { + Red = 31, + Green = 32, + Yellow = 33, +} + +function colorize(value: any, color: number): string { + return /* "\u001b[" + color + "m" + */ String(value) /* + "\u001b[39m" */ +} + +type PrintTreeOptions = { from?: number; to?: number; start?: number; includeParents?: boolean } + +export function printTree( + cursor: TreeCursor | Tree | SyntaxNode, + input: Input | string, + { from, to, start = 0, includeParents }: PrintTreeOptions = {} +): string { + const inp = typeof input === 'string' ? new StringInput(input) : input + const text = Text.of(inp.read(0, inp.length).split('\n')) + const state = { + output: '', + prefixes: [] as string[], + hasNextSibling: false, + } + const validator = validatorTraversal(inp) + traverseTree(cursor, { + from, + to, + includeParents, + beforeEnter(cursor) { + state.hasNextSibling = cursor.nextSibling() && cursor.prevSibling() + }, + onEnter(node) { + validator.traversal.onEnter(node) + const isTop = state.output === '' + const hasPrefix = !isTop || node.from > 0 + if (hasPrefix) { + state.output += (!isTop ? '\n' : '') + state.prefixes.join('') + if (state.hasNextSibling) { + state.output += ' ├─ ' + state.prefixes.push(' │ ') + } else { + state.output += ' └─ ' + state.prefixes.push(' ') + } + } + const hasRange = node.from !== node.to + state.output += + (node.type.isError || !validator.state.valid ? colorize(node.type.name, Color.Red) : node.type.name) + + ' ' + + (hasRange + ? '[' + + colorize(locAt(text, start + node.from), Color.Yellow) + + '..' + + colorize(locAt(text, start + node.to), Color.Yellow) + + ']' + : colorize(locAt(text, start + node.from), Color.Yellow)) + if (hasRange && node.isLeaf) { + state.output += ': ' + colorize(JSON.stringify(inp.read(node.from, node.to)), Color.Green) + } + }, + onLeave(node) { + validator.traversal.onLeave!(node) + state.prefixes.pop() + }, + }) + return state.output +} + +function locAt(text: Text, pos: number): string { + const line = text.lineAt(pos) + return line.number + ':' + (pos - line.from) +} + +export function logTree(tree: TreeCursor | Tree | SyntaxNode, input: string, options?: PrintTreeOptions): void { + console.log(printTree(tree, input, options)) +}