mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2025-06-11 17:23:17 +02:00
Basic feedback and more control
Display temperature Only show temperature when connected with printer Move index.html javascript to main.js stop button (Still having issues in firmware) OOP style printer control Added a proxy.php file to forward cross domain posts and get's. (should not be necessary)
This commit is contained in:
79
js/Printer.js
Normal file
79
js/Printer.js
Normal file
@ -0,0 +1,79 @@
|
||||
function Printer() {
|
||||
this.temperature = 0;
|
||||
this.targetTemperature = 0;
|
||||
|
||||
this.wifiboxURL;
|
||||
|
||||
this.checkTemperatureIntervalTime = 1000;
|
||||
this.checkTemperatureInterval;
|
||||
|
||||
this.maxTempLastMod = 5; // max time (seconds) since the last temp info modification before the printer connection is considered lost
|
||||
|
||||
// Events
|
||||
Printer.UPDATE = "update";
|
||||
|
||||
this.init = function() {
|
||||
console.log("Printer:init");
|
||||
//this.wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
||||
//this.wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
||||
this.wifiboxURL = wifiboxURL;
|
||||
//this.wifiboxURL = "proxy5.php";
|
||||
console.log(" wifiboxURL: ",this.wifiboxURL);
|
||||
|
||||
var self = this;
|
||||
this.checkTemperatureInterval = setInterval(function() { self.checkTemperature(); },this.checkTemperatureIntervalTime);
|
||||
}
|
||||
|
||||
this.preheat = function() {
|
||||
console.log("Printer:preheat");
|
||||
var postData = { id: 0 };
|
||||
$.post( this.wifiboxURL + "/printer/heatup", postData , function(e) {
|
||||
console.log("Printer:preheat response: " + e);
|
||||
|
||||
if (e.success = true) {
|
||||
console.log(" success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.stop = function() {
|
||||
console.log("Printer:stop");
|
||||
var postData = { id: 0 };
|
||||
$.post( this.wifiboxURL + "/printer/stop", postData , function(e) {
|
||||
console.log("Printer:stop response: " + e);
|
||||
|
||||
if (e.success = true) {
|
||||
console.log(" success");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.checkTemperature = function() {
|
||||
//console.log("Printer:checkTemperature");
|
||||
var getData = { id: 0 };
|
||||
var self = this;
|
||||
$.get( this.wifiboxURL + "/printer/temperature", getData , function(e) {
|
||||
//console.log("Printer:temperature response: " + e);
|
||||
|
||||
if (e.success = true) {
|
||||
var response = jQuery.parseJSON(e);
|
||||
//console.log("response: ",response);
|
||||
|
||||
if(response.status == "success") {
|
||||
//console.log("temp: ",response.data.hotend+"/"+response.data.hotend_target+" ("+response.data.last_mod+")");
|
||||
|
||||
self.temperature = response.data.hotend;
|
||||
if(response.data.hotend_target != undefined) {
|
||||
self.targetTemperature = response.data.hotend_target;
|
||||
}
|
||||
|
||||
self.alive = (response.data.last_mod < self.maxTempLastMod);
|
||||
} else {
|
||||
self.alive = false;
|
||||
}
|
||||
//console.log(" this.alive: ",self.alive);
|
||||
$(document).trigger(Printer.UPDATE);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -13,6 +13,8 @@ var btnMoveUp, btnMoveDown, btnTwistLeft, btnTwistRight;
|
||||
var btnInfo, btnSettings;
|
||||
var btnDebug; // debug
|
||||
|
||||
var displayTempEnabled = false;
|
||||
|
||||
function initButtonBehavior() {
|
||||
console.log("f:initButtonBehavior >> btnNew = " + btnNew);
|
||||
|
||||
@ -25,6 +27,8 @@ function initButtonBehavior() {
|
||||
btnInfo = $("#btnInfo");
|
||||
btnSettings = $("#btnSettings");
|
||||
// btnPrint= $("#btnPrint");
|
||||
btnStop = $("#btnStop");
|
||||
displayTemp = $("#displayTemp");
|
||||
|
||||
// btnPrevious = $("#btnPrevious");
|
||||
// btnNext = $("#btnNext");
|
||||
@ -202,6 +206,10 @@ function initButtonBehavior() {
|
||||
$(".agentInfo").toggleClass("agentInfoToggle");
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
btnStop.click(function(e) {
|
||||
printer.stop()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -290,4 +298,20 @@ function previewTwistRight() {
|
||||
rStep += twistIncrement;
|
||||
// }
|
||||
redrawPreview();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updatePrinterInfo() {
|
||||
if(!displayTempEnabled && printer.alive) {
|
||||
displayTemp.show();
|
||||
displayTempEnabled = true;
|
||||
} else if(displayTempEnabled && !printer.alive) {
|
||||
displayTemp.hide();
|
||||
displayTempEnabled = false;
|
||||
}
|
||||
|
||||
if(displayTempEnabled) {
|
||||
displayTemp.text(printer.temperature+"/"+printer.targetTemperature);
|
||||
}
|
||||
}
|
@ -121,6 +121,8 @@ function generate_gcode(callback) {
|
||||
var sublayer = (layer == 0) ? 0.0 : layer + (useSubLayers ? (curLayerCommand/totalLayerCommands) : 0);
|
||||
var z = (sublayer + 1) * settings["printer.layerHeight"] + zOffset;
|
||||
|
||||
// TODO if (z > layerheight*2) do M106 (enable fan)
|
||||
|
||||
var isTraveling = !isLoop && i==0;
|
||||
var doRetract = prev.distance(to) > retractionminDistance;
|
||||
|
||||
|
51
js/main.js
Normal file
51
js/main.js
Normal file
@ -0,0 +1,51 @@
|
||||
// not using these at the moment
|
||||
$("#btnPrevious").css("opacity", "0.3");
|
||||
$("#btnNext").css("opacity", "0.3");
|
||||
$("#btnSave").css("opacity", "0.3");
|
||||
$("#btnInfo").css("opacity", "0.3");
|
||||
//$("#btnSettings").css("opacity", "0.3");
|
||||
|
||||
// var debug = true;
|
||||
|
||||
var printer = new Printer();
|
||||
var updateTemperatureInterval;
|
||||
|
||||
$(function() {
|
||||
console.log("ready");
|
||||
//var wifiboxURL = "http://" + window.location.host + "/cgi-bin/d3dapi";
|
||||
var wifiboxURL = "http://192.168.5.1/cgi-bin/d3dapi";
|
||||
console.log("wifibox URL: " + wifiboxURL);
|
||||
|
||||
initLayouting();
|
||||
|
||||
initDoodleDrawing();
|
||||
initPreviewRendering();
|
||||
|
||||
initButtonBehavior();
|
||||
|
||||
initSettingsPopup(wifiboxURL);
|
||||
|
||||
$("#settings .settings").load("settings.html", function() {
|
||||
console.log("finished loading settings.html, now loading settings...");
|
||||
loadSettings();
|
||||
});
|
||||
|
||||
if(debug) {
|
||||
console.log("debug mode");
|
||||
$("body").css("overflow", "auto");
|
||||
$("#debug_textArea").css("display", "block");
|
||||
}
|
||||
|
||||
printer.init();
|
||||
printer.preheat();
|
||||
|
||||
$(document).on(Printer.UPDATE,updatePrinterInfo);
|
||||
// $("#mycanvas").css("scale", 0.5);
|
||||
|
||||
|
||||
|
||||
|
||||
//debug
|
||||
// generate_gcode();
|
||||
|
||||
})
|
@ -185,5 +185,5 @@ var windowbounds = [0, 0, 800, 500];
|
||||
var windowcenter = true;
|
||||
var windowfullscreen = false;
|
||||
var autoWarmUpCommand = "M104 S230";
|
||||
var checkTemperatureInterval = 3;
|
||||
//var checkTemperatureInterval = 3;
|
||||
var autoWarmUpDelay = 3;
|
||||
|
Reference in New Issue
Block a user