Skip to content

Commit 4bdf684

Browse files
authored
klipper: rework tools image (#244)
* klipper: clean up tools stage * remove redundant copy statements * add requirements file for tools stage * set path to use venv by default * remove calibrate-shaper and rename make * add symlink for klippy-env * update docs * docs: update changelog
1 parent b82acdd commit 4bdf684

File tree

6 files changed

+56
-25
lines changed

6 files changed

+56
-25
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
<!--
88
## [Unreleased]
9+
10+
A helper script has been introduced to simplify builds and interacting with klipper scripts.
11+
If you're already using prind, simply run the following command and you'll be able to follow the instructions in the README again.
12+
13+
```bash
14+
cd prind
15+
16+
cat <<EOF | sudo install /dev/stdin /usr/local/bin/prind-tools
17+
#!/bin/sh
18+
docker compose -f $(pwd)/docker-compose.extra.tools.yaml run --rm tools "\$@"
19+
EOF
20+
```
21+
922
### Added
23+
* docs: new `prind-tools` wrapper script
24+
* `docker-compose.extra.tools.yaml` used by `prind-tools` script
25+
* klipper: add a symlink to provide the venv at ${HOME}/klippy-env in the tools image #241
1026
### Fixed
1127
### Changed
28+
* docs: update build to use `prind-tools`
29+
* docs: update calibrate shaper to use `prind-tools`
1230
### Removed
31+
* `docker-compose.extra.make.yaml` and `docker-compose.extra.calibrate-shaper.yaml` have been consolidated into `docker-compose.extra.tools.yaml`
32+
* klipper: remove redundant copy statements from tools image after #242
1333
1434
**Full Changelog**: https://github.com/mkuf/prind/compare/v1.18.0...vX.X.X
1535
-->

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,41 @@ Follow the official guides to install and set them up:
3737
* [Install Docker Compose v2](https://docs.docker.com/compose/cli-command/#installing-compose-v2)
3838

3939
Clone this repository onto your Docker host using Git:
40-
```
40+
```bash
4141
git clone https://github.com/mkuf/prind
4242
```
43+
44+
Install the `prind-tools` helper script.
45+
```bash
46+
cd prind
47+
48+
cat <<EOF | sudo install /dev/stdin /usr/local/bin/prind-tools
49+
#!/bin/sh
50+
docker compose -f $(pwd)/docker-compose.extra.tools.yaml run --rm tools "\$@"
51+
EOF
52+
```
53+
4354
Unless otherwise specified, all commands mentioned in the documentation should be run from the root of the repository.
4455

4556
### Build the MCU Code
4657
Before using Klipper, you'll have to build and flash the microcontroller-code for your printers mainboard.
47-
As this can be accomplished via docker, we can create an alias that replaces `make` with the appropriate docker compose command. After setting this alias, follow the Instructions on finding your printer, building and flashing the microcontroller found in the [Klipper Docs](https://www.klipper3d.org/Installation.html#building-and-flashing-the-micro-controller).
58+
This can be done in a container by calling the build commands via `prind-tools`.
59+
Follow the Instructions on finding your printer, building and flashing the microcontroller found in the [Klipper Docs](https://www.klipper3d.org/Installation.html#building-and-flashing-the-micro-controller).
4860

4961
Adapted from the official Docs, a generic Build would look like this.
62+
```bash
63+
prind-tools "make menuconfig"
64+
prind-tools "make"
65+
prind-tools "make flash FLASH_DEVICE=/dev/serial/by-id/<my printer>"
5066
```
51-
alias make="docker compose -f docker-compose.extra.make.yaml run --rm make"
5267

53-
make menuconfig
54-
make
55-
make flash FLASH_DEVICE=/dev/serial/by-id/<my printer>
68+
If your Board can be flashed via SD-Card, you can also use the `flash-sdcard.sh` script provided by klipper
69+
70+
```bash
71+
prind-tools "scripts/flash-sdcard.sh <device> <board>"
5672
```
5773

58-
If your Board can be flashed via SD-Card, you may want to omit `make flash` and retrieve the `klipper.bin` from the `out` directory that is created by `make`. Follow your boards instructions on how to proceed with flashing via SD-Card.
74+
If no official flash method is available, you can retrieve the `klipper.bin` from the `out` directory that is created by `make` and Follow your boards instructions on how to proceed with flashing.
5975

6076
### Add your Configuration to docker-compose.override.yaml
6177
Locate the `webcam` Service within `docker-compose.override.yaml` and update the `device` Section with the Device Name of your Webcam.
@@ -279,16 +295,13 @@ docker compose cp klipper:/tmp/resonances_x_20220708_124515.csv ./resonances/
279295
docker compose cp klipper:/tmp/resonances_y_20220708_125150.csv ./resonances/
280296
```
281297

282-
`docker-compose.extra.calibrate-shaper.yaml` is set up to run `calibrate_shaper.py`, so any options supported by the script can also be used with the container.
283-
Set an alias to save yourself from typing the the docker compose command multiple times. The generated Images are located besides the csv files in `./resonances`
298+
To analyze the generated files, call `calibrate_shaper.py` via `prind-tools`
284299
```
285-
alias calibrate_shaper="docker compose -f docker-compose.extra.calibrate-shaper.yaml run --rm calibrate_shaper"
286-
287-
calibrate_shaper resonances_x_20220708_124515.csv -o cal_x.png
300+
prind-tools "scripts/calibrate_shaper.py resonances/resonances_x_20220708_124515.csv -o resonances/cal_x.png"
288301
[...]
289302
Recommended shaper is ei @ 90.2 Hz
290303
291-
calibrate_shaper resonances_y_20220708_125150.csv -o cal_y.png
304+
prind-tools "scripts/calibrate_shaper.py resonances/resonances_y_20220708_125150.csv -o resonances/cal_y.png"
292305
[...]
293306
Recommended shaper is mzv @ 48.2 Hz
294307
```

docker-compose.extra.calibrate-shaper.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
services:
2-
make:
2+
tools:
33
image: mkuf/klipper:${TAG:-latest}-tools
44
tty: true
55
privileged: true
6-
entrypoint: make
6+
entrypoint: bash -c
77
working_dir: /opt/klipper
88
volumes:
99
- /dev:/dev
1010
- ./config/build.config:/opt/klipper/.config
1111
- ./out:/opt/klipper/out
12+
- ./resonances:/opt/klipper/resonances

docker/klipper/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ RUN apt update \
6363
avrdude gcc-avr binutils-avr avr-libc \
6464
stm32flash dfu-util libnewlib-arm-none-eabi \
6565
gcc-arm-none-eabi binutils-arm-none-eabi libusb-1.0-0 libusb-1.0-0-dev \
66-
python3-numpy python3-matplotlib \
6766
&& apt clean
6867

69-
COPY --from=build /opt/klipper ./klipper
70-
COPY --from=build /opt/venv ./venv
68+
COPY requirements-prind-tools.txt .
69+
RUN venv/bin/pip install -r requirements-prind-tools.txt
70+
71+
RUN ln -s /opt/venv /root/klippy-env
72+
ENV PATH=/opt/venv/bin:$PATH
7173
ENTRYPOINT ["/usr/bin/bash"]
7274
###
7375

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy
2+
matplotlib

0 commit comments

Comments
 (0)