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


Java Hub类代码示例

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


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

示例1: onDemoPressed

import com.thalmic.myo.Hub; //导入依赖的package包/类
public void onDemoPressed(View v)
{
    final Hub hub = Hub.getInstance();
    Thread t1 = new Thread(new Runnable() {
        public void run() {
            if(hub.getConnectedDevices().isEmpty())
            {
                Log.e("Logue_SSJ", "device not found");
            }
            else
            {
                com.thalmic.myo.Myo myo = hub.getConnectedDevices().get(0);
                startVibrate(myo, hub);
            }
        }
    });
    t1.start();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:19,代码来源:MainActivity.java

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: onStop

import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
protected void onStop() {
  if(mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
    Wearable.MessageApi.removeListener(mGoogleApiClient, mWearMessageListener);
    mGoogleApiClient.disconnect();
  }
  // We don't want any callbacks when the Activity is gone, so unregister the listener.
  Hub.getInstance().removeListener(mFeatureControlListener);
  Hub.getInstance().removeListener(mMapControlListener);

  if (isFinishing()) {
    // The Activity is finishing, so shutdown the Hub. This will disconnect from the Myo.
    Hub.getInstance().shutdown();
  }
  super.onStop();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:17,代码来源:MainActivity.java

示例10: myoInitialization

import com.thalmic.myo.Hub; //导入依赖的package包/类
private void myoInitialization() {
    // Hub initialization (manages Myo instances)
    mHub = Hub.getInstance();
    boolean status = mHub.init(this);

    // checks Hub initialization (fails if the system doesn't support Bluetooth Low Energy)
    if (!status) {
        Toast.makeText(this, "Bluetooth Low Energy not available. Aborting.", Toast.LENGTH_LONG).show();
    } else {
        // prevents statistics data to be sent
        mHub.setSendUsageData(false);
        mHub.addListener(new DeviceListener(this));
    }

    // pairing with the nearest device (unattended mode)
    mHub.attachToAdjacentMyo();
}
 
开发者ID:palazzem,项目名称:android-udoo-rover,代码行数:18,代码来源:RoverActivity.java

示例11: Configuration

import com.thalmic.myo.Hub; //导入依赖的package包/类
public Configuration(Hub hub, final MyoListener listener, EmgMode emg, boolean imu, boolean gestures)
{
    super(hub);
    _name = "Myo_Config";

    this.hub = hub;
    mListener = listener;

    this.emgMode = emg;
    this.imuMode = imu;
    this.gesturesMode = gestures;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:13,代码来源:Configuration.java

示例12: disconnect

import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
public void disconnect() {
    super.disconnect();
    // We don't want any callbacks when the Activity is gone, so unregister the listener.
    Hub.getInstance().removeListener(mListener);
    // The Activity is finishing, so shutdown the Hub. This will disconnect from the Myo.
    Hub.getInstance().shutdown();

    sendDisconnected();
}
 
开发者ID:gradlman,项目名称:SensorLib,代码行数:11,代码来源:MyoSensor.java

示例13: 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

示例14: onDestroy

import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
protected void onDestroy() {
	super.onDestroy();
	Hub.getInstance().removeListener(listener);
	if (isFinishing())
		Hub.getInstance().shutdown();
	
}
 
开发者ID:myofit,项目名称:MyoFit,代码行数:9,代码来源:ExerciseActivity.java

示例15: onDestroy

import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
protected void onDestroy() {
  Log.d("ArcGIS", "Exiting MapActivity, removing view");
  mSensorManager.unregisterListener(this);
  ((ViewGroup)mMapView.getParent()).removeView(mMapView);
  Hub.getInstance().removeListener(mListener);
  if (isFinishing()) {
    // The Activity is finishing, so shutdown the Hub. This will disconnect from the Myo.
    Hub.getInstance().shutdown();
  }
  if(!mDying)
    MapService.returnToLiveCard();
  super.onDestroy();
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demos-android,代码行数:15,代码来源:MapActivity.java


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