Skip to content

Commit 35d7620

Browse files
committed
Add support for MKS SD/TFT upload
Allow to navigate in MKS subdirs and print from them Display print status for MKS
1 parent d48e0d3 commit 35d7620

File tree

7 files changed

+99
-29
lines changed

7 files changed

+99
-29
lines changed

dist/grbl/debug/index.html.gz

2 Bytes
Binary file not shown.

dist/grbl/production/index.html.gz

2 Bytes
Binary file not shown.

dist/printer/debug/index.html.gz

272 Bytes
Binary file not shown.
301 Bytes
Binary file not shown.

src/components/printer/files.js

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,37 @@ let queryOngoing = QUERY_NONE
7777
function listSDSerialFilesCmd() {
7878
switch (currentFilesType) {
7979
case "TFTSD":
80-
return [
81-
"M20 SD:" + currentPath[currentFilesType],
82-
"Begin file list",
83-
"End file list",
84-
"error",
85-
]
80+
if (esp3dSettings.serialprotocol == "MKS") {
81+
return [
82+
"M998 1\r\nM20 1:" + currentPath[currentFilesType],
83+
"Begin file list",
84+
"End file list",
85+
"error",
86+
]
87+
} else {
88+
return [
89+
"M20 SD:" + currentPath[currentFilesType],
90+
"Begin file list",
91+
"End file list",
92+
"error",
93+
]
94+
}
8695
case "TFTUSB":
87-
return [
88-
"M20 U:" + currentPath[currentFilesType],
89-
"Begin file list",
90-
"End file list",
91-
"error",
92-
]
96+
if (esp3dSettings.serialprotocol == "MKS") {
97+
return [
98+
"M998 0\r\nM20 0:" + currentPath[currentFilesType],
99+
"Begin file list",
100+
"End file list",
101+
"error",
102+
]
103+
} else {
104+
return [
105+
"M20 U:" + currentPath[currentFilesType],
106+
"Begin file list",
107+
"End file list",
108+
"error",
109+
]
110+
}
93111
case "TARGETSD":
94112
switch (esp3dSettings.FWTarget) {
95113
case "repetier":
@@ -251,10 +269,15 @@ function consvertStringToFileDescriptor(data, list) {
251269
if (name.startsWith("/")) {
252270
name = name.substring(1)
253271
}
254-
return { name: name, size: size }
272+
if (esp3dSettings.serialprotocol == "MKS" && entry.endsWith(".DIR")) {
273+
name = entry.substring(0, entry.length - 4)
274+
return { name: name, size: -1 }
275+
} else return { name: name, size: size }
255276
} else {
256277
if (esp3dSettings.serialprotocol == "MKS") {
257-
if (entry.endsWith(".DIR")) return null
278+
if (entry.endsWith(".DIR")) {
279+
return null
280+
}
258281
return { name: entry, size: "" }
259282
}
260283
pos = entry.lastIndexOf(" ")
@@ -456,14 +479,14 @@ function processFiles(rawdata) {
456479
* Check is can create directory
457480
*/
458481
function canDelete(entry) {
459-
if (
460-
currentFilesType == "SDDirect" ||
461-
currentFilesType == "FS" ||
462-
currentFilesType == "TFTSD" ||
463-
currentFilesType == "TFTUSB"
464-
) {
482+
if (currentFilesType == "SDDirect" || currentFilesType == "FS") {
465483
return true
466484
}
485+
if (currentFilesType == "TFTSD" || currentFilesType == "TFTUSB") {
486+
if (esp3dSettings.serialprotocol == "MKS") return false
487+
else return true
488+
}
489+
467490
if (currentFilesType == "TARGETSD") {
468491
switch (esp3dSettings.FWTarget) {
469492
case "repetier":
@@ -525,6 +548,8 @@ function canUpload() {
525548
currentFilesType == "FS" ||
526549
currentFilesType == "SDDirect" ||
527550
(currentFilesType == "TARGETSD" &&
551+
esp3dSettings.serialprotocol == "MKS") ||
552+
((currentFilesType == "TFTSD" || currentFilesType == "TFTUSB") &&
528553
esp3dSettings.serialprotocol == "MKS")
529554
) {
530555
return true
@@ -695,7 +720,7 @@ function processCreateDir() {
695720

696721
function startJobFile(source, filename) {
697722
console.log("print " + filename + " from " + source)
698-
let cmd
723+
let cmd =""
699724
const { dispatch } = useStoreon()
700725
dispatch("status/print", T("P63"))
701726
switch (source) {
@@ -706,7 +731,11 @@ function startJobFile(source, filename) {
706731
case "repetier":
707732
case "marlin":
708733
case "marlinkimbra":
709-
cmd = "M23 " + filename + "\nM24"
734+
if((esp3dSettings.serialprotocol == "MKS") && ((source=="TFTSD") || (source=="TFTUSB"))) {
735+
if (source=="TFTSD") cmd = "M998 1\n"
736+
else cmd = "M998 0\n"
737+
}
738+
cmd += "M23 " + filename + "\nM24"
710739
break
711740
case "smoothieware":
712741
cmd = "play /sd" + filename
@@ -739,12 +768,18 @@ function processPrint(entry) {
739768
case "TFTSD":
740769
path = currentPath[currentFilesType]
741770
if (!path.endsWith("/")) path += "/"
742-
path += "SD:" + entry.name
771+
if (esp3dSettings.serialprotocol != "MKS") {
772+
path += "SD:"
773+
}
774+
path += entry.name
743775
break
744776
case "TFTUSB":
745777
path = currentPath[currentFilesType]
746778
if (!path.endsWith("/")) path += "/"
747-
path += "U:" + entry.name
779+
if (esp3dSettings.serialprotocol != "MKS") {
780+
path += "U:"
781+
}
782+
ath += entry.name
748783
break
749784
case "TARGETSD":
750785
path = currentPath[currentFilesType]
@@ -1268,8 +1303,15 @@ function clickUpload() {
12681303
document
12691304
.getElementById("uploadFilesControl")
12701305
.setAttribute("multiple", "false")
1271-
if (esp3dSettings.serialprotocol == "MKS") pathUpload = "/upload"
1272-
else pathUpload = "/sdfiles"
1306+
if (esp3dSettings.serialprotocol == "MKS") {
1307+
if (currentFilesType == "TFTUSB") {
1308+
pathUpload = "/upload?rpath=USB:"
1309+
} else if (currentFilesType == "TFTSD") {
1310+
pathUpload = "/upload?rpath=SD:"
1311+
} else {
1312+
pathUpload = "/upload"
1313+
}
1314+
} else pathUpload = "/sdfiles"
12731315
}
12741316
PrepareUpload()
12751317
}

src/components/printer/status.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,28 @@ function processStatus(buffer) {
6868
output += lastStatus
6969
dispatch("status/print", output)
7070
}
71-
//busy:XXXX
71+
} else if (buffer.startsWith("M27 ")) {
72+
//M27 30 = 30%
73+
let buf = buffer
74+
let percent = buf.split(" ")
75+
let output = T("P63")
76+
if (printFileName.length > 0) output = printFileName
77+
lastStatus = ": " + percent[1] + "%"
78+
output += lastStatus
79+
dispatch("status/print", output)
7280
} else if (buffer.indexOf("busy:") != -1) {
81+
//busy:XXXX
7382
let status = buffer.split("busy:")
7483
resetTimeout = true
7584
dispatch(
7685
"status/msg",
7786
<span class="text-info">{T(status[1])}</span>
7887
)
7988
//Not SD printing
80-
} else if (buffer == "Not SD printing") {
89+
} else if (
90+
buffer == "Not SD printing" ||
91+
buffer.startsWith("M997 IDLE")
92+
) {
8193
lastStatus = ""
8294
dispatch("status/print", T("P64"))
8395
lastStatusReset = 0
@@ -99,6 +111,22 @@ function processStatus(buffer) {
99111
dispatch("status/print", T("P64"))
100112
} else dispatch("status/print", printFileName + lastStatus)
101113
lastStatusReset = 0
114+
} else if (buffer.startsWith("M997 PRINTING")) {
115+
let output = T("P63")
116+
if (printFileName.length > 0) output = printFileName
117+
if (lastStatus.length > 0) output += lastStatus
118+
dispatch("status/print", output)
119+
lastStatusReset = 0
120+
} else if (buffer.startsWith("M994 ")) {
121+
//M994 filename;size
122+
let status = buffer.split(" ")
123+
printFileName = status[1].split(";")[0]
124+
if (printFileName.startsWith("0:") || printFileName.startsWith("1:")){
125+
let f = printFileName.replace("0:", "USB:")
126+
printFileName = f.replace("1:", "SD:")
127+
}
128+
dispatch("status/print", printFileName + lastStatus)
129+
lastStatusReset = 0
102130
} else {
103131
resetTimeout = false
104132
}

src/components/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
*/
2020
import { h } from "preact"
2121

22-
export const Esp3dVersion = () => <span>3.0.0.78</span>
22+
export const Esp3dVersion = () => <span>3.0.0.79</span>

0 commit comments

Comments
 (0)