Skip to content

Commit 63d3f99

Browse files
committed
Update extended_macro readme
1 parent 0565c05 commit 63d3f99

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

extended_macro/readme.md

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,39 @@
11
# extended_macro
22
---
33
* Allow the use of custom Python functions in your Klipper macros by defining the functions in a YAML config file
4+
* By default includes many additional modules and functions. See below for more information.
45
* Functions can accept parameters and return values to the macro.
56

67
### WARNING:
78

89
**Do not blindly download Python scripts, both for use in your macros and this script itself.** Read the script and ensure you understand what is going on. The scripts can be powerful and useful, but they can also be dangerous. If the script looks questionable, dangerous, or too confusing, it's better to assume that it is malicious.
910

1011
**Installation:**
11-
1. Clone this repository or download both `extended_macro.py` and `extended_template.py`
12-
2. Locate where the `klippy-env` directory is on your Klipper instance.
13-
3. Run the following command, substituting `~/klippy-env/` with the location found above:
12+
1. Write down the location of the following directories:
13+
* Klipper Extras: Usually located at `/home/USER/klipper/klippy/extras`.
14+
* Klippy Virtual Environment `bin` directory: Usually located at `/home/USER/klippy/bin`
15+
2. Clone this repository or download `extended_macro.py`, `extended_template.py`, and `requirements.txt`
16+
3. Move `extended_macro.py` and `extended_template.py` to your Klipper Extras folder.
17+
4. Move `requirements.txt` to your home directory.
18+
5. Run the following command, substituting `${KLIPPY_ENV}` with the Klippy Virtual Environment bin directory:
1419

15-
`~/klippy-env/bin/python -m pip install pyyaml==3.1.4`
16-
17-
4. Finally, move `extended_macro.py` and `extended_template.py` to your Klippy Extras file. This usually is located at `~/klipper/klippy/extras`.
20+
```
21+
${KLIPPY_ENV}/pip install -r ${HOME}/requirements.txt
22+
```
1823

1924
---
2025
**Setup:**
2126

22-
See the examples folder for more guidance.
27+
1. In your Klipper config, add the following section:
28+
```
29+
[extended_template]
30+
```
31+
32+
---
33+
**Adding your own Python functions**
34+
35+
*See the examples folder for more guidance.*
36+
2337
1. Create your Python script(s) with the function(s) you intend to use.
2438
2. Create a function configuration file using `example/function_config.yaml` as reference. YAML is the allowed schema. The extension must be `yml` or `yaml`
2539
3. In your Klipper config, add the `[extended_template]` section to define the location of your function config file.
@@ -29,4 +43,41 @@ See the examples folder for more guidance.
2943

3044
See the examples folder for more guidance.
3145

32-
When defining the macro, use `extended_macro` as the config name instead of `gcode_macro`. To use your function, you will wrap the name with curly brackets (`{gcode_function_name_goes_here}`).
46+
When defining the macro, use `extended_macro` as the config name instead of `gcode_macro`. To use your function, you will wrap the name with curly brackets (`{gcode_function_name_goes_here}`).
47+
48+
---
49+
**Defaults**
50+
51+
`extended_macro` comes with many default functions which do not need to be added or declared by the user. These include:
52+
53+
*Types:*
54+
```
55+
list
56+
dict
57+
set
58+
tuple
59+
str
60+
int
61+
float
62+
bool
63+
type
64+
```
65+
66+
*Built-ins:*
67+
```
68+
dir
69+
getattr
70+
setattr
71+
locals
72+
globals
73+
math
74+
itertools
75+
```
76+
77+
*Additional:*
78+
```
79+
pandas
80+
numpy
81+
datetime
82+
collections
83+
```

0 commit comments

Comments
 (0)