• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Hub类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


示例17: startVibrate

import com.thalmic.myo.Hub; //导入依赖的package包/类
private void startVibrate(Myo myo, Hub hub) {
    String _name = "test";
    Log.i(_name, "connected");
    try {
        Vibrate2Command vibrate2Command = new Vibrate2Command(hub);

        Log.i(_name, "vibrate 1...");
        myo.vibrate(Myo.VibrationType.MEDIUM);
        Thread.sleep(3000);

        Log.i(_name, "vibrate 2...");
        //check strength 50
        vibrate2Command.vibrate(myo, 1000, (byte) 50);
        Thread.sleep(3000);

        Log.i(_name, "vibrate 3 ...");
        //check strength 100
        vibrate2Command.vibrate(myo, 1000, (byte) 100);
        Thread.sleep(3000);

        Log.i(_name, "vibrate 4 ...");
        //check strength 100
        vibrate2Command.vibrate(myo, 1000, (byte) 150);
        Thread.sleep(3000);

        Log.i(_name, "vibrate 5...");
        //check strength 250
        vibrate2Command.vibrate(myo, 1000, (byte) 200);
        Thread.sleep(3000);

        Log.i(_name, "vibrate 6...");
        //check strength 250
        vibrate2Command.vibrate(myo, 1000, (byte) 250);
        Thread.sleep(3000);

        Log.i(_name, "vibrate pattern...");
        //check vibrate pattern
        vibrate2Command.vibrate(myo, new int[]{500, 500, 500, 500, 500, 500}, new byte[]{25, 50, 100, (byte) 150, (byte) 200, (byte) 250});
        Thread.sleep(3000);
    } catch (Exception e) {
        Log.e(_name, "exception in vibrate test", e);
    }
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:44,代码来源:MainActivity.java


示例18: run

import com.thalmic.myo.Hub; //导入依赖的package包/类
public void run()
{
	finished = false;

	// Check if hub can be initialized
	if (!hub.init(SSJApplication.getAppContext()))
	{
		errorMsg = "Could not initialize the Hub.";
		finished = true;
		return;
	}
	else
	{
		myoInitialized = true;
	}

	hub.setLockingPolicy(options.locking.get() ? Hub.LockingPolicy.STANDARD : Hub.LockingPolicy.NONE);

	// Disable usage data sending
	hub.setSendUsageData(false);

	// Add listener for callbacks
	hub.addListener(listener);

	// Connect to myo
	if (hub.getConnectedDevices().isEmpty())
	{
		// If there is a mac address connect to it, otherwise look for myo nearby
		if (options.macAddress.get() != null && !options.macAddress.get().isEmpty())
		{
			Log.i("Connecting to MAC: " + options.macAddress.get());
			hub.attachByMacAddress(options.macAddress.get());
		}
		else
		{
			//Log.i("Connecting to nearest myo");
			//hub.attachToAdjacentMyo(); //buggy, not usable
			errorMsg = "Cannot connect, please specify MAC address of Myo.";
		}
	}

	finished = true;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:44,代码来源:Myo.java


示例19: connect

import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
public boolean connect() throws SSJFatalException
{
	myoInitialized = false;
	hub = Hub.getInstance();
       listener = new MyoListener();

	// Myo hub must be initialized in the main ui thread
	Handler handler = new Handler(Looper.getMainLooper());
	MyoConnThread connThread = new MyoConnThread();
	handler.postDelayed(connThread, 1);

	// Wait until myo is connected
	long time = SystemClock.elapsedRealtime();
	while (hub.getConnectedDevices().isEmpty() && SystemClock.elapsedRealtime() - time < _frame.options.waitSensorConnect.get() * 1000 && !_terminate)
	{
		try {
			Thread.sleep(Cons.SLEEP_IN_LOOP);
		} catch (InterruptedException e) {}
	}

	if(connThread.errorMsg != null && !connThread.errorMsg.isEmpty())
	{
		throw new SSJFatalException(connThread.errorMsg);
	}

	if(hub.getConnectedDevices().isEmpty())
	{
		hub.shutdown();

		Log.e("device not found");
		return false;
	}

       myo = hub.getConnectedDevices().get(0);

       //configure myo
       config = new Configuration(hub, listener, options.emg.get(), options.imu.get(), options.gestures.get());
       config.apply(myo.getMacAddress());

	myo.unlock(com.thalmic.myo.Myo.UnlockType.HOLD);

	Log.i("Myo successfully connected: " + myo.getMacAddress());
	return true;
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:46,代码来源:Myo.java


示例20: Vibrate2Command

import com.thalmic.myo.Hub; //导入依赖的package包/类
public Vibrate2Command(Hub hub) {
    super(hub);
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:4,代码来源:Vibrate2Command.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JsConstructor类代码示例发布时间:2022-05-23
下一篇:
Java DeltaIteration类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap