diff --git a/languages/printerpack/en.json b/languages/printerpack/en.json index 5abbc025..14e7f0cc 100644 --- a/languages/printerpack/en.json +++ b/languages/printerpack/en.json @@ -436,9 +436,9 @@ "P98": "Pause command", "P99": "Resume command", "P100": "Stop command", - "P101": "SD print commands", - "P102": "TFT SD print commands", - "P103": "TFT USB print commands", + "P101": "SD play commands", + "P102": "TFT SD play commands", + "P103": "TFT USB play commands", "P104": "Preset values", "P105": "Elapsed", "P106": "Command", diff --git a/src/components/Helpers/components.js b/src/components/Helpers/components.js index 723a585f..b62cf017 100644 --- a/src/components/Helpers/components.js +++ b/src/components/Helpers/components.js @@ -125,10 +125,10 @@ const connectionDepend = (depend, settings) => { } //this is dynamic as it is depending on the preferences settings -const settingsDepend = (depend, settings, isOr) => { +const settingsDepend = (depend, settings, isOr=false) => { if (typeof depend!="undefined"){ //console.log("settingsDepend", depend, settings, isOr) - console.log("settingsDepend", depend[0]) + //console.log("settingsDepend", depend[0]) } if (Array.isArray(depend)) { return depend.reduce( diff --git a/src/tabs/interface/index.js b/src/tabs/interface/index.js index ee1bfb29..2ecadcac 100644 --- a/src/tabs/interface/index.js +++ b/src/tabs/interface/index.js @@ -40,19 +40,7 @@ import { importPreferences, formatPreferences } from "./importHelper" const isDependenciesMet = (depend) => { const { interfaceSettings } = useSettingsContext() - let met = false - depend.forEach((d) => { - if (d.id) { - const element = useUiContextFn.getElement( - d.id, - interfaceSettings.current.settings - ) - if (element.value == d.value) { - met = true - } - } - }) - return met + return settingsDepend(depend, interfaceSettings.current.settings) } const InterfaceTab = () => { @@ -388,8 +376,6 @@ const InterfaceTab = () => { section[ subsectionId ] - // console.log(fieldData); - if ( fieldData.type == "group" diff --git a/src/targets/Printer3D/Marlin/DIRECTSD-source.js b/src/targets/Printer3D/Marlin/DIRECTSD-source.js index 99861acd..adb5dc2c 100644 --- a/src/targets/Printer3D/Marlin/DIRECTSD-source.js +++ b/src/targets/Printer3D/Marlin/DIRECTSD-source.js @@ -20,7 +20,7 @@ import { h } from 'preact' import { canProcessFile } from '../../helpers' import { sortedFilesList, formatStatus } from '../../../components/Helpers' -import { useSettingsContextFn } from '../../../contexts' +import { useUiContextFn, useSettingsContextFn } from '../../../contexts' const capabilities = { Process: (path, filename) => { @@ -125,17 +125,15 @@ const commands = { '/sd' + path + (path.endsWith('/') ? '' : '/') + filename return { type: 'cmd', - cmd: '[ESP700]stream=' + fullpath.replaceAll(' ', ' '), + cmd: '[ESP700]stream=' + fullpath.replaceAll('//', '/'), } } else { + const spath = + (path + (path == '/' ? '' : '/') + filename).replaceAll('//', '/') + const cmd = useUiContextFn.getValue('sdplaycmd').replace("#", spath) return { type: 'cmd', - cmd: - 'M23 ' + - path + - (path == '/' ? '' : '/') + - filename + - '\nM24', + cmd } } }, diff --git a/src/targets/Printer3D/Marlin/SD-source.js b/src/targets/Printer3D/Marlin/SD-source.js index 174723bd..c2a973e0 100644 --- a/src/targets/Printer3D/Marlin/SD-source.js +++ b/src/targets/Printer3D/Marlin/SD-source.js @@ -126,13 +126,15 @@ const commands = { return res }, play: (path, filename) => { - let cmdstr = 'M23 ' + path + (path == '/' ? '' : '/') + filename + '\nM24' + const spath = (path + (path == '/' ? '' : '/') + filename).replaceAll('//', '/') + const cmd = useUiContextFn.getValue('sdplaycmd').replace('#', spath) return { type: 'cmd', - cmd: cmdstr.replace("//", "/"), + cmd, } }, delete: (path, filename) => { + //TODO: extract command from settings return { type: 'cmd', cmd: 'M30 ' + path + (path == '/' ? '' : '/') + filename, diff --git a/src/targets/Printer3D/Marlin/SDEXT-source.js b/src/targets/Printer3D/Marlin/SDEXT-source.js index 4183848e..19fdfc5a 100644 --- a/src/targets/Printer3D/Marlin/SDEXT-source.js +++ b/src/targets/Printer3D/Marlin/SDEXT-source.js @@ -125,13 +125,15 @@ const commands = { return res }, play: (path, filename) => { - let cmdstr = 'M23 ' + path + (path == '/' ? '' : '/') + filename + '\nM24' + const spath = (path + (path == '/' ? '' : '/') + filename).replaceAll('//', '/') + const cmd = useUiContextFn.getValue('sdextplaycmd').replace('#', spath) return { type: 'cmd', - cmd: cmdstr.replace("//", "/"), + cmd, } }, delete: (path, filename) => { + //TODO:: extract from settings return { type: 'cmd', cmd: 'M30 ' + path + (path == '/' ? '' : '/') + filename, diff --git a/src/targets/Printer3D/Marlin/TFT-SD-source.js b/src/targets/Printer3D/Marlin/TFT-SD-source.js index 7378ec8f..a57a2dd5 100644 --- a/src/targets/Printer3D/Marlin/TFT-SD-source.js +++ b/src/targets/Printer3D/Marlin/TFT-SD-source.js @@ -118,16 +118,19 @@ const capabilities = { const commands = { list: (path, filename) => { - if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS') { + if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS' || useUiContextFn.getValue('tftfs') == 'mks'){ + const cmd = useUiContextFn.getValue('tftmkssdlistcmd').replace("#",path) return { type: 'cmd', - cmd: 'M998 1\r\nM20 1:' + path, + cmd, } - } else + } else { + const cmd = useUiContextFn.getValue('tftbttsdlistcmd').replace("#",path) return { type: 'cmd', - cmd: 'M20 SD:' + path, + cmd, } + } }, upload: (path, filename) => { if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS') @@ -167,30 +170,27 @@ const commands = { res.status = formatStatus(data.status) return res }, - play: (path, filename) => { - if (useSettingsContextFn.getValue('SerialProtocol') != 'MKS') { + play: (path, filename) => { + const spath = (path + + (path == '/' ? '' : '/') + + filename).replaceAll('//', '/') + if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS' || useUiContextFn.getValue('tftfs') == 'mks') + { + const cmd = useUiContextFn.getValue('tftmkssdplaycmd').replace("#",spath) return { type: 'cmd', - cmd: - 'M23 SD:' + - path + - (path == '/' ? '' : '/') + - filename + - '\nM24', + cmd, } } else { + const cmd = useUiContextFn.getValue('tftbttsdplaycmd').replace("#",spath) return { type: 'cmd', - cmd: - 'M23 M998 1\r\n1:' + - path + - (path == '/' ? '' : '/') + - filename + - '\nM24', + cmd, } } }, delete: (path, filename) => { + //TODO: extract command from settings return { type: 'cmd', cmd: 'M30 SD:' + path + (path == '/' ? '' : '/') + filename, diff --git a/src/targets/Printer3D/Marlin/TFT-USB-source.js b/src/targets/Printer3D/Marlin/TFT-USB-source.js index c7be2e69..556d41fb 100644 --- a/src/targets/Printer3D/Marlin/TFT-USB-source.js +++ b/src/targets/Printer3D/Marlin/TFT-USB-source.js @@ -118,16 +118,19 @@ const capabilities = { const commands = { list: (path, filename) => { - if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS') { + if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS' || useUiContextFn.getValue('tftfs') == 'mks'){ + const cmd = useUiContextFn.getValue('tftmksusblistcmd').replace("#",path) return { type: 'cmd', - cmd: 'M998 0\r\nM20 0:' + path, + cmd, } - } else + } else { + const cmd = useUiContextFn.getValue('tftbttusblistcmd').replace("#",path) return { type: 'cmd', - cmd: 'M20 U:' + path, + cmd, } + } }, upload: (path, filename) => { if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS') @@ -167,30 +170,27 @@ const commands = { res.status = formatStatus(data.status) return res }, - play: (path, filename) => { - if (useSettingsContextFn.getValue('SerialProtocol') != 'MKS') { + play: (path, filename) => { + const spath = (path + + (path == '/' ? '' : '/') + + filename).replaceAll('//', '/') + if (useSettingsContextFn.getValue('SerialProtocol') == 'MKS' || useUiContextFn.getValue('tftfs') == 'mks') + { + const cmd = useUiContextFn.getValue('tftmksusbplaycmd').replace("#",spath) return { type: 'cmd', - cmd: - 'M23 U:' + - path + - (path == '/' ? '' : '/') + - filename + - '\nM24', + cmd, } } else { + const cmd = useUiContextFn.getValue('tftbttusbplaycmd').replace("#",spath) return { type: 'cmd', - cmd: - 'M23 M998 0\r\n1:' + - path + - (path == '/' ? '' : '/') + - filename + - '\nM24', + cmd, } } }, delete: (path, filename) => { + //TODO: extract command from settings return { type: 'cmd', cmd: 'M30 U:' + path + (path == '/' ? '' : '/') + filename, diff --git a/src/targets/Printer3D/Marlin/preferences.json b/src/targets/Printer3D/Marlin/preferences.json index 2e9ba6a8..b209c09e 100644 --- a/src/targets/Printer3D/Marlin/preferences.json +++ b/src/targets/Printer3D/Marlin/preferences.json @@ -89,6 +89,32 @@ } ] }, + { + "id": "sdplaycmd", + "type": "text", + "label": "P119", + "value": "M21;M23 #;M24", + "help": "S97", + "depend": [ + { + "id": "sd", + "value": true + } + ] + }, + { + "id": "sddeletecmd", + "type": "text", + "label": "P122", + "value": "M21;M30 #", + "help": "S97", + "depend": [ + { + "id": "sd", + "value": true + } + ] + }, { "id": "sdext", "type": "boolean", @@ -117,6 +143,40 @@ "value": "!='none'" } ] + }, + { + "id": "sdextplaycmd", + "type": "text", + "label": "P119", + "value": "M21;M23 #;M24", + "help": "S97", + "depend": [ + { + "id": "sdext", + "value": true + }, + { + "connection_id": "SDConnection", + "value": "!='none'" + } + ] + }, + { + "id": "sdextdeletecmd", + "type": "text", + "label": "P122", + "value": "M21;M3 #", + "help": "S97", + "depend": [ + { + "id": "sdext", + "value": true + }, + { + "connection_id": "SDConnection", + "value": "!='none'" + } + ] } ], "extruders": [ @@ -199,7 +259,16 @@ "id": "tftsdcommands", "type": "group", "label": "P102", - "depend": [{ "id": "tftsd", "value": true }], + "depend": [ + { + "id": "tftfs", + "notvalue": "none" + }, + { + "id": "tftsd", + "value": true + } + ], "value": [ { "id": "tftsdpausecmd", @@ -228,7 +297,7 @@ "id": "tftusbcommands", "type": "group", "label": "P103", - "depend": [{ "id": "tftusb", "value": true }], + "depend": [{ "id": "tftfs", "notvalue": "none"},{ "id": "tftusb", "value": true }], "value": [ { "id": "tftusbpausecmd", diff --git a/src/targets/Printer3D/preferences.json b/src/targets/Printer3D/preferences.json index b37b7eea..f4229935 100644 --- a/src/targets/Printer3D/preferences.json +++ b/src/targets/Printer3D/preferences.json @@ -286,7 +286,41 @@ "id": "tftbttsdlistcmd", "type": "text", "label": "P117", - "value": "M21;M20", + "value": "M21;M20 SD:#", + "help": "S97", + "depend": [ + { + "id": "tftsd", + "value": true + }, + { + "id": "tftfs", + "value": "btt" + } + ] + }, + { + "id": "tftbttsdplaycmd", + "type": "text", + "label": "P120", + "value": "M21;M23 SD:#;M24", + "help": "S97", + "depend": [ + { + "id": "tftsd", + "value": true + }, + { + "id": "tftfs", + "value": "btt" + } + ] + }, + { + "id": "tftbttsddeletecmd", + "type": "text", + "label": "P123", + "value": "M21;M30 SD:#", "help": "S97", "depend": [ { @@ -303,7 +337,24 @@ "id": "tftmkssdlistcmd", "type": "text", "label": "P117", - "value": "M21;M20", + "value": "M998 1;M20 1:#", + "help": "S97", + "depend": [ + { + "id": "tftsd", + "value": true + }, + { + "id": "tftfs", + "value": "mks" + } + ] + }, + { + "id": "tftmkssdplaycmd", + "type": "text", + "label": "P120", + "value": "M998 1;M23 1:#;M24", "help": "S97", "depend": [ { @@ -327,11 +378,11 @@ "id": "tftbttusblistcmd", "type": "text", "label": "P118", - "value": "M21;M20", + "value": "M21;M20 U:#", "help": "S97", "depend": [ { - "id": "tftsd", + "id": "tftusb", "value": true }, { @@ -344,7 +395,58 @@ "id": "tftmksusblistcmd", "type": "text", "label": "P117", - "value": "M21;M20", + "value": "M998 0;M23 0:#;M24", + "help": "S97", + "depend": [ + { + "id": "tftusb", + "value": true + }, + { + "id": "tftfs", + "value": "mks" + } + ] + }, + { + "id": "tftbttusbplaycmd", + "type": "text", + "label": "P121", + "value": "M21;M23 U:#;M24", + "help": "S97", + "depend": [ + { + "id": "tftusb", + "value": true + }, + { + "id": "tftfs", + "value": "btt" + } + ] + }, + { + "id": "tftbttusbdeletecmd", + "type": "text", + "label": "P124", + "value": "M21;M30 U:#", + "help": "S97", + "depend": [ + { + "id": "tftusb", + "value": true + }, + { + "id": "tftfs", + "value": "btt" + } + ] + }, + { + "id": "tftmskusbplaycmd", + "type": "text", + "label": "P121", + "value": "M998 0;M23 0:#;M24", "help": "S97", "depend": [ { diff --git a/src/targets/Printer3D/translations/en.json b/src/targets/Printer3D/translations/en.json index 36545ad2..97e7c98e 100644 --- a/src/targets/Printer3D/translations/en.json +++ b/src/targets/Printer3D/translations/en.json @@ -93,9 +93,9 @@ "P98": "Pause command", "P99": "Resume command", "P100": "Stop command", - "P101": "SD print commands", - "P102": "TFT SD print commands", - "P103": "TFT USB print commands", + "P101": "SD control commands", + "P102": "TFT SD control commands", + "P103": "TFT USB control commands", "P104": "Preset values", "P105": "Elapsed", "P106": "Command", @@ -111,6 +111,12 @@ "P116": "Swap X/Y", "P117": "TFT SD List commands", "P118": "TFT USB List commands", + "P119": "SD play command", + "P120": "TFT SD play command", + "P121": "TFT USB play command", + "P122": "SD delete path command", + "P123": "TFT SD delete path command", + "P124": "TFT USB delete path command", "pause": "pause", "processing": "Processing", "heating": "Heating",