From b5692fb6077ada580dfb70aa9ca6d2a337be7dfe Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sat, 5 Sep 2026 13:39:34 +0200 Subject: [PATCH] tutorial --- README.md | 21 +- examples/netz/sketch.js | 109 --------- examples/{netz => rechteck}/index.html | 4 +- examples/rechteck/sketch.js | 46 ++++ examples/zickzack/sketch.js | 6 +- gcode.md | 27 +++ hardware.md | 93 ++++++++ lib/README.md | 251 +++---------------- lib/doc.md | 222 +++++++++++++++++ tutorial.md | 318 +++++++++++++++++++++++++ 10 files changed, 757 insertions(+), 340 deletions(-) delete mode 100644 examples/netz/sketch.js rename examples/{netz => rechteck}/index.html (93%) create mode 100644 examples/rechteck/sketch.js create mode 100644 gcode.md create mode 100644 hardware.md create mode 100644 lib/doc.md create mode 100644 tutorial.md diff --git a/README.md b/README.md index 64ae48a..421f45c 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,20 @@ 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 # public API +│ ├── README.md # short intro + example +│ └── doc.md # full API └── examples/ - └── zickzack/ # example sketch - ├── index.html - └── sketch.js + ├── zickzack/ # example sketch + └── rechteck/ # rectangle sketch ``` ## Run the example @@ -51,14 +56,14 @@ function draw() { } async function plot() { - await drawArt(false); + await drawPlot(false); } async function test() { - await drawArt(true); + await drawPlot(true); } -async function drawArt(testOnly) { +async function drawPlot(testOnly) { wp.startPath(); wp.move(-200, -200); wp.draw(200, -200); @@ -66,6 +71,6 @@ async function drawArt(testOnly) { } ``` -Full API: [lib/README.md](lib/README.md). +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`). diff --git a/examples/netz/sketch.js b/examples/netz/sketch.js deleted file mode 100644 index be3ffff..0000000 --- a/examples/netz/sketch.js +++ /dev/null @@ -1,109 +0,0 @@ -let wp; - -let area = 100; - -function setup() { - const canvas = createCanvas(windowWidth, windowHeight); - canvas.parent('sketch-host'); - - wp = new WallPlotter({ - penUpGcode: 'M280 P0 S120', - penDownGcode: 'M280 P0 S30', - penUpDelayMs: 250, - penDownDelayMs: 150, - }); - wp.setSpeed(10000, 10000); - wp.setTimingMultiplier(1); // tune if machine is slower than speed estimate, the higher the slower - wp.enableKeyInputs(); - wp.enablePlotButtons(); -} - -function draw() { - background(28, 28, 32); - wp.showInfos(); -} - -function windowResized() { - resizeCanvas(windowWidth, windowHeight); -} - -async function plot() { - await drawArt(false); -} - -async function test() { - await drawArt(true); -} - -async function drawArt(testOnly) { - wp.startPath(); - - - wp.move(-area, -area); - //wp.wait(1000 * 10); - - let step = area / 40; - - let points = []; - let last_points = []; - let row = -1; - - for (let y = -area; y <= area; y+=step){ - - // clear points - if(points.length>0){ - last_points = deepCopy(points); - points = []; - } - - let px = -area; - let py = y+random(10) - if (row==1){ - py = last_points[0].y; - } - - - wp.move(px, py); - points.push(createVector(px,py)); - - let index = 1; - for (let x = -area+step; x <= area; x+=step){ - px = x; - py = y+random(step); - - if (row==1 && index%2==0){ - py = last_points[index].y - } - - if (row==1 && index%2!=0){ - py = last_points[index-1].y+random(step*3); - } - - if (last_points.length>0 && row==-1 && index%2!=0){ - py = last_points[index].y - } - - if (last_points.length>0 && row==-1 && index%2==0){ - py = last_points[index-1].y+random(step*1); - } - - wp.draw(px, py); - points.push(createVector(px,py)); - - index++; - } - - row = row*-1; - - } - await wp.runPath(testOnly); -} - - -function deepCopy(copy_array){ - let new_array = [] - for(let i=0; i - Wall Plotter — zigzag + Wall Plotter — rectangle