Standalone package for Marlin polargraph control over Web Serial, including API docs and a runnable zigzag sketch. Co-authored-by: Cursor <cursoragent@cursor.com>
72 lines
1.5 KiB
Markdown
72 lines
1.5 KiB
Markdown
# p5-wallplotter
|
|
|
|
p5.js library for a Marlin polargraph (wall plotter) over Web Serial, plus a zigzag example.
|
|
|
|
```
|
|
p5-wallplotter/
|
|
├── lib/
|
|
│ ├── WallPlotter.js # library
|
|
│ └── README.md # public API
|
|
└── examples/
|
|
└── zickzack/ # example sketch
|
|
├── index.html
|
|
└── sketch.js
|
|
```
|
|
|
|
## 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 drawArt(false);
|
|
}
|
|
|
|
async function test() {
|
|
await drawArt(true);
|
|
}
|
|
|
|
async function drawArt(testOnly) {
|
|
wp.startPath();
|
|
wp.move(-200, -200);
|
|
wp.draw(200, -200);
|
|
await wp.runPath(testOnly);
|
|
}
|
|
```
|
|
|
|
Full API: [lib/README.md](lib/README.md).
|
|
|
|
Baud **115200**. Pen servo: `M280 P0 S90` up, `M280 P0 S50` down. Coordinates in mm, origin at home (`G92`).
|