Skip to content

Commit

Permalink
Update for grblHAL to allow to use flash as gcode source
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Feb 26, 2025
1 parent e7b9c7c commit c841a90
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 18 deletions.
Binary file modified dist/CNC/GRBLHal/index.html.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/targets/CNC/grblHAL/DIRECTSD-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const commands = {
"/"
)
const cmd = useUiContextFn
.getValue("sdplaycmd")
.getValue("playcmd")
.replace("#", spath)
.replaceAll("//", "/")
return {
Expand Down
133 changes: 133 additions & 0 deletions src/targets/CNC/grblHAL/FLASH-source.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/*
FLASH-source.js - ESP3D WebUI Target file
Copyright (c) 2020 Luc Lebosse. All rights reserved.
This code is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with This code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
import { h } from "preact"
import { sortedFilesList, formatStatus } from "../../../components/Helpers"
import { canProcessFile } from "../../helpers"
import { useSettingsContextFn, useUiContextFn } from "../../../contexts"
const capabilities = {
Process: (path, filename) => {
return canProcessFile(filename)
},
UseFilters: () => true,
IsFlatFS: () => false,
Upload: () => {
return true
},
Mount: () => {
return false
},
UploadMultiple: () => {
return true
},
Download: () => {
return true
},
DeleteFile: () => {
return true
},
DeleteDir: () => {
return true
},
CreateDir: () => {
return true
},
}

const commands = {
list: (path, filename) => {
return {
type: "url",
url: "files",
args: { path, action: "list" },
}
},
upload: (path, filename) => {
const upath = (
useSettingsContextFn.getValue("HostUploadPath") + path
).replaceAll("//", "/")
return {
type: "url",
url: "files",
args: { path: upath },
}
},
formatResult: (resultTxT) => {
const res = JSON.parse(resultTxT)
if (useUiContextFn.getValue("sort_flashfs_files")){
res.files = sortedFilesList(res.files)
}
res.status = formatStatus(res.status)
return res
},

deletedir: (path, filename) => {
return {
type: "url",
url: "files",
args: { path, action: "deletedir", filename },
}
},
delete: (path, filename) => {
return {
type: "url",
url: "files",
args: { path, action: "delete", filename },
}
},
createdir: (path, filename) => {
return {
type: "url",
url: "files",
args: { path, action: "createdir", filename },
}
},
download: (path, filename) => {
const upath = (
useSettingsContextFn.getValue("HostUploadPath") +
path +
(path == "/" ? "" : "/") +
filename
).replaceAll("//", "/")
//console.log('Upath:', upath)
return {
type: "url",
url: upath,
args: {},
}
},
play: (path, filename) => {
const spath = (path + (path == "/" ? "" : "/") + filename).replaceAll(
"//",
"/"
)
const cmd = useUiContextFn
.getValue("playcmd")
.replace("#", spath)
.replaceAll("//", "/")
return {
type: "cmd",
cmd,
}
},
}

const FLASH = { capabilities, commands }

export { FLASH }
2 changes: 1 addition & 1 deletion src/targets/CNC/grblHAL/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
import { h } from "preact"
import { FLASH } from "../../FLASH-source"
import { FLASH } from "./FLASH-source"
import { DIRECTSD } from "./DIRECTSD-source"
import { useSettingsContextFn, useUiContextFn } from "../../../contexts"

Expand Down
2 changes: 1 addition & 1 deletion src/targets/CNC/grblHAL/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { AppLogo } from "./logo"
import { addObjectItem, removeObjectItem } from "../../../components/Helpers"

const Target = "grblHAL"
const webUIbuild = "GH4"
const webUIbuild = "GH5"
const Name = "grblHAL"
const fwUrl = [
"https://github.com/grblHAL",
Expand Down
40 changes: 26 additions & 14 deletions src/targets/CNC/grblHAL/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,11 @@
{
"id": "directsd",
"type": "boolean",
"depend": [{ "connection_id": "SDConnection", "value": "!='none'" }],

"label": "S63",
"value": true
},
{
"id": "sdplaycmd",
"type": "text",
"label": "P119",
"value": "$F=#",
"help": "S97",
"depend": [
{
"id": "directsd",
"value": true
}
]
},

{
"id": "sort_directsd_files",
"type": "boolean",
Expand All @@ -143,6 +131,30 @@

]
},
{
"id": "playcmd",
"type": "text",
"label": "P119",
"value": "$F=#",
"help": "S97",
"depend": [ {

"orGroups": [
[
{
"id": "directsd",
"value": true
}
],
[
{
"id": "flashfs",
"value": true
}
]
]
}]
},
{
"id": "default_filesystem",
"type": "select",
Expand Down
2 changes: 1 addition & 1 deletion src/targets/CNC/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"CN111": "OVC rpm enable",
"CN112": "OVC hold disable",
"CN113": "OVC parking disable",
"P119": "SD play command",
"P119": "Play command",
"btnZX": "Zero X",
"btnZY": "Zero Y",
"btnZZ": "Zero Z",
Expand Down

0 comments on commit c841a90

Please sign in to comment.