index.js
// Move X & Y base on X & Y Stick Movments
Move X & Y base on X & Y Stick Movments
Move X & Y base on X & Y Stick Movments
function stickMovment() {
			var sum_x = Number(left_x + right_x);
			var sum_y = Number(left_y + right_y);
			if (left_x >= stick_sensitivity | left_x <= -stick_sensitivity || left_y >= stick_sensitivity || left_y <= -stick_sensitivity || right_x >= stick_sensitivity || right_x <= -stick_sensitivity || right_y >= stick_sensitivity || right_y <= -stick_sensitivity) {
				if (!stick_left) {
					left_x = 0; left_y = 0;
				}
				if (!stick_right) {
					right_x = 0; right_y = 0;
				}
				socket.emit('command', options.port, 'gcode', 'G21');  
				socket.emit('command', options.port, 'gcode', 'G91 G0 X' + map(sum_x, 0, 128, 0.0001, 2).toFixed(4) + ' Y' + map(sum_y, 0, 128, 0.0001, 2).toFixed(4)); 
				socket.emit('command', options.port, 'gcode', 'G90');  
			}
		}
function stickMovment ( ) { var sum_x = Number ( left_x + right_x ) ; var sum_y = Number ( left_y + right_y ) ; if ( left_x >= stick_sensitivity | left_x <= - stick_sensitivity || left_y >= stick_sensitivity || left_y <= - stick_sensitivity || right_x >= stick_sensitivity || right_x <= - stick_sensitivity || right_y >= stick_sensitivity || right_y <= - stick_sensitivity ) { if ( ! stick_left ) { left_x = 0 ; left_y = 0 ; } if ( ! stick_right ) { right_x = 0 ; right_y = 0 ; } socket . emit ( 'command' , options . port , 'gcode' , 'G21' ) ; socket . emit ( 'command' , options . port , 'gcode' , 'G91 G0 X' + map ( sum_x , 0 , 128 , 0.0001 , 2 ) . toFixed ( 4 ) + ' Y' + map ( sum_y , 0 , 128 , 0.0001 , 2 ) . toFixed ( 4 ) ) ; socket . emit ( 'command' , options . port , 'gcode' , 'G90' ) ; } }
Move X & Y base on X & Y Stick Movments
Move X & Y base on X & Y Stick Movments
// Additional Safty Catch //!!!!!!!!!!!!!!!!! need to detect if it's in inches or millimetersmm to avoid and overrun in the multiplier this can be done with agreeable status I believe. // set to millimeters // Move based on stick imput and mapping, need to add exponital curve. // Switch to relative coordinates, Move one unit right in X and one unit right in Y // Switch back to absolute coordinates //console.log('setInterval: x' + sum_x + ' y' + sum_y + ' | ' + 'G91 G0 X' + map(sum_x, 0, 128, 0.0001, 2).toFixed(4) + ' Y' + map(sum_y, 0, 128, 0.0001, 2).toFixed(4));