2013-08-16 22:28:58 +02:00
|
|
|
var debugMode = false; // debug mode
|
|
|
|
var sendPrintCommands = true; // if Doodle3d should send print commands to the 3d printer
|
|
|
|
var communicateWithWifibox = true; // if Doodle3d should try interfacing with the wifibox (in case one is not connected)
|
2013-08-20 10:55:08 +02:00
|
|
|
var wifiboxIsRemote = false; // when you want to run the client on a computer and have it remotely connect to the wifibox
|
2013-08-27 15:34:28 +02:00
|
|
|
var autoUpdate = true; // auto retrieve updates about temperature and progress from printer
|
2013-08-07 20:47:47 +02:00
|
|
|
|
2013-09-17 13:08:52 +02:00
|
|
|
var printer = new Printer();
|
|
|
|
var thermometer = new Thermometer();
|
2013-08-27 15:34:28 +02:00
|
|
|
var settingsWindow = new SettingsWindow();
|
2013-09-17 13:08:52 +02:00
|
|
|
|
2013-09-18 10:46:36 +02:00
|
|
|
var $drawAreaContainer, $doodleCanvas, doodleCanvas, doodleCanvasContext, $previewContainer;
|
|
|
|
|
2013-08-07 20:47:47 +02:00
|
|
|
$(function() {
|
|
|
|
console.log("ready");
|
2013-08-16 22:28:58 +02:00
|
|
|
|
2013-09-18 10:46:36 +02:00
|
|
|
|
|
|
|
//TODO give more logical place in code
|
|
|
|
$drawAreaContainer = $("#drawAreaContainer");
|
|
|
|
$doodleCanvas = $("#mycanvas");
|
|
|
|
doodleCanvas = $("#mycanvas")[0];
|
|
|
|
doodleCanvasContext = doodleCanvas.getContext('2d');
|
|
|
|
|
|
|
|
$drawAreaContainer.css("margin", 0);
|
|
|
|
$drawAreaContainer.css("marginLeft", -parseInt($drawAreaContainer.css("width"))/2);
|
|
|
|
$drawAreaContainer.css("marginTop", -parseInt($drawAreaContainer.css("height"))/2);
|
|
|
|
|
|
|
|
doodleCanvas.width = doodleCanvas.clientWidth;
|
|
|
|
doodleCanvas.height = doodleCanvas.clientWidth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-16 22:28:58 +02:00
|
|
|
if (getURLParameter("d") != "null") debugMode = (getURLParameter("d") == "1");
|
|
|
|
if (getURLParameter("p") != "null") sendPrintCommands = (getURLParameter("p") == "1");
|
|
|
|
if (getURLParameter("c") != "null") communicateWithWifibox = (getURLParameter("c") == "1");
|
|
|
|
if (getURLParameter("r") != "null") wifiboxIsRemote = (getURLParameter("r") == "1");
|
2013-08-27 15:34:28 +02:00
|
|
|
if (getURLParameter("u") != "null") autoUpdate = (getURLParameter("u") == "1");
|
2013-08-19 17:55:01 +02:00
|
|
|
|
|
|
|
if (wifiboxIsRemote) {
|
|
|
|
wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
|
|
|
} else {
|
|
|
|
wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!communicateWithWifibox) {
|
2013-08-16 22:28:58 +02:00
|
|
|
sendPrintCommands = false; // 'communicateWithWifibox = false' implies this
|
|
|
|
}
|
|
|
|
console.log("debugMode: " + debugMode);
|
|
|
|
console.log("sendPrintCommands: " + sendPrintCommands);
|
|
|
|
console.log("communicateWithWifibox: " + communicateWithWifibox);
|
|
|
|
console.log("wifiboxIsRemote: " + wifiboxIsRemote);
|
2013-08-07 20:47:47 +02:00
|
|
|
console.log("wifibox URL: " + wifiboxURL);
|
2013-08-09 22:25:14 +02:00
|
|
|
|
2013-08-07 20:47:47 +02:00
|
|
|
initLayouting();
|
|
|
|
initDoodleDrawing();
|
|
|
|
initPreviewRendering();
|
|
|
|
initButtonBehavior();
|
|
|
|
|
2013-09-17 13:08:52 +02:00
|
|
|
thermometer.init($("#thermometerCanvas"));
|
|
|
|
|
|
|
|
printer.init();
|
2013-08-27 15:34:28 +02:00
|
|
|
$(document).on(Printer.UPDATE,update);
|
|
|
|
|
|
|
|
settingsWindow.init(wifiboxURL);
|
|
|
|
$(document).on(SettingsWindow.SETTINGS_LOADED,settingsLoaded);
|
2013-09-07 16:06:59 +02:00
|
|
|
|
2013-08-27 15:34:28 +02:00
|
|
|
if(debugMode) {
|
2013-08-16 22:28:58 +02:00
|
|
|
console.log("debug mode is true");
|
2013-08-07 20:47:47 +02:00
|
|
|
$("body").css("overflow", "auto");
|
|
|
|
$("#debug_textArea").css("display", "block");
|
2013-08-21 17:37:20 +02:00
|
|
|
$("#preview_tmp").css("display", "block");
|
2013-09-07 16:06:59 +02:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
//*/
|
2013-08-07 20:47:47 +02:00
|
|
|
}
|
2013-08-27 15:34:28 +02:00
|
|
|
})
|
|
|
|
function settingsLoaded() {
|
|
|
|
console.log("settingsLoaded");
|
|
|
|
console.log("autoWarmUp: ",settings["printer.autoWarmUp"]);
|
|
|
|
if(settings["printer.autoWarmUp"]) {
|
|
|
|
printer.preheat();
|
|
|
|
}
|
|
|
|
}
|