@@ -5,6 +5,75 @@ var gotWCO = false;
55var WCOx = 0 ;
66var WCOy = 0 ;
77var WCOz = 0 ;
8+ var WCOa = 0 ;
9+ var WCOb = 0 ;
10+ var WCOc = 0 ;
11+ var grblaxis = 2 ;
12+ var grblzerocmd = 'X0 Y0' ;
13+ var axis_Z_feedrate = 0 ;
14+ var axis_A_feedrate = 0 ;
15+ var axis_B_feedrate = 0 ;
16+ var axis_C_feedrate = 0 ;
17+ var last_axis_letter = "Z" ;
18+
19+ function build_axis_selection ( ) {
20+ var html = "<select class='form-control wauto' id='control_select_axis' onchange='control_changeaxis()' >" ;
21+ for ( var i = 3 ; i <= grblaxis ; i ++ ) {
22+ var letter ;
23+ if ( i == 3 ) letter = "Z" ;
24+ else if ( i == 4 ) letter = "A" ;
25+ else if ( i == 5 ) letter = "B" ;
26+ else if ( i == 6 ) letter = "C" ;
27+ html += "<option value='" + letter + "'" ;
28+ if ( i == 3 ) html += " selected " ;
29+ html += ">" ;
30+ html += letter ;
31+ html += "</option>\n" ;
32+ }
33+ html += "</select>\n" ;
34+ if ( grblaxis > 3 ) {
35+ document . getElementById ( 'axis_selection' ) . innerHTML = html ;
36+ document . getElementById ( 'axis_label' ) . innerHTML = translate_text_item ( "Axis" ) + ":" ;
37+ document . getElementById ( 'axis_selection' ) . style . display = "table-row"
38+ }
39+ }
40+
41+ function control_changeaxis ( ) {
42+ var letter = document . getElementById ( 'control_select_axis' ) . value ;
43+ document . getElementById ( 'axisup' ) . innerHTML = '+' + letter ;
44+ document . getElementById ( 'axisdown' ) . innerHTML = '-' + letter ;
45+ document . getElementById ( 'homeZlabel' ) . innerHTML = ' ' + letter + ' ' ;
46+ switch ( last_axis_letter ) {
47+ case "Z" :
48+ axis_Z_feedrate = document . getElementById ( 'control_z_velocity' ) . value ;
49+ break ;
50+ case "A" :
51+ axis_A_feedrate = document . getElementById ( 'control_z_velocity' ) . value ;
52+ break ;
53+ case "B" :
54+ axis_B_feedrate = document . getElementById ( 'control_z_velocity' ) . value ;
55+ break ;
56+ case "C" :
57+ axis_C_feedrate = document . getElementById ( 'control_z_velocity' ) . value ;
58+ break ;
59+ }
60+
61+ last_axis_letter = letter ;
62+ switch ( last_axis_letter ) {
63+ case "Z" :
64+ document . getElementById ( 'control_z_velocity' ) . value = axis_Z_feedrate ;
65+ break ;
66+ case "A" :
67+ document . getElementById ( 'control_z_velocity' ) . value = axis_A_feedrate ;
68+ break ;
69+ case "B" :
70+ document . getElementById ( 'control_z_velocity' ) . value = axis_B_feedrate ;
71+ break ;
72+ case "C" :
73+ document . getElementById ( 'control_z_velocity' ) . value = axis_C_feedrate ;
74+ break ;
75+ }
76+ }
877
978function init_grbl_panel ( ) {
1079 grbl_set_probe_detected ( false ) ;
@@ -117,10 +186,25 @@ function process_grbl_position(response) {
117186 } else {
118187 WCOy = 0 ;
119188 }
120- if ( tab3 . length > 2 ) {
189+ if ( ( tab3 . length > 2 ) && ( grblaxis > 2 ) ) {
121190 WCOz = parseFloat ( tab3 [ 2 ] ) ;
122191 } else {
123192 WCOz = 0 ;
193+ }
194+ if ( ( tab3 . length > 3 ) && ( grblaxis > 3 ) ) {
195+ WCOa = parseFloat ( tab3 [ 3 ] ) ;
196+ } else {
197+ WCOa = 0 ;
198+ }
199+ if ( ( tab3 . length > 4 ) && ( grblaxis > 4 ) ) {
200+ WCOb = parseFloat ( tab3 [ 4 ] ) ;
201+ } else {
202+ WCOb = 0 ;
203+ }
204+ if ( ( tab3 . length > 5 ) && ( grblaxis > 5 ) ) {
205+ WCOc = parseFloat ( tab3 [ 5 ] ) ;
206+ } else {
207+ WCOc = 0 ;
124208 }
125209 gotWCO = true ;
126210 }
@@ -134,10 +218,22 @@ function process_grbl_position(response) {
134218 document . getElementById ( 'control_y_position' ) . innerHTML = tab3 [ 1 ] ;
135219 if ( gotWCO ) document . getElementById ( 'control_ym_position' ) . innerHTML = ( WCOy + parseFloat ( tab3 [ 1 ] ) ) . toFixed ( 3 ) ;
136220 }
137- if ( tab3 . length > 2 ) {
221+ if ( ( tab3 . length > 2 ) && ( grblaxis > 2 ) ) {
138222 document . getElementById ( 'control_z_position' ) . innerHTML = tab3 [ 2 ] ;
139223 if ( gotWCO ) document . getElementById ( 'control_zm_position' ) . innerHTML = ( WCOz + parseFloat ( tab3 [ 2 ] ) ) . toFixed ( 3 ) ;
140224 }
225+ if ( ( tab3 . length > 3 ) && ( grblaxis > 3 ) ) {
226+ document . getElementById ( 'control_a_position' ) . innerHTML = tab3 [ 3 ] ;
227+ if ( gotWCO ) document . getElementById ( 'control_am_position' ) . innerHTML = ( WCOa + parseFloat ( tab3 [ 3 ] ) ) . toFixed ( 3 ) ;
228+ }
229+ if ( ( tab3 . length > 4 ) && ( grblaxis > 4 ) ) {
230+ document . getElementById ( 'control_b_position' ) . innerHTML = tab3 [ 4 ] ;
231+ if ( gotWCO ) document . getElementById ( 'control_bm_position' ) . innerHTML = ( WCOb + parseFloat ( tab3 [ 4 ] ) ) . toFixed ( 3 ) ;
232+ }
233+ if ( ( tab3 . length > 5 ) && ( grblaxis > 5 ) ) {
234+ document . getElementById ( 'control_c_position' ) . innerHTML = tab3 [ 5 ] ;
235+ if ( gotWCO ) document . getElementById ( 'control_cm_position' ) . innerHTML = ( WCOc + parseFloat ( tab3 [ 5 ] ) ) . toFixed ( 3 ) ;
236+ }
141237
142238 } else {
143239 tab1 = response . split ( "MPos:" ) ;
@@ -150,10 +246,22 @@ function process_grbl_position(response) {
150246 document . getElementById ( 'control_ym_position' ) . innerHTML = tab3 [ 1 ] ;
151247 if ( gotWCO ) document . getElementById ( 'control_y_position' ) . innerHTML = ( parseFloat ( tab3 [ 1 ] ) - WCOy ) . toFixed ( 3 ) ;
152248 }
153- if ( tab3 . length > 2 ) {
249+ if ( ( tab3 . length > 2 ) && ( grblaxis > 2 ) ) {
154250 document . getElementById ( 'control_zm_position' ) . innerHTML = tab3 [ 2 ] ;
155251 if ( gotWCO ) document . getElementById ( 'control_z_position' ) . innerHTML = ( parseFloat ( tab3 [ 2 ] ) - WCOz ) . toFixed ( 3 ) ;
156252 }
253+ if ( ( tab3 . length > 3 ) && ( grblaxis > 3 ) ) {
254+ document . getElementById ( 'control_am_position' ) . innerHTML = tab3 [ 3 ] ;
255+ if ( gotWCO ) document . getElementById ( 'control_a_position' ) . innerHTML = ( parseFloat ( tab3 [ 3 ] ) - WCOa ) . toFixed ( 3 ) ;
256+ }
257+ if ( ( tab3 . length > 4 ) && ( grblaxis > 4 ) ) {
258+ document . getElementById ( 'control_bm_position' ) . innerHTML = tab3 [ 4 ] ;
259+ if ( gotWCO ) document . getElementById ( 'control_b_position' ) . innerHTML = ( parseFloat ( tab3 [ 4 ] ) - WCOb ) . toFixed ( 3 ) ;
260+ }
261+ if ( ( tab3 . length > 5 ) && ( grblaxis > 5 ) ) {
262+ document . getElementById ( 'control_cm_position' ) . innerHTML = tab3 [ 5 ] ;
263+ if ( gotWCO ) document . getElementById ( 'control_c_position' ) . innerHTML = ( parseFloat ( tab3 [ 5 ] ) - WCOc ) . toFixed ( 3 ) ;
264+ }
157265 }
158266 }
159267}
@@ -317,4 +425,4 @@ function StartProbeProcess() {
317425 document . getElementById ( "probingtext" ) . style . display = "table-row" ;
318426 grbl_error_msg = "" ;
319427 document . getElementById ( 'grbl_status_text' ) . innerHTML = grbl_error_msg ;
320- }
428+ }
0 commit comments