cBluetooth.TAG, Bluetooth is not available. Exit );
Toast.makeText (activity.getBaseContext (), Bluetooth is not available raquo ;, Toast.LENGTH_SHORT) .show ();
activity.finish ();
break;
case cBluetooth.BL_INCORRECT_ADDRESS:
Log.d (cBluetooth.TAG, Incorrect MAC address );
Toast.makeText (activity.getBaseContext (), Incorrect Bluetooth address raquo ;, Toast.LENGTH_SHORT) .show ();
break;
case cBluetooth.BL_REQUEST_ENABLE:
Log.d (cBluetooth.TAG, Request Bluetooth Enable );
BluetoothAdapter.getDefaultAdapter ();
Intent enableBtIntent=new Intent (BluetoothAdapter.ACTION_REQUEST_ENABLE);
activity.startActivityForResult (enableBtIntent, 1);
break;
case cBluetooth.BL_SOCKET_FAILED:
Toast.makeText (activity.getBaseContext (), Socket failed raquo ;, Toast.LENGTH_SHORT) .show ();
break;
} final MyHandler mHandler=new MyHandler (this); final static Runnable sRunnable=new Runnable () {void run () {}
}; void onSensorChanged (SensorEvent e) {(e.values ??[0], VSeekBar.getProgress ());=e.values ??[0];
} void MotionChanged (float x, int y) {directionL= raquo ;; directionR= raquo ;; cmdSendL, cmdSendR; .d (cBluetooth.TAG, Math.round (x) + + y);=Math.round (x * pwmMax/xR); (isRear) yAxis=y; yAxis=-y; (xAxis gt; pwmMax) xAxis=pwmMax; if (xAxis lt; -pwmMax ) xAxis=-pwmMax; (yAxis gt; pwmMax) yAxis=pwmMax; if (yAxis lt; -pwmMax) yAxis=-pwmMax; if (yAxis gt;=0 amp; amp; yAxis lt; yThreshold) yAxis=0; if (yAxis lt; 0 amp ; amp; yAxis gt; -yThreshold) yAxis=0; (xAxis gt; 0) {= yAxis; (Math.abs (Math.round (x)) gt; xR) {= Math.round ((x-xR) * pwmMax/(xMax-xR));=Math.round (-motorLeft * yAxis/pwmMax);
} motorLeft=yAxis - yAxis * xAxis/pwmMax;
} if (xAxis lt; 0) {= yAxis; (Math.abs (Math.round (x)) gt; xR) {= Math.round ((Math.abs (x) -xR) * pwmMax/(xMax-xR));=Math.round (-motorRight * yAxis/pwmMax); motorRight=yAxis - yAxis * Math.abs (xAxis)/pwmMax; if (xAxis == 0) {= yAxis ;=yAxis; (motorLeft gt; 0) {= - raquo ;;
} (motorRight gt; 0) {= - raquo ;;
}=Math.abs (motorLeft);=Math.abs (motorRight); (motorLeft gt; pwmMax) motorLeft=pwmMax; (motorRight gt; pwmMax) motorRight=pwmMax;=String.valueOf ( commandLeft + directionL + motorLeft + r );=String.valueOf (commandRight + directionR + motorRight + r ); (BT_is_connect) bl.sendData (cmdSendL + cmdSendR); textX=(TextView) findViewById ( R.id.textViewX); textY=(TextView) findViewById (R.id.textViewY); mLeft=(TextView) findViewById (R.id.mLeft); mRight=(TextView) findViewById (R.id.mRight); textCmdSend =(TextView) findViewById (R.id.textViewCmdSend); (show_Debug) {. setText (String.valueOf ( X: + String.format (%. 1f , x) + laquo ;; xPWM: + xAxis));
textY.setText (String.valueOf ( Y: + String.valueOf (y) + laquo ;; yPWM: + yAxis));
mLeft.setText (String.valueOf ( MotorL: + directionL + . + motorLeft));
mRight.setText (String.valueOf ( MotorR: + directionR + . + motorRight));
textCmdSend.setText (String.valueOf ( Send: + cmdSendL.toUpperCase (Locale.getDefault ()) + cmdSendR.toUpperCase (Locale.getDefault ())));
}{.setText(laquo;raquo;);.setText(laquo;raquo;);.setText(laquo;raquo;);.setText(laquo;raquo;);.setText(laquo;raquo;);
} void loadPref () {mySharedPreferences=PreferenceManager.getDefaultSharedPreferences (this); =MySharedPreferences.getString ( pref_MAC_address raquo ;, address); xMax=Integer.parseInt (mySharedPreferences.getString ( pref_xMax raquo ;, String.valueOf (xMax)));=Integer.parseInt (mySharedPreferences.getString ( pref_xR raquo ;, String.valueOf (xR)));=Integer. parseInt (mySharedPreferences.getString ( pref_yMax raquo ;, String.valueOf (yMax)));=Integer.parseInt (mySharedPreferences.getString ( pref_yThreshold raquo ;, String.valueOf (yThreshold)));=Integer.parseInt (mySharedPreferences. getString ( pref_pwmMax raquo ;, String.valueOf (pwmMax))); _ Debug=mySharedPreferences.getBoolean ( pref_Debug raquo ;, false);=mySharedPreferences.getString ( pref_commandLeft raquo ;, commandLeft);=mySharedPreferences.getString ( pref_commandRight raquo ;, commandRight);=mySharedPreferences.getString ( pref_commandHorn raquo ;, commandHorn);
}
@ Overridevoid onResume () {.onResume (); _ is_connect=bl.BT_Connect (address, false...