本文整理汇总了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();
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
}
示例14: onDestroy
import com.thalmic.myo.Hub; //导入依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
Hub.getInstance().removeListener(listener);
if (isFinishing())
Hub.getInstance().shutdown();
}
示例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();
}