mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-21 17:07:55 +01:00
Add temperature setting to config interface; move temperature setting from start code and use configuration.
This commit is contained in:
parent
d78317ecd6
commit
d13051e40f
@ -6,6 +6,10 @@ function startPrint(gcode) {
|
||||
console.log("f:startPrint()");
|
||||
console.log("total # of lines: " + gcode.length);
|
||||
data = gcode;
|
||||
|
||||
for (i = 0; i < data.length; i++) {
|
||||
data[i] += " (" + i + ")";
|
||||
}
|
||||
|
||||
sendIndex = 0;
|
||||
sendLength = 2000; // 2000 regels
|
||||
|
@ -2,7 +2,6 @@ var gcodeStart = [];
|
||||
gcodeStart.push("G21 (mm)");
|
||||
gcodeStart.push("G91 (relative)");
|
||||
gcodeStart.push("G28 X0 Y0 Z0 (physical home)");
|
||||
gcodeStart.push("M104 S230 (temperature)");
|
||||
gcodeStart.push("G1 E10 F250 (flow)");
|
||||
gcodeStart.push("G92 X-100 Y-100 Z0 E10");
|
||||
gcodeStart.push("G1 Z3 F5000 (prevent diagonal line)");
|
||||
@ -36,8 +35,13 @@ function generate_gcode(callback) {
|
||||
|
||||
// add gcode begin commands
|
||||
gcode = gcode.concat(gcodeStart);
|
||||
|
||||
console.log("printer temperature: ",settings["printer.temperature"]);
|
||||
|
||||
gcode.push("M104 S" + settings["printer.temperature"] + " (temperature)");
|
||||
gcode.push("M109 S" + settings["printer.temperature"] + " (wait for heating)");
|
||||
|
||||
var layers = maxObjectHeight / layerHeight; //maxObjectHeight instead of objectHeight
|
||||
var layers = maxObjectHeight / settings["printer.layerHeight"]; //maxObjectHeight instead of objectHeight
|
||||
var extruder = 0.0;
|
||||
var prev = new Point(); prev.set(0, 0);
|
||||
|
||||
@ -99,7 +103,7 @@ function generate_gcode(callback) {
|
||||
}
|
||||
}
|
||||
// console.log("f:generategcode() >> paths.length: " + paths.length);
|
||||
|
||||
|
||||
// loop over the subpaths (the separately drawn lines)
|
||||
for (var j = 0; j < paths.length; j++) {
|
||||
// this line is probably for drawing efficiency, alternating going from 0->end and end->0 (i.e. to and fro)
|
||||
@ -114,11 +118,11 @@ 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) * settings["printer.layerHeight"] + zOffset;
|
||||
|
||||
var isTraveling = !isLoop && i==0;
|
||||
var doRetract = prev.distance(to) > retractionminDistance;
|
||||
|
||||
|
||||
if (enableTraveling && isTraveling) {
|
||||
// console.log("enableTraveling && isTraveling >> doRetract: " + doRetract + ", retractionspeed: " + retractionspeed);
|
||||
if (doRetract) gcode.push("G1 E" + (extruder - retractionamount).toFixed(3) + " F" + (retractionspeed * 60).toFixed(3));
|
||||
@ -126,7 +130,7 @@ function generate_gcode(callback) {
|
||||
if (doRetract) gcode.push("G1 E" + extruder.toFixed(3) + " F" + (retractionspeed * 60).toFixed(3));
|
||||
} else {
|
||||
// console.log(" else");
|
||||
extruder += prev.distance(to) * wallThickness * layerHeight / filamentThickness;
|
||||
extruder += prev.distance(to) * settings["printer.wallThickness"] * settings["printer.layerHeight"] / filamentThickness;
|
||||
gcode.push("G1 X" + to.x.toFixed(3) + " Y" + to.y.toFixed(3) + " Z" + z.toFixed(3) + " F" + (speed * 60).toFixed(3) + " E" + extruder.toFixed(3));
|
||||
}
|
||||
|
||||
|
128
js/settings.js
128
js/settings.js
@ -1,21 +1,28 @@
|
||||
var wifiboxURL;//"http://192.168.5.1/cgi-bin/d3dapi";
|
||||
|
||||
//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings()
|
||||
var settings = {
|
||||
layerHeight: 0.2,
|
||||
wallThickness: 0.6,
|
||||
filamentThickness: 2.89,
|
||||
speed: 50,
|
||||
travelSpeed: 200,
|
||||
autoWarmup: true,
|
||||
firstLayerSlow: true,
|
||||
useSubLayers: true,
|
||||
useRetraction: true,
|
||||
retractionAmount: 2,
|
||||
retractionMinDistance: 1,
|
||||
retractionSpeed: 250,
|
||||
networkIP: "192.168.10.1",
|
||||
networkNetmask: "255.255.255.0",
|
||||
networkSsid: "d3d-ap-%%MAC_ADDR_TAIL%%"
|
||||
// "network.ap.ssid": "d3d-ap-%%MAC_ADDR_TAIL%%",
|
||||
// "network.ap.address": "192.168.10.1",
|
||||
// "network.ap.netmask": "255.255.255.0",
|
||||
// "printer.temperature": 215,
|
||||
// "printer.objectHeight": '???',
|
||||
// "printer.layerHeight": 0.2,
|
||||
// "printer.wallThickness": 0.6,
|
||||
// "printer.speed": 50,
|
||||
// "printer.travelSpeed": 200,
|
||||
// "printer.filamentThickness": 2.89,
|
||||
// "printer.useSubLayers": true,
|
||||
// "printer.firstLayerSlow": true,
|
||||
// "printer.autoWarmUp": true,
|
||||
// "printer.simplify.iterations": 10,
|
||||
// "printer.simplify.minNumPoints": 15,
|
||||
// "printer.simplify.minDistance": 3,
|
||||
// "printer.retraction.enabled": true,
|
||||
// "printer.retraction.speed": 250,
|
||||
// "printer.retraction.minDistance": 1,
|
||||
// "printer.retraction.amount": 2,
|
||||
// "printer.autoWarmUpCommand": "M104 S230 (hardcoded temperature)"
|
||||
}
|
||||
|
||||
var settingsForm = $("#settingsForm");
|
||||
@ -29,6 +36,8 @@ function initSettingsPopup(apiURL) {
|
||||
console.log("f:initSettingsPopup()");
|
||||
wifiboxURL = apiURL;
|
||||
|
||||
loadSettings();
|
||||
|
||||
$("#contentOverlay").hide();
|
||||
|
||||
$("div.content .btnOK").click(function(e) {
|
||||
@ -57,60 +66,58 @@ function showSettings() {
|
||||
function loadSettings() {
|
||||
console.log("f:loadSettings() >> getting new data...");
|
||||
$.get(wifiboxURL + "/config/all", {}, function(data) {
|
||||
// console.log("f:loadSettings()");
|
||||
var settings = JSON.parse(data).data;
|
||||
// var printer_layerHeight = settings["printer.layerHeight"];
|
||||
// var printer_autoWarmup = settings["printer.autoWarmUp"];
|
||||
console.log("print_layerHeight = " + settings["printer.layerHeight"]);
|
||||
console.log("printer_autoWarmup = " + settings["printer.autoWarmUp"] + ", type: " + (typeof settings["printer.autoWarmUp"]));
|
||||
console.log("printer_useSubLayers = " + settings["printer.useSubLayers"] + " type: " + (typeof settings["printer.useSubLayers"]));
|
||||
$("#formpje input[name='printer.layerHeight']").attr('value', settings["printer.layerHeight"]);
|
||||
settings = JSON.parse(data).data;
|
||||
|
||||
// // var printer_layerHeight = settings["printer.layerHeight"];
|
||||
// // var printer_autoWarmup = settings["printer.autoWarmUp"];
|
||||
// console.log("print_layerHeight = " + settings["printer.layerHeight"]);
|
||||
// console.log("printer_autoWarmup = " + settings["printer.autoWarmUp"] + ", type: " + (typeof settings["printer.autoWarmUp"]));
|
||||
// console.log("printer_useSubLayers = " + settings["printer.useSubLayers"] + " type: " + (typeof settings["printer.useSubLayers"]));
|
||||
// $("#formpje input[name='printer.layerHeight']").attr('value', settings["printer.layerHeight"]);
|
||||
|
||||
// printer settings
|
||||
$('#autoWarmUp').prop('checked', settings["printer.autoWarmUp"]);
|
||||
$('#firstLayerSlow').prop('checked', settings["printer.firstLayerSlow"]);
|
||||
$('#useSubLayers').prop('checked', settings["printer.useSubLayers"]);
|
||||
$("#layerHeight").attr('value', settings["printer.layerHeight"]);
|
||||
$("#wallThickness").attr('value', settings["printer.wallThickness"]);
|
||||
$("#filamentThickness").attr('value', settings["printer.filamentThickness"]);
|
||||
$("#speed").attr('value', settings["printer.speed"]);
|
||||
$("#travelSpeed").attr('value', settings["printer.travelSpeed"]);
|
||||
$("#retractionAmount").attr('value', settings["printer.retraction.amount"]);
|
||||
$("#retractionMinDistance").attr('value', settings["printer.retraction.minDistance"]);
|
||||
$("#retractionSpeed").attr('value', settings["printer.retraction.speed"]);
|
||||
|
||||
// wifi settings
|
||||
|
||||
//update html with loaded wifi settings
|
||||
$("#ipaddress").attr('value', settings["network.ap.address"]);
|
||||
$("#netmask").attr('value', settings["network.ap.netmask"]);
|
||||
$("#ssid").attr('value', settings["network.ap.ssid"]);
|
||||
// network.ap.address: "192.168.10.1"
|
||||
// network.ap.netmask: "255.255.255.0"
|
||||
// network.ap.ssid: "d3d-ap-%%MAC_ADDR_TAIL%%"
|
||||
|
||||
//update html with loaded printer settings
|
||||
$("#printersettings input").each( function(index,element) {
|
||||
var element = $(element);
|
||||
//console.log("printer setting input",index,element,element.attr('name'));
|
||||
if(element.attr("type") == "text") {
|
||||
element.val(settings[element.attr('name')]);
|
||||
} else if(element.attr("type") == "checkbox") {
|
||||
//console.log("settings setting: ",settings[element.attr('name')],typeof settings[element.attr('name')]);
|
||||
element.attr('checked', settings[element.attr('name')]);
|
||||
}
|
||||
|
||||
//console.log(" val: ",$(element).val(),element);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function saveSettings(callback) {
|
||||
console.log("settings form submitted");
|
||||
console.log(" printer.layerHeight:" + $("#formpje input[name='printer.layerHeight']").attr('value'));
|
||||
console.log(" first layer slow (checkbox):" + $('#firstLayerSlow').prop('checked'));
|
||||
console.log(" use sublayers (checkbox):" + $('#useSubLayers').prop('checked'));
|
||||
// console.log("settings form submitted");
|
||||
// console.log(" printer.layerHeight:" + $("#formpje input[name='printer.layerHeight']").attr('value'));
|
||||
// console.log(" first layer slow (checkbox):" + $('#firstLayerSlow').prop('checked'));
|
||||
// console.log(" use sublayers (checkbox):" + $('#useSubLayers').prop('checked'));
|
||||
|
||||
//var printerSettings = {};
|
||||
$("#printersettings input").each( function(index,element) {
|
||||
var element = $(element);
|
||||
//populate settings are with values from html
|
||||
if(element.attr("type") == "text") {
|
||||
settings[element.attr('name')] = element.val();
|
||||
} else if(element.attr("type") == "checkbox") {
|
||||
settings[element.attr('name')] = element.attr('checked')
|
||||
}
|
||||
});
|
||||
|
||||
$.post(
|
||||
wifiboxURL + "/config",
|
||||
{
|
||||
"printer.autoWarmUp" : ($('#autoWarmUp').prop('checked') == true) ? 1 : 0,
|
||||
"printer.firstLayerSlow": ($('#firstLayerSlow').prop('checked') == true) ? 1 : 0,
|
||||
"printer.useSubLayers": ($('#useSubLayers').prop('checked') == true) ? true : false,
|
||||
// "printer.useSubLayers": $('#useSubLayers').prop('checked'),
|
||||
"printer.layerHeight": $("#layerHeight").attr('value'),
|
||||
"printer.wallThickness": $("#wallThickness").attr('value'),
|
||||
"printer.filamentThickness": $("#filamentThickness").attr('value'),
|
||||
"printer.speed": $("#speed").attr('value'),
|
||||
"printer.travelSpeed": $("#travelSpeed").attr('value'),
|
||||
"printer.retraction.amount": $("#retractionAmount").attr('value'),
|
||||
"printer.retraction.minDistance": $("#retractionMinDistance").attr('value'),
|
||||
"printer.retraction.speed": $("#retractionSpeed").attr('value')
|
||||
},
|
||||
settings,
|
||||
function(data) {
|
||||
var res = JSON.parse(data).data;
|
||||
$.each(res, function(index, val) {
|
||||
@ -121,8 +128,6 @@ function saveSettings(callback) {
|
||||
if (callback != undefined) {
|
||||
callback();
|
||||
}
|
||||
// console.log(JSON.stringify(data));
|
||||
// console.log(JSON.parse(data).data);
|
||||
}
|
||||
);
|
||||
}
|
||||
@ -135,6 +140,7 @@ function saveSettings(callback) {
|
||||
* FROM DOODLE3D.INI
|
||||
*
|
||||
*/
|
||||
//TODO: find all references to these variables, replace them and finally remove these.
|
||||
var objectHeight = 20;
|
||||
var layerHeight = .2;
|
||||
var wallThickness = .5;
|
||||
@ -180,4 +186,4 @@ var windowcenter = true;
|
||||
var windowfullscreen = false;
|
||||
var autoWarmUpCommand = "M104 S230";
|
||||
var checkTemperatureInterval = 3;
|
||||
var autoWarmUpDelay = 3;
|
||||
var autoWarmUpDelay = 3;
|
||||
|
@ -47,23 +47,24 @@
|
||||
<button>Check connection...</button>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<fieldset id="printersettings">
|
||||
<legend>Print settings</legend>
|
||||
<label for="layerHeight">Layer height:</label><input type="text" class="small" name="layerHeight" id="layerHeight" value="0.12">mm<br>
|
||||
<label for="wallThickness">Wall thickness:</label><input type="text" class="small" name="wallThickness" id="wallThickness" value="0.6">mm<br>
|
||||
<label for="filamentThickness">Filament thickness:</label><input type="text" class="small" name="filamentThickness" id="filamentThickness" value="2.89">mm<br>
|
||||
<label for="layerHeight">Layer height:</label><input type="text" class="small" name="printer.layerHeight">mm<br>
|
||||
<label for="wallThickness">Wall thickness:</label><input type="text" class="small" name="printer.wallThickness">mm<br>
|
||||
<label for="filamentThickness">Filament thickness:</label><input type="text" class="small" name="printer.filamentThickness">mm<br>
|
||||
<label for="temperature">Temperature:</label><input type="text" class="small" name="printer.temperature">degrees C<br>
|
||||
<br>
|
||||
<label for="speed">Speed:</label><input type="text" name="speed" id="speed" class="small" value="50">mm/s<br>
|
||||
<label for="travelSpeed">Travel speed:</label><input type="text" name="travelSpeed" id="travelSpeed" class="small" value="200">mm/s<br>
|
||||
<label for="speed">Speed:</label><input type="text" name="printer.speed" class="small">mm/s<br>
|
||||
<label for="travelSpeed">Travel speed:</label><input type="text" name="printer.travelSpeed" class="small">mm/s<br>
|
||||
<br>
|
||||
<label for="autoWarmUp">Auto warm-up:</label><input type="checkbox" name="autoWarmUp" id="autoWarmUp" value="autoWarmUp" checked><br>
|
||||
<label for="firstLayerSlow">First layer slow:</label><input type="checkbox" name="firstLayerSlow" id="firstLayerSlow" value="firstLayerSlow" checked><br>
|
||||
<label for="useSubLayers">Use sub-layers:</label><input type="checkbox" name="useSubLayers" id="useSubLayers" value="firstLayerSlow" checked><br>
|
||||
<label for="useRetraction">Use retraction:</label><input type="checkbox" name="useRetraction" id="useRetraction" value="useRetraction" checked><br>
|
||||
<label for="autoWarmUp">Auto warm-up:</label><input type="checkbox" name="printer.autoWarmUp" value="autoWarmUp"><br>
|
||||
<label for="firstLayerSlow">First layer slow:</label><input type="checkbox" name="printer.firstLayerSlow" value="firstLayerSlow"><br>
|
||||
<label for="useSubLayers">Use sub-layers:</label><input type="checkbox" name="printer.useSubLayers" value="firstLayerSlow"><br>
|
||||
<label for="useRetraction">Use retraction:</label><input type="checkbox" name="printer.retraction.enabled" value="useRetraction"><br>
|
||||
<br>
|
||||
<label for="retractionAmount">Retraction amount:</label><input type="text" class="small" name="retractionAmount" id="retractionAmount" value="2">mm<br>
|
||||
<label for="retractionMinDistance">Retraction min distance:</label><input type="text" class="small" name="retractionMinDistance" id="retractionMinDistance" value="1">mm<br>
|
||||
<label for="retractionSpeed">Retraction speed:</label><input type="text" class="small" name="retractionSpeed" id="retractionSpeed" value="250">mm/s<br>
|
||||
<label for="retractionAmount">Retraction amount:</label><input type="text" class="small" name="printer.retraction.amount">mm<br>
|
||||
<label for="retractionMinDistance">Retraction min distance:</label><input type="text" class="small" name="printer.retraction.minDistance">mm<br>
|
||||
<label for="retractionSpeed">Retraction speed:</label><input type="text" class="small" name="printer.retraction.speed">mm/s<br>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@ -243,5 +244,6 @@ printer.temperature: 230
|
||||
X printer.travelSpeed: 200
|
||||
X printer.useSubLayers: true
|
||||
X printer.wallThickness: 0.5
|
||||
X printer.temperature: 230
|
||||
|
||||
-->
|
||||
|
Loading…
Reference in New Issue
Block a user