Changeset de10cbc in orbit for iOS


Ignore:
Timestamp:
08/02/13 19:00:35 (7 years ago)
Author:
Jonathon Horsman <jonathon@…>
Branches:
master, Servo, Tab_Interface, pyramid
Children:
1472980
Parents:
ce0a7ee
Message:

Add a test button on flight tab
Add a reset button on advanced tab
Correctly detect device volume
Add more tutorial HTML

Location:
iOS/Orbit
Files:
3 added
2 deleted
12 edited

Legend:

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

    rce0a7ee rde10cbc  
    2424    return YES; 
    2525} 
    26                                                          
     26 
    2727- (void)applicationWillResignActive:(UIApplication *)application 
    2828{ 
  • iOS/Orbit/Orbit/SignalConverter.h

    rce0a7ee rde10cbc  
    88 
    99#import <Foundation/Foundation.h> 
     10//#import <MediaPlayer/MediaPlayer.h> 
    1011#import <AVFoundation/AVFoundation.h> 
    1112#import "TGAccessoryManager.h" 
     
    2223@property (nonatomic) float meditationThreshold; 
    2324@property (nonatomic) BOOL running; 
     25@property (nonatomic) BOOL testing; 
    2426 
    2527 
     
    3133- (BOOL) isVolumeMax; 
    3234- (void) setYaw:(int)y throttle:(int)t pitch:(int)p; 
     35- (void) playTestSound; 
     36- (void) stopTestSound; 
    3337 
    3438@end 
  • iOS/Orbit/Orbit/SignalConverter.m

    rce0a7ee rde10cbc  
    3030} 
    3131 
    32 @synthesize attentionThreshold, meditationThreshold, running; 
     32@synthesize attentionThreshold, meditationThreshold, running, testing; 
    3333 
    3434 
     
    139139- (BOOL) isVolumeMax 
    140140{ 
    141     float volume = [[AVAudioSession sharedInstance] outputVolume]; 
    142     return volume == 1.0; 
     141    AudioSessionSetActive(YES); 
     142    return 1.0 == [[AVAudioSession sharedInstance] outputVolume]; 
    143143} 
    144144 
     
    147147- (BOOL) startProcessing 
    148148{ 
     149    if (testing) return NO; 
    149150    EAAccessory *accessory = [[TGAccessoryManager sharedTGAccessoryManager] accessory]; 
    150151    if (accessory != nil) { 
     
    160161- (void) stopProcessing 
    161162{ 
    162     [self appStopped]; 
     163    if (running) [self appStopped]; 
     164} 
     165 
     166- (void) playTestSound 
     167{ 
     168    if (!running && !testing) { 
     169        testing = YES; 
     170        [audioPlayer playWithThrottle:throttle yaw:yaw pitch:pitch]; 
     171    } 
     172} 
     173 
     174- (void) stopTestSound 
     175{ 
     176    if (testing) { 
     177        testing = NO; 
     178        [audioPlayer stop]; 
     179    } 
    163180} 
    164181 
  • iOS/Orbit/Orbit/controllers/AdvancedViewController.h

    rab9d63b rde10cbc  
    1717@property (nonatomic, retain) IBOutlet UILabel *pitchPercent; 
    1818@property (nonatomic, retain) IBOutlet UISlider *pitch; 
     19@property (nonatomic, retain) IBOutlet UIBarButtonItem *resetButton; 
    1920 
    2021- (IBAction) pitchChanged:(id)sender; 
     
    2223- (IBAction) throttleChanged:(id)sender; 
    2324 
     25- (IBAction) resetButtonPressed:(id)button; 
     26 
    2427@end 
  • iOS/Orbit/Orbit/controllers/AdvancedViewController.m

    rce0a7ee rde10cbc  
    5353- (void) adjustValues 
    5454{ 
    55      
     55    [signalConverter setYaw:[self yawValue]throttle:[self throttleValue] pitch:[self pitchValue]]; 
     56} 
     57 
     58- (int) yawValue 
     59{ 
     60    return round(yaw.value * 100); 
     61} 
     62 
     63- (int) pitchValue 
     64{ 
     65    return round(pitch.value * 100); 
     66} 
     67 
     68- (int) throttleValue 
     69{ 
     70    return round(throttle.value * 100); 
     71} 
     72 
     73- (IBAction) resetButtonPressed:(id)button 
     74{ 
     75    pitch.value = 0.5; 
     76    yaw.value = 0.5; 
     77    throttle.value = 0.5; 
     78    NSString *zero = @"0%"; 
     79    throttlePercent.text = zero; 
     80    yawPercent.text = zero; 
     81    pitchPercent.text = zero; 
     82    [self adjustValues]; 
    5683} 
    5784 
  • iOS/Orbit/Orbit/controllers/FlightViewController.h

    rab9d63b rde10cbc  
    2727@property (nonatomic, retain) IBOutlet UISlider *meditationThreshold; 
    2828@property (nonatomic, retain) IBOutlet UIBarButtonItem *connectButton; 
     29@property (nonatomic, retain) IBOutlet UIBarButtonItem *testButton; 
    2930@property (nonatomic, retain) IBOutlet UIImageView *statusImage; 
    3031 
    3132- (IBAction) connectButtonPressed:(id) sender; 
     33- (IBAction) testButtonPressed:(id) sender; 
    3234 
    3335@end 
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    rce0a7ee rde10cbc  
    2626} 
    2727 
    28 @synthesize status, attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, statusImage, signalPercent, attentionPercent, meditationPercent, powerPercent; 
     28@synthesize status, attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, testButton, statusImage, signalPercent, attentionPercent, meditationPercent, powerPercent; 
    2929 
    3030- (void)viewDidLoad 
     
    142142        [signalConverter stopProcessing]; 
    143143        [self resetViews]; 
     144    } else if (!signalConverter.isVolumeMax) { 
     145        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Turn Up The Volume" message:@"Your device volume must be at the maximum for proper operation" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     146        [alert show]; 
    144147    } else if (!signalConverter.isBluetoothReady) { 
    145148        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Device not found" message:@"No Bluetooth device detected. Ensure Bluetooth is on and the Mindwave headset is paired" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    146         [alert show]; 
    147     } else if (!signalConverter.isVolumeMax) { 
    148         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Turn Up The Volume" message:@"Your device volume must be at the maximum for proper operation" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    149149        [alert show]; 
    150150    } else if ([signalConverter startProcessing]) { 
     
    157157} 
    158158 
     159- (IBAction) testButtonPressed:(id) sender { 
     160    if (signalConverter.running) { 
     161        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Stop test sound" message:@"Press Stop first to end the test" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
     162        [alert show]; 
     163    } else { 
     164        if (signalConverter.testing) { 
     165            testButton.title = @"Test"; 
     166            [signalConverter stopTestSound]; 
     167        } else { 
     168            testButton.title = @"Stop"; 
     169            [signalConverter playTestSound]; 
     170        } 
     171    } 
     172} 
     173 
    159174@end 
  • iOS/Orbit/Orbit/controllers/TutorialViewController.m

    rce0a7ee rde10cbc  
    1515- (void)viewDidLoad 
    1616{ 
    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]; 
     17    [webView loadRequest: 
     18     [NSURLRequest requestWithURL: 
     19      [NSURL fileURLWithPath: 
     20       [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]]]]; 
    2021    [super viewDidLoad]; 
    2122} 
  • iOS/Orbit/Orbit/en.lproj/MainStoryboard.storyboard

    rce0a7ee rde10cbc  
    189189                                <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/> 
    190190                                <items> 
    191                                     <navigationItem title="Advanced" id="5si-2Z-XrP"/> 
     191                                    <navigationItem title="Advanced" id="5si-2Z-XrP"> 
     192                                        <barButtonItem key="rightBarButtonItem" title="Reset" id="gTs-AS-CLK"> 
     193                                            <connections> 
     194                                                <action selector="resetButtonPressed:" destination="GcO-3J-amz" id="BNP-eK-aEX"/> 
     195                                            </connections> 
     196                                        </barButtonItem> 
     197                                    </navigationItem> 
    192198                                </items> 
    193199                            </navigationBar> 
     
    199205                        <outlet property="pitch" destination="pE4-wd-89x" id="Sbm-iD-GAE"/> 
    200206                        <outlet property="pitchPercent" destination="cMg-2k-3dB" id="CuC-M3-EWV"/> 
     207                        <outlet property="resetButton" destination="gTs-AS-CLK" id="xuL-gD-ehx"/> 
    201208                        <outlet property="throttle" destination="mKS-gr-qpn" id="O0G-49-cDf"/> 
    202209                        <outlet property="throttlePercent" destination="uE4-bJ-AfU" id="2eT-1d-7nT"/> 
     
    222229                                <items> 
    223230                                    <navigationItem title="Flight" id="adH-fG-xVu"> 
    224                                         <barButtonItem key="rightBarButtonItem" title="Connect" id="Lwp-ZU-iKO"> 
     231                                        <barButtonItem key="leftBarButtonItem" title="Connect" id="Lwp-ZU-iKO"> 
    225232                                            <connections> 
    226233                                                <action selector="connectButtonPressed:" destination="2FE-fA-6q3" id="01p-85-w79"/> 
     234                                            </connections> 
     235                                        </barButtonItem> 
     236                                        <barButtonItem key="rightBarButtonItem" title="Test" id="Geo-cL-sK5"> 
     237                                            <connections> 
     238                                                <action selector="testButtonPressed:" destination="FNb-Lg-ILk" id="eh7-gJ-44x"/> 
    227239                                            </connections> 
    228240                                        </barButtonItem> 
     
    398410                        <outlet property="status" destination="BOS-Js-1rx" id="fDM-Of-lza"/> 
    399411                        <outlet property="statusImage" destination="aa9-oz-0Qj" id="ilQ-PQ-gI8"/> 
     412                        <outlet property="testButton" destination="Geo-cL-sK5" id="P8n-GW-Eih"/> 
    400413                    </connections> 
    401414                </viewController> 
     
    474487            <relationships> 
    475488                <relationship kind="action" name="pitchChanged:"/> 
     489                <relationship kind="action" name="resetButtonPressed:"/> 
    476490                <relationship kind="action" name="throttleChanged:"/> 
    477491                <relationship kind="action" name="yawChanged:"/> 
    478492                <relationship kind="outlet" name="pitch" candidateClass="UISlider"/> 
    479493                <relationship kind="outlet" name="pitchPercent" candidateClass="UILabel"/> 
     494                <relationship kind="outlet" name="resetButton" candidateClass="UIBarButtonItem"/> 
    480495                <relationship kind="outlet" name="throttle" candidateClass="UISlider"/> 
    481496                <relationship kind="outlet" name="throttlePercent" candidateClass="UILabel"/> 
     
    488503            <relationships> 
    489504                <relationship kind="action" name="connectButtonPressed:"/> 
     505                <relationship kind="action" name="testButtonPressed:"/> 
    490506                <relationship kind="outlet" name="attention" candidateClass="UIProgressView"/> 
    491507                <relationship kind="outlet" name="attentionPercent" candidateClass="UILabel"/> 
     
    501517                <relationship kind="outlet" name="status" candidateClass="UILabel"/> 
    502518                <relationship kind="outlet" name="statusImage" candidateClass="UIImageView"/> 
     519                <relationship kind="outlet" name="testButton" candidateClass="UIBarButtonItem"/> 
    503520            </relationships> 
    504521        </class> 
  • iOS/Orbit/index.html

    rce0a7ee rde10cbc  
    33    <head> 
    44        <meta name="viewport" content="width=device-width"> 
     5        <link rel="stylesheet" type="text/css" href="style.css"> 
    56        <title>Orbit Tutorial</title> 
    67    </head> 
    78    <body> 
    8         <h1>Content goes here</h1> 
     9        <h1>Step 1</h1> 
     10        <a class='next button' href="step2.html">Step 2 &raquo;</a> 
    911    </body> 
    1012</html> 
  • iOS/Orbit/orbit.xcodeproj/project.pbxproj

    rce0a7ee rde10cbc  
    2828                28174C71167F2EA900104752 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 28174C70167F2EA900104752 /* AppDelegate.m */; }; 
    2929                28174C7A167F2EAA00104752 /* MainStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 28174C78167F2EAA00104752 /* MainStoryboard.storyboard */; }; 
    30                 28174C7D167F2EAA00104752 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28174C7C167F2EAA00104752 /* ViewController.m */; }; 
    31                 28174C84167F30C400104752 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C83167F30C400104752 /* AVFoundation.framework */; }; 
     30                282B687017ABD601003DA675 /* step2.html in Resources */ = {isa = PBXBuildFile; fileRef = 282B686F17ABD601003DA675 /* step2.html */; }; 
     31                282B687217ABD9EC003DA675 /* style.css in Resources */ = {isa = PBXBuildFile; fileRef = 282B687117ABD9EC003DA675 /* style.css */; }; 
     32                282B687417ABDAB2003DA675 /* step3.html in Resources */ = {isa = PBXBuildFile; fileRef = 282B687317ABDAB2003DA675 /* step3.html */; }; 
     33                282B687517ABEE33003DA675 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C83167F30C400104752 /* AVFoundation.framework */; }; 
    3234                2843FE891790205900C79D56 /* status_1.png in Resources */ = {isa = PBXBuildFile; fileRef = 2843FE811790205900C79D56 /* status_1.png */; }; 
    3335                2843FE8A1790205900C79D56 /* status_1@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2843FE821790205900C79D56 /* status_1@2x.png */; }; 
     
    8385                28174C70167F2EA900104752 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; 
    8486                28174C79167F2EAA00104752 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard.storyboard; sourceTree = "<group>"; }; 
    85                 28174C7B167F2EAA00104752 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; }; 
    86                 28174C7C167F2EAA00104752 /* ViewController.m */ = {isa = PBXFileReference; indentWidth = 3; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; tabWidth = 3; }; 
    8787                28174C83167F30C400104752 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 
     88                282B686D17ABC368003DA675 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; }; 
     89                282B686F17ABD601003DA675 /* step2.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = step2.html; sourceTree = "<group>"; }; 
     90                282B687117ABD9EC003DA675 /* style.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = style.css; sourceTree = "<group>"; }; 
     91                282B687317ABDAB2003DA675 /* step3.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = step3.html; sourceTree = "<group>"; }; 
    8892                2843FE811790205900C79D56 /* status_1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = status_1.png; sourceTree = "<group>"; }; 
    8993                2843FE821790205900C79D56 /* status_1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "status_1@2x.png"; sourceTree = "<group>"; }; 
     
    199203                        buildActionMask = 2147483647; 
    200204                        files = ( 
     205                                282B687517ABEE33003DA675 /* AVFoundation.framework in Frameworks */, 
    201206                                286608E417A7D40F003FA806 /* AudioToolbox.framework in Frameworks */, 
    202207                                28F901301799436F003FB5ED /* CoreBluetooth.framework in Frameworks */, 
     
    206211                                2815BC0E167F42F500F7E6DA /* Accelerate.framework in Frameworks */, 
    207212                                2815BC0F167F42F500F7E6DA /* ExternalAccessory.framework in Frameworks */, 
    208                                 28174C84167F30C400104752 /* AVFoundation.framework in Frameworks */, 
    209213                                28174C61167F2EA900104752 /* UIKit.framework in Frameworks */, 
    210214                                28174C63167F2EA900104752 /* Foundation.framework in Frameworks */, 
     
    220224                        children = ( 
    221225                                280D2AB417A802DB002D6863 /* index.html */, 
     226                                282B686F17ABD601003DA675 /* step2.html */, 
     227                                282B687117ABD9EC003DA675 /* style.css */, 
     228                                282B687317ABDAB2003DA675 /* step3.html */, 
    222229                        ); 
    223230                        name = Tutorial; 
     
    240247                        isa = PBXGroup; 
    241248                        children = ( 
     249                                282B686D17ABC368003DA675 /* MediaPlayer.framework */, 
    242250                                280D2AB317A802C7002D6863 /* Tutorial */, 
    243251                                286608E317A7D40F003FA806 /* AudioToolbox.framework */, 
     
    282290                                28174C70167F2EA900104752 /* AppDelegate.m */, 
    283291                                28174C78167F2EAA00104752 /* MainStoryboard.storyboard */, 
    284                                 28174C7B167F2EAA00104752 /* ViewController.h */, 
    285                                 28174C7C167F2EAA00104752 /* ViewController.m */, 
    286292                                2815BC08167F428B00F7E6DA /* Libraries */, 
    287293                                28174C67167F2EA900104752 /* Supporting Files */, 
     
    498504                                280D2AC417A81714002D6863 /* tutorial.png in Resources */, 
    499505                                280D2AC517A81714002D6863 /* tutorial@2x.png in Resources */, 
     506                                282B687017ABD601003DA675 /* step2.html in Resources */, 
     507                                282B687217ABD9EC003DA675 /* style.css in Resources */, 
     508                                282B687417ABDAB2003DA675 /* step3.html in Resources */, 
    500509                        ); 
    501510                        runOnlyForDeploymentPostprocessing = 0; 
     
    510519                                28174C6D167F2EA900104752 /* main.m in Sources */, 
    511520                                28174C71167F2EA900104752 /* AppDelegate.m in Sources */, 
    512                                 28174C7D167F2EAA00104752 /* ViewController.m in Sources */, 
    513521                                289C7CCF178C36A9005C08EC /* TutorialViewController.m in Sources */, 
    514522                                289C7D0E178D757F005C08EC /* FlightViewController.m in Sources */, 
Note: See TracChangeset for help on using the changeset viewer.