Skip to content

Commit

Permalink
Better Tft support and command extraction (#383)
Browse files Browse the repository at this point in the history
* Add Select as option for interface settings

* Hide TFT if FW is for ESP3D-TFT

* Add code base to change TFT List  command according target

* extract list / print / delete commands according target and put in settings
  • Loading branch information
luc-github authored Mar 3, 2024
1 parent 6193b2a commit 806041c
Show file tree
Hide file tree
Showing 39 changed files with 1,195 additions and 1,238 deletions.
6 changes: 3 additions & 3 deletions languages/printerpack/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
383 changes: 259 additions & 124 deletions package-lock.json

Large diffs are not rendered by default.

149 changes: 0 additions & 149 deletions server/Printer3D/Marlin-embedded/Flash/preferences.json

This file was deleted.

102 changes: 0 additions & 102 deletions server/Printer3D/Repetier/Flash/preferences.json

This file was deleted.

3 changes: 2 additions & 1 deletion src/components/Controls/Fields/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { Fragment, h } from "preact"
import { useEffect } from "preact/hooks"
import { useSettingsContext, useUiContextFn } from "../../../contexts"
import { T } from "../../Translations"
import {
generateDependIds,
connectionDepend,
Expand All @@ -46,7 +47,7 @@ const Option = ({ label, depend, ...props }) => {
)
} else return null
}
return <option {...props}>{label}</option>
return <option {...props}>{T(label)}</option>
}

const Select = ({
Expand Down
17 changes: 16 additions & 1 deletion src/components/Helpers/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,16 @@ 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])
}
if (Array.isArray(depend)) {
return depend.reduce(
(acc, d) => {
if (d.id) {
if (typeof d.value != "undefined"){
const element = useUiContextFn.getElement(d.id, settings)
if (isOr) {
if (element) return acc || element.value === d.value
Expand All @@ -138,6 +143,16 @@ const settingsDepend = (depend, settings, isOr) => {
if (element) return acc && element.value === d.value
else return acc && false === d.value
}
} else if (typeof d.notvalue != "undefined"){
const element = useUiContextFn.getElement(d.id, settings)
if (isOr) {
if (element) return acc || element.value != d.notvalue
return acc || false != d.notvalue
} else {
if (element) return acc && element.value != d.notvalue
else return acc && false != d.notvalue
}
}
}
if (d.ids) {
return acc && settingsDepend(d.ids, settings, true)
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ const useSettings = () => {
})
return
}
connectionSettings.current = jsonResult.data
connectionSettings.current = jsonResult.data
if (typeof connectionSettings.current.Screen == "undefined" ){
connectionSettings.current.Screen = "none"
}
processData('core', 'ESP800', true)

console.log(connectionSettings.current)
document.title = connectionSettings.current.Hostname
if (
!connectionSettings.current.HostPath ||
Expand Down
16 changes: 1 addition & 15 deletions src/tabs/interface/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -388,8 +376,6 @@ const InterfaceTab = () => {
section[
subsectionId
]
// console.log(fieldData);

if (
fieldData.type ==
"group"
Expand Down
10 changes: 4 additions & 6 deletions src/targets/CNC/grblHAL/DIRECTSD-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { h } from "preact"
import { sortedFilesList, formatStatus } from "../../../components/Helpers"
import { canProcessFile } from "../../helpers"
import { useUiContextFn, useSettingsContextFn } from '../../../contexts'

const capabilities = {
Process: (path, filename) => {
Expand Down Expand Up @@ -101,14 +102,11 @@ const commands = {
}
},
play: (path, filename) => {
const spath = (path + (path == '/' ? '' : '/') + filename).replaceAll('//', '/')
const cmd = useUiContextFn.getValue('sdplaycmd').replace("#",spath).replaceAll('//', '/')
return {
type: "cmd",
cmd:
"$F=" +
path +
(path.endsWith("/") ? "" : "/") +
filename +
"\n",
cmd,
}
},
}
Expand Down
Loading

0 comments on commit 806041c

Please sign in to comment.