Skip to content

Commit

Permalink
Fix #372 Thanks @DivingDuck for pointing this out
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Nov 15, 2023
1 parent 1187bd7 commit d373e54
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
Binary file modified dist/Printer3D/Smoothieware/index.html.gz
Binary file not shown.
28 changes: 14 additions & 14 deletions src/targets/Printer3D/Smoothieware/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
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 { useSettingsContextFn } from "../../../contexts"
import { h } from 'preact'
import { useSettingsContextFn } from '../../../contexts'

////////////////////////////////////////////////////////
//
// ok acknowledge
const isOk = (str) => {
if (str.startsWith("ok")) {
if (str == 'ok') {
return true
}
return false
Expand Down Expand Up @@ -70,7 +70,7 @@ const getTemperatures = (str) => {
//result[4] = target
//Note :on multiple extruders T is the active one, it will be erased by the next T0
while ((result = regex_search.exec(str)) !== null) {
response[result[1]][result[2] == "" ? 0 : result[2]] = {
response[result[1]][result[2] == '' ? 0 : result[2]] = {
value: result[3],
target: result[4],
}
Expand Down Expand Up @@ -130,12 +130,12 @@ const getPrintStatus = (str) => {
}
if ((result = reg_search2.exec(str)) !== null) {
return {
status: "Printing",
status: 'Printing',
printing: true,
progress: result[1],
}
}
return { status: "Unknown", printing: false, progress: 0 }
return { status: 'Unknown', printing: false, progress: 0 }
}

////////////////////////////////////////////////////////
Expand All @@ -157,7 +157,7 @@ const getPrintFileName = (str) => {
if ((result = reg_search1.exec(str)) !== null) {
return result[1]
}
return "Unknown"
return 'Unknown'
}

////////////////////////////////////////////////////////
Expand Down Expand Up @@ -186,7 +186,7 @@ const getStatus = (str) => {
if ((result = reg_search2.exec(str)) !== null) {
return result[1]
}
return "Unknown"
return 'Unknown'
}

////////////////////////////////////////////////////////
Expand Down Expand Up @@ -242,17 +242,17 @@ const getFeedRate = (str) => {
//...
const isPrinterCapability = (str) => {
const reg_search1 = /^Cap:([^:]+):[0-1]$/
if (str.startsWith("FIRMWARE_NAME:") || reg_search1.test(str)) {
if (str.startsWith('FIRMWARE_NAME:') || reg_search1.test(str)) {
return true
}
return false
}

const getPrinterCapability = (str) => {
let result = null
const res = str.split(",").reduce((acc, cur) => {
const sp = cur.split(":")
acc.push({ name: sp[0], value: sp.slice(1).join(":") })
const res = str.split(',').reduce((acc, cur) => {
const sp = cur.split(':')
acc.push({ name: sp[0], value: sp.slice(1).join(':') })
return acc
}, [])

Expand All @@ -263,12 +263,12 @@ const getPrinterCapability = (str) => {
//
//Sensor
const isSensor = (str) => {
return str.startsWith("SENSOR:")
return str.startsWith('SENSOR:')
}

const getSensor = (str) => {
const result = []
const data = " " + str.substring(7)
const data = ' ' + str.substring(7)
let res = null
const reg_search = /\s(?<value>[^\[]+)\[(?<unit>[^\]]+)\]/g
while ((res = reg_search.exec(data))) {
Expand Down
46 changes: 23 additions & 23 deletions src/targets/Printer3D/Smoothieware/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,59 @@
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 { iconsTarget } from "./icons"
import { files } from "./files"
import { processor } from "./processor"
import { defaultPanelsList } from "./panels"
import { MachineSettings } from "./MachineSettings"
import { h } from 'preact'
import { iconsTarget } from './icons'
import { files } from './files'
import { processor } from './processor'
import { defaultPanelsList } from './panels'
import { MachineSettings } from './MachineSettings'
import {
InformationsControls,
QuickButtonsBar,
MixedExtrudersControl,
BackgroundContainer,
} from "./Controls"
} from './Controls'
import {
TargetContextProvider,
useTargetContext,
useTargetContextFn,
} from "./TargetContext"
import variablesTable from "./variablesTable"
import { AppLogo } from "../../../components/Images/logo"
import { Eye as WebUILogo } from "preact-feather"
import { addObjectItem, removeObjectItem } from "../../../components/Helpers"
} from './TargetContext'
import variablesTable from './variablesTable'
import { AppLogo } from '../../../components/Images/logo'
import { Eye as WebUILogo } from 'preact-feather'
import { addObjectItem, removeObjectItem } from '../../../components/Helpers'

const Target = "Smoothieware"
const webUIbuild = "S2"
const Name = "ESP3D"
const Target = 'Smoothieware'
const webUIbuild = 'S3'
const Name = 'ESP3D'
const fwUrl = [
"https://github.com/luc-github/ESP3D/tree/3.0",
"https://github.com/luc-github/ESP3D-TFT",
'https://github.com/luc-github/ESP3D/tree/3.0',
'https://github.com/luc-github/ESP3D-TFT',
]

const restartdelay = 30
const variablesList = {
commands: [...variablesTable],
addCommand: (variable) =>
addObjectItem(variablesList.commands, "name", variable),
addObjectItem(variablesList.commands, 'name', variable),
removeCommand: (name) =>
removeObjectItem(variablesList.commands, "name", name),
removeObjectItem(variablesList.commands, 'name', name),
}
const eventsList = {
evts: [],
on: (event, fn) => {
if (typeof eventsList.evts[event] === "undefined") {
if (typeof eventsList.evts[event] === 'undefined') {
eventsList.evts[event] = []
}
addObjectItem(eventsList.evts[event], "fn", { fn: fn })
addObjectItem(eventsList.evts[event], 'fn', { fn: fn })
},
off: (event, fn) => {
removeObjectItem(variablesList.evts[event], "fn", fn)
removeObjectItem(variablesList.evts[event], 'fn', fn)
},
emit: (event, data) => {
if (eventsList.evts[event])
eventsList.evts[event].forEach((element) => {
if (typeof element.fn === "function") element.fn(data)
if (typeof element.fn === 'function') element.fn(data)
})
},
}
Expand Down

0 comments on commit d373e54

Please sign in to comment.