Skip to content

Commit 2a9f943

Browse files
committed
Added custom message handling
1 parent 1af1725 commit 2a9f943

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

www/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ <H3>Loading....</H3>
112112
<script src="js/dropmenu.js"></script>
113113
<script src="js/localstorage.js"></script>
114114
<script src="js/UIdisableddlg.js"></script>
115+
<script src="js/custom.js"></script>
115116
<!--endRemoveIf(cleanheader)-->
116117
<!-- smoosh -->
117118
<script src="js/app.js"></script>

www/js/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ function process_socket_response(msg) {
694694
if (msg.startsWith("X:")) {
695695
process_Position(msg);
696696
}
697+
if (msg.startsWith("esp3d:")) {
698+
process_Custom(msg); // handles custom messages sent via M118
699+
}
697700
if (msg.startsWith("ok")) {
698701
if (socket_is_settings) {
699702
//update settings

www/js/custom.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Functions to handle custom messages sent via serial.
2+
// In gcode file, M118 can be used to send messages on serial.
3+
// This allows the microcontroller to communicate with hosts.
4+
// Example:
5+
// M118 esp3d:<your message>
6+
// will send "esp3d:<your message>" over serial, which can be picked up by host
7+
// to trigger certain actions.
8+
9+
function process_Custom(response) {
10+
var freq = 440; // beep frequency on end of print
11+
var dur = 100; // beep duration on end of print
12+
if (response.startsWith("esp3d:eop")) {
13+
// Sound to play on end of print
14+
// Triggered by message on serial terminal
15+
// ESP3D:eop
16+
//
17+
// This message can be sent via M118.
18+
beep(dur, freq);
19+
}
20+
}

0 commit comments

Comments
 (0)