Skip to content

Commit d48e0d3

Browse files
author
Luc
committed
Allow to disable sound notifications
apply astyle
1 parent f8d5b5e commit d48e0d3

File tree

14 files changed

+66
-55
lines changed

14 files changed

+66
-55
lines changed

dist/grbl/debug/index.html.gz

59 Bytes
Binary file not shown.

dist/grbl/production/index.html.gz

54 Bytes
Binary file not shown.

dist/printer/debug/index.html.gz

52 Bytes
Binary file not shown.
52 Bytes
Binary file not shown.

package-lock.json

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/audio/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ audio.js - ESP3D audio management file
1717
License along with This code; if not, write to the Free Software
1818
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1919
*/
20+
import { h } from "preact"
21+
import { preferences } from "../app"
2022

2123
/*
2224
* Local variables
@@ -58,6 +60,7 @@ function initAudio() {
5860
*
5961
*/
6062
function playSound() {
63+
if (preferences.settings.sound == false) return
6164
beepongoing = true
6265
if (typeof audioCtx == "undefined") initAudio()
6366
if (beepListList.length > 0) {
@@ -83,6 +86,7 @@ function playSound() {
8386
*
8487
*/
8588
function beep(duration, frequency) {
89+
if (preferences.settings.sound == false) return
8690
beepListList.push({ d: duration, f: frequency })
8791
if (beepongoing) {
8892
return

src/components/printer/files.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function checkSerialSDCmd() {
142142
case "marlin-embedded":
143143
case "marlin":
144144
case "marlinkimbra":
145-
if(esp3dSettings.serialprotocol == "MKS")
145+
if (esp3dSettings.serialprotocol == "MKS")
146146
return ["M21", "ok", "SD init fail"]
147147
return ["M21", "SD card ok", "SD init fail"]
148148
case "smoothieware":
@@ -253,10 +253,10 @@ function consvertStringToFileDescriptor(data, list) {
253253
}
254254
return { name: name, size: size }
255255
} else {
256-
if(esp3dSettings.serialprotocol == "MKS") {
257-
if (entry.endsWith(".DIR"))return null;
256+
if (esp3dSettings.serialprotocol == "MKS") {
257+
if (entry.endsWith(".DIR")) return null
258258
return { name: entry, size: "" }
259-
}
259+
}
260260
pos = entry.lastIndexOf(" ")
261261
size = parseInt(entry.substring(pos))
262262
if (isNaN(size)) {
@@ -427,11 +427,14 @@ function processFiles(rawdata) {
427427
} else if (rawdata.startsWith("File deleted")) {
428428
queryOngoing = QUERY_NONE
429429
querySuccess = true
430-
} else if ((esp3dSettings.serialprotocol == "MKS") && (currentFilesType == "TARGETSD")) {
430+
} else if (
431+
esp3dSettings.serialprotocol == "MKS" &&
432+
currentFilesType == "TARGETSD"
433+
) {
431434
if (rawdata.startsWith("ok")) {
432-
queryOngoing = QUERY_NONE
433-
querySuccess = true
434-
}
435+
queryOngoing = QUERY_NONE
436+
querySuccess = true
437+
}
435438
}
436439
}
437440
}
@@ -518,9 +521,12 @@ function canCreateDirectory() {
518521
* Check if can upload
519522
*/
520523
function canUpload() {
521-
if ((currentFilesType == "FS")
522-
|| (currentFilesType == "SDDirect")
523-
||( (currentFilesType == "TARGETSD") && (esp3dSettings.serialprotocol == "MKS"))) {
524+
if (
525+
currentFilesType == "FS" ||
526+
currentFilesType == "SDDirect" ||
527+
(currentFilesType == "TARGETSD" &&
528+
esp3dSettings.serialprotocol == "MKS")
529+
) {
524530
return true
525531
}
526532

@@ -1262,7 +1268,7 @@ function clickUpload() {
12621268
document
12631269
.getElementById("uploadFilesControl")
12641270
.setAttribute("multiple", "false")
1265-
if (esp3dSettings.serialprotocol == "MKS")pathUpload = "/upload"
1271+
if (esp3dSettings.serialprotocol == "MKS") pathUpload = "/upload"
12661272
else pathUpload = "/sdfiles"
12671273
}
12681274
PrepareUpload()

src/components/printer/index.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,7 @@ function isComment(sline) {
867867
if (isoverloadedconfig && sline.trim().startsWith(";")) return true
868868
return false
869869
}
870-
if (
871-
esp3dSettings.FWTarget == "repetier"
872-
) {
870+
if (esp3dSettings.FWTarget == "repetier") {
873871
return false
874872
}
875873
return false
@@ -903,9 +901,7 @@ function isConfigEntry(sline) {
903901
return true
904902
return false
905903
}
906-
if (
907-
esp3dSettings.FWTarget == "repetier"
908-
) {
904+
if (esp3dSettings.FWTarget == "repetier") {
909905
if (line.indexOf("EPR:") == 0) return true
910906
else return false
911907
}
@@ -945,9 +941,7 @@ function getValue(sline) {
945941
line = tlist[0].substring(p).trim()
946942
}
947943
}
948-
if (
949-
esp3dSettings.FWTarget == "repetier"
950-
) {
944+
if (esp3dSettings.FWTarget == "repetier") {
951945
let tlist = sline.split(" ")
952946
line = tlist[2].trim()
953947
}
@@ -978,9 +972,7 @@ function getLabel(sline) {
978972
let tlist = line.split(" ")
979973
line = tlist[0]
980974
}
981-
if (
982-
esp3dSettings.FWTarget == "repetier"
983-
) {
975+
if (esp3dSettings.FWTarget == "repetier") {
984976
let tlist = sline.split(" ")
985977
line = ""
986978
for (let i = 3; i < tlist.length; i++) {
@@ -1024,9 +1016,7 @@ function getComment(sline) {
10241016
}
10251017
if (line.length < 2) line = "" //no meaning so remove it
10261018
}
1027-
if (
1028-
esp3dSettings.FWTarget == "repetier"
1029-
) {
1019+
if (esp3dSettings.FWTarget == "repetier") {
10301020
let tlist = sline.split("[")
10311021
line = ""
10321022
if (tlist.length == 2) {
@@ -1041,9 +1031,7 @@ function getComment(sline) {
10411031
* Extract P and T values from line (for repetier only)
10421032
*/
10431033
function getPT(sline) {
1044-
if (
1045-
esp3dSettings.FWTarget == "repetier"
1046-
) {
1034+
if (esp3dSettings.FWTarget == "repetier") {
10471035
let tline = sline.split(" ")
10481036
let p = tline[1]
10491037
let t = tline[0].split(":")[1]
@@ -1073,9 +1061,7 @@ function getCommand(entry) {
10731061
return entry.label + " " + value
10741062
}
10751063
}
1076-
if (
1077-
esp3dSettings.FWTarget == "repetier"
1078-
) {
1064+
if (esp3dSettings.FWTarget == "repetier") {
10791065
let cmd = "M206 T" + entry.T + " P" + entry.P //+ (entry.T == "3")?" X":" S" + entry.currentValue
10801066
if (entry.T == "3") cmd += " X"
10811067
else cmd += " S"
@@ -1115,9 +1101,7 @@ function checkValue(entry) {
11151101
return regex.test(entry.currentValue.trim())
11161102
}
11171103
}
1118-
if (
1119-
esp3dSettings.FWTarget == "repetier"
1120-
) {
1104+
if (esp3dSettings.FWTarget == "repetier") {
11211105
//only numbers
11221106
var regex = /^-?(\d+(\.\d+)?)+$/
11231107
return regex.test(entry.currentValue.trim())
@@ -1247,9 +1231,7 @@ const PrinterSetting = ({ entry }) => {
12471231
entryclass += " autoWidth"
12481232
helpclass = "d-none"
12491233
}
1250-
if (
1251-
esp3dSettings.FWTarget == "repetier"
1252-
) {
1234+
if (esp3dSettings.FWTarget == "repetier") {
12531235
entryclass += " W15"
12541236
label = T(entry.label)
12551237
labelclass += " fontsetting"

src/components/printer/temperatures.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ function processTemperatures(buffer) {
163163
if (index > 1) tool += index + 1
164164
}
165165
if (
166-
isNaN(parseFloat(buffer.heaters[index])) || parseFloat(buffer.heaters[index]) < 5
166+
isNaN(parseFloat(buffer.heaters[index])) ||
167+
parseFloat(buffer.heaters[index]) < 5
167168
)
168169
value = "error"
169170
else
@@ -201,7 +202,10 @@ function processTemperatures(buffer) {
201202
var tool = result[1]
202203
var value
203204
var value2
204-
if ((isNaN(parseFloat(result[4])) || parseFloat(result[4]) < 5) && (result[4]!="0.0"))
205+
if (
206+
(isNaN(parseFloat(result[4])) || parseFloat(result[4]) < 5) &&
207+
result[4] != "0.0"
208+
)
205209
value = "error"
206210
else
207211
value = parseFloat(result[4])
@@ -247,11 +251,17 @@ function processTemperatures(buffer) {
247251
default:
248252
break
249253
}
250-
if (!((value=="0.00") && (esp3dSettings.serialprotocol == "MKS")))dispatch("temperatures/updateT" + tool[0], {
251-
index: index,
252-
value: value,
253-
target: value2,
254-
})
254+
if (
255+
!(
256+
value == "0.00" &&
257+
esp3dSettings.serialprotocol == "MKS"
258+
)
259+
)
260+
dispatch("temperatures/updateT" + tool[0], {
261+
index: index,
262+
value: value,
263+
target: value2,
264+
})
255265
} else {
256266
console.log("no dispatch")
257267
}

src/components/settings/webui.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const default_preferences =
7676
'{"settings":{"language":"en",\
7777
"banner": true,\
7878
"autoload" : true,\
79+
"sound" : true,\
7980
"mobileview" : false,\
8081
"showterminalpanel":true,\
8182
"openterminalonstart":false,\
@@ -149,6 +150,9 @@ function updateUI() {
149150
if (typeof prefs.mobileview == "undefined") {
150151
prefs.mobileview = false
151152
}
153+
if (typeof prefs.sound == "undefined") {
154+
prefs.sound = true
155+
}
152156
if (typeof prefs.expandmacrosbuttonsonstart == "undefined") {
153157
prefs.expandmacrosbuttonsonstart = true
154158
}
@@ -1757,6 +1761,11 @@ const WebUISettings = ({ currentPage }) => {
17571761
title={T("S66")}
17581762
label={T("S64")}
17591763
/>
1764+
<CheckboxControl
1765+
entry="sound"
1766+
title={T("S169")}
1767+
label={T("S170")}
1768+
/>
17601769
<CheckboxControl
17611770
entry="mobileview"
17621771
title={T("S122")}

0 commit comments

Comments
 (0)