当前位置: 首页>>代码示例>>Java>>正文


Java MuseManagerAndroid类代码示例

本文整理汇总了Java中com.choosemuse.libmuse.MuseManagerAndroid的典型用法代码示例。如果您正苦于以下问题:Java MuseManagerAndroid类的具体用法?Java MuseManagerAndroid怎么用?Java MuseManagerAndroid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MuseManagerAndroid类属于com.choosemuse.libmuse包,在下文中一共展示了MuseManagerAndroid类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Make sure permissions are granted, asking for ones that aren't.
  askPermissions();

  MuseManagerAndroid.getInstance().setContext(this);

  ActivityListDevicesBinding binding =
      DataBindingUtil.setContentView(this, R.layout.activity_list_devices);
  binding.setViewModel(viewModel);

  // Hook up the binding for the list of devices.
  RecyclerView listView = (RecyclerView) findViewById(R.id.deviceList);
  listView.setLayoutManager(new LinearLayoutManager(this));
  listView.setAdapter(new DeviceListAdapter(this, viewModel));
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:19,代码来源:ListDevicesActivity.java

示例2: Init

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
@ReactMethod public void Init() {
if (mainActivity == null)
	throw new RuntimeException("LibMuseModule.mainActivity not set. (set it in your main-activity's constructor)");

// We need to set the context on MuseManagerAndroid before we can do anything.
// This must come before other LibMuse API calls as it also loads the library.
try {
	manager = MuseManagerAndroid.getInstance();
	manager.setContext(mainActivity);
} catch (Throwable ex) {
	throw new RuntimeException("Failed to start muse-manager: " + ex);
}

Log.i(TAG, "LibMuse version=" + LibmuseVersion.instance().getString());

// Muse 2016 (MU-02) headbands use Bluetooth Low Energy technology to simplify the connection process.
// This requires the COARSE_LOCATION or FINE_LOCATION permissions. Make sure we have these permissions before proceeding.
EnsurePermissions();

AddMuseListListener();
  }
 
开发者ID:Venryx,项目名称:react-native-libmuse,代码行数:22,代码来源:LibMuseModule.java

示例3: scan

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
/**
 * Scan for devices for a given amount of time, and store all devices found in that period.
 *
 * @param scanLengthSec How long to scan for, in seconds.
 */
public void scan(int scanLengthSec) {
  // Start listening for devices...
  Log.i(Constants.TAG, "Starting scan...");
  this.scanning = true;
  MuseManagerAndroid.getInstance().startListening();

  // ...and after a while...
  new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
    @Override public void run() {
      // ...stop listening.
      Log.i(Constants.TAG, "Stopping scan...");
      MuseListViewModel.this.scanning = false;
      MuseManagerAndroid.getInstance().stopListening();

      // Report the devices we have found:
      MuseListViewModel.this.devices = new ArrayList<>(MuseManagerAndroid.getInstance().getMuses());
      notifyChange();
      if (museListListener != null) {
        MuseListViewModel.this.museListListener.onScanForDevicesFinished();
      }
    }
  }, scanLengthSec * 1000);

  // Also need to let ppl know the scanning field has changed.
  notifyChange();
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:32,代码来源:MuseListViewModel.java

示例4: onCreate

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Initialize Muse first up.
  MuseManagerAndroid.getInstance().setContext(this);

  // Bind viewmodel to the view.
  ActivityRecordBinding binding =
      DataBindingUtil.setContentView(this, R.layout.activity_record);
  binding.setRecordVM(viewModel);
  binding.setDeviceVM(deviceVM);

  // Bind action bar, seems like this can't be done in the layout :(
  deviceVM.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable sender, int propertyId) {
      RecordActivity.this.getSupportActionBar().setTitle(
          String.format("%s: %s", deviceVM.getName(), deviceVM.getConnectionState())
      );
    }
  });

  // And attach the desired muse to the VM once connected.
  final String macAddress = getIntent().getExtras().getString("mac");
  MuseManagerUtil.getByMacAddress(macAddress, new MuseManagerUtil.MuseCallback() {
    @Override
    public void museFound(Muse muse) {
      RecordActivity.this.deviceVM.setMuse(muse);
    }
  });
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:33,代码来源:RecordActivity.java

