0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-25 02:27:56 +01:00

- additional items added to the settings array (which is set from wifibox)

- gcode generation takes more settings from that settings array (making gcode generation more configurable by the user)
This commit is contained in:
Adriaan Wormgoor 2013-09-07 16:06:59 +02:00
parent 7bd05d4f1f
commit edf24d45d2
4 changed files with 155 additions and 68 deletions

View File

@ -4,12 +4,15 @@ var settings = {
"network.ap.address": "192.168.10.1", "network.ap.address": "192.168.10.1",
"network.ap.netmask": "255.255.255.0", "network.ap.netmask": "255.255.255.0",
"printer.temperature": 220, "printer.temperature": 220,
"printer.objectHeight": '???', "printer.objectHeight": 20,
"printer.maxObjectHeight": 150,
"printer.layerHeight": 0.2, "printer.layerHeight": 0.2,
"printer.wallThickness": 0.7, "printer.wallThickness": 0.7,
"printer.screenToMillimeterScale": 0.3,
"printer.speed": 50, "printer.speed": 50,
"printer.travelSpeed": 200, "printer.travelSpeed": 200,
"printer.filamentThickness": 2.85, "printer.filamentThickness": 2.85,
"printer.enableTraveling": true,
"printer.useSubLayers": true, "printer.useSubLayers": true,
"printer.firstLayerSlow": true, "printer.firstLayerSlow": true,
"printer.autoWarmUp": true, "printer.autoWarmUp": true,
@ -17,12 +20,13 @@ var settings = {
"printer.simplify.minNumPoints": 15, "printer.simplify.minNumPoints": 15,
"printer.simplify.minDistance": 3, "printer.simplify.minDistance": 3,
"printer.retraction.enabled": true, "printer.retraction.enabled": true,
"printer.retraction.speed": 250, "printer.retraction.speed": 50,
"printer.retraction.minDistance": 1, "printer.retraction.minDistance": 1,
"printer.retraction.amount": 2, "printer.retraction.amount": 5,
"printer.autoWarmUpCommand": "M104 S220 (hardcoded temperature)" "printer.autoWarmUpCommand": "M104 S220 (hardcoded temperature)"
} }
function SettingsWindow() { function SettingsWindow() {
this.wifiboxURL; this.wifiboxURL;
this.window; this.window;
@ -497,7 +501,7 @@ function SettingsWindow() {
var objectHeight = 20; var objectHeight = 20;
var layerHeight = .2; var layerHeight = .2;
//var wallThickness = .5; //var wallThickness = .5;
var hop = 0; //var hop = 0;
//var speed = 70; //var speed = 70;
//var travelSpeed = 200; //var travelSpeed = 200;
var enableTraveling = true; var enableTraveling = true;
@ -506,10 +510,10 @@ var minScale = .3;
var maxScale = 1; var maxScale = 1;
var shape = "%"; var shape = "%";
var twists = 0; var twists = 0;
var useSubLayers = true; //var useSubLayers = true;
//var debug = false; // debug moved to main.js //var debug = false; // debug moved to main.js
var loglevel = 2; var loglevel = 2;
var zOffset = 0; //var zOffset = 0;
var serverport = 8888; var serverport = 8888;
var autoLoadImage = "hand.txt"; var autoLoadImage = "hand.txt";
var loadOffset = [0, 0]; // x en y ? var loadOffset = [0, 0]; // x en y ?
@ -518,18 +522,18 @@ var loopAlways = false;
var firstLayerSlow = true; var firstLayerSlow = true;
var useSubpathColors = false; var useSubpathColors = false;
var autoWarmUp = true; var autoWarmUp = true;
var maxObjectHeight = 150; //var maxObjectHeight = 150;
var maxScaleDifference = .1; var maxScaleDifference = .1;
var frameRate = 60; var frameRate = 60;
var quitOnEscape = true; var quitOnEscape = true;
var screenToMillimeterScale = .3; // 0.3 var screenToMillimeterScale = .3; // 0.3
var targetTemperature = 230; //var targetTemperature = 220;
var simplifyiterations = 10; //var simplifyiterations = 10;
var simplifyminNumPoints = 15; //var simplifyminNumPoints = 15;
var simplifyminDistance = 3; //var simplifyminDistance = 3;
var retractionspeed = 50; //var retractionspeed = 50;
var retractionminDistance = 5; //var retractionminDistance = 5;
var retractionamount = 3; //var retractionamount = 3;
var sideis3D = true; var sideis3D = true;
var sidevisible = true; var sidevisible = true;
var sidebounds = [900, 210, 131, 390]; var sidebounds = [900, 210, 131, 390];

View File

@ -12,6 +12,7 @@ var btnOops, btnStop, btnClear;
var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight; var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight;
var btnInfo, btnSettings; var btnInfo, btnSettings;
var btnDebug; // debug var btnDebug; // debug
var displayTemp, displayProgress;
var displayTempEnabled = false; var displayTempEnabled = false;
@ -36,6 +37,7 @@ function initButtonBehavior() {
btnPrint= $("#btnPrint"); btnPrint= $("#btnPrint");
btnStop = $("#btnStop"); btnStop = $("#btnStop");
displayTemp = $("#displayTemp"); displayTemp = $("#displayTemp");
displayProgress = $("#printProgressContainer");
// btnPrevious = $("#btnPrevious"); // btnPrevious = $("#btnPrevious");
// btnNext = $("#btnNext"); // btnNext = $("#btnNext");
@ -205,15 +207,18 @@ function nextDoodle(e) {
function print(e) { function print(e) {
console.log("f:print() >> sendPrintCommands = " + sendPrintCommands); console.log("f:print() >> sendPrintCommands = " + sendPrintCommands);
if (sendPrintCommands) {
$("#textdump").text(""); $("#textdump").text("");
if (_points.length > 2) { if (_points.length > 2) {
setState(PRINTING_STATE); setState(PRINTING_STATE);
var gcode = generate_gcode(); var gcode = generate_gcode();
//startPrint(gencode); //startPrint(gencode);
printer.print(gcode);
if (sendPrintCommands) {
printer.print(gcode);
} else {
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
}
// console.log(""); // console.log("");
// console.log(""); // console.log("");
// console.log("-------------------------------------------------"); // console.log("-------------------------------------------------");
@ -224,7 +229,10 @@ function print(e) {
// console.log(""); // console.log("");
// console.log(""); // console.log("");
if (debugMode) $("#textdump").text(gcode.join("\n")); if (debugMode) {
console.log("f:print() >> debugMode is true, dumping gcode to textarea #textdump");
$("#textdump").text(gcode.join("\n"));
}
// copyToClipboard(gencode); // copyToClipboard(gencode);
//*/ //*/
@ -236,9 +244,6 @@ function print(e) {
// $.post("/doodle3d.of", { data:output }, function(data) { // $.post("/doodle3d.of", { data:output }, function(data) {
// btnPrint.disabled = false; // btnPrint.disabled = false;
// }); // });
} else {
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
}
} }
@ -263,7 +268,7 @@ function oopsUndo() {
} }
function previewUp(redrawLess) { function previewUp(redrawLess) {
// console.log("f:previewUp()"); // console.log("f:previewUp()");
if (numLayers < 100) { if (numLayers < maxNumLayers) {
numLayers++; numLayers++;
} }
// redrawPreview(redrawLess); // redrawPreview(redrawLess);
@ -271,7 +276,7 @@ function previewUp(redrawLess) {
} }
function previewDown(redrawLess) { function previewDown(redrawLess) {
// console.log("f:previewDown()"); // console.log("f:previewDown()");
if (numLayers > 2) { if (numLayers > minNumLayers) {
numLayers--; numLayers--;
} }
// redrawPreview(redrawLess); // redrawPreview(redrawLess);
@ -300,16 +305,21 @@ function previewTwistRight(redrawLess) {
function update() { function update() {
if(!displayTempEnabled && printer.alive) { if(!displayTempEnabled && printer.alive) {
displayTemp.show(); displayTemp.show();
$displayThermometer.show();
displayTempEnabled = true; displayTempEnabled = true;
} else if(displayTempEnabled && !printer.alive) { } else if(displayTempEnabled && !printer.alive) {
displayTemp.hide(); displayTemp.hide();
$displayThermometer.hide();
displayTempEnabled = false; displayTempEnabled = false;
} }
if(displayTempEnabled) { if(displayTempEnabled) {
displayTemp.text(printer.temperature+"/"+printer.targetTemperature); displayTemp.text(printer.temperature+"/"+printer.targetTemperature);
updateThermometer(printer.temperature, printer.targetTemperature);
} }
setPrintprogress(printer.currentLine/printer.num_lines);
var btnPrint= $("#btnPrint"); var btnPrint= $("#btnPrint");
setState(printer.printing? PRINTING_STATE : IDLE_STATE); setState(printer.printing? PRINTING_STATE : IDLE_STATE);
@ -325,6 +335,7 @@ function setState(newState) {
btnPrint.removeClass("disabled"); // enable print button btnPrint.removeClass("disabled"); // enable print button
btnStop.addClass("disabled"); // disable stop button btnStop.addClass("disabled"); // disable stop button
btnPrint.bind('touchstart mousedown',print); btnPrint.bind('touchstart mousedown',print);
displayProgress.hide();
break; break;
case PRINTING_STATE: case PRINTING_STATE:
@ -332,6 +343,7 @@ function setState(newState) {
btnPrint.addClass("disabled"); // disable print button btnPrint.addClass("disabled"); // disable print button
btnStop.removeClass("disabled"); // enable stop button btnStop.removeClass("disabled"); // enable stop button
btnPrint.unbind('touchstart mousedown'); btnPrint.unbind('touchstart mousedown');
displayProgress.show();
break; break;
} }

View File

@ -24,12 +24,72 @@ gcodeEnd.push("M84"); // disable axes / steppers
gcodeEnd.push("G90"); // absolute positioning gcodeEnd.push("G90"); // absolute positioning
gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen) gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)
var gcode = []; var gcode = [];
function generate_gcode(callback) { function generate_gcode(callback) {
console.log("f:generategcode()"); console.log("f:generategcode()");
var startGcode = [];
var endGcode = [];
// get gcode start statements
if ($("#startgcode").val().trim().length != 0) {
console.log(" found contents for start-gcode in settings.html")
startGcode = $("#startgcode").val().trim().split("\n");
} else {
console.log(" no start-gcode in settings.html, using defaults")
startGcode.concat(gcodeStart);
}
// get gcode end statements
if ($("#endgcode").val().trim().length != 0) {
console.log(" found contents for end-gcode in settings.html")
endGcode = $("#endgcode").val().trim().split("\n");
} else {
console.log(" no end-gcode in settings.html, using defaults")
endGcode.concat(gcodeEnd);
}
gcode = []; gcode = [];
console.log("settings: ",settings);
var speed = settings["printer.speed"]
var normalSpeed = speed;
var bottomSpeed = speed*0.5;
var travelSpeed = settings["printer.travelSpeed"]
var filamentThickness = settings["printer.filamentThickness"];
var wallThickness = settings["printer.wallThickness"];
var screenToMillimeterScale = isNaN(settings["printer.screenToMillimeterScale"]) ? 0.3 : settings["printer.screenToMillimeterScale"]; // TODO add this item to the settings on 'kastje'
var layerHeight = settings["printer.layerHeight"];
var objectHeight = settings["printer.objectHeight"];
var maxObjectHeight = isNaN(settings["printer.maxObjectHeight"]) ? 150 : settings["printer.maxObjectHeight"]; // TODO add this item to the settings on 'kastje'
var temperature = settings["printer.temperature"];
var useSubLayers = settings["printer.useSubLayers"];
var enableTraveling = isNaN(settings["printer.enableTraveling"]) ? true : settings["printer.enableTraveling"]; // TODO add this item to the settings on 'kastje'
var retractionspeed = settings["printer.retraction.speed"];
var retractionminDistance = settings["printer.retraction.minDistance"];
var retractionamount = settings["printer.retraction.amount"];
/*
console.log("f:generate_gcode >> EFFE CHECKEN:");
console.log(" speed: " + speed);
console.log(" travelSpeed: " + travelSpeed);
console.log(" filamentThickness: " + filamentThickness);
console.log(" wallThickness: " + wallThickness);
console.log(" screenToMillimeterScale: " + screenToMillimeterScale);
console.log(" layerHeight: " + layerHeight);
console.log(" objectHeight: " + objectHeight);
console.log(" maxObjectHeight: " + maxObjectHeight);
console.log(" temperature: " + temperature);
console.log(" maxObjectHeight: " + maxObjectHeight);
console.log(" useSubLayers: " + useSubLayers);
console.log(" enableTraveling: " + enableTraveling);
console.log(" retractionspeed: " + retractionspeed);
console.log(" retractionminDistance: " + retractionminDistance);
console.log(" retractionamount: " + retractionamount);
console.log("");
//*/
objectHeight = Math.ceil(numLayers / 5); // in settings objectHeight = 20, in previewRendering_v01.js numLayers is 100, hence the / 5 objectHeight = Math.ceil(numLayers / 5); // in settings objectHeight = 20, in previewRendering_v01.js numLayers is 100, hence the / 5
objectHeight = numLayers; // in settings objectHeight = 20, in previewRendering_v01.js numLayers is 100, hence the / 5 objectHeight = numLayers; // in settings objectHeight = 20, in previewRendering_v01.js numLayers is 100, hence the / 5
@ -43,20 +103,10 @@ function generate_gcode(callback) {
// console.log("paths.toString(): " + paths.toString()); // console.log("paths.toString(): " + paths.toString());
// return; // return;
console.log("settings: ",settings);
var speed = settings["printer.speed"]
var normalSpeed = speed;
var bottomSpeed = speed*0.5;
var travelSpeed = settings["printer.travelSpeed"]
var filamentThickness = settings["printer.filamentThickness"];
var wallThickness = settings["printer.wallThickness"];
var layerHeight = settings["printer.layerHeight"];
var temperature = settings["printer.temperature"];
console.log("printer temperature: ",temperature); console.log("printer temperature: ",temperature);
gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
// add gcode begin commands // add gcode begin commands
gcode = gcode.concat(gcodeStart); gcode = gcode.concat(startGcode);
//gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it //gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
@ -72,11 +122,8 @@ function generate_gcode(callback) {
// y: doodleBounds[1] // y: doodleBounds[1]
} }
console.log("f:generategcode() >> layers: " + layers); console.log("f:generategcode() >> layers: " + layers);
if (layers == Infinity) return;
for (var layer = 0; layer < layers; layer++) { for (var layer = 0; layer < layers; layer++) {
@ -149,7 +196,7 @@ function generate_gcode(callback) {
// ofPoint to = commands[(even || isLoop || loopAlways) ? i : last-i].to; // ofPoint to = commands[(even || isLoop || loopAlways) ? i : last-i].to;
var to = new Point(); to.set(commands[i][0], commands[i][1]); var to = new Point(); to.set(commands[i][0], commands[i][1]);
var sublayer = (layer == 0) ? 0.0 : layer + (useSubLayers ? (curLayerCommand/totalLayerCommands) : 0); var sublayer = (layer == 0) ? 0.0 : layer + (useSubLayers ? (curLayerCommand/totalLayerCommands) : 0);
var z = (sublayer + 1) * layerHeight + zOffset; var z = (sublayer + 1) * layerHeight; // 2013-09-06 removed zOffset (seemed to be useless)
var isTraveling = !isLoop && i==0; var isTraveling = !isLoop && i==0;
var doRetract = prev.distance(to) > retractionminDistance; var doRetract = prev.distance(to) > retractionminDistance;
@ -157,7 +204,7 @@ function generate_gcode(callback) {
if (enableTraveling && isTraveling) { if (enableTraveling && isTraveling) {
// console.log("enableTraveling && isTraveling >> doRetract: " + doRetract + ", retractionspeed: " + retractionspeed); // console.log("enableTraveling && isTraveling >> doRetract: " + doRetract + ", retractionspeed: " + retractionspeed);
if (doRetract) gcode.push("G0 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); //retract if (doRetract) gcode.push("G0 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); //retract
gcode.push("G0 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + (z + (doRetract ? hop : 0)).toFixed(3) + " F" + (travelSpeed * 60).toFixed(3)); gcode.push("G0 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + z.toFixed(3) + " F" + (travelSpeed * 60).toFixed(3));
if (doRetract) gcode.push("G0 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); // return to normal if (doRetract) gcode.push("G0 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3)); // return to normal
} else { } else {
// console.log(" else"); // console.log(" else");
@ -174,7 +221,7 @@ function generate_gcode(callback) {
} }
if ((layer/layers) > (objectHeight/maxObjectHeight)) { if ((layer/layers) > (objectHeight/maxObjectHeight)) {
console.log("f:generategcode() >> (layer/layers) > (objectHeight/maxObjectHeight) is true -> breaking"); console.log("f:generategcode() >> (layer/layers) > (objectHeight/maxObjectHeight) is true -> breaking at layer " + (layer + 1));
break; break;
} }
@ -182,7 +229,7 @@ function generate_gcode(callback) {
} }
// add gcode end commands // add gcode end commands
gcode = gcode.concat(gcodeEnd); gcode = gcode.concat(endGcode);
// debug // debug
// var _gc = gc.join("\n"); // var _gc = gc.join("\n");

View File

@ -46,6 +46,30 @@ $(function() {
$("body").css("overflow", "auto"); $("body").css("overflow", "auto");
$("#debug_textArea").css("display", "block"); $("#debug_textArea").css("display", "block");
$("#preview_tmp").css("display", "block"); $("#preview_tmp").css("display", "block");
/* TEMP CODE!! -> artificially populates the startgcode and endgcode textareas in the settings window */
// todo remove this temporary code...
/*
setTimeout(function() {
$("#startgcode").text("");
$("#startgcode").append("G21 (mm) \n");
$("#startgcode").append("G91 (relative) \n");
$("#startgcode").append("G28 X0 Y0 Z0 (physical home) \n");
$("#startgcode").append("M104 S230 (temperature) \n");
$("#startgcode").append("G1 E10 F250 (flow) \n");
$("#startgcode").append("G92 X-100 Y-100 Z0 E10 \n");
$("#startgcode").append("G1 Z3 F5000 (prevent diagonal line) \n");
$("#startgcode").append("G90 (absolute) \n");
$("#startgcode").append("M106 (fan on)");
console.log("$('#startgcode'): " + $("#startgcode").val());
$("#endgcode").text("");
$("#endgcode").append("G1 X-100 Y-100 F15000 (fast homing) \n");
$("#endgcode").append("M107 \n");
$("#endgcode").append("M84 (disable axes) \n");
console.log("$('#endgcode'): " + $("#endgcode").val());
}, 1000);
//*/
} }
}) })
function settingsLoaded() { function settingsLoaded() {