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


Java Hub.addListener方法代码示例

本文整理汇总了Java中com.thalmic.myo.Hub.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java Hub.addListener方法的具体用法?Java Hub.addListener怎么用?Java Hub.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thalmic.myo.Hub的用法示例。


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

示例1: connect

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
@Override
public boolean connect() throws Exception {
    Log.d("", "preConnect");
    super.connect();
    // First, we initialize the Hub singleton with an application identifier.
    Hub hub = Hub.getInstance();
    if (!hub.init(mContext, mContext.getPackageName())) {
        // We can't do anything with the Myo device if the Hub can't be initialized, so exit.
        //Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
        //finish();
        return false;
    }
    // Next, register for DeviceListener callbacks.
    hub.addListener(mListener);
    hub.attachToAdjacentMyo();

    sendConnected();

    return true;
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:21,代码来源:MyoSensor.java

示例2: connect

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public void connect() {

		hub = new Hub("com.example.hello-myo");

		System.out.println("Attempting to find a Myo...");
		log.info("Attempting to find a Myo");
		myo = hub.waitForMyo(10000);

		if (myo == null) {
			// throw new RuntimeException("Unable to find a Myo!");
			log.info("Unable to find a Myo");
		}

		System.out.println("Connected to a Myo armband!");
		log.info("Connected to a Myo armband");
		hub.addListener(this);
		
		if (hubThread == null){
			hubThread = new HubThread(this);
			hubThread.start();
		}

	}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:24,代码来源:MyoThalmic.java

示例3: main

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		Hub hub = new Hub("com.example.emg-data-sample");

		System.out.println("Attempting to find a Myo...");
		Myo myo = hub.waitForMyo(10000);

		if (myo == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		myo.setStreamEmg(StreamEmgType.STREAM_EMG_ENABLED);
		DeviceListener dataCollector = new EmgDataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.println(dataCollector);
		}
	} catch (Exception e) {
		System.err.println("Error: ");
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:27,代码来源:EmgDataSample.java

示例4: main

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public static void main(String... args) {
	try {
		Hub hub = new Hub("com.example.multiple-myos");

		DeviceListener printer = new PrintMyoEvents();
		hub.addListener(printer);

		while (true) {
			hub.run(10);
		}
	} catch (Exception e) {
		System.err.println("Error: ");
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:17,代码来源:MultipleMyos.java

示例5: main

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public static void main(String[] args) {
	try {
		Hub hub = new Hub("com.example.hello-myo");

		System.out.println("Attempting to find a Myo...");
		Myo myo = hub.waitForMyo(10000);

		if (myo == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		DeviceListener dataCollector = new DataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.print(dataCollector);
		}
	} catch (Exception e) {
		System.err.println("Error: ");
		e.printStackTrace();
		System.exit(1);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:26,代码来源:HelloMyo.java

示例6: onCreate

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mMapView = MapService.getMap(this);
  Log.d("ArcGIS", "Entering MapActivity");
  initGestureDetector(this);
  initSensors(this);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  setContentView(mMapView);
  Hub hub = Hub.getInstance();
  if (!hub.init(this, getPackageName())) {
    // We can't do anything with the Myo device if the Hub can't be initialized, so exit.
    Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  mListener = new MyoMapListener(this, mMapView);
  hub.addListener(mListener);
  hub.setLockingPolicy(Hub.LockingPolicy.NONE);
  hub.attachToAdjacentMyo();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:22,代码来源:MapActivity.java

示例7: switchMyoListener

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public void switchMyoListener() {
  Hub hub = Hub.getInstance();
  String message;
  if(mIsFeatureControl) {
    message = "Switching to map control";
    hub.removeListener(mFeatureControlListener);
    mMapControlListener.prepareSwitch();
    hub.addListener(mMapControlListener);
  } else {
    message = "Switching to feature control";
    hub.removeListener(mMapControlListener);
    mFeatureControlListener.prepareSwitch();
    hub.addListener(mFeatureControlListener);
  }
  mIsFeatureControl = !mIsFeatureControl;
  Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:18,代码来源:MainActivity.java

示例8: main

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
public static void main(String[] args) {
	LoggingFactory.getInstance().configure();
	LoggingFactory.getInstance().setLevel(Level.INFO);

	try {

		MyoThalmic myo = (MyoThalmic) Runtime.start("myo", "MyoThalmic");
		myo.test();

		Hub hub = new Hub("com.example.hello-myo");

		System.out.println("Attempting to find a Myo...");
		log.info("Attempting to find a Myo");

		Myo myodevice = hub.waitForMyo(10000);

		if (myodevice == null) {
			throw new RuntimeException("Unable to find a Myo!");
		}

		System.out.println("Connected to a Myo armband!");
		log.info("Connected to a Myo armband");
		DeviceListener dataCollector = new DataCollector();
		hub.addListener(dataCollector);

		while (true) {
			hub.run(1000 / 20);
			System.out.print(dataCollector);

			Runtime.start("gui", "GUIService");

		}
	} catch (Exception e) {
		Logging.logError(e);
	}
}
 
开发者ID:glaudiston,项目名称:project-bianca,代码行数:37,代码来源:MyoThalmic.java

示例9: onCreate

import com.thalmic.myo.Hub; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  // First, we initialize the Hub singleton
  final Hub hub = Hub.getInstance();
  if (!hub.init(this, getPackageName())) {
    // We can't do anything with the Myo device if the Hub can't be initialized, so exit.
    Toast.makeText(this, "Couldn't initialize Hub", Toast.LENGTH_SHORT).show();
    finish();
    return;
  }
  hub.setLockingPolicy(Hub.LockingPolicy.NONE);
  // Connects to a Myo that is physically touching the device
  hub.attachToAdjacentMyo();
  mMapView = new MapView(this, "http://csf.maps.arcgis.com/home/item.html?id=f065c8fa4e514749aeef57919b3d192e", null, null);
  mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
    @Override
    public void onStatusChanged(Object source, STATUS status) {
      if (source instanceof ArcGISFeatureLayer && status == STATUS.LAYER_LOADED) {
        mFeatureControlListener = new MyoFeatureControlListener(MainActivity.this, mMapView, (ArcGISFeatureLayer) source);
      }
    }
  });
  mMapControlListener = new MyoMapControlListener(this, mMapView);
  hub.addListener(mMapControlListener);
  setContentView(mMapView);
  mWearMessageListener = new WearMessageListener(mMapView);
  initGoogleApiClient();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:30,代码来源:MainActivity.java


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