77 lines
1.9 KiB
Markdown
77 lines
1.9 KiB
Markdown
# p5-wallplotter
|
|
|
|
p5.js library for a Marlin polargraph (wall plotter) over Web Serial, plus a zigzag example.
|
|
|
|
**Anleitung** (Download, Linux/Windows/macOS, USB, Marlin/G-code): [tutorial.md](tutorial.md). Hardware: [hardware.md](hardware.md). G-code: [gcode.md](gcode.md).
|
|
|
|
```
|
|
p5-wallplotter/
|
|
├── tutorial.md # setup + plotter + G-code
|
|
├── hardware.md # motors, board, geometry
|
|
├── gcode.md # G-code used by this setup
|
|
├── lib/
|
|
│ ├── WallPlotter.js # library
|
|
│ ├── README.md # short intro + example
|
|
│ └── doc.md # full API
|
|
└── examples/
|
|
├── zickzack/ # example sketch
|
|
└── rechteck/ # rectangle sketch
|
|
```
|
|
|
|
## Run the example
|
|
|
|
Chrome or Edge. Serve over localhost (Web Serial does not work from `file://`).
|
|
|
|
```bash
|
|
cd p5-wallplotter
|
|
python -m http.server 8080
|
|
```
|
|
|
|
Open http://localhost:8080/examples/zickzack/
|
|
|
|
Press **C** to connect, **H** to set home, then **Test** (preview) or **Plot** (send G-code).
|
|
|
|
## Use in a sketch
|
|
|
|
```html
|
|
<script src="https://cdn.jsdelivr.net/npm/p5@1.11.3/lib/p5.min.js"></script>
|
|
<script src="../../lib/WallPlotter.js"></script>
|
|
<script src="sketch.js"></script>
|
|
```
|
|
|
|
```javascript
|
|
let wp;
|
|
|
|
function setup() {
|
|
createCanvas(windowWidth, windowHeight).parent('sketch-host');
|
|
wp = new WallPlotter();
|
|
wp.setSpeed(3000, 1500);
|
|
wp.enableKeyInputs();
|
|
wp.enablePlotButtons();
|
|
}
|
|
|
|
function draw() {
|
|
background(28, 28, 32);
|
|
wp.showInfos();
|
|
}
|
|
|
|
async function plot() {
|
|
await drawPlot(false);
|
|
}
|
|
|
|
async function test() {
|
|
await drawPlot(true);
|
|
}
|
|
|
|
async function drawPlot(testOnly) {
|
|
wp.startPath();
|
|
wp.move(-200, -200);
|
|
wp.draw(200, -200);
|
|
await wp.runPath(testOnly);
|
|
}
|
|
```
|
|
|
|
Full API: [lib/doc.md](lib/doc.md).
|
|
|
|
Baud **115200**. Pen servo: `M280 P0 S90` up, `M280 P0 S50` down. Coordinates in mm, origin at home (`G92`).
|