Changeset bfa2ba1 in orbit for iOS


Ignore:
Timestamp:
12/30/13 13:35:18 (6 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo
Children:
9a24f48
Parents:
876e42b
Message:
  • Tilt Control pays attention to UISwitches
  • Tilt Control set to faster update interval
Location:
iOS/Orbit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/controllers/AdvancedViewController.m

    r876e42b rbfa2ba1  
    3434    
    3535   self.motionManager = [[CMMotionManager alloc] init]; 
    36    self.motionManager.accelerometerUpdateInterval = .2; 
    37    self.motionManager.gyroUpdateInterval = .2; 
     36   //   self.motionManager.accelerometerUpdateInterval = .2; 
     37   //   self.motionManager.gyroUpdateInterval = .2; 
     38   self.motionManager.accelerometerUpdateInterval = .1; 
     39   self.motionManager.gyroUpdateInterval = .1; 
    3840    
    3941   [self.motionManager startAccelerometerUpdatesToQueue:[NSOperationQueue currentQueue] 
     
    167169   // http://nscookbook.com/2013/03/ios-programming-recipe-19-using-core-motion-to-access-gyro-and-accelerometer/ 
    168170    
    169    //   // Sensor.TYPE_GRAVITY 
    170    //   if (checkBoxTiltSensorControlThrottle.isChecked()) { 
    171    //      seekBarThrottle.setProgress(defaultControlThrottle - (int) ((tiltX * 2) - (referenceTiltX * 2))); 
    172    //   } else { 
    173    //      seekBarYaw.setProgress(defaultControlYaw + (int) (tiltY - referenceTiltY)); 
    174    //      seekBarPitch.setProgress(defaultControlPitch + (int) (tiltX - referenceTiltX)); 
    175    //   } 
    176     
    177    double tiltX = acceleration.x; 
    178    double tiltY = acceleration.y * -1;  // invert the Y axis so that negative values equal left 
    179     
    180    NSLog(@"DEBUG: tiltX:%f tiltY:%f", tiltX, tiltY); 
    181  
    182    double newYaw = defaultControlYaw + (tiltX - referenceTiltX); 
    183    double newPitch = defaultControlPitch - (tiltY - referenceTiltY); 
    184     
    185    NSLog(@"DEBUG: yaw:%f pitch:%f", yaw.value, pitch.value); 
    186    NSLog(@"DEBUG: newYaw:%f newPitch:%f", newYaw, newPitch); 
    187     
    188    yaw.value = newYaw; 
    189    pitch.value = newPitch; 
    190     
    191    [self adjustValues]; 
     171   if ([_switchTiltSensorControl isOn]) { 
     172       
     173      if (! [_switchTiltSensorControlThrottle isOn]) { 
     174          
     175         // Pitch/Yaw Tilt Control 
     176          
     177         double tiltX = acceleration.x; 
     178         double tiltY = acceleration.y * -1;  // invert the Y axis so that negative values equal left 
     179          
     180         //   NSLog(@"DEBUG: tiltX:%f tiltY:%f", tiltX, tiltY); 
     181          
     182         double newYaw = defaultControlYaw + (tiltX - referenceTiltX); 
     183         double newPitch = defaultControlPitch - (tiltY - referenceTiltY); 
     184          
     185         //   NSLog(@"DEBUG: yaw:%f pitch:%f", yaw.value, pitch.value); 
     186         //   NSLog(@"DEBUG: newYaw:%f newPitch:%f", newYaw, newPitch); 
     187          
     188         yaw.value = newYaw; 
     189         pitch.value = newPitch; 
     190          
     191         [self adjustValues]; 
     192          
     193      } // Pitch/Yaw Tilt Control 
     194       
     195      else { 
     196          
     197         // Throttle Tilt Control 
     198          
     199         double tiltY = acceleration.y * -1;  // invert the Y axis so that negative values equal forward 
     200          
     201         throttle.value = defaultControlThrottle - (tiltY - referenceTiltY);         
     202          
     203      } // Throttle Tilt Control 
     204       
     205   } 
    192206    
    193207} 
Note: See TracChangeset for help on using the changeset viewer.