示例5: MuseSensor

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
public MuseSensor(Context context, String deviceName, String deviceAddress, SensorDataProcessor dataHandler) {
    super(context, deviceName, deviceAddress, dataHandler);

    mMuseManager = MuseManagerAndroid.getInstance();
    mMuseManager.setContext(mContext);

    mConnectionListener = new ConnectionListener(this);
    mDataListener = new DataListener(this);
    mMuseManager.setMuseListener(new MuseScanListener(this));
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:11,代码来源:MuseSensor.java

示例6: onCreate

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Initialize Muse first up.
  MuseManagerAndroid.getInstance().setContext(this);

  // Bind viewmodel to the view.
  ActivityDeviceDetailsBinding binding =
      DataBindingUtil.setContentView(this, R.layout.activity_device_details);
  binding.setDeviceVM(deviceVM);
  binding.setIsGoodVM(new SensorGoodViewModel(deviceVM));
  binding.setConnectionVM(new ConnectionStrengthViewModel(deviceVM));
  binding.setRawVM(  deviceVM.createRawTimeSeries(Eeg.EEG3, DURATION_SEC));
  binding.setThetaVM(deviceVM.createFrequencyLiveValue(Band.THETA, ValueType.SCORE));
  binding.setDeltaVM(deviceVM.createFrequencyLiveValue(Band.DELTA, ValueType.SCORE));
  binding.setAlphaVM(deviceVM.createFrequencyLiveValue(Band.ALPHA, ValueType.SCORE));
  binding.setBetaVM( deviceVM.createFrequencyLiveValue(Band.BETA,  ValueType.SCORE));

  // Bind action bar, seems like this can't be done in the layout :(
  deviceVM.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable sender, int propertyId) {
      DeviceDetailsActivity.this.getSupportActionBar().setTitle(
          String.format("%s: %s", deviceVM.getName(), deviceVM.getConnectionState())
      );
    }
  });

  // And attach the desired muse to the VM once connected.
  final String macAddress = getIntent().getExtras().getString("mac");
  if (macAddress != null) {
    MuseManagerAndroid.getInstance().startListening();
    MuseManagerAndroid.getInstance().setMuseListener(new MuseListener() {
      @Override
      public void museListChanged() {
        for (Muse muse : MuseManagerAndroid.getInstance().getMuses()) {
          if (macAddress.equals(muse.getMacAddress())) {
            DeviceDetailsActivity.this.deviceVM.setMuse(muse);
            MuseManagerAndroid.getInstance().stopListening();
            break;
          }
        }
      }
    });
  }
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:48,代码来源:DeviceDetailsActivity.java

示例7: onCreate

import com.choosemuse.libmuse.MuseManagerAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Initialize Muse first up.
  MuseManagerAndroid.getInstance().setContext(this);

  // Bind viewmodel to the view.
  ActivityMoreDeviceDetailsBinding binding =
      DataBindingUtil.setContentView(this, R.layout.activity_more_device_details);
  binding.setDeviceVM(deviceVM);
  binding.setEpochs(epochCollector);

  // Bind action bar, seems like this can't be done in the layout :(
  deviceVM.addOnPropertyChangedCallback(new Observable.OnPropertyChangedCallback() {
    @Override
    public void onPropertyChanged(Observable sender, int propertyId) {
      MoreDeviceDetailsActivity.this.getSupportActionBar().setTitle(
          String.format("%s: %s", deviceVM.getName(), deviceVM.getConnectionState())
      );
    }
  });

  // Attach the desired muse to the VM once connected.
  final String macAddress = getIntent().getExtras().getString("mac");
  MuseManagerUtil.getByMacAddress(macAddress, new MuseManagerUtil.MuseCallback() {
    @Override
    public void museFound(Muse muse) {
      Log.i(Constants.TAG, "SETTING MUSE");
      MoreDeviceDetailsActivity.this.deviceVM.setMuse(muse);
    }
  });

  // Add frequency listeners to the 2D plot:
  FrequencyBandViewModel relativeTheta = deviceVM.createFrequencyLiveValue(
      FrequencyBands.Band.THETA, FrequencyBands.ValueType.SCORE);
  FrequencyBandViewModel relativeBeta = deviceVM.createFrequencyLiveValue(
      FrequencyBands.Band.BETA, FrequencyBands.ValueType.SCORE);
  TimeSeries<Double[]> plotTimeSeries = TimeSeries.fromLiveSeries(
      new MergedSeries(relativeTheta, relativeBeta), DURATION_SEC * 1000
  );
  plot2DView = (Plot2DView) findViewById(R.id.tbr2DPlot);
  plot2DView.setTimeSeries(plotTimeSeries);

  // Add raw listeners for the epoch collector:
  epochCollector.addSource("3", deviceVM.createRawTimeSeries(Eeg.EEG3, 2));
}
 
开发者ID:padster,项目名称:Muse-EEG-Toolkit,代码行数:48,代码来源:MoreDeviceDetailsActivity.java


注:本文中的com.choosemuse.libmuse.MuseManagerAndroid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。