Skip to content

Commit

Permalink
adding pause/wait commands
Browse files Browse the repository at this point in the history
  • Loading branch information
jgphilpott committed Mar 29, 2024
1 parent a1b0997 commit e29bd38
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 15 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"cura",
"forkme",
"gcode",
"interruptible",
"polyslice",
"srcset",
"usbserial"
Expand Down
6 changes: 6 additions & 0 deletions serial/browser/sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ document.addEventListener("DOMContentLoaded", (event) => {
if (command.includes("G21 ")) command += "<span class='emoji'>📏</span>" // Set length units to millimeters.
if (command.includes("M149 ")) command += "<span class='emoji'>📏🌡️</span>" // Set temperature units to celsius [C], fahrenheit [F] or kelvin [K].

// Pause/Wait
if (command.includes("G4 ")) command += "<span class='emoji'>⏲️</span>" // Uninterruptible pause command.
if (command.includes("M0 ")) command += "<span class='emoji'>⏰</span>" // Interruptible pause command.
if (command.includes("M1 ")) command += "<span class='emoji'>⏰</span>" // Interruptible pause command.
if (command.includes("M400 ")) command += "<span class='emoji'>💤</span>" // Wait for queue to finish.

// Fan
if (command.includes("M106 ")) command += "<span class='emoji'>🪭</span>" // Set fan speed.
if (command.includes("M107 ")) command += "<span class='emoji'>🪭🚫</span>" // Turn fan off.
Expand Down
51 changes: 36 additions & 15 deletions src/polyslice.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class Polyslice

setWorkspacePlane: (plane = "XY") ->

if ["XY", "XZ", "YZ"].includes(plane)
plane = plane.toUpperCase().trim()

if ["XY", "XZ", "YZ"].includes plane

this.workspacePlane = String plane

Expand Down Expand Up @@ -81,13 +83,7 @@ class Polyslice
# https://marlinfw.org/docs/gcode/G000-G001.html
codeLinearMovement: (x = null, y = null, z = null, e = null, f = null, s = null) ->

if e is null

gcode = "G0"

else

gcode = "G1"
if e is null then gcode = "G0" else gcode = "G1"

gcode += this.codeMovement x, y, z, e, f, s

Expand All @@ -96,13 +92,7 @@ class Polyslice
# https://marlinfw.org/docs/gcode/G002-G003.html
codeArcMovement: (direction = "clockwise", x = null, y = null, z = null, e = null, f = null, s = null, i = null, j = null, r = null, p = null) ->

if direction is "clockwise"

gcode = "G2"

else

gcode = "G3"
if direction is "clockwise" then gcode = "G2" else gcode = "G3"

if (i isnt null or j isnt null) and r is null

Expand Down Expand Up @@ -138,6 +128,37 @@ class Polyslice

return gcode + this.newline

# https://marlinfw.org/docs/gcode/G004.html
# https://marlinfw.org/docs/gcode/M000-M001.html
codeDwell: (time = null, interruptible = true, message = "") ->

if interruptible then gcode = "M0" else gcode = "G4"

if time isnt null and typeof time is "number" and time > 0

gcode += " P" + time

if message and typeof message is "string"

gcode += " " + message

return gcode + this.newline

# https://marlinfw.org/docs/gcode/M108.html
codeInterrupt: ->

return "M108" + this.newline

# https://marlinfw.org/docs/gcode/M400.html
codeWait: ->

return "M400" + this.newline

# https://marlinfw.org/docs/gcode/M112.html
codeShutdown: ->

return "M112" + this.newline

slice: (scene = {}) ->

if this.getAutohome()
Expand Down
34 changes: 34 additions & 0 deletions src/polyslice.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e29bd38

Please sign in to comment.