private void setSpeedReal(float speedLeft, float speedRight) { Log.i(LOG_TAG, "Setting speeds to " + speedLeft + ", " + speedRight); this.speedLeft = speedLeft; this.speedRight = speedRight; try { if (gameControl != null && gameControl.hasRobotControl()) { gameControl.setLeftMotorSpeed(speedLeft); gameControl.setRightMotorSpeed(speedRight); lastCommandTime = System.currentTimeMillis(); } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public void onServiceConnected(ComponentName name, IBinder serviceBinder) { gameControl = IGameControl.Stub.asInterface(serviceBinder); try { gameControl.registerCallback(serviceCallback); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Setup driving try { gameControl.prepareRobots(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
@Override public void onServiceDisconnected(ComponentName name) { try { gameControl.unregisterCallback(serviceCallback); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } gameControl = null; }
private void setFullStop(boolean fullStop) { // Stop the motors Log.i(LOG_TAG, "Fullstop: " + fullStop); try { if (gameControl != null && gameControl.hasRobotControl()) { if (fullStop && !gameControl.isAtFullStop()) { gameControl.setFullStop(true); return; } if (!fullStop && gameControl.isAtFullStop()) { gameControl.setFullStop(false); return; } } } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Add this to the SeekBars' change listener. }
@Override protected void onPause() { super.onStop(); if (DEBUG) { Log.d(LOG_TAG, "onStop()"); } if (gameControl != null) { try { gameControl.shutdownRobots(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } unbindService(serviceConnection); } // Stop preventing the screen from sleeping screenWakeLock.release(); screenWakeLock = null; }