- Timestamp:
- 11/29/12 19:40:56 (8 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- dccf843, e3d7c4a
- Parents:
- 389c84b
- Location:
- android
- Files:
-
- 2 added
- 1 deleted
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
android/.settings/org.eclipse.jdt.core.prefs
r3909100 r5b7f570 1 1 eclipse.preferences.version=1 2 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 2 3 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 4 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 3 5 org.eclipse.jdt.core.compiler.compliance=1.5 6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 4 11 org.eclipse.jdt.core.compiler.source=1.5 -
android/gen/info/puzzlebox/orbit/R.java
r1a53973 r5b7f570 12 12 } 13 13 public static final class dimen { 14 public static final int padding_large=0x7f0 50002;15 public static final int padding_medium=0x7f0 50001;16 public static final int padding_small=0x7f0 50000;14 public static final int padding_large=0x7f060002; 15 public static final int padding_medium=0x7f060001; 16 public static final int padding_small=0x7f060000; 17 17 } 18 18 public static final class drawable { … … 21 21 } 22 22 public static final class id { 23 public static final int button1=0x7f0 9000c;24 public static final int button2=0x7f0 9000d;25 public static final int menu_settings=0x7f0 9000e;26 public static final int progressBarAttention=0x7f0 90001;27 public static final int progressBarMeditation=0x7f0 90004;28 public static final int progressBarPower=0x7f0 90009;29 public static final int progressBarSignal=0x7f0 90007;30 public static final int scrollViewDebugConsole=0x7f0 9000a;31 public static final int seekBarAttention=0x7f0 90002;32 public static final int seekBarMeditation=0x7f0 90005;33 public static final int textViewDebugConsole=0x7f0 9000b;34 public static final int textViewLabelAttention=0x7f0 90000;35 public static final int textViewLabelMeditation=0x7f0 90003;36 public static final int textViewLabelPower=0x7f0 90008;37 public static final int textViewLabelSignal=0x7f0 90006;23 public static final int button1=0x7f0a000c; 24 public static final int button2=0x7f0a000d; 25 public static final int menu_settings=0x7f0a000e; 26 public static final int progressBarAttention=0x7f0a0001; 27 public static final int progressBarMeditation=0x7f0a0004; 28 public static final int progressBarPower=0x7f0a0009; 29 public static final int progressBarSignal=0x7f0a0007; 30 public static final int scrollViewDebugConsole=0x7f0a000a; 31 public static final int seekBarAttention=0x7f0a0002; 32 public static final int seekBarMeditation=0x7f0a0005; 33 public static final int textViewDebugConsole=0x7f0a000b; 34 public static final int textViewLabelAttention=0x7f0a0000; 35 public static final int textViewLabelMeditation=0x7f0a0003; 36 public static final int textViewLabelPower=0x7f0a0008; 37 public static final int textViewLabelSignal=0x7f0a0006; 38 38 } 39 39 public static final class layout { … … 41 41 } 42 42 public static final class menu { 43 public static final int activity_main=0x7f080000; 43 public static final int activity_main=0x7f090000; 44 } 45 public static final class raw { 46 public static final int throttle_max_android_common=0x7f050000; 47 public static final int throttle_max_android_htc_one_x=0x7f050001; 48 public static final int throttle_min_android_common=0x7f050002; 44 49 } 45 50 public static final class string { 46 public static final int app_name=0x7f0 60001;47 public static final int button_connect=0x7f0 60008;48 public static final int button_demo=0x7f0 60009;49 public static final int hello=0x7f0 60000;50 public static final int label_attention=0x7f0 60003;51 public static final int label_debug_console=0x7f0 60007;52 public static final int label_meditation=0x7f0 60004;53 public static final int label_power=0x7f0 60006;54 public static final int label_signal=0x7f0 60005;55 public static final int menu_settings=0x7f0 60002;56 public static final int seekbar_from_touch=0x7f0 6000c;57 public static final int seekbar_tracking_off=0x7f0 6000b;58 public static final int seekbar_tracking_on=0x7f0 6000a;51 public static final int app_name=0x7f070001; 52 public static final int button_connect=0x7f070008; 53 public static final int button_demo=0x7f070009; 54 public static final int hello=0x7f070000; 55 public static final int label_attention=0x7f070003; 56 public static final int label_debug_console=0x7f070007; 57 public static final int label_meditation=0x7f070004; 58 public static final int label_power=0x7f070006; 59 public static final int label_signal=0x7f070005; 60 public static final int menu_settings=0x7f070002; 61 public static final int seekbar_from_touch=0x7f07000c; 62 public static final int seekbar_tracking_off=0x7f07000b; 63 public static final int seekbar_tracking_on=0x7f07000a; 59 64 } 60 65 public static final class style { … … 63 68 <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" /> 64 69 */ 65 public static final int AppTheme=0x7f0 70000;70 public static final int AppTheme=0x7f080000; 66 71 } 67 72 public static final class xml { -
android/res/layout/activity_main.xml
r1a53973 r5b7f570 48 48 android:layout_height="wrap_content" 49 49 android:max="100" 50 android:progress=" 0"50 android:progress="82" 51 51 android:progressDrawable="@xml/progress_drawable" 52 52 android:thumb="@xml/thumb_drawable" /> -
android/src/info/puzzlebox/orbit/MainActivity.java
r2fc778c r5b7f570 43 43 public class MainActivity extends Activity implements SeekBar.OnSeekBarChangeListener { 44 44 45 // @Override46 // public void onCreate(Bundle savedInstanceState) {47 // super.onCreate(savedInstanceState);48 // setContentView(R.layout.activity_main);49 // getActionBar().setDisplayHomeAsUpEnabled(true);50 // }51 //52 // @Override53 // public boolean onCreateOptionsMenu(Menu menu) {54 // getMenuInflater().inflate(R.menu.activity_main, menu);55 // return true;56 // }57 //58 //59 // @Override60 // public boolean onOptionsItemSelected(MenuItem item) {61 // switch (item.getItemId()) {62 // case android.R.id.home:63 // NavUtils.navigateUpFromSameTask(this);64 // return true;65 // }66 // return super.onOptionsItemSelected(item);67 // }68 45 // @Override 46 // public void onCreate(Bundle savedInstanceState) { 47 // super.onCreate(savedInstanceState); 48 // setContentView(R.layout.activity_main); 49 // getActionBar().setDisplayHomeAsUpEnabled(true); 50 // } 51 // 52 // @Override 53 // public boolean onCreateOptionsMenu(Menu menu) { 54 // getMenuInflater().inflate(R.menu.activity_main, menu); 55 // return true; 56 // } 57 // 58 // 59 // @Override 60 // public boolean onOptionsItemSelected(MenuItem item) { 61 // switch (item.getItemId()) { 62 // case android.R.id.home: 63 // NavUtils.navigateUpFromSameTask(this); 64 // return true; 65 // } 66 // return super.onOptionsItemSelected(item); 67 // } 68 69 69 BluetoothAdapter bluetoothAdapter; 70 70 … … 87 87 SerialDevice serial; 88 88 int serialBaudRate = 9600; 89 // int serialBaudRate = 133333;89 // int serialBaudRate = 133333; 90 90 91 91 … … 95 95 96 96 private static final String MAC_ADDRESS = "D0:DF:9A:69:5D:42"; // MindWave Mobile Dev (p1-dev-60-01) 97 //private static final String MAC_ADDRESS = "00:16:53:09:0B:B9"; 98 99 100 101 // 2012.11.28-orbit-hdmi-android-manual_from_untitled08.wav 97 // private static final String MAC_ADDRESS = "9C:B7:0D:5E:E5:6A"; // UK So Television 98 // private static final String MAC_ADDRESS = "00:16:53:09:0B:B9"; 99 100 101 102 String currentCommand = "neutral"; 103 104 // 2012.11.28-orbit-hdmi-android-manual_from_untitled08.wav 102 105 private SoundPool soundPool; 103 106 private int soundID; 104 107 boolean loaded = false; 105 108 109 106 110 // Tone Generator 107 111 // http://stackoverflow.com/questions/2413426/playing-an-arbitrary-tone-with-android 108 112 private final int duration = 10; // seconds 109 private final int sampleRate = 8000; 110 private final int numSamples = duration * sampleRate; 111 private final double sample[] = new double[numSamples]; 112 private final double freqOfTone = 440; // hz 113 114 private final byte generatedSnd[] = new byte[2 * numSamples]; 115 116 117 void genTone(){ 118 // fill out the array 119 for (int i = 0; i < numSamples; ++i) { 120 sample[i] = Math.sin(2 * Math.PI * i / (sampleRate/freqOfTone)); 121 } 122 123 // convert to 16 bit pcm sound array 124 // assumes the sample buffer is normalized. 125 int idx = 0; 126 for (final double dVal : sample) { 127 // scale to maximum amplitude 128 final short val = (short) ((dVal * 32767)); 129 // in 16 bit wav PCM, first byte is the low order byte 130 generatedSnd[idx++] = (byte) (val & 0x00ff); 131 generatedSnd[idx++] = (byte) ((val & 0xff00) >>> 8); 132 133 } 134 } 135 136 void playSound(){ 137 @SuppressWarnings("deprecation") 138 final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 139 // sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, 140 sampleRate, AudioFormat.CHANNEL_OUT_MONO, 141 // sampleRate, AudioFormat.CHANNEL_OUT_STEREO, 142 // sampleRate, AudioFormat.CHANNEL_OUT_FRONT_RIGHT, 143 // sampleRate, AudioFormat.CHANNEL_CONFIGURATION_STEREO, 144 AudioFormat.ENCODING_PCM_16BIT, generatedSnd.length, 145 AudioTrack.MODE_STATIC); 146 audioTrack.write(generatedSnd, 0, generatedSnd.length); 147 audioTrack.play(); 148 } 149 150 113 private final int sampleRate = 8000; 114 private final int numSamples = duration * sampleRate; 115 private final double sample[] = new double[numSamples]; 116 private final double freqOfTone = 440; // hz 117 118 private final byte generatedSnd[] = new byte[2 * numSamples]; 119 120 151 121 /** 152 122 * The device currently in use, or {@code null}. … … 265 235 serial = new SerialDevice(); 266 236 serial.setSerialDevice(mSerialDevice); 267 268 237 238 269 239 genTone(); 270 //play Sound();271 272 240 //playTone(); 241 242 273 243 // Set the hardware buttons to control the music 274 this.setVolumeControlStream(AudioManager.STREAM_MUSIC); 275 // Load the sound 276 soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); 277 soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { 278 // @Override 279 public void onLoadComplete(SoundPool soundPool, int sampleId, 280 int status) { 281 loaded = true; 282 } 283 }); 284 soundID = soundPool.load(this, R.raw.htc_one_x, 1); 244 this.setVolumeControlStream(AudioManager.STREAM_MUSIC); 245 // Load the sound 246 soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); 247 soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() { 248 // @Override 249 public void onLoadComplete(SoundPool soundPool, int sampleId, 250 int status) { 251 loaded = true; 252 } 253 }); 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); 285 257 286 258 … … 440 412 441 413 442 } 414 } // connectHeadset 443 415 444 416 … … 480 452 updatePower(); 481 453 482 } 454 } // onProgressChanged 483 455 484 456 485 457 public void onStartTrackingTouch(SeekBar seekBar) { 486 458 //appendTextAndScroll(getString(R.string.seekbar_tracking_on)); 487 } 459 } // onStartTrackingTouch 488 460 489 461 490 462 public void onStopTrackingTouch(SeekBar seekBar) { 491 463 //appendTextAndScroll(getString(R.string.seekbar_tracking_off)); 492 } 464 } // onStopTrackingTouch 493 465 494 466 … … 547 519 } 548 520 549 } 521 } // updatePowerThresholds 550 522 551 523 … … 553 525 554 526 int new_speed = calculateSpeed(); 555 String command ;527 String command = ""; 556 528 progressBarPower.setProgress(new_speed); 557 529 558 530 if (new_speed > 0) { 531 532 if (currentCommand == "neutral") { 533 playControl(); 534 } 535 559 536 command = "hover"; 537 560 538 } else { 539 540 if (currentCommand == "hover") { 541 stopControl(); 542 } 543 561 544 command = "neutral"; 562 545 } … … 572 555 } 573 556 574 } 557 currentCommand = command; 558 559 } // updatePower 575 560 576 561 … … 592 577 return(command); 593 578 579 } // getPowerCommand 580 581 582 public void playControl() { 583 584 // Getting the user sound settings 585 AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); 586 float actualVolume = (float) audioManager 587 .getStreamVolume(AudioManager.STREAM_MUSIC); 588 float maxVolume = (float) audioManager 589 .getStreamMaxVolume(AudioManager.STREAM_MUSIC); 590 float volume = actualVolume / maxVolume; 591 // Is the sound loaded already? 592 if (loaded) { 593 soundPool.play(soundID, volume, volume, 1, 0, 1f); 594 Log.e("Test", "Played sound"); 595 } 596 597 } // playControl 598 599 600 public void stopControl() { 601 602 try { 603 soundPool.stop(soundID); 604 } catch (Exception e) { 605 // TODO Auto-generated catch block 606 e.printStackTrace(); 607 } 608 594 609 } 595 610 596 611 597 612 public void demoMode(View view) { 598 599 // playSound(); 600 601 602 // Getting the user sound settings 603 AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE); 604 float actualVolume = (float) audioManager 605 .getStreamVolume(AudioManager.STREAM_MUSIC); 606 float maxVolume = (float) audioManager 607 .getStreamMaxVolume(AudioManager.STREAM_MUSIC); 608 float volume = actualVolume / maxVolume; 609 // Is the sound loaded already? 610 if (loaded) { 611 soundPool.play(soundID, volume, volume, 1, 0, 1f); 612 Log.e("Test", "Played sound"); 613 } 614 615 616 // String command = "neutral"; 617 // 618 // appendTextAndScroll("Command for serial device: " + command + "\n"); 619 // serial.setCommand(command); 620 // 621 // try { 622 // Thread.sleep(5000); 623 // } catch (InterruptedException e) { 624 // // TODO Auto-generated catch block 625 // e.printStackTrace(); 626 // } 627 // 628 //// command = "hover"; 629 // command = "idle"; 630 // appendTextAndScroll("Command for serial device: " + command + "\n"); 631 // serial.setCommand(command); 632 // 633 // try { 634 // Thread.sleep(2500); 635 // } catch (InterruptedException e) { 636 // // TODO Auto-generated catch block 637 // e.printStackTrace(); 638 // } 639 // 640 // 641 // command = "neutral"; 642 // appendTextAndScroll("Command for serial device: " + command + "\n"); 643 // serial.setCommand(command); 613 614 // playTone(); 615 616 playControl(); 617 618 619 620 // String command = "neutral"; 621 // 622 // appendTextAndScroll("Command for serial device: " + command + "\n"); 623 // serial.setCommand(command); 624 // 625 // try { 626 // Thread.sleep(5000); 627 // } catch (InterruptedException e) { 628 // // TODO Auto-generated catch block 629 // e.printStackTrace(); 630 // } 631 // 632 //// command = "hover"; 633 // command = "idle"; 634 // appendTextAndScroll("Command for serial device: " + command + "\n"); 635 // serial.setCommand(command); 636 // 637 // try { 638 // Thread.sleep(2500); 639 // } catch (InterruptedException e) { 640 // // TODO Auto-generated catch block 641 // e.printStackTrace(); 642 // } 643 // 644 // 645 // command = "neutral"; 646 // appendTextAndScroll("Command for serial device: " + command + "\n"); 647 // serial.setCommand(command); 644 648 645 649 … … 668 672 return(speed); 669 673 670 } 674 } // calculateSpeed 671 675 672 676 … … 677 681 mSerialIoManager = null; 678 682 } 679 } 683 } // stopIoManager 680 684 681 685 … … 686 690 mExecutor.submit(mSerialIoManager); 687 691 } 688 } 692 } // startIoManager 689 693 690 694 … … 692 696 stopIoManager(); 693 697 startIoManager(); 694 } 698 } // onDeviceStateChange 699 700 701 void genTone(){ 702 // fill out the array 703 for (int i = 0; i < numSamples; ++i) { 704 sample[i] = Math.sin(2 * Math.PI * i / (sampleRate/freqOfTone)); 705 } 706 707 // convert to 16 bit pcm sound array 708 // assumes the sample buffer is normalized. 709 int idx = 0; 710 for (final double dVal : sample) { 711 // scale to maximum amplitude 712 final short val = (short) ((dVal * 32767)); 713 // in 16 bit wav PCM, first byte is the low order byte 714 generatedSnd[idx++] = (byte) (val & 0x00ff); 715 generatedSnd[idx++] = (byte) ((val & 0xff00) >>> 8); 716 717 } 718 } // genTone 719 720 721 void playTone(){ 722 @SuppressWarnings("deprecation") 723 final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 724 // sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, 725 sampleRate, AudioFormat.CHANNEL_OUT_MONO, 726 // sampleRate, AudioFormat.CHANNEL_OUT_STEREO, 727 // sampleRate, AudioFormat.CHANNEL_OUT_FRONT_RIGHT, 728 // sampleRate, AudioFormat.CHANNEL_CONFIGURATION_STEREO, 729 AudioFormat.ENCODING_PCM_16BIT, generatedSnd.length, 730 AudioTrack.MODE_STATIC); 731 audioTrack.write(generatedSnd, 0, generatedSnd.length); 732 audioTrack.play(); 733 } // playTone 734 695 735 696 736 }
Note: See TracChangeset
for help on using the changeset viewer.