Skip to content

Instantly share code, notes, and snippets.

@randallagordon
Created November 9, 2012 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randallagordon/4048447 to your computer and use it in GitHub Desktop.
Save randallagordon/4048447 to your computer and use it in GitHub Desktop.
Controlling a ShapeOko using a cup of Coffee creamed with Zappa goodness!
serialport = require "serialport"
port = "/dev/ttyACM0" # your ShapeOko's port here
oko = new serialport.SerialPort port, {
baudrate: 9600,
parser: serialport.parsers.readline "\n"
}
G = (g) ->
oko.write g + "\n"
return g
require('zappajs') ->
@get '/a': -> G "G90"
@get '/i': -> G "G91"
@get '/G1/:feed/:axis/:distance': ->
G "G1 F#{@params.feed} #{@params.axis} #{@params.distance}"
@randallagordon
Copy link
Author

Change the port to the path of your Grbl or other G code consuming serial device and then make sure the serialport and zappajs packages are installed:

npm install serialport zappajs

The following request will send a G91 to switch to incremental positioning:

http://localhost:3000/i

Then go nuts sending G1s via requests like:

http://localhost:3000/G1/2500/X/50
http://localhost:3000/G1/250/Z/-5
http://localhost:3000/G1/5000/Y/-173.2

Obviously isn't robust in any way, shape or form—but, gives me a way to position my ShapeOko via teh interwebs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment