File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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+ // M118 [esp3d]<function call>
9+ // will call the function, as long as a handler has been predefined to identify
10+ // the call.
11+
12+ function process_Custom ( response ) {
13+ var freq = 440 ; // beep frequency on end of print
14+ var dur = 100 ; // beep duration on end of print
15+ response = response . replace ( "[esp3d]" , "" ) ;
16+ if ( response . startsWith ( "eop" ) ) {
17+ // Example 1
18+ // Sound to play on end of print
19+ // Triggered by message on serial terminal
20+ // [ESP3D]eop
21+ beep ( dur , freq ) ;
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