0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-12-26 14:43:49 +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.netmask": "255.255.255.0",
"printer.temperature": 220,
"printer.objectHeight": '???',
"printer.objectHeight": 20,
"printer.maxObjectHeight": 150,
"printer.layerHeight": 0.2,
"printer.wallThickness": 0.7,
"printer.screenToMillimeterScale": 0.3,
"printer.speed": 50,
"printer.travelSpeed": 200,
"printer.filamentThickness": 2.85,
"printer.enableTraveling": true,
"printer.useSubLayers": true,
"printer.firstLayerSlow": true,
"printer.autoWarmUp": true,
@ -17,12 +20,13 @@ var settings = {
"printer.simplify.minNumPoints": 15,
"printer.simplify.minDistance": 3,
"printer.retraction.enabled": true,
"printer.retraction.speed": 250,
"printer.retraction.speed": 50,
"printer.retraction.minDistance": 1,
"printer.retraction.amount": 2,
"printer.retraction.amount": 5,
"printer.autoWarmUpCommand": "M104 S220 (hardcoded temperature)"
}
function SettingsWindow() {
this.wifiboxURL;
this.window;
@ -130,7 +134,7 @@ function SettingsWindow() {
timeout: this.timeoutTime,
success: function(data){
console.log("Settings:loadSettings response: ",data);
settings = data.data;
settings = data.data;
console.log(" settings: ",settings);
self.fillForm();
$(document).trigger(SettingsWindow.SETTINGS_LOADED);
@ -497,7 +501,7 @@ function SettingsWindow() {
var objectHeight = 20;
var layerHeight = .2;
//var wallThickness = .5;
var hop = 0;
//var hop = 0;
//var speed = 70;
//var travelSpeed = 200;
var enableTraveling = true;
@ -506,10 +510,10 @@ var minScale = .3;
var maxScale = 1;
var shape = "%";
var twists = 0;
var useSubLayers = true;
//var useSubLayers = true;
//var debug = false; // debug moved to main.js
var loglevel = 2;
var zOffset = 0;
//var zOffset = 0;
var serverport = 8888;
var autoLoadImage = "hand.txt";
var loadOffset = [0, 0]; // x en y ?
@ -518,18 +522,18 @@ var loopAlways = false;
var firstLayerSlow = true;
var useSubpathColors = false;
var autoWarmUp = true;
var maxObjectHeight = 150;
//var maxObjectHeight = 150;
var maxScaleDifference = .1;
var frameRate = 60;
var quitOnEscape = true;
var screenToMillimeterScale = .3; // 0.3
var targetTemperature = 230;
var simplifyiterations = 10;
var simplifyminNumPoints = 15;
var simplifyminDistance = 3;
var retractionspeed = 50;
var retractionminDistance = 5;
var retractionamount = 3;
//var targetTemperature = 220;
//var simplifyiterations = 10;
//var simplifyminNumPoints = 15;
//var simplifyminDistance = 3;
//var retractionspeed = 50;
//var retractionminDistance = 5;
//var retractionamount = 3;
var sideis3D = true;
var sidevisible = true;
var sidebounds = [900, 210, 131, 390];

View File

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

View File

@ -24,12 +24,72 @@ gcodeEnd.push("M84"); // disable axes / steppers
gcodeEnd.push("G90"); // absolute positioning
gcodeEnd.push("M117 Done "); // display message (20 characters to clear whole screen)
var gcode = [];
function generate_gcode(callback) {
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 = [];
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 = 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());
// 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);
gcode.push("M109 S" + temperature); // set target temperature and wait for the extruder to reach it
// 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
@ -71,13 +121,10 @@ function generate_gcode(callback) {
// x: doodleBounds[0],
// y: doodleBounds[1]
}
console.log("f:generategcode() >> layers: " + layers);
if (layers == Infinity) return;
for (var layer = 0; layer < layers; layer++) {
var p = JSON.parse(JSON.stringify(points)); // [].concat(points);
@ -149,7 +196,7 @@ function generate_gcode(callback) {
// ofPoint to = commands[(even || isLoop || loopAlways) ? i : last-i].to;
var to = new Point(); to.set(commands[i][0], commands[i][1]);
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 doRetract = prev.distance(to) > retractionminDistance;
@ -157,7 +204,7 @@ function generate_gcode(callback) {
if (enableTraveling && isTraveling) {
// console.log("enableTraveling && isTraveling >> doRetract: " + doRetract + ", retractionspeed: " + retractionspeed);
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
} else {
// console.log(" else");
@ -174,7 +221,7 @@ function generate_gcode(callback) {
}
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;
}
@ -182,7 +229,7 @@ function generate_gcode(callback) {
}
// add gcode end commands
gcode = gcode.concat(gcodeEnd);
gcode = gcode.concat(endGcode);
// debug
// var _gc = gc.join("\n");

View File

@ -40,12 +40,36 @@ $(function() {
settingsWindow.init(wifiboxURL);
$(document).on(SettingsWindow.SETTINGS_LOADED,settingsLoaded);
if(debugMode) {
console.log("debug mode is true");
$("body").css("overflow", "auto");
$("#debug_textArea").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() {