Changeset de10cbc in orbit for iOS/Orbit/Orbit


Ignore:
Timestamp:
08/02/13 19:00:35 (8 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/Orbit
Files:
2 deleted
9 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> 
Note: See TracChangeset for help on using the changeset viewer.