Changeset 0ab8242 in orbit for iOS/Orbit/Orbit


Ignore:
Timestamp:
08/01/13 08:33:40 (9 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, RawEEG, Servo, Tab_Interface, pyramid
Children:
c1c6a1d
Parents:
4da9757 (diff), ce0a7ee (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'RawEEG', remote-tracking branch 'origin' into RawEEG

Location:
iOS/Orbit/Orbit
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/AppDelegate.m

    r9015b1e rce0a7ee  
    2121{ 
    2222    // Override point for customization after application launch. 
    23     NSLog(@"didFinsihLaunching - signal convertor init"); 
    2423    signalConverter = [[SignalConverter alloc] init]; 
    25 //    [[TGAccessoryManager sharedTGAccessoryManager] setupManagerWithInterval:0.05]; 
    26 //    [[TGAccessoryManager sharedTGAccessoryManager] setDelegate:(ViewController *)self.window.rootViewController]; 
    2724    return YES; 
    2825} 
     
    3229    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 
    3330    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 
    34 //    ViewController *rootController = (ViewController *)self.window.rootViewController; 
    35 //    [rootController appClosed]; 
    3631    [signalConverter appStopped]; 
    37     NSLog(@"Application will resign active - appClosed"); 
    3832} 
    3933 
     
    5751{ 
    5852    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 
    59     NSLog(@"Application will terminate - teardownManager"); 
    6053    [[TGAccessoryManager sharedTGAccessoryManager] teardownManager]; 
    6154} 
  • iOS/Orbit/Orbit/SignalConverter.h

    r9015b1e rce0a7ee  
    1212#import "TGAccessoryDelegate.h" 
    1313#import "SignalConverterDelegate.h" 
     14#import "AudioGenerator.h" 
    1415 
    1516@interface SignalConverter : NSObject <TGAccessoryDelegate> { 
    16     AVAudioPlayer *audioPlayer; 
     17    AudioGenerator *audioPlayer; 
    1718} 
    1819 
     
    2425 
    2526- (void) setValuesForAttention:(float) attention meditation:(float) meditation; 
    26 - (void) prepare; 
    2727- (BOOL) startProcessing; 
    2828- (void) stopProcessing; 
     
    3030- (BOOL) isBluetoothReady; 
    3131- (BOOL) isVolumeMax; 
     32- (void) setYaw:(int)y throttle:(int)t pitch:(int)p; 
    3233 
    3334@end 
  • iOS/Orbit/Orbit/SignalConverter.m

    r9015b1e rce0a7ee  
    2727     
    2828    int signalStrength, attentionLevel, meditationLevel; // the latest readings from the headset 
     29    int yaw, throttle, pitch; 
    2930} 
    3031 
     
    3940        [[TGAccessoryManager sharedTGAccessoryManager] setupManagerWithInterval:0.05]; 
    4041        [[TGAccessoryManager sharedTGAccessoryManager] setDelegate:self]; 
     42        audioPlayer = [[AudioGenerator alloc] init]; 
     43         
     44        // defaults 
     45        throttle = 80; 
     46        yaw = 78; 
     47        pitch = 31; 
    4148    } 
    4249    return self; 
     
    4855    meditationThreshold = meditation; 
    4956    [self calculatePowerValues]; 
    50 } 
    51  
    52 - (void) prepare 
    53 { 
    54     NSURL *audioFilePath = [[NSBundle mainBundle] URLForResource:AUDIO_FILE_NAME withExtension:nil]; 
    55     audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFilePath error:nil]; 
    56     if (audioPlayer) { 
    57         [audioPlayer prepareToPlay]; 
    58     } 
    5957} 
    6058 
     
    142140{ 
    143141    float volume = [[AVAudioSession sharedInstance] outputVolume]; 
    144 //    Float32 volume; 
    145 //    UInt32 dataSize = sizeof(Float32); 
    146 //     
    147 //    AudioSessionGetProperty ( 
    148 //                             kAudioSessionProperty_CurrentHardwareOutputVolume, 
    149 //                             &dataSize, 
    150 //                             &volume 
    151 //                             ); 
    152142    return volume == 1.0; 
    153143} 
     
    171161{ 
    172162    [self appStopped]; 
    173     [self prepare];     
    174163} 
    175164 
     
    187176} 
    188177 
     178- (void) setYaw:(int)y throttle:(int)t pitch:(int)p 
     179{ 
     180    yaw = y; 
     181    throttle = t; 
     182    pitch = p; 
     183} 
     184 
    189185- (void) playAudio 
    190186{ 
    191     //   audioPlayer.volume = [self currentPowerLevel]; 
    192187    if ([self currentPowerLevel] > 0) { 
    193         audioPlayer.volume = 1.0; 
    194         [audioPlayer play]; 
     188        [audioPlayer playWithThrottle:throttle yaw:yaw pitch:pitch]; 
    195189    } else { 
    196190        [audioPlayer stop]; 
    197         [self prepare]; 
    198191         
    199192    } 
     
    229222} 
    230223 
    231 // calculate the checksum for the generated code used to generate the WAV array 
    232 - (int) codeChecksum:(int)code 
    233 { 
    234     int checksum = 0; 
    235     for (int i = 0; i < 7; i++) { 
    236         checksum += (code >> 4*i) & 15; 
    237     } 
    238     return 16 - (checksum & 15); 
    239 } 
    240  
    241 // Generate the code used to create the WAV file based on the given throttle, yaw and pitch. 
    242 // Copied from AudioService.java in the Android app 
    243 // throttle: 0~127, nothing will happen if this value is below 30. 
    244 // yaw: 0~127, normally 78 will keep orbit from rotating. 
    245 // pitch: 0~63, normally 31 will stop the top propeller. 
    246 // channel: 1=Channel A, 0=Channel B 2= Channel C, depend on which channel you want to pair to the orbit. You can fly at most 3 orbit in a same room. 
    247 - (int) generateCodeFromThrottle: (int)throttle yaw: (int)yaw pitch: (int)pitch channel: (int)channel 
    248 { 
    249     int code = (throttle << 21) + 1048576 + (yaw << 12) + (pitch << 4) + (((channel >> 1) & 1) << 19) + ((channel & 1) << 11); 
    250     return code;// + codeChecksum(code); 
    251 } 
    252  
    253224@end 
  • iOS/Orbit/Orbit/controllers/AdvancedViewController.m

    rab9d63b rce0a7ee  
    88 
    99#import "AdvancedViewController.h" 
     10#import "SignalConverter.h" 
     11#import "AppDelegate.h" 
    1012 
    1113@interface AdvancedViewController () 
     
    1315@end 
    1416 
    15 @implementation AdvancedViewController 
     17@implementation AdvancedViewController { 
     18    SignalConverter *signalConverter; 
     19} 
    1620 
    1721@synthesize pitch, pitchPercent, yaw, yawPercent, throttle, throttlePercent; 
     22 
     23- (void)viewDidLoad 
     24{ 
     25    [super viewDidLoad]; 
     26    AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
     27    signalConverter = appDelegate.signalConverter; 
     28} 
    1829 
    1930- (IBAction) pitchChanged:(id) sender 
    2031{ 
    2132    pitchPercent.text = [self percentStringFromSlider:pitch]; 
     33    [self adjustValues]; 
    2234} 
    2335 
     
    2537{ 
    2638    yawPercent.text = [self percentStringFromSlider:yaw]; 
     39    [self adjustValues]; 
    2740} 
    2841 
     
    3043{ 
    3144    throttlePercent.text = [self percentStringFromSlider:throttle]; 
     45    [self adjustValues]; 
    3246} 
    3347 
     
    3751} 
    3852 
     53- (void) adjustValues 
     54{ 
     55     
     56} 
     57 
    3958@end 
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    r9015b1e rce0a7ee  
    2323@implementation FlightViewController { 
    2424    SignalConverter *signalConverter; 
    25     int deviceStatus; 
     25    int deviceStatus;     
    2626} 
    2727 
     
    3737    [self.attentionThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 
    3838    [self.meditationThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 
    39     [signalConverter prepare]; 
    4039} 
    4140 
     
    151150    } else if ([signalConverter startProcessing]) { 
    152151        [self logMessage:@"Searching for device"]; 
    153 //        [self updateStatusImage:STATUS_CONNECTING]; 
    154152        connectButton.title = @"Disconnect"; 
    155153    } else { 
  • iOS/Orbit/Orbit/controllers/SupportViewController.m

    rab9d63b rce0a7ee  
    3333} 
    3434 
    35 - (void)didReceiveMemoryWarning 
    36 { 
    37     [super didReceiveMemoryWarning]; 
    38     // Dispose of any resources that can be recreated. 
    39 } 
    40  
    4135#pragma mark UIWebViewDelegate methods 
    4236 
    43 - (void)webViewDidStartLoad:(UIWebView *)webView 
     37- (void)webViewDidFinishLoad:(UIWebView *)webView 
    4438{ 
    4539    retryButton.hidden = YES; 
  • iOS/Orbit/Orbit/controllers/TutorialViewController.m

    rab9d63b rce0a7ee  
    1111@implementation TutorialViewController 
    1212 
     13@synthesize webView; 
    1314 
    1415- (void)viewDidLoad 
    1516{ 
     17    NSString *file = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 
     18    NSString *html = [NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:nil]; 
     19    [webView loadHTMLString:html baseURL:nil]; 
    1620    [super viewDidLoad]; 
    17      
    1821} 
    1922@end 
  • iOS/Orbit/Orbit/en.lproj/MainStoryboard.storyboard

    r9015b1e rce0a7ee  
    4646                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 
    4747                    </view> 
    48                     <tabBarItem key="tabBarItem" title="Support" id="cac-uP-cgJ"/> 
     48                    <tabBarItem key="tabBarItem" title="Support" image="help.png" id="cac-uP-cgJ"/> 
    4949                    <connections> 
    5050                        <outlet property="retryButton" destination="ito-kx-zLv" id="yP6-IV-eHf"/> 
     
    195195                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 
    196196                    </view> 
    197                     <tabBarItem key="tabBarItem" title="Advanced" id="cd7-uP-s8P"/> 
     197                    <tabBarItem key="tabBarItem" title="Advanced" image="advanced.png" id="cd7-uP-s8P"/> 
    198198                    <connections> 
    199199                        <outlet property="pitch" destination="pE4-wd-89x" id="Sbm-iD-GAE"/> 
     
    382382                        <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 
    383383                    </view> 
    384                     <tabBarItem key="tabBarItem" title="Flight" id="ysb-Df-cyR"/> 
     384                    <tabBarItem key="tabBarItem" title="Flight" image="plane.png" id="ysb-Df-cyR"/> 
    385385                    <navigationItem key="navigationItem" id="iTN-dz-EXc"/> 
    386386                    <connections> 
     
    423423                                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 
    424424                                <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> 
     425                                <dataDetectorType key="dataDetectorTypes"/> 
    425426                                <connections> 
    426427                                    <outlet property="delegate" destination="Wc6-MU-jew" id="cBE-hV-4Fe"/> 
     
    430431                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 
    431432                    </view> 
    432                     <tabBarItem key="tabBarItem" title="Tutorial" id="JJR-hA-hnf"/> 
     433                    <tabBarItem key="tabBarItem" title="Tutorial" image="tutorial.png" id="JJR-hA-hnf"/> 
     434                    <connections> 
     435                        <outlet property="webView" destination="yFF-oy-BYh" id="UOH-dC-3Mk"/> 
     436                    </connections> 
    433437                </viewController> 
    434438                <placeholder placeholderIdentifier="IBFirstResponder" id="phY-I4-vyg" userLabel="First Responder" sceneMemberID="firstResponder"/> 
     
    459463    </scenes> 
    460464    <resources> 
     465        <image name="advanced.png" width="20" height="20"/> 
     466        <image name="help.png" width="20" height="20"/> 
     467        <image name="plane.png" width="20" height="20"/> 
    461468        <image name="status_0.png" width="238" height="213"/> 
     469        <image name="tutorial.png" width="20" height="20"/> 
    462470    </resources> 
    463471    <classes> 
Note: See TracChangeset for help on using the changeset viewer.