The Quaternion Mode

In this mode, the SDK can receive the movement information of the Ring device in quaternion format.
The origin is the place where the ring is when its mode has been set to the point mode, and the distance from the origin will be sent to the SDK periodically.

CRQuaternion

To receive the movement information from the Ring, use the CRQuaternion struct defined in CRCommon.h

didReceiveQuaternion

You can receive the movement information via this function.

Implementation Example

This example logs the movement information of the Ring device.

Swift

import UIKit

class ViewController: UIViewController, CRApplicationDelegate {

  var ringApp: CRApplication!

  override func viewDidLoad() {
    super.viewDidLoad()

    ringApp = CRApplication(delegate:self, background: false)
    ringApp.start()
  }

  func didReceiveEvent(event: CRRingEvent) {
    if event == .LongPress {
      print("LongPress")
      ringApp.setRingMode(.Quaternion)
    }
  }

  func didReceivePoint(point: CGPoint) {
  }

  func didReceiveQuaternion(quaternion: CRQuaternion) {
    print(quaternion)
  }

  func didReceiveGesture(identifier: String!) {
  }

  func deviceDidInitialize() {
    ringApp.setRingMode(.Quaternion)
  }

  func deviceDidDisconnect() {
  }
}

Objective-C

#import "ViewController.h"
#import <CoreRing/CoreRing.h>

@interface ViewController () <CRApplicationDelegate>
@property (nonatomic, strong) CRApplication *ringApp;
@end

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  self.ringApp = [[CRApplication alloc] initWithDelegate:self background:NO];
  [self.ringApp start];
}

- (void)didReceiveEvent:(CRRingEvent)event {
  if (event == CRRingEventLongPress) {
    NSLog(@"LongPress");
    [self.ringApp setRingMode:CRRingModeQuaternion];
  }
}

- (void)didReceivePoint:(CGPoint)point {
}

- (void)didReceiveQuaternion:(CRQuaternion)quaternion {
  NSLog(@"w: %f, x: %f, y: %f, z: %f", quaternion.w, quaternion.x, quaternion.y, quaternion.z);
}

- (void)didReceiveGesture:(NSString *)identifier {
}

- (void)deviceDidInitialize {
  [self.ringApp setRingMode:CRRingModeQuaternion];
}

- (void)deviceDidDisconnect {
}

@end

<The Point Mode     |     TOP     |     Gestures and The Gesture Mode>