Changeset 4634b1d in orbit for android/src
- Timestamp:
- 12/06/12 03:15:32 (8 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- 2b4365b
- Parents:
- c30c900
- Location:
- android/src/info/puzzlebox/orbit
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
android/src/info/puzzlebox/orbit/MainActivity.java
re3d7c4a r4634b1d 34 34 import android.widget.Button; 35 35 import android.widget.ProgressBar; 36 import android.widget.RemoteViews; 36 37 import android.widget.SeekBar; 37 38 import android.widget.TextView; … … 78 79 Button b; 79 80 81 String TAG = "MainActivity"; 82 80 83 int tgSignal = 0; 81 84 int[] thresholdValuesAttention = new int[101]; … … 98 101 // private static final String MAC_ADDRESS = "00:16:53:09:0B:B9"; 99 102 100 103 // int audioFile = R.raw.throttle_max_android_common; 104 // int audioFile = R.raw.throttle_min_android_common; 105 // int audioFile = R.raw.throttle_max_android_htc_one_x; 106 int audioFile = R.raw.throttle_hover_android_htc_one_x; 101 107 102 108 String currentCommand = "neutral"; 103 109 104 // 2012.11.28-orbit-hdmi-android-manual_from_untitled08.wav105 110 private SoundPool soundPool; 106 111 private int soundID; … … 211 216 212 217 updatePowerThresholds(); 213 // updateNXTPower();214 218 updatePower(); 215 219 … … 252 256 } 253 257 }); 254 soundID = soundPool.load(this, R.raw.throttle_max_android_common, 1); 255 // soundID = soundPool.load(this, R.raw.throttle_min_android_common, 1); 256 // soundID = soundPool.load(this, R.raw.throttle_max_android_htc_one_x, 1); 258 259 soundID = soundPool.load(this, audioFile, 1); 257 260 258 261 … … 266 269 // Log.d(TAG, "Resumed, mSerialDevice=" + mSerialDevice); 267 270 if (mSerialDevice == null) { 268 // mTitleTextView.setText("No serial device."); 269 // tv.setText("No serial device.\n"); 270 appendTextAndScroll("No serial device.\n"); 271 Log.d(TAG, "No Serial device found"); 272 // appendTextAndScroll("No serial device found\n"); 271 273 } else { 272 274 try { … … 276 278 serial.execute(new String[] {""} ); 277 279 } catch (IOException e) { 278 // Log.e(TAG, "Error setting up device: " + e.getMessage(), e); 279 // mTitleTextView.setText("Error opening device: " + e.getMessage()); 280 // tv.setText("Error opening device: " + e.getMessage() + "\n"); 281 appendTextAndScroll("Error opening device: " + e.getMessage() + "\n"); 280 Log.e(TAG, "Error opening device: " + e.getMessage(), e); 281 // appendTextAndScroll("Error opening device: " + e.getMessage() + "\n"); 282 282 283 283 try { … … 327 327 break; 328 328 case TGDevice.STATE_CONNECTING: 329 appendTextAndScroll("Connecting: " + MAC_ADDRESS + "\n"); 329 Log.d(TAG, "Connecting to EEG: " + MAC_ADDRESS); 330 appendTextAndScroll("Connecting to EEG: " + MAC_ADDRESS + "\n"); 330 331 break; 331 332 case TGDevice.STATE_CONNECTED: 332 appendTextAndScroll("Connected.\n"); 333 Log.d(TAG, "EEG Connected"); 334 appendTextAndScroll("Bluetooth Connected\n"); 335 setButtonText(R.id.button1, "Disconnect"); 333 336 tgDevice.start(); 334 337 break; 335 338 case TGDevice.STATE_NOT_FOUND: 336 appendTextAndScroll("Can't find\n"); 339 Log.d(TAG, "EEG headset not found"); 340 appendTextAndScroll("EEG headset not found\n"); 337 341 break; 338 342 case TGDevice.STATE_NOT_PAIRED: 339 appendTextAndScroll("not paired\n"); 343 Log.d(TAG, "EEG headset not paired"); 344 appendTextAndScroll("EEG headset not paired\n"); 340 345 break; 341 346 case TGDevice.STATE_DISCONNECTED: 342 appendTextAndScroll("Disconnected mang\n"); 347 Log.d(TAG, "EEG Disconnected"); 348 // appendTextAndScroll("EEG Disconnected\n"); 343 349 break; 344 350 } … … 350 356 //signal = msg.arg1; 351 357 // tv.append("PoorSignal: " + msg.arg1 + "\n"); 352 appendTextAndScroll("\nPoorSignal: " + msg.arg1 + "\n"); 358 Log.v(TAG, "PoorSignal: " + msg.arg1); 359 // appendTextAndScroll("\nPoorSignal: " + msg.arg1 + "\n"); 353 360 progressBarSignal.setProgress(tgSignal); 354 361 355 356 // updateNXTPower();357 362 updatePower(); 358 363 … … 364 369 break; 365 370 case TGDevice.MSG_HEART_RATE: 366 // tv.append("Heart rate: " + msg.arg1 + "\n");367 appendTextAndScroll("Heart rate: " + msg.arg1 + "\n");371 Log.v(TAG, "Heart rate: " + msg.arg1); 372 // appendTextAndScroll("Heart rate: " + msg.arg1 + "\n"); 368 373 break; 369 374 case TGDevice.MSG_ATTENTION: 370 //att = msg.arg1; 371 // tv.append("Attention: " + msg.arg1 + "\n"); 372 appendTextAndScroll("Attention: " + msg.arg1 + "\n"); 375 Log.v(TAG, "Attention: " + msg.arg1); 376 // appendTextAndScroll("Attention: " + msg.arg1 + "\n"); 373 377 progressBarAttention.setProgress(msg.arg1); 374 //Log.v("HelloA", "Attention: " + att + "\n");375 376 // updateNXTPower();377 378 updatePower(); 378 379 379 380 break; 380 381 case TGDevice.MSG_MEDITATION: 381 // tv.append("Meditation: " + msg.arg1 + "\n");382 appendTextAndScroll("Meditation: " + msg.arg1 + "\n");382 Log.v(TAG, "Meditation: " + msg.arg1); 383 // appendTextAndScroll("Meditation: " + msg.arg1 + "\n"); 383 384 progressBarMeditation.setProgress(msg.arg1); 384 385 // updateNXTPower();386 385 updatePower(); 387 386 … … 408 407 public void connectHeadset(View view) { 409 408 410 if (tgDevice.getState() != TGDevice.STATE_CONNECTING && tgDevice.getState() != TGDevice.STATE_CONNECTED)409 if (tgDevice.getState() != TGDevice.STATE_CONNECTING && tgDevice.getState() != TGDevice.STATE_CONNECTED) 411 410 tgDevice.connect(rawEnabled); 412 411 412 else if (tgDevice.getState() == TGDevice.STATE_CONNECTED) 413 disconnectHeadset(); 414 413 415 414 416 } // connectHeadset 417 418 419 public void disconnectHeadset() { 420 tgDevice.stop(); 421 tgDevice.close(); 422 stopControl(); 423 progressBarAttention.setProgress(0); 424 progressBarMeditation.setProgress(0); 425 progressBarSignal.setProgress(0); 426 progressBarPower.setProgress(0); 427 setButtonText(R.id.button1, "Connect"); 428 appendTextAndScroll("EEG Disconnected\n"); 429 } // disconnectHeadset 430 431 432 public void setButtonText(int buttonId, String text) { 433 434 // RemoteViews remoteViews = new RemoteViews(getApplicationContext().getPackageName(), R.layout.activity_main); 435 // remoteViews.setTextViewText(buttonId, text); 436 437 Button button = (Button) findViewById(buttonId); 438 button.setText(text); 439 440 } 415 441 416 442 … … 506 532 thresholdValuesAttention[i] = power; 507 533 508 // appendTextAndScroll(i + ":" + power + " ");509 534 } 510 535 } … … 545 570 } 546 571 547 appendTextAndScroll("Command: " + command + "\n"); 572 // appendTextAndScroll("Command: " + command + "\n"); 573 Log.v(TAG, "Command: " + command); 548 574 549 575 // String command = getPowerCommand(new_speed); … … 573 599 command = "%000"; 574 600 575 appendTextAndScroll("Command for serial device: " + command + "\n"); 601 Log.v(TAG, "Command for serial device: " + command); 602 // appendTextAndScroll("Command for serial device: " + command + "\n"); 576 603 577 604 return(command); … … 614 641 // playTone(); 615 642 616 playControl(); 617 618 643 playControl(); 619 644 620 645 // String command = "neutral";
Note: See TracChangeset
for help on using the changeset viewer.