File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -694,7 +694,7 @@ function process_socket_response(msg) {
694
694
if ( msg . startsWith ( "X:" ) ) {
695
695
process_Position ( msg ) ;
696
696
}
697
- if ( msg . startsWith ( "esp3d: " ) ) {
697
+ if ( msg . startsWith ( "[ esp3d] " ) ) {
698
698
process_Custom ( msg ) ; // handles custom messages sent via M118
699
699
}
700
700
if ( msg . startsWith ( "ok" ) ) {
Original file line number Diff line number Diff line change 2
2
// In gcode file, M118 can be used to send messages on serial.
3
3
// This allows the microcontroller to communicate with hosts.
4
4
// Example:
5
- // M118 esp3d: <your message>
5
+ // M118 [ esp3d] <your message>
6
6
// will send "esp3d:<your message>" over serial, which can be picked up by host
7
7
// to trigger certain actions.
8
+ // M118 [esp3d]<function call>
9
+ // will call the function, as long as a handler has been predefined to identify
10
+ // the call.
8
11
9
12
function process_Custom ( response ) {
10
13
var freq = 440 ; // beep frequency on end of print
11
14
var dur = 100 ; // beep duration on end of print
12
- if ( response . startsWith ( "esp3d:eop" ) ) {
15
+ response = response . replace ( "[esp3d]" , "" ) ;
16
+ if ( response . startsWith ( "eop" ) ) {
17
+ // Example 1
13
18
// Sound to play on end of print
14
19
// Triggered by message on serial terminal
15
- // ESP3D:eop
16
- //
17
- // This message can be sent via M118.
20
+ // [ESP3D]eop
18
21
beep ( dur , freq ) ;
19
- }
20
- }
22
+ }
23
+ if ( response . startsWith ( "beep(" ) ) {
24
+ // Example 2
25
+ // Call a function within webUI, in this case beep()
26
+ // Triggered by message on serial terminal
27
+ // [ESP3D]beep(100, 261)
28
+ eval ( response ) ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments