Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed and/or commented logs #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions RNMotionManager/Accelerometer.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,91 +15,91 @@ @implementation Accelerometer
RCT_EXPORT_MODULE();

- (id) init {
self = [super init];
NSLog(@"Accelerometer");

if (self) {
self->_motionManager = [[CMMotionManager alloc] init];
//Accelerometer
if([self->_motionManager isAccelerometerAvailable])
{
NSLog(@"Accelerometer available");
/* Start the accelerometer if it is not active already */
if([self->_motionManager isAccelerometerActive] == NO)
{
NSLog(@"Accelerometer active");
} else {
NSLog(@"Accelerometer not active");
}
}
else
{
NSLog(@"Accelerometer not Available!");
self = [super init];
// NSLog(@"Accelerometer");

if (self) {
self->_motionManager = [[CMMotionManager alloc] init];
//Accelerometer
if([self->_motionManager isAccelerometerAvailable])
{
// NSLog(@"Accelerometer available");
/* Start the accelerometer if it is not active already */
if([self->_motionManager isAccelerometerActive] == NO)
{
// NSLog(@"Accelerometer active");
} else {
// NSLog(@"Accelerometer not active");
}
}
else
{
// NSLog(@"Accelerometer not Available!");
}
}
}
return self;
return self;
}

RCT_EXPORT_METHOD(setAccelerometerUpdateInterval:(double) interval) {
NSLog(@"setAccelerometerUpdateInterval: %f", interval);

[self->_motionManager setAccelerometerUpdateInterval:interval];
// NSLog(@"setAccelerometerUpdateInterval: %f", interval);
[self->_motionManager setAccelerometerUpdateInterval:interval];
}

RCT_EXPORT_METHOD(getAccelerometerUpdateInterval:(RCTResponseSenderBlock) cb) {
double interval = self->_motionManager.accelerometerUpdateInterval;
NSLog(@"getAccelerometerUpdateInterval: %f", interval);
cb(@[[NSNull null], [NSNumber numberWithDouble:interval]]);
double interval = self->_motionManager.accelerometerUpdateInterval;
// NSLog(@"getAccelerometerUpdateInterval: %f", interval);
cb(@[[NSNull null], [NSNumber numberWithDouble:interval]]);
}

RCT_EXPORT_METHOD(getAccelerometerData:(RCTResponseSenderBlock) cb) {
double x = self->_motionManager.accelerometerData.acceleration.x;
double y = self->_motionManager.accelerometerData.acceleration.y;
double z = self->_motionManager.accelerometerData.acceleration.z;
double timestamp = self->_motionManager.accelerometerData.timestamp;

NSLog(@"getAccelerometerData: %f, %f, %f, %f", x, y, z, timestamp);

cb(@[[NSNull null], @{
@"acceleration": @{
@"x" : [NSNumber numberWithDouble:x],
@"y" : [NSNumber numberWithDouble:y],
@"z" : [NSNumber numberWithDouble:z],
@"timestamp" : [NSNumber numberWithDouble:timestamp]
}
}]
);
double x = self->_motionManager.accelerometerData.acceleration.x;
double y = self->_motionManager.accelerometerData.acceleration.y;
double z = self->_motionManager.accelerometerData.acceleration.z;
double timestamp = self->_motionManager.accelerometerData.timestamp;
// NSLog(@"getAccelerometerData: %f, %f, %f, %f", x, y, z, timestamp);
cb(@[[NSNull null], @{
@"acceleration": @{
@"x" : [NSNumber numberWithDouble:x],
@"y" : [NSNumber numberWithDouble:y],
@"z" : [NSNumber numberWithDouble:z],
@"timestamp" : [NSNumber numberWithDouble:timestamp]
}
}]
);
}

RCT_EXPORT_METHOD(startAccelerometerUpdates) {
NSLog(@"startAccelerometerUpdates");
[self->_motionManager startAccelerometerUpdates];

/* Receive the ccelerometer data on this block */
[self->_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error)
{
double x = accelerometerData.acceleration.x;
double y = accelerometerData.acceleration.y;
double z = accelerometerData.acceleration.z;
double timestamp = accelerometerData.timestamp;
NSLog(@"startAccelerometerUpdates: %f, %f, %f, %f", x, y, z, timestamp);

[self.bridge.eventDispatcher sendDeviceEventWithName:@"AccelerationData" body:@{
@"acceleration": @{
@"x" : [NSNumber numberWithDouble:x],
@"y" : [NSNumber numberWithDouble:y],
@"z" : [NSNumber numberWithDouble:z],
@"timestamp" : [NSNumber numberWithDouble:timestamp]
}
}];
}];

// NSLog(@"startAccelerometerUpdates");
[self->_motionManager startAccelerometerUpdates];

/* Receive the ccelerometer data on this block */
[self->_motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMAccelerometerData *accelerometerData, NSError *error)
{
double x = accelerometerData.acceleration.x;
double y = accelerometerData.acceleration.y;
double z = accelerometerData.acceleration.z;
double timestamp = accelerometerData.timestamp;

[self.bridge.eventDispatcher sendDeviceEventWithName:@"AccelerationData" body:@{
@"acceleration": @{
@"x" : [NSNumber numberWithDouble:x],
@"y" : [NSNumber numberWithDouble:y],
@"z" : [NSNumber numberWithDouble:z],
@"timestamp" : [NSNumber numberWithDouble:timestamp]
}
}];
}];

}

RCT_EXPORT_METHOD(stopAccelerometerUpdates) {
NSLog(@"stopAccelerometerUpdates");
[self->_motionManager stopAccelerometerUpdates];
// NSLog(@"stopAccelerometerUpdates");
[self->_motionManager stopAccelerometerUpdates];
}

@end

34 changes: 16 additions & 18 deletions RNMotionManager/Gyroscope.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ @implementation Gyroscope

- (id) init {
self = [super init];
NSLog(@"Gyroscope");

//NSLog(@"Gyroscope");
if (self) {
self->_motionManager = [[CMMotionManager alloc] init];
//Gyroscope
if([self->_motionManager isGyroAvailable])
{
NSLog(@"Gyroscope available");
//NSLog(@"Gyroscope available");
/* Start the gyroscope if it is not active already */
if([self->_motionManager isGyroActive] == NO)
{
NSLog(@"Gyroscope active");
//NSLog(@"Gyroscope active");
} else {
NSLog(@"Gyroscope not active");
//NSLog(@"Gyroscope not active");
}
}
else
{
NSLog(@"Gyroscope not Available!");
//NSLog(@"Gyroscope not Available!");
}
}
return self;
}

RCT_EXPORT_METHOD(setGyroUpdateInterval:(double) interval) {
NSLog(@"setGyroUpdateInterval: %f", interval);

//NSLog(@"setGyroUpdateInterval: %f", interval);
[self->_motionManager setGyroUpdateInterval:interval];
}

RCT_EXPORT_METHOD(getGyroUpdateInterval:(RCTResponseSenderBlock) cb) {
double interval = self->_motionManager.gyroUpdateInterval;
NSLog(@"getGyroUpdateInterval: %f", interval);
//NSLog(@"getGyroUpdateInterval: %f", interval);
cb(@[[NSNull null], [NSNumber numberWithDouble:interval]]);
}

Expand All @@ -57,9 +57,7 @@ - (id) init {
double y = self->_motionManager.gyroData.rotationRate.y;
double z = self->_motionManager.gyroData.rotationRate.z;
double timestamp = self->_motionManager.gyroData.timestamp;

NSLog(@"getGyroData: %f, %f, %f, %f", x, y, z, timestamp);


cb(@[[NSNull null], @{
@"rotationRate": @{
@"x" : [NSNumber numberWithDouble:x],
Expand All @@ -72,9 +70,9 @@ - (id) init {
}

RCT_EXPORT_METHOD(startGyroUpdates) {
NSLog(@"startGyroUpdates");
//NSLog(@"startGyroUpdates");
[self->_motionManager startGyroUpdates];

/* Receive the gyroscope data on this block */
[self->_motionManager startGyroUpdatesToQueue:[NSOperationQueue mainQueue]
withHandler:^(CMGyroData *gyroData, NSError *error)
Expand All @@ -83,8 +81,7 @@ - (id) init {
double y = gyroData.rotationRate.y;
double z = gyroData.rotationRate.z;
double timestamp = gyroData.timestamp;
NSLog(@"startGyroUpdates: %f, %f, %f, %f", x, y, z, timestamp);


[self.bridge.eventDispatcher sendDeviceEventWithName:@"GyroData" body:@{
@"rotationRate": @{
@"x" : [NSNumber numberWithDouble:x],
Expand All @@ -94,12 +91,13 @@ - (id) init {
}
}];
}];

}

RCT_EXPORT_METHOD(stopGyroUpdates) {
NSLog(@"stopGyroUpdates");
//NSLog(@"stopGyroUpdates");
[self->_motionManager stopGyroUpdates];
}

@end

Loading