Skip to content

updates for newest makerbot gcode #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion web/gcode-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ function createObjectFromGCode(gcode) {
// happens from the current extruded length to a length of
// 22.4 mm.

/* newer makerbot gcode uses A instead of E on G1 */
if (args.a && !args.e) {
args.e = args.a;
}
var newLine = {
x: args.x !== undefined ? absolute(lastLine.x, args.x) : lastLine.x,
y: args.y !== undefined ? absolute(lastLine.y, args.y) : lastLine.y,
Expand Down Expand Up @@ -136,6 +140,22 @@ function createObjectFromGCode(gcode) {
lastLine = newLine;
},

G130: function(args) {
// G130: MakerBot Set Stepper Motor VRef to defaults
},

G161: function(args) {
// G161: MakerBot Home Z Axis
},

G162: function(args) {
// G162: MakerBot Home XY Axis
},

M73: function(args) {
// M73: MakerBot Progress Meter Info
},

M82: function(args) {
// M82: Set E codes absolute (default)
// Descriped in Sprintrun source code.
Expand All @@ -155,8 +175,28 @@ function createObjectFromGCode(gcode) {
// No-op
},

M126: function(args) {
// M126: MakerBot Turn On Fan
},

M127: function(args) {
// M127: MakerBot Turn Off Fan
},

M132: function(args) {
// M132: MakerBot Recall Stored Offsets
},

M136: function(args) {
// M136: MakerBot Build Begin
},

M137: function(args) {
// M136: MakerBot Build End
},

'default': function(args, info) {
console.error('Unknown command:', args.cmd, args, info);
console.log('Unknown command:', args.cmd, args, info);
},
});

Expand Down
9 changes: 6 additions & 3 deletions web/gcode-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function GCodeParser(handlers) {

GCodeParser.prototype.parseLine = function(text, info) {
text = text.replace(/;.*$/, '').trim(); // Remove comments
text = text.replace(/^\(.*\)$/, '').trim(); // Remove MakeBot layer info
if (text) {
var tokens = text.split(' ');
if (tokens) {
Expand All @@ -19,9 +20,11 @@ GCodeParser.prototype.parseLine = function(text, info) {
'cmd': cmd
};
tokens.splice(1).forEach(function(token) {
var key = token[0].toLowerCase();
var value = parseFloat(token.substring(1));
args[key] = value;
if (token[0]) {
var key = token[0].toLowerCase();
var value = parseFloat(token.substring(1));
args[key] = value;
}
});
var handler = this.handlers[tokens[0]] || this.handlers['default'];
if (handler) {
Expand Down
8 changes: 6 additions & 2 deletions web/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ function openGCodeFromText(gcode) {
}
object = createObjectFromGCode(gcode);
scene.add(object);
localStorage.setItem('last-imported', gcode);
localStorage.removeItem('last-loaded');
try {
localStorage.setItem('last-imported', gcode);
localStorage.removeItem('last-loaded');
} catch (e) {
alert('error storing model: '+e);
}
}


Expand Down