Changeset 5c11ea9 in orbit
- Timestamp:
- 03/05/13 16:59:51 (9 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- 8358488
- Parents:
- 136014a
- Location:
- android
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
android/res/layout-large/activity_main.xml
r136014a r5c11ea9 254 254 <ImageView 255 255 android:id="@+id/imageViewStatus" 256 android:layout_width=" wrap_content"256 android:layout_width="match_parent" 257 257 android:layout_height="wrap_content" 258 258 android:contentDescription="@string/image_description_status" -
android/res/layout/activity_main.xml
r136014a r5c11ea9 257 257 <ImageView 258 258 android:id="@+id/imageViewStatus" 259 android:layout_width=" wrap_content"259 android:layout_width="match_parent" 260 260 android:layout_height="wrap_content" 261 261 android:contentDescription="@string/image_description_status" -
android/src/info/puzzlebox/orbit/OrbitActivity.java
r136014a r5c11ea9 11 11 * NOTE: USB Serial support is necessary for communicating with 12 12 * an Arduino UNO, however requires Android 3.2 or later. 13 * For compatibility with earlier handsets we have left USB Serial14 * support commented out by default throughout this source file.13 * For compatibility with earlier handsets we have moved 14 * all USB Serial support to OrbitUSBActivity 15 15 */ 16 16 17 import android.media.AudioFormat;18 17 import android.media.AudioManager; 19 import android.media.AudioTrack;20 18 import android.media.SoundPool; 21 19 import android.media.SoundPool.OnLoadCompleteListener; … … 38 36 import android.graphics.drawable.ShapeDrawable; 39 37 import android.graphics.drawable.shapes.RoundRectShape; 40 import android.util.DisplayMetrics;41 //import android.hardware.usb.UsbManager;42 38 import android.util.Log; 43 import android.view.Display;44 39 import android.view.Gravity; 45 40 import android.view.View; … … 59 54 60 55 import com.neurosky.thinkgear.TGDevice; 61 62 //import com.hoho.android.usbserial.driver.UsbSerialDriver;63 //import com.hoho.android.usbserial.driver.UsbSerialProber;64 //import com.hoho.android.usbserial.util.SerialInputOutputManager;65 56 66 57 … … 166 157 167 158 168 /**169 * USB Serial170 */171 // SerialDevice serial;172 // int serialBaudRate = 9600;173 174 /** The device currently in use, or {@code null}. */175 // private UsbSerialDriver mSerialDevice;176 177 /** The system's USB service. */178 // private UsbManager mUsbManager;179 180 /** Thread Service */181 // private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();182 183 // private SerialInputOutputManager mSerialIoManager;184 185 // private final SerialInputOutputManager.Listener mListener =186 // new SerialInputOutputManager.Listener() {187 //188 // public void onRunError(Exception e) {189 // // Log.d(TAG, "Runner stopped.");190 // }191 //192 // public void onNewData(final byte[] data) {193 // // PuzzleboxBrainstormsHelicopter.this.runOnUiThread(new Runnable() {194 // // @Override195 // // public void run() {196 // // PuzzleboxBrainstormsHelicopter.this.updateReceivedData(data);197 // // }198 // // });199 // }200 // };201 202 203 159 @Override 204 160 public void onCreate(Bundle savedInstanceState) { … … 218 174 config = getResources().getConfiguration(); 219 175 220 // Log.v(TAG, "screenLayout: " + config.screenLayout);221 222 176 switch(config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK){ 223 177 case Configuration.SCREENLAYOUT_SIZE_SMALL: 224 // Log.v(TAG, "screenLayout: small");225 178 requestWindowFeature(Window.FEATURE_NO_TITLE); 226 179 break; 227 180 case Configuration.SCREENLAYOUT_SIZE_NORMAL: 228 // Log.v(TAG, "screenLayout: normal");229 181 requestWindowFeature(Window.FEATURE_NO_TITLE); 230 182 break; 231 183 case Configuration.SCREENLAYOUT_SIZE_LARGE: 232 // Log.v(TAG, "screenLayout: large");233 184 break; 234 185 case Configuration.SCREENLAYOUT_SIZE_XLARGE: 235 // Log.v(TAG, "screenLayout: xlarge");236 186 break; 237 187 case Configuration.SCREENLAYOUT_SIZE_UNDEFINED: 238 // Log.v(TAG, "screenLayout: undefined");239 188 requestWindowFeature(Window.FEATURE_NO_TITLE); 240 189 break; … … 332 281 updateScreenLayout(); 333 282 updateAdvancedOptions(); 334 283 335 284 updatePowerThresholds(); 336 285 updatePower(); … … 388 337 389 338 390 /**391 * Prepare USB Serial392 */393 // mUsbManager = (UsbManager) getSystemService(Context.USB_SERVICE);394 // serial = new SerialDevice();395 // serial.setSerialDevice(mSerialDevice);396 397 398 339 } // onCreate 399 340 … … 409 350 */ 410 351 352 updateAdvancedOptions(); 411 353 super.onResume(); 412 354 413 /** This section handles the USB Serial device when the program is resumed */ 414 // mSerialDevice = UsbSerialProber.acquire(mUsbManager); 415 // // Log.d(TAG, "Resumed, mSerialDevice=" + mSerialDevice); 416 // if (mSerialDevice == null) { 417 // Log.d(TAG, "No Serial device found"); 418 // // appendTextAndScroll("No serial device found\n"); 419 // } else { 420 // try { 421 // mSerialDevice.open(); 422 // mSerialDevice.setBaudRate(serialBaudRate); 423 // serial.setSerialDevice(mSerialDevice); 424 // serial.execute(new String[] {""} ); 425 // } catch (IOException e) { 426 // Log.e(TAG, "Error opening device: " + e.getMessage(), e); 427 // // appendTextAndScroll("Error opening device: " + e.getMessage() + "\n"); 428 // 429 // try { 430 // mSerialDevice.close(); 431 // } catch (IOException e2) { 432 // // Ignore. 433 // } 434 // mSerialDevice = null; 435 // serial.setSerialDevice(null); 436 // return; 437 // } 438 // appendTextAndScroll("Serial device: " + mSerialDevice + "\n"); 439 // } 440 // 441 // onDeviceStateChange(); 442 } 355 } // onResume 443 356 444 357 … … 454 367 tgDevice.close(); 455 368 456 /** Handle USB Serial */457 // if (mSerialDevice != null) {458 // try {459 // mSerialDevice.close();460 // } catch (IOException e) {461 // // TODO Auto-generated catch block462 // e.printStackTrace();463 // }464 // }465 466 369 super.onDestroy(); 467 } 468 469 470 // ################################################################ 471 472 // @Override 473 // public boolean onCreateOptionsMenu(Menu menu) { 474 // getMenuInflater().inflate(R.menu.activity_main, menu); 475 // return true; 476 // } 477 // 478 // 479 // @Override 480 // public boolean onOptionsItemSelected(MenuItem item) { 481 // switch (item.getItemId()) { 482 // case android.R.id.home: 483 // NavUtils.navigateUpFromSameTask(this); 484 // return true; 485 // } 486 // return super.onOptionsItemSelected(item); 487 // } 488 489 490 // ################################################################ 491 492 private void appendTextAndScroll(String text) { 370 371 } // onDestroy 372 373 374 // ################################################################ 375 376 protected void appendTextAndScroll(String text) { 493 377 494 378 /** … … 548 432 } 549 433 } // updateScreenLayout 550 551 552 // ################################################################ 553 434 435 436 // ################################################################ 437 554 438 public void updateScreenLayoutSmall() { 555 439 556 440 setButtonText(R.id.buttonTestFly, "Test"); 557 441 radioGroupChannel.setVisibility(View.GONE); … … 559 443 checkBoxGenerateAudio.setText("Generate Signal"); 560 444 checkBoxInvertControlSignal.setText("Invert Signal"); 561 // viewSpaceGenerateAudioWidth = LayoutParams.MATCH_PARENT;562 445 // viewSpaceGenerateAudioWidth = LayoutParams.MATCH_PARENT; 446 563 447 int width = getWindowManager().getDefaultDisplay().getWidth(); 564 448 int height = getWindowManager().getDefaultDisplay().getHeight(); 565 449 566 450 viewSpaceGenerateAudioWidth = width / 4; // approximate center of screen 567 451 568 452 } // updateScreenLayoutSmall 569 453 570 454 571 455 // ################################################################ … … 692 576 693 577 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) { 694 //appendTextAndScroll(progress + " " +695 //getString(R.string.seekbar_from_touch) + "=" + fromTouch);696 578 697 579 updatePowerThresholds(); … … 709 591 */ 710 592 711 //appendTextAndScroll(getString(R.string.seekbar_tracking_on));712 593 713 594 } // onStartTrackingTouch … … 728 609 729 610 730 //appendTextAndScroll(getString(R.string.seekbar_tracking_off));731 732 611 } // onStopTrackingTouch 733 734 735 // private void stopIoManager() {736 //737 // /**738 // * Method required by USB Serial739 // */740 //741 // if (mSerialIoManager != null) {742 // // Log.i(TAG, "Stopping io manager ..");743 // mSerialIoManager.stop();744 // mSerialIoManager = null;745 // }746 // } // stopIoManager747 748 749 // private void startIoManager() {750 //751 // /**752 // * Method required by USB Serial753 // */754 //755 // if (mSerialDevice != null) {756 // // Log.i(TAG, "Starting io manager ..");757 // mSerialIoManager = new SerialInputOutputManager(mSerialDevice, mListener);758 // mExecutor.submit(mSerialIoManager);759 // }760 // } // startIoManager761 762 763 // private void onDeviceStateChange() {764 //765 // /**766 // * Called by onResume() to manage USB Serial767 // */768 //769 // stopIoManager();770 // startIoManager();771 // } // onDeviceStateChange772 612 773 613 … … 1125 965 } 1126 966 1127 /** This sequence is used for managing the USB Serial control */1128 // command = getPowerCommand(new_speed);1129 //1130 // if (mSerialDevice != null) {1131 // serial.setCommand(command);1132 // }1133 1134 967 currentCommand = command; 1135 968 1136 969 } // updatePower 1137 1138 1139 // public String getPowerCommand(int speed) {1140 //1141 // /**1142 // * This method is used to set the throttle1143 // * level using USB Serial to communicate1144 // * with an Arduino device1145 // */1146 //1147 // String command = "%";1148 //1149 // if (speed >= 100)1150 // command = "%100";1151 // else if (speed >= 10)1152 // command = "%0" + speed;1153 // else if (speed >= 0)1154 // command = "%00" + speed;1155 // else1156 // command = "%000";1157 //1158 // if (DEBUG) {1159 // Log.v(TAG, "Command for serial device: " + command);1160 //// appendTextAndScroll("Command for serial device: " + command + "\n");1161 // }1162 //1163 // return(command);1164 //1165 // } // getPowerCommand1166 970 1167 971 … … 1269 1073 demoFlightMode = false; 1270 1074 1271 // playTone();1272 1273 1274 /** The following demo mode, when used with an Arduino-controlled infrared circuit,1275 * should cause the helicopter to briefly hover, then return to the ground1276 */1277 //1278 // String command = "neutral";1279 //1280 // appendTextAndScroll("Command for serial device: " + command + "\n");1281 // serial.setCommand(command);1282 //1283 // try {1284 // Thread.sleep(5000);1285 // } catch (InterruptedException e) {1286 // // TODO Auto-generated catch block1287 // e.printStackTrace();1288 // }1289 //1290 // command = "hover";1291 // appendTextAndScroll("Command for serial device: " + command + "\n");1292 // serial.setCommand(command);1293 //1294 // try {1295 // Thread.sleep(2500);1296 // } catch (InterruptedException e) {1297 // // TODO Auto-generated catch block1298 // e.printStackTrace();1299 // }1300 //1301 //1302 // command = "neutral";1303 // appendTextAndScroll("Command for serial device: " + command + "\n");1304 // serial.setCommand(command);1305 1306 1075 1307 1076 } // demoMode … … 1317 1086 1318 1087 } // demoStop 1319 1320 1321 // ################################################################1322 1323 // public void testFly(View view) {1324 //// if (serviceBinder != null) {1325 //// serviceBinder.ifFlip = checkBoxInvertControlSignal.isChecked(); // if checked then flip1326 //// int channel = radioGroupChannel.getCheckedRadioButtonId();1327 //// serviceBinder.channel = channel;1328 //// serviceBinder.loopNumberWhileMindControl = 20;1329 //// startService(new Intent (OrbitActivity.this, AudioService.class));1330 //// }1331 //1332 // demoMode(view);1333 //1334 // } // testFly1335 1336 1337 // ################################################################1338 1339 // public void stopTest(View view) {1340 //1341 // stopControl();1342 //1343 // } //stopTest1344 1088 1345 1089 … … 1358 1102 serviceBinder = ((AudioService.OrbitBinder)service).getService(); 1359 1103 } 1360 }; 1361 1362 1363 } // MainActivity 1104 1105 }; // ServiceConnection 1106 1107 1108 } // OrbitActivity
Note: See TracChangeset
for help on using the changeset viewer.