mirror of
https://github.com/Doodle3D/doodle3d-client.git
synced 2024-11-22 09:17:56 +01:00
Enable sending gcode. It prints!
This commit is contained in:
parent
cbbe820d77
commit
7972273e27
@ -213,36 +213,34 @@ function nextDoodle(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function print(e) {
|
function print(e) {
|
||||||
console.log("f:print()");
|
console.log("f:print()");
|
||||||
|
|
||||||
$("#textdump").text("");
|
$("#textdump").text("");
|
||||||
if (_points.length > 2) {
|
if (_points.length > 2) {
|
||||||
//*
|
var gencode = generate_gcode();
|
||||||
// generate_gcode();
|
startPrint(gencode);
|
||||||
var gencode = generate_gcode();
|
|
||||||
startPrint();
|
|
||||||
|
|
||||||
// console.log("");
|
// console.log("");
|
||||||
// console.log("");
|
// console.log("");
|
||||||
// console.log("-------------------------------------------------");
|
// console.log("-------------------------------------------------");
|
||||||
// console.log("generated gcode:");
|
// console.log("generated gcode:");
|
||||||
// console.log(gencode);
|
// console.log(gencode);
|
||||||
// console.log("-------------------------------------------------");
|
// console.log("-------------------------------------------------");
|
||||||
// console.log("");
|
// console.log("");
|
||||||
// console.log("");
|
// console.log("");
|
||||||
// console.log("");
|
// console.log("");
|
||||||
|
|
||||||
$("#textdump").text(gencode);
|
$("#textdump").text(gencode.join("\n"));
|
||||||
// copyToClipboard(gencode);
|
// copyToClipboard(gencode);
|
||||||
//*/
|
//*/
|
||||||
} else {
|
} else {
|
||||||
console.log("f:print >> not enough points!");
|
console.log("f:print >> not enough points!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// $.post("/doodle3d.of", { data:output }, function(data) {
|
// $.post("/doodle3d.of", { data:output }, function(data) {
|
||||||
// btnPrint.disabled = false;
|
// btnPrint.disabled = false;
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,32 +5,20 @@ var sendLength;
|
|||||||
var kastjeURL = "http://192.168.5.1/cgi-bin/d3dapi/";
|
var kastjeURL = "http://192.168.5.1/cgi-bin/d3dapi/";
|
||||||
|
|
||||||
|
|
||||||
var mydata = "";
|
var data = "";
|
||||||
function startPrint() {
|
function startPrint(gcode) {
|
||||||
console.log("f:startPrint()");
|
console.log("f:startPrint()");
|
||||||
|
console.log("total # of lines: " + gcode.length);
|
||||||
|
data = gcode;
|
||||||
|
|
||||||
// sendIndex = 0;
|
sendIndex = 0;
|
||||||
// sendLength = 2000; // 2000 regels
|
sendLength = 2000; // 2000 regels
|
||||||
// sendGCodeSlice(sendIndex, sendLength);
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sendGCodeSlice(startIndex, sendAmt) {
|
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") {
|
if (typeof startIndex == "number" && typeof sendAmt == "number") {
|
||||||
var lastOne = false;
|
var lastOne = false;
|
||||||
@ -42,10 +30,16 @@ function sendGCodeSlice(startIndex, sendAmt) {
|
|||||||
var _tmp = data.slice(startIndex, startIndex+sendAmt);
|
var _tmp = data.slice(startIndex, startIndex+sendAmt);
|
||||||
// console.log("f:senGCodeSlice >> _tmp.length:" + _tmp.length);
|
// console.log("f:senGCodeSlice >> _tmp.length:" + _tmp.length);
|
||||||
|
|
||||||
$.post("/doodle3d.of", { data:output }, function(data) {
|
// $.post("/doodle3d.of", { data:data }, function(data) {
|
||||||
btnPrint.disabled = false;
|
// btnPrint.disabled = false;
|
||||||
});
|
// });
|
||||||
sendBoy( { data: _tmp, lastOne: lastOne} , function(e) {
|
|
||||||
|
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("sendBoy callback: " + e);
|
||||||
// console.log(e);
|
// console.log(e);
|
||||||
// console.log("e.success: " + e.success);
|
// console.log("e.success: " + e.success);
|
||||||
@ -63,7 +57,7 @@ function sendGCodeSlice(startIndex, sendAmt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendBoy(sendObj, callback) {
|
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("");
|
console.log("");
|
||||||
if (callback != undefined) callback({success:true});
|
if (callback != undefined) callback({success:true});
|
||||||
}
|
}
|
@ -155,7 +155,7 @@ function generate_gcode(callback) {
|
|||||||
// Return the gcode array, joined to one string with '\n' (line break) as the join parameter
|
// 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
|
// This should result in a nice long string with line breaks
|
||||||
if (callback == undefined) {
|
if (callback == undefined) {
|
||||||
return gcode.join("\n");
|
return gcode;
|
||||||
} else {
|
} else {
|
||||||
// post
|
// post
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user