Changeset 12d011e in orbit for android/src
- Timestamp:
- 12/16/13 16:29:03 (9 years ago)
- Branches:
- master, Servo
- Children:
- baab323
- Parents:
- cf3a627
- Location:
- android/src/info/puzzlebox/orbit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
android/src/info/puzzlebox/orbit/FragmentTabFlight.java
rcf3a627 r12d011e 41 41 42 42 43 //public class FragmentTabFlight extends Fragment implements OnClickListener, SeekBar.OnSeekBarChangeListener {44 43 public class FragmentTabFlight extends Fragment implements OnClickListener, SeekBar.OnSeekBarChangeListener { 45 44 … … 84 83 ProgressBar progressBarSignal; 85 84 ProgressBar progressBarPower; 86 // SeekBar seekBarThrottle;87 // SeekBar seekBarYaw;88 // SeekBar seekBarPitch;89 85 Button connectButton; 90 86 Button testFlightButton; … … 137 133 TGDevice tgDevice; 138 134 int tgSignal = 0; 139 // int[] thresholdValuesAttention = new int[101];140 // int[] thresholdValuesMeditation = new int[101];141 // int minimumPower = 0; // minimum power for the helicopter throttle142 // int maximumPower = 100; // maximum power for the helicopter throttle143 String currentCommand = "neutral";144 135 // final boolean rawEnabled = false; 145 136 final boolean rawEnabled = true; 146 147 148 // OnClickListener Flight_enterOnClickListener149 // = new OnClickListener(){150 //151 // public void onClick(View arg0) {152 //153 // Log.v(TAG, "Flight_enterOnClickListener()");154 //155 // String textPassToAdvanced = "textPassToAdvanced: input.getText().toString()";156 // Log.v(TAG, textPassToAdvanced);157 //158 //159 // }160 //161 // };162 137 163 138 … … 293 268 if(bluetoothAdapter == null) { 294 269 // Alert user that Bluetooth is not available 295 // Toast.makeText(this, "Bluetooth not available", Toast.LENGTH_LONG).show();296 270 Toast.makeText(((OrbitTabActivity)getActivity()), "Bluetooth not available", Toast.LENGTH_LONG).show(); 297 271 … … 323 297 324 298 325 } 299 } // onCreateView() 326 300 327 301 … … 544 518 545 519 connectHeadset(v); 546 // ((OrbitTabActivity)getActivity()).connectHeadset(v);547 548 520 549 521 } … … 592 564 */ 593 565 594 // @SuppressLint("HandlerLeak")595 // @Override596 566 public void handleMessage(Message msg) { 597 567 … … 704 674 break; 705 675 case TGDevice.MSG_LOW_BATTERY: 706 // Toast.makeText(getApplicationContext(), "Low battery!", Toast.LENGTH_SHORT).show();707 676 Toast.makeText(((OrbitTabActivity)getActivity()), "EEG battery low!", Toast.LENGTH_SHORT).show(); 708 677 break; … … 723 692 724 693 Log.v(TAG, "connectHeadset()"); 725 726 // ((OrbitTabActivity)getActivity()).connectHeadset(v);727 728 694 729 695 /** Stop audio stream */ … … 750 716 751 717 } // connectHeadset 752 753 718 754 719 … … 787 752 788 753 } 789 // else if (eegDevice == "Emotiv") {790 //791 // stopControl();792 //793 // FragmentTabFlightEmotiv fragmentFlight =794 // (FragmentTabFlightEmotiv) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );795 //796 // if (fragmentFlight != null)797 // fragmentFlight.disconnectHeadset();798 //799 // }800 801 754 802 755 … … 982 935 Log.v(TAG, "hideEEGRawHistory()"); 983 936 984 //if (eegRawHistoryPlot != null)985 //eegRawHistoryPlot.setVisibility(View.GONE);937 if (eegRawHistoryPlot != null) 938 eegRawHistoryPlot.setVisibility(View.GONE); 986 939 987 940 -
android/src/info/puzzlebox/orbit/OrbitTabActivity.java
rcf3a627 r12d011e 31 31 import android.os.Build; 32 32 import android.os.Bundle; 33 import android.os.Handler;34 import android.os.Message;35 33 import android.annotation.SuppressLint; 36 //import android.bluetooth.BluetoothAdapter;37 34 import android.content.Context; 38 35 import android.content.Intent; … … 48 45 import android.view.Window; 49 46 import android.widget.LinearLayout; 50 //import android.widget.SeekBar;51 47 import android.widget.TabHost; 52 48 import android.widget.TabWidget; … … 58 54 import android.support.v4.view.ViewPager; 59 55 60 //import com.neurosky.thinkgear.TGDevice; 61 62 //public class OrbitTabActivity extends FragmentActivity implements SeekBar.OnSeekBarChangeListener { 56 63 57 public class OrbitTabActivity extends FragmentActivity { 64 58 … … 101 95 int viewSpaceGenerateAudioWidth = 120; 102 96 103 // private static final int EEG_RAW_HISTORY_SIZE = 512; // number of points to plot in EEG history104 105 97 String saveToAdvanced = null; 106 98 … … 142 134 143 135 144 // /** 145 // * Bluetooth 146 // */ 147 // BluetoothAdapter bluetoothAdapter; 148 // // ArrayList<String> pairedBluetoothDevices; 149 // 150 // 151 // /** 152 // * NeuroSky ThinkGear Device 153 // */ 154 // TGDevice tgDevice; 155 // int tgSignal = 0; 156 // int[] thresholdValuesAttention = new int[101]; 157 // int[] thresholdValuesMeditation = new int[101]; 158 // int minimumPower = 0; // minimum power for the helicopter throttle 159 // int maximumPower = 100; // maximum power for the helicopter throttle 136 /** 137 * Flight status 138 */ 160 139 String currentCommand = "neutral"; 161 // final boolean rawEnabled = false;162 // final boolean rawEnabled = true;163 140 164 141 … … 324 301 325 302 326 // /**327 // * Prepare Bluetooth and NeuroSky ThinkGear EEG interface328 // */329 //330 // bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();331 //332 // if(bluetoothAdapter == null) {333 // // Alert user that Bluetooth is not available334 // Toast.makeText(this, "Bluetooth not available", Toast.LENGTH_LONG).show();335 //336 // } else {337 // /** create the TGDevice */338 // tgDevice = new TGDevice(bluetoothAdapter, handlerThinkGear);339 //340 // /** Retrieve a list of paired Bluetooth adapters */341 // // Set<BluetoothDevice> pairedDevices = bluetoothAdapter.getBondedDevices();342 // // pairedBluetoothDevices = new ArrayList<String>(Arrays.asList(pairedDevices.toString()));343 // /**344 // * NOTE: To get device names iterate through pairedBluetoothDevices345 // * and call the getName() method on each BluetoothDevice object.346 // */347 // }348 349 350 303 } // onCreate 351 352 353 // ################################################################354 355 public boolean onUnbind(Intent intent) {356 357 Log.d(this.getClass().getName(), "UNBIND");358 359 try {360 361 if (audioHandler != null)362 audioHandler.shutdown();363 364 } catch (Exception e) {365 // TODO Auto-generated catch block366 Log.v(TAG, "Exception: onUnbind()");367 e.printStackTrace();368 }369 370 371 return true;372 } // onUnbind373 304 374 305 … … 528 459 // ################################################################ 529 460 461 public void onPause() { 462 463 Log.v(TAG, "onPause()"); 464 465 super.onPause(); 466 467 } // onPause 468 469 470 // ################################################################ 471 530 472 @Override 531 473 protected void onResume() { … … 540 482 super.onResume(); 541 483 542 543 484 } // onResume 544 485 … … 552 493 super.onStop(); 553 494 554 // try {555 //556 // // disconnectHeadset();557 //558 // // if (eegDevice == "ThinkGear") {559 // // FragmentTabFlight fragmentFlight =560 // // (FragmentTabFlight) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );561 // // fragmentFlight.disconnectHeadset();562 // // }563 // if (eegDevice == "Emotiv") {564 // FragmentTabFlightEmotiv fragmentFlightEmotiv =565 // (FragmentTabFlightEmotiv) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlightEmotiv() );566 // fragmentFlightEmotiv.disconnectHeadset();567 // }568 //569 //570 // } catch (Exception e) {571 // // TODO Auto-generated catch block572 // Log.v(TAG, "Exception: onStop()");573 // e.printStackTrace();574 // }575 576 577 495 } // onStop 578 579 580 // ################################################################581 582 public void onPause() {583 584 Log.v(TAG, "onPause()");585 586 super.onPause();587 588 // try {589 //590 // // disconnectHeadset();591 //592 //593 // if (eegDevice == "ThinkGear") {594 // FragmentTabFlight fragmentFlight =595 // (FragmentTabFlight) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );596 // fragmentFlight.disconnectHeadset();597 // }598 //599 // } catch (Exception e) {600 // // TODO Auto-generated catch block601 // Log.v(TAG, "Exception: onPause()");602 // e.printStackTrace();603 // }604 605 606 } // onPause607 496 608 497 … … 620 509 if (audioHandler != null) 621 510 audioHandler.shutdown(); 622 623 // if(bluetoothAdapter != null)624 // tgDevice.close();625 511 626 512 } catch (Exception e) { … … 630 516 } 631 517 632 633 518 super.onDestroy(); 634 519 635 636 520 } // onDestroy 521 522 523 // ################################################################ 524 525 public boolean onUnbind(Intent intent) { 526 527 Log.d(this.getClass().getName(), "UNBIND"); 528 529 try { 530 531 if (audioHandler != null) 532 audioHandler.shutdown(); 533 534 } catch (Exception e) { 535 // TODO Auto-generated catch block 536 Log.v(TAG, "Exception: onUnbind()"); 537 e.printStackTrace(); 538 } 539 540 return true; 541 542 } // onUnbind 637 543 638 544 … … 753 659 754 660 if (fragmentFlight != null) 755 // fragmentFlight.hideEEGRawHistory();756 661 fragmentFlight.updateScreenLayoutSmall(); 757 662 … … 811 716 812 717 813 814 718 } // onCheckBoxGenerateAudioClicked 815 719 … … 841 745 842 746 } // updateAdvancedOptions 843 844 845 // ################################################################846 847 // public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {848 //849 // updatePower();850 //851 // } // onProgressChanged852 853 854 // ################################################################855 856 // public void onStartTrackingTouch(SeekBar seekBar) {857 //858 // /**859 // * Method required by SeekBar.OnSeekBarChangeListener860 // */861 //862 //863 // } // onStartTrackingTouch864 865 866 // ################################################################867 868 // public void onStopTrackingTouch(SeekBar seekBar) {869 //870 // /**871 // * Update AudioService.command after moving a seekBar.872 // */873 //874 // Log.v(TAG, "onStopTrackingTouch()");875 //876 // FragmentTabAdvanced fragmentAdvanced =877 // (FragmentTabAdvanced) getSupportFragmentManager().findFragmentByTag( getTabFragmentAdvanced() );878 //879 // if (fragmentAdvanced != null) {880 //881 // Integer[] command = {882 // fragmentAdvanced.seekBarThrottle.getProgress(),883 // fragmentAdvanced.seekBarYaw.getProgress(),884 // fragmentAdvanced.seekBarPitch.getProgress(),885 // 1};886 //887 // updateAudioHandlerCommand(command);888 //889 // }890 //891 // } // onStopTrackingTouch892 893 894 // ################################################################895 896 private final Handler handlerThinkGear = new Handler() {897 898 /**899 * Handles data packets from NeuroSky ThinkGear device900 */901 902 @SuppressLint("HandlerLeak")903 @Override904 public void handleMessage(Message msg) {905 906 Log.v(TAG, "handlerThinkGear handleMessage()");907 908 FragmentTabFlight fragmentFlight =909 (FragmentTabFlight) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );910 911 if (fragmentFlight != null){912 fragmentFlight.parseEEG(msg);913 }914 915 // switch (msg.what) {916 // case TGDevice.MSG_STATE_CHANGE:917 //918 // switch (msg.arg1) {919 // case TGDevice.STATE_IDLE:920 // break;921 // case TGDevice.STATE_CONNECTING:922 // if (DEBUG)923 // Log.v(TAG, "Connecting to EEG");924 // appendDebugConsole("Connecting to EEG\n");925 // break;926 // case TGDevice.STATE_CONNECTED:927 // if (DEBUG)928 // Log.v(TAG, "EEG Connected");929 // appendDebugConsole("Bluetooth Connected\n");930 // tgDevice.start();931 // break;932 // case TGDevice.STATE_NOT_FOUND:933 // if (DEBUG)934 // Log.v(TAG, "EEG headset not found");935 // appendDebugConsole("EEG headset not found\n");936 // break;937 // case TGDevice.STATE_NOT_PAIRED:938 // if (DEBUG)939 // Log.v(TAG, "EEG headset not paired");940 // appendDebugConsole("EEG headset not paired\n");941 // break;942 // case TGDevice.STATE_DISCONNECTED:943 // if (DEBUG)944 // Log.v(TAG, "EEG Disconnected");945 // appendDebugConsole("EEG Disconnected\n");946 // disconnectHeadset();947 // break;948 // }949 //950 // break;951 //952 // case TGDevice.MSG_POOR_SIGNAL:953 // eegSignal = calculateSignal(msg.arg1);954 // if (DEBUG)955 // Log.v(TAG, "PoorSignal: " + msg.arg1);956 // // appendDebugConsole("\nPoorSignal: " + msg.arg1 + "\n");957 // updatePower();958 //959 // break;960 // case TGDevice.MSG_RAW_DATA:961 //962 // rawEEG[arrayIndex] = msg.arg1;963 // arrayIndex = arrayIndex + 1;964 //965 // if (arrayIndex == EEG_RAW_HISTORY_SIZE - 1)966 // updateEEGRawHistory();967 //968 // break;969 // case TGDevice.MSG_HEART_RATE:970 // if (DEBUG)971 // Log.v(TAG, "Heart rate: " + msg.arg1);972 // // appendDebugConsole("Heart rate: " + msg.arg1 + "\n");973 // break;974 // case TGDevice.MSG_ATTENTION:975 // eegAttention = msg.arg1;976 // if (DEBUG)977 // Log.v(TAG, "Attention: " + eegAttention);978 // // appendDebugConsole("Attention: " + eegAttention + "\n");979 //980 // // dataEEGAttention.put(eegAttention);981 //982 // updatePower();983 //984 // break;985 // case TGDevice.MSG_MEDITATION:986 // eegMeditation = msg.arg1;987 // if (DEBUG)988 // Log.v(TAG, "Meditation: " + eegMeditation);989 // // appendDebugConsole("Meditation: " + eegMeditation + "\n");990 //991 // // dataEEGAttention.put(eegAttention);992 //993 // updatePower();994 //995 // break;996 // case TGDevice.MSG_BLINK:997 // //tv.append("Blink: " + msg.arg1 + "\n");998 // break;999 // case TGDevice.MSG_RAW_COUNT:1000 // //tv.append("Raw Count: " + msg.arg1 + "\n");1001 // break;1002 // case TGDevice.MSG_LOW_BATTERY:1003 // Toast.makeText(getApplicationContext(), "Low battery!", Toast.LENGTH_SHORT).show();1004 // break;1005 // case TGDevice.MSG_RAW_MULTI:1006 // //TGRawMulti rawM = (TGRawMulti)msg.obj;1007 // //tv.append("Raw1: " + rawM.ch1 + "\nRaw2: " + rawM.ch2);1008 // default:1009 // break;1010 // }1011 }1012 };1013 1014 1015 // ################################################################1016 1017 // public void connectHeadset(View view) {1018 //1019 // /**1020 // * Called when the "Connect" button is pressed1021 // */1022 //1023 // Log.v(TAG, "connectHeadset()");1024 //1025 // /** Pass message to fragmentAdvanced */1026 //1027 // /** Stop audio stream */1028 // stopControl();1029 //1030 // if(bluetoothAdapter == null) {1031 //1032 // // Alert user that Bluetooth is not available1033 // Toast.makeText(this, "Bluetooth not available", Toast.LENGTH_LONG).show();1034 //1035 // } else {1036 //1037 // if (tgDevice.getState() != TGDevice.STATE_CONNECTING && tgDevice.getState() != TGDevice.STATE_CONNECTED) {1038 // tgDevice.connect(rawEnabled);1039 // maximizeAudioVolume(); // Automatically set media volume to maximum1040 // }1041 //1042 //1043 // else if (tgDevice.getState() == TGDevice.STATE_CONNECTED)1044 // /** "Disconnect" button was pressed */1045 // disconnectHeadset();1046 //1047 // }1048 //1049 // } // connectHeadset1050 1051 1052 // ################################################################1053 1054 // public void disconnectHeadset() {1055 //1056 // /**1057 // * Called when "Disconnect" button is pressed1058 // */1059 //1060 // if (eegDevice == "ThinkGear") {1061 //1062 // if (tgDevice.getState() == TGDevice.STATE_CONNECTED) {1063 // tgDevice.stop();1064 // tgDevice.close();1065 // }1066 //1067 // stopControl();1068 //1069 // FragmentTabFlight fragmentFlight =1070 // (FragmentTabFlight) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );1071 //1072 // if (fragmentFlight != null)1073 // fragmentFlight.disconnectHeadset();1074 //1075 // }1076 // else if (eegDevice == "Emotiv") {1077 //1078 // stopControl();1079 //1080 // FragmentTabFlightEmotiv fragmentFlight =1081 // (FragmentTabFlightEmotiv) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );1082 //1083 // if (fragmentFlight != null)1084 // fragmentFlight.disconnectHeadset();1085 //1086 // }1087 //1088 //1089 // } // disconnectHeadset1090 747 1091 748 … … 1172 829 1173 830 } // updatePower 1174 1175 1176 // ################################################################1177 1178 // public void updateEEGRawHistory() {1179 //1180 // if (eegDevice == "ThinkGear") {1181 //1182 // FragmentTabFlight fragmentFlight =1183 // (FragmentTabFlight) getSupportFragmentManager().findFragmentByTag( getTabFragmentFlight() );1184 //1185 // if (fragmentFlight != null)1186 // fragmentFlight.updateEEGRawHistory(rawEEG);1187 //1188 // rawEEG = new Number[512];1189 // arrayIndex = 0;1190 //1191 // }1192 //1193 // } // updateEEGRawHistory1194 831 1195 832
Note: See TracChangeset
for help on using the changeset viewer.