Skip to content

Commit 0cf4d10

Browse files
committed
Revert "Merge pull request #193 from cotepat/surfacewiz"
This reverts commit d4fcb39, reversing changes made to 29c1ebb.
1 parent cdbfc17 commit 0cf4d10

File tree

7 files changed

+27
-578
lines changed

7 files changed

+27
-578
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
node_modules
22
dist
33
src
4-
.DS_Store
5-
docs/.DS_Store
6-
www/.DS_Store

www/js/files.js

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,20 @@ function process_files_Createdir(answer) {
182182
}
183183

184184
function files_create_dir(name) {
185-
files_create_dir(name, files_currentPath)
186-
}
187-
188-
function files_create_dir2(name, path) {
189185
if (direct_sd && !((target_firmware == "smoothieware") && files_currentPath.startsWith(secondary_sd))) {
190-
var cmdpath = path;
191-
if (target_firmware == "smoothieware") cmdpath = path.substring(primary_sd.length);
186+
var cmdpath = files_currentPath;
187+
if (target_firmware == "smoothieware") cmdpath = files_currentPath.substring(primary_sd.length);
192188
var url = "/upload?path=" + encodeURIComponent(cmdpath) + "&action=createdir&filename=" + encodeURIComponent(name);
193189
document.getElementById('files_nav_loader').style.display = "block";
194190
SendGetHttp(url, files_directSD_list_success, files_directSD_list_failed);
195191
} else {
196192
var command = "";
197193
if (target_firmware == "smoothieware") {
198-
command = "mkdir " + path + name;
194+
command = "mkdir " + files_currentPath + name;
199195
} else {
200-
command = "M32 " + path + name;
196+
command = "M32 " + files_currentPath + name;
201197
}
202-
SendPrinterCommand(command, true, files_process_and_update);
198+
SendPrinterCommand(command, true, files_proccess_and_update);
203199
}
204200
}
205201

@@ -238,11 +234,11 @@ function files_delete_file(index) {
238234
if ((current_source == tft_usb)|| (current_source == tft_sd))command +=current_source;
239235
command += files_currentPath + files_file_list[index].name;
240236
}
241-
SendPrinterCommand(command, true, files_process_and_update);
237+
SendPrinterCommand(command, true, files_proccess_and_update);
242238
}
243239
}
244240

