2013-07-29 19:07:41 +02:00
|
|
|
var wifiboxURL;//"http://192.168.5.1/cgi-bin/d3dapi";
|
2013-07-28 02:47:42 +02:00
|
|
|
|
2013-08-01 20:01:52 +02:00
|
|
|
//these settings are defined in the firmware (conf_defaults.lua) and will be initialized in loadSettings()
|
2013-07-28 02:47:42 +02:00
|
|
|
var settings = {
|
2013-08-08 00:22:23 +02:00
|
|
|
"network.ap.ssid": "d3d-ap-%%MAC_ADDR_TAIL%%",
|
|
|
|
"network.ap.address": "192.168.10.1",
|
|
|
|
"network.ap.netmask": "255.255.255.0",
|
2013-08-12 21:54:30 +02:00
|
|
|
"printer.temperature": 220,
|
2013-08-08 00:22:23 +02:00
|
|
|
"printer.objectHeight": '???',
|
|
|
|
"printer.layerHeight": 0.2,
|
2013-08-12 21:54:30 +02:00
|
|
|
"printer.wallThickness": 0.7,
|
2013-08-08 00:22:23 +02:00
|
|
|
"printer.speed": 50,
|
|
|
|
"printer.travelSpeed": 200,
|
2013-08-12 21:54:30 +02:00
|
|
|
"printer.filamentThickness": 2.85,
|
2013-08-08 00:22:23 +02:00
|
|
|
"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,
|
2013-08-09 22:25:14 +02:00
|
|
|
"printer.autoWarmUpCommand": "M104 S220 (hardcoded temperature)"
|
2013-07-28 02:47:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var settingsForm = $("#settingsForm");
|
|
|
|
settingsForm.submit(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
saveSettings();
|
|
|
|
return false;
|
|
|
|
})
|
|
|
|
|
2013-07-29 19:07:41 +02:00
|
|
|
function initSettingsPopup(apiURL) {
|
2013-07-28 02:47:42 +02:00
|
|
|
console.log("f:initSettingsPopup()");
|
2013-07-29 19:07:41 +02:00
|
|
|
wifiboxURL = apiURL;
|
2013-07-28 02:47:42 +02:00
|
|
|
|
2013-08-16 22:25:25 +02:00
|
|
|
if (communicateWithWifibox) loadSettings();
|
|
|
|
|
2013-07-28 02:47:42 +02:00
|
|
|
$("#contentOverlay").hide();
|
|
|
|
|
|
|
|
$("div.content .btnOK").click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2013-08-16 22:25:25 +02:00
|
|
|
|
2013-07-28 02:47:42 +02:00
|
|
|
// TODO something like a callback or feedback that saving went well / or failed
|
2013-08-16 22:25:25 +02:00
|
|
|
|
|
|
|
if (communicateWithWifibox) saveSettings();
|
2013-07-28 02:47:42 +02:00
|
|
|
|
|
|
|
$("#contentOverlay").fadeOut(375, function() {
|
|
|
|
document.body.addEventListener('touchmove',prevent,false);
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log("button OK in settings popup pressed");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function showSettings() {
|
|
|
|
console.log("f:showSettings()");
|
2013-08-16 22:25:25 +02:00
|
|
|
if (!communicateWithWifibox) console.log(" communicateWithWifibox is false: settings aren't being loaded from wifibox...")
|
2013-07-28 02:47:42 +02:00
|
|
|
$("#contentOverlay").fadeIn(375, function() {
|
|
|
|
console.log("#contentOverlay faded in...");
|
2013-08-16 22:25:25 +02:00
|
|
|
if (communicateWithWifibox) loadSettings();
|
2013-07-28 02:47:42 +02:00
|
|
|
document.body.removeEventListener('touchmove',prevent,false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadSettings() {
|
|
|
|
console.log("f:loadSettings() >> getting new data...");
|
|
|
|
$.get(wifiboxURL + "/config/all", {}, function(data) {
|
2013-08-01 20:01:52 +02:00
|
|
|
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"]);
|
|
|
|
|
|
|
|
|
|
|
|
//update html with loaded wifi settings
|
2013-07-28 02:47:42 +02:00
|
|
|
$("#ipaddress").attr('value', settings["network.ap.address"]);
|
|
|
|
$("#netmask").attr('value', settings["network.ap.netmask"]);
|
|
|
|
$("#ssid").attr('value', settings["network.ap.ssid"]);
|
|
|
|
|
2013-08-01 20:01:52 +02:00
|
|
|
//update html with loaded printer settings
|
2013-08-12 21:54:30 +02:00
|
|
|
|
2013-08-01 20:01:52 +02:00
|
|
|
$("#printersettings input").each( function(index,element) {
|
|
|
|
var element = $(element);
|
2013-08-12 21:54:30 +02:00
|
|
|
//console.log("printer setting input: ",index,element.attr("type"),element.attr('name')); //,element);
|
2013-08-01 20:01:52 +02:00
|
|
|
if(element.attr("type") == "text") {
|
|
|
|
element.val(settings[element.attr('name')]);
|
|
|
|
} else if(element.attr("type") == "checkbox") {
|
2013-08-12 21:54:30 +02:00
|
|
|
element.prop('checked', settings[element.attr('name')]);
|
2013-08-01 20:01:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//console.log(" val: ",$(element).val(),element);
|
|
|
|
|
|
|
|
});
|
2013-07-28 02:47:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveSettings(callback) {
|
2013-08-16 22:25:25 +02:00
|
|
|
console.log("settings form submitted");
|
2013-08-01 20:01:52 +02:00
|
|
|
// 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") {
|
2013-08-12 21:54:30 +02:00
|
|
|
settings[element.attr('name')] = element.prop('checked')
|
2013-08-01 20:01:52 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-07-28 02:47:42 +02:00
|
|
|
$.post(
|
|
|
|
wifiboxURL + "/config",
|
2013-08-01 20:01:52 +02:00
|
|
|
settings,
|
2013-07-28 02:47:42 +02:00
|
|
|
function(data) {
|
|
|
|
var res = JSON.parse(data).data;
|
|
|
|
$.each(res, function(index, val) {
|
|
|
|
if (val != "ok") {
|
|
|
|
console.log("ERROR: value '" + index + "' not successfully set. Message: " + val);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (callback != undefined) {
|
|
|
|
callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* FROM DOODLE3D.INI
|
|
|
|
*
|
|
|
|
*/
|
2013-08-01 20:01:52 +02:00
|
|
|
//TODO: find all references to these variables, replace them and finally remove these.
|
2013-07-26 22:39:28 +02:00
|
|
|
var objectHeight = 20;
|
|
|
|
var layerHeight = .2;
|
2013-08-12 21:54:30 +02:00
|
|
|
//var wallThickness = .5;
|
2013-07-26 22:39:28 +02:00
|
|
|
var hop = 0;
|
2013-08-12 21:54:30 +02:00
|
|
|
//var speed = 70;
|
|
|
|
//var travelSpeed = 200;
|
2013-07-26 22:39:28 +02:00
|
|
|
var enableTraveling = true;
|
2013-08-12 21:54:30 +02:00
|
|
|
//var filamentThickness = 2.89;
|
2013-07-26 22:39:28 +02:00
|
|
|
var minScale = .3;
|
|
|
|
var maxScale = 1;
|
|
|
|
var shape = "%";
|
|
|
|
var twists = 0;
|
|
|
|
var useSubLayers = true;
|
2013-08-16 22:25:25 +02:00
|
|
|
//var debug = false; // debug moved to main.js
|
2013-07-26 22:39:28 +02:00
|
|
|
var loglevel = 2;
|
|
|
|
var zOffset = 0;
|
|
|
|
var serverport = 8888;
|
|
|
|
var autoLoadImage = "hand.txt";
|
|
|
|
var loadOffset = [0, 0]; // x en y ?
|
|
|
|
var showWarmUp = true;
|
|
|
|
var loopAlways = false;
|
|
|
|
var firstLayerSlow = true;
|
|
|
|
var useSubpathColors = false;
|
|
|
|
var autoWarmUp = true;
|
|
|
|
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 sideis3D = true;
|
|
|
|
var sidevisible = true;
|
|
|
|
var sidebounds = [900, 210, 131, 390];
|
|
|
|
var sideborder = [880, 169, 2, 471];
|
|
|
|
var windowbounds = [0, 0, 800, 500];
|
|
|
|
var windowcenter = true;
|
|
|
|
var windowfullscreen = false;
|
|
|
|
var autoWarmUpCommand = "M104 S230";
|
2013-08-07 20:47:47 +02:00
|
|
|
//var checkTemperatureInterval = 3;
|
2013-08-01 20:01:52 +02:00
|
|
|
var autoWarmUpDelay = 3;
|