0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-21 17:07:55 +01:00

Enable sending gcode. It prints!

This commit is contained in:
Wouter R 2013-07-29 16:48:13 +02:00
parent cbbe820d77
commit 7972273e27
3 changed files with 44 additions and 52 deletions

View File

@ -213,36 +213,34 @@ function nextDoodle(e) {
}
function print(e) {
console.log("f:print()");
console.log("f:print()");
$("#textdump").text("");
if (_points.length > 2) {
//*
// generate_gcode();
var gencode = generate_gcode();
startPrint();
$("#textdump").text("");
if (_points.length > 2) {
var gencode = generate_gcode();
startPrint(gencode);
// console.log("");
// console.log("");
// console.log("-------------------------------------------------");
// console.log("generated gcode:");
// console.log(gencode);
// console.log("-------------------------------------------------");
// console.log("");
// console.log("");
// console.log("");
// console.log("");
// console.log("");
// console.log("-------------------------------------------------");
// console.log("generated gcode:");
// console.log(gencode);
// console.log("-------------------------------------------------");
// console.log("");
// console.log("");
// console.log("");
$("#textdump").text(gencode);
// copyToClipboard(gencode);
//*/
} else {
console.log("f:print >> not enough points!");
}
$("#textdump").text(gencode.join("\n"));
// copyToClipboard(gencode);
//*/
} else {
console.log("f:print >> not enough points!");
}
// $.post("/doodle3d.of", { data:output }, function(data) {
// btnPrint.disabled = false;
// });
// $.post("/doodle3d.of", { data:output }, function(data) {
// btnPrint.disabled = false;
// });
}

View File

@ -5,32 +5,20 @@ var sendLength;
var kastjeURL = "http://192.168.5.1/cgi-bin/d3dapi/";
var mydata = "";
function startPrint() {
console.log("f:startPrint()");
var data = "";
function startPrint(gcode) {
console.log("f:startPrint()");
console.log("total # of lines: " + gcode.length);
data = gcode;
// sendIndex = 0;
// sendLength = 2000; // 2000 regels
// sendGCodeSlice(sendIndex, sendLength);
// 2013-07-28 tot hier en niet verder... de GCODE kan al wel worden gegenereerd, maar we sturen het nu niet naar het kastje.
/*
$.post(kastjeURL + "test/" + "write/", { data: "test"}, function(data) {
console.log("returned data: " + JSON.stringify(data));
data = JSON.parse(data);
console.log(" data.msg: " + data.msg);
console.log(" data.status: " + data.status);
// console.log(" status: " + data["status"]);
// btnPrint.disabled = false;
});
//*/
//http://192.168.10.1/cgi-bin/d3dapi/write
sendIndex = 0;
sendLength = 2000; // 2000 regels
sendGCodeSlice(sendIndex, sendLength);
}
function sendGCodeSlice(startIndex, sendAmt) {
console.log("f:senGCodeSlice >> startIndex:" + startIndex + ", sendAmt:" + sendAmt);
console.log("f:sendGCodeSlice >> startIndex:" + startIndex + ", sendAmt:" + sendAmt);
if (typeof startIndex == "number" && typeof sendAmt == "number") {
var lastOne = false;
@ -42,10 +30,16 @@ function sendGCodeSlice(startIndex, sendAmt) {
var _tmp = data.slice(startIndex, startIndex+sendAmt);
// console.log("f:senGCodeSlice >> _tmp.length:" + _tmp.length);
$.post("/doodle3d.of", { data:output }, function(data) {
btnPrint.disabled = false;
});
sendBoy( { data: _tmp, lastOne: lastOne} , function(e) {
// $.post("/doodle3d.of", { data:data }, function(data) {
// btnPrint.disabled = false;
// });
var firstOne = false;
if (startIndex == 0) { firstOne = true; }
var postData = { id: 0, gcode: _tmp.join("\n"), first: firstOne, last: lastOne};
$.post( wifiboxURL + "/printer/print", postData , function(e) {
console.log("sendBoy callback: " + e);
// console.log(e);
// console.log("e.success: " + e.success);
@ -63,7 +57,7 @@ function sendGCodeSlice(startIndex, sendAmt) {
}
function sendBoy(sendObj, callback) {
console.log("f:sendBoy() (dummy kastje) >> data length: " + sendObj.data.length + ", lastOne: " + sendObj.lastOne);
console.log("f:sendBoy() (dummy kastje) >> data length: " + sendObj.data.length + ", lastOne: " + sendObj.last);
console.log("");
if (callback != undefined) callback({success:true});
}

View File

@ -155,7 +155,7 @@ function generate_gcode(callback) {
// Return the gcode array, joined to one string with '\n' (line break) as the join parameter
// This should result in a nice long string with line breaks
if (callback == undefined) {
return gcode.join("\n");
return gcode;
} else {
// post
}