以编程方式振动 Myo Armband

Vibrate Myo Armband programmatically

如何以编程方式让 Myo 振动。

我可以在 TLMHubDidConnectDeviceNotification 中振动,但我可以在 TLMMyoDidReceiveOrientationEventNotification 中使用它,因为在此通知中没有 TLMMyo.

的实例

例如:振动在TLMHubDidConnectDeviceNotification

TLMMyo *myo = notification.userInfo[kTLMKeyMyo];

[myo vibrateWithLength:TLMVibrationLengthLong];
[myo vibrateWithLength:TLMVibrationLengthMedium];
[myo vibrateWithLength:TLMVibrationLengthShort];

我也尝试将实例保存在@property中,但在TLMMyoDidReceiveOrientationEventNotification中这个实例是nil

PS: Question in Myo Developer Forum

该通知似乎存在错误。同时,您可以在 TLMHub 单例的 myoDevices 方法上访问 TLMMyos。如果您使用多个 Myo 设备,您可以使用 TLMMyo 上的 identifier 属性 来确定您要使用的设备。

不过,我会考虑在长期内修复通知。

TLMMyo *myo = [[[TLMHub sharedHub] myoDevices] firstObject];

if (myo.identifier == self.identifier) {
    [myo vibrateWithLength:TLMVibrationLengthLong];
    [myo vibrateWithLength:TLMVibrationLengthMedium];
    [myo vibrateWithLength:TLMVibrationLengthShort];
}