本文整理汇总了Java中com.thalmic.myo.Hub.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java Hub.getInstance方法的具体用法?Java Hub.getInstance怎么用?Java Hub.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thalmic.myo.Hub
的用法示例。
在下文中一共展示了Hub.getInstance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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;
}
示例8: onCreate
import com.thalmic.myo.Hub; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exercise);
initUIElements();
// Create Hub for Connection
hub = Hub.getInstance();
// Unlock Myo Permanently
hub.setLockingPolicy(LockingPolicy.NONE);
// Terminate Usage Data Sending
hub.setSendUsageData(false);
// Initialize Hub by Context
if (!hub.init(this,getPackageName())) {
// Hub Issue
Log.e("MyoTestActivity","Could not initialize hub");
// Terminate Activity
finish();
} else
Log.i("MyoTestActivity", "connected");
// Myo SDK Activity for Connecting
Intent intent = new Intent(this,ScanActivity.class);
startActivity(intent);
hub.setLockingPolicy(LockingPolicy.NONE);
Log.i("MyoTestActivity", "MyoTestActivity - "+hub.getLockingPolicy());
myoTV.setText("Myo Connected!");
// FADE OUT
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Sync Myo");
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
continueApp();
}
});
alert.show();
}