From 1c930efdf58732eccb7c3d63799fd390c2acacf5 Mon Sep 17 00:00:00 2001 From: peteruithoven Date: Fri, 11 Oct 2013 15:33:37 +0200 Subject: [PATCH] Starting print right away, remove some target temp display hacks --- js/Printer.js | 23 ++++++++++++++--------- js/Thermometer.js | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/js/Printer.js b/js/Printer.js index 362ba8f..8868dc0 100644 --- a/js/Printer.js +++ b/js/Printer.js @@ -111,7 +111,7 @@ function Printer() { return; } - this.targetTemperature = settings["printer.temperature"]; // slight hack + //this.targetTemperature = settings["printer.temperature"]; // slight hack this.sendPrintPart(this.sendIndex, this.sendLength); } @@ -122,15 +122,18 @@ function Printer() { console.log("Printer:sendPrintPart sendIndex: " + sendIndex + "/" + this.gcode.length + ", sendLength: " + sendLength); var firstOne = (sendIndex == 0)? true : false; - var lastOne = false; + var start = true; // start printing right away + + var completed = false; if (this.gcode.length < (sendIndex + sendLength)) { console.log(" sending less than max sendLength (and last)"); sendLength = this.gcode.length - sendIndex; - lastOne = true; + //lastOne = true; + completed = true; } var gcodePart = this.gcode.slice(sendIndex, sendIndex+sendLength); - var postData = { gcode: gcodePart.join("\n"), first: firstOne, last: lastOne}; + var postData = { gcode: gcodePart.join("\n"), first: firstOne, start: start}; var self = this; if (communicateWithWifibox) { $.ajax({ @@ -143,11 +146,12 @@ function Printer() { console.log("Printer:sendPrintPart response: ",data); if(data.status == "success") { - if (lastOne) { + if (completed) { console.log("Printer:sendPrintPart:gcode sending completed"); this.gcode = []; - self.targetTemperature = settings["printer.temperature"]; // slight hack + //self.targetTemperature = settings["printer.temperature"]; // slight hack } else { + console.log("sending next part"); self.sendPrintPart(sendIndex + sendLength, sendLength); } } @@ -155,7 +159,10 @@ function Printer() { }).fail(function() { console.log("Printer:sendPrintPart: failed"); clearTimeout(self.retrySendPrintPartDelay); - self.retrySendPrintPartDelay = setTimeout(function() { self.sendPrintPart(sendIndex, sendLength) },self.retryDelay); // retry after delay + self.retrySendPrintPartDelay = setTimeout(function() { + console.log("request printer:sendPrintPart failed retry"); + self.sendPrintPart(sendIndex, sendLength) + },self.retryDelay); // retry after delay }); } else { console.log ("Printer >> f:sendPrintPart() >> communicateWithWifibox is false, so not executing this function"); @@ -173,8 +180,6 @@ function Printer() { timeout: this.timeoutTime, success: function(data){ console.log("Printer:stop response: ", data); - - setTimeout(function() { console.log("send: ",gcodeEnd); self.print(gcodeEnd) },self.sendStopGCodeDelay); } }).fail(function() { console.log("Printer:stop: failed"); diff --git a/js/Thermometer.js b/js/Thermometer.js index 2e79fa2..cae66d3 100644 --- a/js/Thermometer.js +++ b/js/Thermometer.js @@ -5,7 +5,7 @@ var $displayThermometer = $("#thermometerContainer"); //TODO 2013-09-18 allow displaying temperatures HIGHER than the targTemp (it's now being capped at targTemp). function Thermometer() { this.currentTemperature = 0; // default val - this.targetTemperature = 180; // default val + this.targetTemperature = 0; // default val this.thermoOverlayImg = new Image(); this.thermoOverlayImgSrc = "img/thermometer_fg_overlay.png"; // ../img/thermometer_fg_overlay.png