Skip to content

Commit c841a90

Browse files
committed
Update for grblHAL to allow to use flash as gcode source
1 parent e7b9c7c commit c841a90

File tree

7 files changed

+163
-18
lines changed

7 files changed

+163
-18
lines changed

dist/CNC/GRBLHal/index.html.gz

-15 Bytes
Binary file not shown.

src/targets/CNC/grblHAL/DIRECTSD-source.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const commands = {
109109
"/"
110110
)
111111
const cmd = useUiContextFn
112-
.getValue("sdplaycmd")
112+
.getValue("playcmd")
113113
.replace("#", spath)
114114
.replaceAll("//", "/")
115115
return {
+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
FLASH-source.js - ESP3D WebUI Target file
3+
4+
Copyright (c) 2020 Luc Lebosse. All rights reserved.
5+
6+
This code is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This code is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with This code; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
import { h } from "preact"
21+
import { sortedFilesList, formatStatus } from "../../../components/Helpers"
22+
import { canProcessFile } from "../../helpers"
23+
import { useSettingsContextFn, useUiContextFn } from "../../../contexts"
24+
const capabilities = {
25+
Process: (path, filename) => {
26+
return canProcessFile(filename)
27+
},
28+
UseFilters: () => true,
29+
IsFlatFS: () => false,
30+
Upload: () => {
31+
return true
32+
},
33+
Mount: () => {
34+
return false
35+
},
36+
UploadMultiple: () => {
37+
return true
38+
},
39+
Download: () => {
40+
return true
41+
},
42+
DeleteFile: () => {
43+
return true
44+
},
45+
DeleteDir: () => {
46+
return true
47+
},
48+
CreateDir: () => {
49+
return true
50+
},
51+
}
52+
53+
const commands = {
54+
list: (path, filename) => {
55+
return {
56+
type: "url",
57+
url: "files",
58+
args: { path, action: "list" },
59+
}
60+
},
61+
upload: (path, filename) => {
62+
const upath = (
63+
useSettingsContextFn.getValue("HostUploadPath") + path
64+
).replaceAll("//", "/")
65+
return {
66+
type: "url",
67+
url: "files",
68+
args: { path: upath },
69+
}
70+
},
71+
formatResult: (resultTxT) => {
72+
const res = JSON.parse(resultTxT)
73+
if (useUiContextFn.getValue("sort_flashfs_files")){
74+
res.files = sortedFilesList(res.files)
75+
}
76+
res.status = formatStatus(res.status)
77+
return res
78+
},
79+
80+
deletedir: (path, filename) => {
81+
return {
82+
type: "url",
83+
url: "files",
84+
args: { path, action: "deletedir", filename },
85+
}
86+
},
87+
delete: (path, filename) => {
88+
return {
89+
type: "url",
90+
url: "files",
91+
args: { path, action: "delete", filename },
92+
}
93+
},
94+
createdir: (path, filename) => {
95+
return {
96+
type: "url",
97+
url: "files",
98+
args: { path, action: "createdir", filename },
99+
}
100+
},
101+
download: (path, filename) => {
102+
const upath = (
103+
useSettingsContextFn.getValue("HostUploadPath") +
104+
path +
105+
(path == "/" ? "" : "/") +
106+
filename
107+
).replaceAll("//", "/")
108+
//console.log('Upath:', upath)
109+
return {
110+
type: "url",
111+
url: upath,
112+
args: {},
113+
}
114+
},
115+
play: (path, filename) => {
116+
const spath = (path + (path == "/" ? "" : "/") + filename).replaceAll(
117+
"//",
118+
"/"
119+
)
120+
const cmd = useUiContextFn
121+
.getValue("playcmd")
122+
.replace("#", spath)
123+
.replaceAll("//", "/")
124+
return {
125+
type: "cmd",
126+
cmd,
127+
}
128+
},
129+
}
130+
131+
const FLASH = { capabilities, commands }
132+
133+
export { FLASH }

src/targets/CNC/grblHAL/files.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
2020
import { h } from "preact"
21-
import { FLASH } from "../../FLASH-source"
21+
import { FLASH } from "./FLASH-source"
2222
import { DIRECTSD } from "./DIRECTSD-source"
2323
import { useSettingsContextFn, useUiContextFn } from "../../../contexts"
2424

src/targets/CNC/grblHAL/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import { AppLogo } from "./logo"
4141
import { addObjectItem, removeObjectItem } from "../../../components/Helpers"
4242

4343
const Target = "grblHAL"
44-
const webUIbuild = "GH4"
44+
const webUIbuild = "GH5"
4545
const Name = "grblHAL"
4646
const fwUrl = [
4747
"https://github.com/grblHAL",

src/targets/CNC/grblHAL/preferences.json

+26-14
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,11 @@
116116
{
117117
"id": "directsd",
118118
"type": "boolean",
119-
"depend": [{ "connection_id": "SDConnection", "value": "!='none'" }],
119+
120120
"label": "S63",
121121
"value": true
122122
},
123-
{
124-
"id": "sdplaycmd",
125-
"type": "text",
126-
"label": "P119",
127-
"value": "$F=#",
128-
"help": "S97",
129-
"depend": [
130-
{
131-
"id": "directsd",
132-
"value": true
133-
}
134-
]
135-
},
123+
136124
{
137125
"id": "sort_directsd_files",
138126
"type": "boolean",
@@ -143,6 +131,30 @@
143131

144132
]
145133
},
134+
{
135+
"id": "playcmd",
136+
"type": "text",
137+
"label": "P119",
138+
"value": "$F=#",
139+
"help": "S97",
140+
"depend": [ {
141+
142+
"orGroups": [
143+
[
144+
{
145+
"id": "directsd",
146+
"value": true
147+
}
148+
],
149+
[
150+
{
151+
"id": "flashfs",
152+
"value": true
153+
}
154+
]
155+
]
156+
}]
157+
},
146158
{
147159
"id": "default_filesystem",
148160
"type": "select",

src/targets/CNC/translations/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"CN111": "OVC rpm enable",
103103
"CN112": "OVC hold disable",
104104
"CN113": "OVC parking disable",
105-
"P119": "SD play command",
105+
"P119": "Play command",
106106
"btnZX": "Zero X",
107107
"btnZY": "Zero Y",
108108
"btnZZ": "Zero Z",

0 commit comments

Comments
 (0)