Skip to content

Commit

Permalink
Slight delay for gcode generation so that display is updated first. H…
Browse files Browse the repository at this point in the history
…ide stop untill gcode is send completely.
  • Loading branch information
peteruithoven committed Oct 14, 2013
1 parent e29dd15 commit 51e4394
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
1 change: 1 addition & 0 deletions js/Printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function Printer() {
if (completed) {
console.log("Printer:sendPrintPart:gcode sending completed");
this.gcode = [];
btnStop.css("display","block");
//self.targetTemperature = settings["printer.temperature"]; // slight hack
} else {
// only if the state hasn't bin changed (by for example pressing stop) we send more gcode
Expand Down
51 changes: 30 additions & 21 deletions js/buttonbehaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ var state;
var prevState;
var hasControl;

var gcodeGenerateDelayer;
var gcodeGenerateDelay = 50;

function initButtonBehavior() {
console.log("f:initButtonBehavior");

Expand Down Expand Up @@ -207,35 +210,41 @@ function nextDoodle(e) {
function print(e) {
console.log("f:print() >> sendPrintCommands = " + sendPrintCommands);

$(".btnPrint").css("display","none");
//$(".btnPrint").css("display","none");

$("#textdump").text("");

if (_points.length > 2) {

//setState(Printer.BUFFERING_STATE,printer.hasControl);
//setState(Printer.BUFFERING_STATE,printer.hasControl);
printer.overruleState(Printer.BUFFERING_STATE);
var gcode = generate_gcode();
//startPrint(gencode);

if (sendPrintCommands) {
printer.print(gcode);
} else {
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
}

//if (debugMode) {
//console.log("f:print() >> debugMode is true, dumping gcode to textarea #textdump");
$("#textdump").text(gcode.join("\n"));
//}

// copyToClipboard(gencode);
//*/

btnStop.css("display","none");

// we put the gcode generation in a little delay
// so that for example the print button is disabled right away
clearTimeout(gcodeGenerateDelayer);
gcodeGenerateDelayer = setTimeout(function() {
var gcode = generate_gcode();
//startPrint(gencode);

if (sendPrintCommands) {
printer.print(gcode);
} else {
console.log("sendPrintCommands is false: not sending print command to 3dprinter");
}

if (debugMode) {
$("#textdump").text("");
$("#textdump").text(gcode.join("\n"));
}

}, gcodeGenerateDelay);
} else {
console.log("f:print >> not enough points!");
}

alert("Je tekening zal nu geprint worden");
$(".btnPrint").css("display","block");
//alert("Je tekening zal nu geprint worden");
//$(".btnPrint").css("display","block");


// $.post("/doodle3d.of", { data:output }, function(data) {
Expand Down

0 comments on commit 51e4394

Please sign in to comment.