Skip to content

Instantly share code, notes, and snippets.

@edy555
edy555 / gc4marlin.rb
Created September 17, 2012 12:02
convert g-code to acceptable format for sprinter or marlin.
#!/usr/bin/env ruby
lastcmd="G0"
while line = gets
print "#{lastcmd}" if /^\s/ =~ line
print line
if /G(\d+)/ =~ line then
case $1.to_i
when 0 .. 3
lastcmd=$&
end