245-
function files_process_and_update(answer) {
241+
function files_proccess_and_update(answer) {
246242
document.getElementById('files_navigation_buttons').style.display = "block";
247243
if (answer.startsWith("{") && answer.endsWith("}")) {
248244
try {
@@ -811,28 +807,25 @@ function process_check_sd_presence(answer) {
811807
}
812808

813809
function files_start_upload() {
814-
var files = document.getElementById("files_input_file").files;
815-
files_start_upload(files, files_currentPath)
816-
}
817-
818-
function files_start_upload2(files, path) {
819810
if (http_communication_locked) {
820811
alertdlg(translate_text_item("Busy..."), translate_text_item("Communications are currently locked, please wait and retry."));
821812
console.log("communication locked");
822813
return;
823814
}
824815
var url = "/upload";
825-
if (direct_sd && (target_firmware == "smoothieware") && (path.startsWith(primary_sd))) {
826-
path = path.substring(primary_sd.length);
816+
var path = files_currentPath;
817+
if (direct_sd && (target_firmware == "smoothieware") && (files_currentPath.startsWith(primary_sd))) {
818+
path = files_currentPath.substring(primary_sd.length);
827819
}
828-
if (!direct_sd || (target_firmware == "smoothieware" && path.startsWith(secondary_sd))) {
820+
if (!direct_sd || (target_firmware == "smoothieware" && files_currentPath.startsWith(secondary_sd))) {
829821
url = "/upload_serial";
830822
if (target_firmware == "smoothieware") {
831-
if (path.startsWith(secondary_sd)) path = path.substring(secondary_sd.length);
832-
else path = path.substring(primary_sd.length);
823+
if (files_currentPath.startsWith(secondary_sd)) path = files_currentPath.substring(secondary_sd.length);
824+
else path = files_currentPath.substring(primary_sd.length);
833825
}
834826
}
835-
console.log("upload from " + path );
827+
//console.log("upload from " + path );
828+
var files = document.getElementById("files_input_file").files;
836829

837830
if (files.value == "" || typeof files[0].name === 'undefined') {
838831
console.log("nothing to upload");
@@ -847,21 +840,22 @@ function files_start_upload2(files, path) {
847840
//append file size first to check updload is complete
848841
formData.append(arg, file.size);
849842
formData.append('myfile[]', file, path + file.name);
850-
console.log(path +file.name);
843+
//console.log( path +file.name);
851844
}
852845
files_error_status = "Upload " + file.name;
853846
document.getElementById('files_currentUpload_msg').innerHTML = file.name;
854847
document.getElementById('files_uploading_msg').style.display = "block";
855848
document.getElementById('files_navigation_buttons').style.display = "none";
856-
if (direct_sd && !(target_firmware == "smoothieware" && path.startsWith(secondary_sd))) {
849+
if (direct_sd && !(target_firmware == "smoothieware" && files_currentPath.startsWith(secondary_sd))) {
857850
SendFileHttp(url, formData, FilesUploadProgressDisplay, files_directSD_list_success, files_directSD_list_failed);
851+
//console.log("send file");
858852
} else {
859-
SendFileHttp(url, formData, FilesUploadProgressDisplay, files_process_and_update, files_serial_M20_list_failed);
853+
SendFileHttp(url, formData, FilesUploadProgressDisplay, files_proccess_and_update, files_serial_M20_list_failed);
860854
}
861855
document.getElementById("files_input_file").value = "";
862-
files_refreshFiles(path)
863856
}
864857

858+
865859
function FilesUploadProgressDisplay(oEvent) {
866860
if (oEvent.lengthComputable) {
867861
var percentComplete = (oEvent.loaded / oEvent.total) * 100;

www/js/grbl.js

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var interval_status = -1;
22
var probe_progress_status = 0;
3-
var surface_progress_status = 0;
43
var grbl_error_msg = "";
54
var gotWCO = false;
65
var WCOx = 0;
@@ -125,24 +124,6 @@ function onprobetouchplatethicknessChange() {
125124
return true;
126125
}
127126

128-
function onsurfacewidthChange() {
129-
var travel = parseFloat(document.getElementById('surfacewidth').value);
130-
if (travel > 9999 || travel <= 0 || isNaN(travel) || (travel === null)) {
131-
alertdlg(translate_text_item("Out of range"), translate_text_item("Value of surface width must be between 1 mm and 9999 mm !"));
132-
return false;
133-
}
134-
return true;
135-
}
136-
137-
function onsurfacelengthChange() {
138-
var travel = parseFloat(document.getElementById('surfacelength').value);
139-
if (travel > 9999 || travel <= 0 || isNaN(travel) || (travel === null)) {
140-
alertdlg(translate_text_item("Out of range"), translate_text_item("Value of surface length must be between 1 mm and 9999 mm !"));
141-
return false;
142-
}
143-
return true;
144-
}
145-
146127
function on_autocheck_status(use_value) {
147128
if (probe_progress_status != 0) {
148129
document.getElementById('autocheck_status').checked = true;
@@ -308,9 +289,6 @@ function process_grbl_status(response) {
308289
if (probe_progress_status != 0) {
309290
probe_failed_notification();
310291
}
311-
if (surface_progress_status != 0) {
312-
surface_failed_notification();
313-
}
314292
//grbl_error_msg = "";
315293
//check we are printing or not
316294
if (response.indexOf("|SD:") != -1) {
@@ -325,10 +303,6 @@ function process_grbl_status(response) {
325303
document.getElementById('sd_reset_btn').style.display = "none";
326304
}
327305
if (tab2.toLowerCase().startsWith("idle")) {
328-
329-
if(surface_progress_status == 100) {
330-
finalize_surfacing();
331-
}
332306
grbl_error_msg = "";
333307
}
334308
document.getElementById('grbl_status_text').innerHTML = translate_text_item(grbl_error_msg);
@@ -343,16 +317,6 @@ function finalize_probing() {
343317
document.getElementById("probingtext").style.display = "none";
344318
document.getElementById('sd_pause_btn').style.display = "none";
345319
document.getElementById('sd_resume_btn').style.display = "none";
346-
document.getElementById('sd_reset_btn').style.display = "none";
347-
}
348-
349-
function finalize_surfacing() {
350-
surface_progress_status = 0;
351-
grbl_error_msg = "";
352-
document.getElementById("surfacebtn").style.display = "table-row";
353-
document.getElementById("surfacingtext").style.display = "none";
354-
document.getElementById('sd_pause_btn').style.display = "none";
355-
document.getElementById('sd_resume_btn').style.display = "none";
356320
document.getElementById('sd_reset_btn').style.display = "none";
357321
}
358322

@@ -370,9 +334,6 @@ function process_grbl_SD(response) {
370334
progress = progress.replace(">", "");
371335
}
372336
document.getElementById('grbl_SD_status').innerHTML = sdname + "&nbsp;<progress id='print_prg' value=" + progress + " max='100'></progress>" + progress + "%";
373-
if(progress == 100 & surface_progress_status != 0) {
374-
surface_progress_status = progress;
375-
}
376337
} else { //no SD printing
377338
//TODO
378339
document.getElementById('grbl_SD_status').innerHTML = "";
@@ -414,7 +375,6 @@ function grbl_process_msg(response) {
414375

415376
function grbl_reset() {
416377
if (probe_progress_status != 0) probe_failed_notification();
417-
if (surface_progress_status != 0) surface_failed_notification();
418378
SendRealtimeCmd(String.fromCharCode(0x18));
419379
}
420380

@@ -450,15 +410,8 @@ function probe_failed_notification() {
450410
beep(70, 261);
451411
}
452412

453-
function surface_failed_notification() {
454-
finalize_surfacing();
455-
alertdlg(translate_text_item("Error"), translate_text_item("Surfacing failed !"));
456-
beep(70, 261);
457-
}
458-
459413
function StartProbeProcess() {
460414
var cmd = "G38.2 G91 Z-";
461-
462415
if (!onprobemaxtravelChange() ||
463416
!onprobefeedrateChange() ||
464417
!onprobetouchplatethicknessChange()) {
@@ -474,78 +427,3 @@ function StartProbeProcess() {
474427
grbl_error_msg = "";
475428
document.getElementById('grbl_status_text').innerHTML = grbl_error_msg;
476429
}
477-
478-
function StartSurfaceProcess() {
479-
var path = "/";
480-
var dirname = "SurfaceWizard";
481-
482-
var bitdiam = document.getElementById('surfacebitdiam').value;;
483-
var stepover = document.getElementById('surfacestepover').value;;
484-
var feedrate = document.getElementById('surfacefeedrate').value;;
485-
var surfacewidth = document.getElementById('surfacewidth').value;
486-
var surfacelength = document.getElementById('surfacelength').value;
487-
var Zdepth = document.getElementById('surfacezdepth').value;;
488-
var spindle = document.getElementById('surfacespindle').value;;
489-
490-
ncProg = CreateSurfaceProgram(bitdiam, stepover, feedrate, surfacewidth, surfacelength, Zdepth, spindle);
491-
492-
filename = "Surface" + "_X" + surfacewidth + "_Y" + surfacelength + "_Z-" + Zdepth + ".nc";
493-
494-
var blob = new Blob([ncProg], {type: "txt"});
495-
496-
files = [];
497-
files.push(new File([blob], filename));
498-
499-
files_start_upload2(files, "/" + dirname + "/")
500-
501-
surface_progress_status = 1;
502-
on_autocheck_status(true);
503-
files_print_filename(path + dirname + "/" + filename);
504-
document.getElementById("surfacebtn").style.display = "none";
505-
document.getElementById("surfacingtext").style.display = "table-row";
506-
//grbl_error_msg = "";
507-
//document.getElementById('grbl_status_text').innerHTML = grbl_error_msg;
508-
//finalize_surfacing()
509-
}
510-
511-
function CreateSurfaceProgram(bitdiam, stepover, feedrate, surfacewidth, surfacelength, Zdepth, spindle) {
512-
var crlf = "\n";
513-
514-
effectiveCuttingWidth = Math.round(1000 * (bitdiam * (1 - stepover/100))) / 1000;
515-
nPasses = Math.floor(surfacelength / effectiveCuttingWidth);
516-
lastPassWidth = surfacelength % effectiveCuttingWidth;
517-
518-
ncProg = "G21" + crlf; // Unit = mm
519-
ncProg += "G90" + crlf; // Absolute Positioning
520-
ncProg += "G53 G0 Z-5" + crlf; // Move spindle to safe height
521-
ncProg += "G54" + crlf; // Work Coordinates
522-
ncProg += "M3 S" + spindle + crlf; // Set spindle speed
523-
ncProg += "G4 P1.8" + crlf; // Spindle delay
524-
ncProg += "G1 F" + feedrate + crlf; // Set feedrate
525-
ncProg += "G0 X0 Y0" + crlf; // Move to XY origin at Z-safe height
526-
ncProg += "G1 Z-" + Zdepth + crlf; // Move to Z origin (while starting to cut)
527-
528-
var Xend = 0;
529-
for (var i = 0; i <= nPasses; i++) {
530-
Xend == 0 ? Xend = surfacewidth : Xend = 0; // alternate X (passes are in X direction)
531-
cmd = "G1 X" + Xend + " Y" + i * effectiveCuttingWidth + " Z-" + Zdepth;
532-
ncProg += cmd + crlf;
533-
if (i < nPasses) {
534-
cmd = "G1 Y" + (i+1) * effectiveCuttingWidth; // increment Y at each pass
535-
ncProg += cmd + crlf;
536-
}
537-
}
538-
539-
if(lastPassWidth > 0) {
540-
Xend == 0 ? Xend = surfacewidth : Xend = 0; // alternate X
541-
cmd = "G1 Y" + surfacelength;
542-
ncProg += cmd + crlf;
543-
cmd = "G1 X" + Xend + " Y" + surfacelength + " Z-" + Zdepth;
544-
ncProg += cmd + crlf;
545-
}
546-
547-
ncProg += "G53 G0 Z-5" + crlf; // Move spindle to safe height
548-
ncProg += "M5 S0" + crlf; // Spindle off
549-
550-
return ncProg;
551-
}

0 commit comments

Comments
 (0)