Created
September 25, 2024 02:46
-
-
Save tabjy/c1da8ef4502d9c73fe578be7b9092556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PRE_SCRIPT = ` | |
G91; | |
` | |
const POST_SCRIPT = ` | |
M107; | |
G90; | |
` | |
const WIDTH = 35 // mm | |
const HEIGHT = 30 // mm | |
const DISTANCE = 1 // mm | |
const BURN_TIME = 100 // ms | |
const POWER = 100 // % | |
const IDLE_POWER = 1 // % | |
const buffer = [] | |
let y = 0 | |
let yy = 0 | |
while (y <= HEIGHT) { | |
let x = 0 | |
if (yy % 2 == 1) { | |
buffer.push(`G0 X${DISTANCE / 2} F30000;`) | |
x += DISTANCE / 2 | |
} | |
while (x <= WIDTH) { | |
buffer.push(`M106 S${POWER / 100 * 255};`) | |
buffer.push(`G4 P${BURN_TIME};`) | |
buffer.push(`M106 S${IDLE_POWER};`) | |
buffer.push(`G0 X${DISTANCE} F30000;`) | |
buffer.push('') | |
x += DISTANCE | |
} | |
buffer.push(`G0 X-${x} F30000;`) | |
buffer.push(`G0 Y${DISTANCE} F30000;`) | |
y += DISTANCE | |
yy++ | |
} | |
console.log([...PRE_SCRIPT.split('\n'), ...buffer, ...POST_SCRIPT.split('\n')].join('\n')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment