Changeset 4010dcc in orbit


Ignore:
Timestamp:
12/22/12 16:16:44 (7 years ago)
Author:
Jonathon Horsman <jonathon@…>
Branches:
master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
Children:
6fdeffc
Parents:
66477ef
Message:

Change the wav file
Tweak interface to start/stop stream when app is fore/backgrounded

Location:
iOS/Orbit
Files:
1 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit.xcodeproj/project.pbxproj

    r66477ef r4010dcc  
    1212                2815BC13167F48BB00F7E6DA /* libTGAccessory.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2815BC10167F48A000F7E6DA /* libTGAccessory.a */; }; 
    1313                2815BC15167F496C00F7E6DA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2815BC14167F496C00F7E6DA /* QuartzCore.framework */; }; 
    14                 2815BC19167F54B600F7E6DA /* throttle_hover_android_common.wav in Resources */ = {isa = PBXBuildFile; fileRef = 2815BC18167F54B500F7E6DA /* throttle_hover_android_common.wav */; }; 
    1514                28174C61167F2EA900104752 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C60167F2EA900104752 /* UIKit.framework */; }; 
    1615                28174C63167F2EA900104752 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C62167F2EA900104752 /* Foundation.framework */; }; 
     
    2726                282F2B331681D0FC00B9A99A /* ic_launcher-57x57.png in Resources */ = {isa = PBXBuildFile; fileRef = 282F2B321681D0FC00B9A99A /* ic_launcher-57x57.png */; }; 
    2827                282F2B361681D10200B9A99A /* ic_launcher-114x114.png in Resources */ = {isa = PBXBuildFile; fileRef = 282F2B351681D10200B9A99A /* ic_launcher-114x114.png */; }; 
     28                285D3D381685D9B1005A534D /* throttle_max_ios_common.wav in Resources */ = {isa = PBXBuildFile; fileRef = 285D3D371685D9B1005A534D /* throttle_max_ios_common.wav */; }; 
    2929/* End PBXBuildFile section */ 
    3030 
     
    3636                2815BC12167F48A000F7E6DA /* TGAccessoryManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TGAccessoryManager.h; sourceTree = "<group>"; }; 
    3737                2815BC14167F496C00F7E6DA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 
    38                 2815BC18167F54B500F7E6DA /* throttle_hover_android_common.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = throttle_hover_android_common.wav; sourceTree = "<group>"; }; 
    3938                28174C5C167F2EA900104752 /* Orbit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Orbit.app; sourceTree = BUILT_PRODUCTS_DIR; }; 
    4039                28174C60167F2EA900104752 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 
     
    5655                282F2B321681D0FC00B9A99A /* ic_launcher-57x57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_launcher-57x57.png"; sourceTree = "<group>"; }; 
    5756                282F2B351681D10200B9A99A /* ic_launcher-114x114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_launcher-114x114.png"; sourceTree = "<group>"; }; 
     57                285D3D371685D9B1005A534D /* throttle_max_ios_common.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = throttle_max_ios_common.wav; sourceTree = "<group>"; }; 
    5858/* End PBXFileReference section */ 
    5959 
     
    144144                                28174C74167F2EA900104752 /* Default@2x.png */, 
    145145                                28174C76167F2EA900104752 /* Default-568h@2x.png */, 
    146                                 2815BC18167F54B500F7E6DA /* throttle_hover_android_common.wav */, 
     146                                285D3D371685D9B1005A534D /* throttle_max_ios_common.wav */, 
    147147                        ); 
    148148                        name = "Supporting Files"; 
     
    205205                                28174C77167F2EA900104752 /* Default-568h@2x.png in Resources */, 
    206206                                28174C7A167F2EAA00104752 /* MainStoryboard.storyboard in Resources */, 
    207                                 2815BC19167F54B600F7E6DA /* throttle_hover_android_common.wav in Resources */, 
    208207                                282F2B331681D0FC00B9A99A /* ic_launcher-57x57.png in Resources */, 
    209208                                282F2B361681D10200B9A99A /* ic_launcher-114x114.png in Resources */, 
     209                                285D3D381685D9B1005A534D /* throttle_max_ios_common.wav in Resources */, 
    210210                        ); 
    211211                        runOnlyForDeploymentPostprocessing = 0; 
  • iOS/Orbit/Orbit/ViewController.m

    r66477ef r4010dcc  
    1010#import <AVFoundation/AVFoundation.h> 
    1111 
    12 #define AUDIO_FILE_NAME @"throttle_hover_android_common.wav" 
     12#define LOGGING true // set to false to stop each received signal being logged 
     13 
     14#define AUDIO_FILE_NAME @"throttle_max_ios_common.wav" 
    1315#define POOR_SIGNAL_KEY @"poorSignal" 
    1416#define ATTENTION_KEY @"eSenseAttention" 
     
    4547} 
    4648 
     49// Start the data stream from the bluetooth headset if it's attached, and reset the display output 
    4750- (void) appForegrounded 
    4851{ 
    49     if ([[TGAccessoryManager sharedTGAccessoryManager] accessory] != nil) { 
     52    EAAccessory *accessory = [[TGAccessoryManager sharedTGAccessoryManager] accessory]; 
     53    if (accessory != nil) { 
     54        [self logMessage:[NSString stringWithFormat:@"App opened with %@ connected. Starting data stream", accessory.name]]; 
    5055        [[TGAccessoryManager sharedTGAccessoryManager] startStream]; 
    5156    } 
    52     [self resetViews]; 
    53 } 
    54  
     57    [self resetViews]; // just in case it didn't happen on close 
     58} 
     59 
     60// Set all levels back to zero and clear the log 
    5561- (void) resetViews 
     62{ 
     63    [self resetOutputToZero]; 
     64    self.log.text = @""; 
     65} 
     66 
     67- (void) resetOutputToZero 
    5668{ 
    5769    [self showSignalStrength:[NSNumber numberWithInt:200]]; 
     
    5971    [self setMeditationLevel:[NSNumber numberWithInt:0]]; 
    6072    [self showPowerLevel]; 
    61     self.log.text = @""; 
    6273} 
    6374 
     
    6576{ 
    6677    [self stopDemo]; 
     78    [self resetViews]; 
    6779    if ([[TGAccessoryManager sharedTGAccessoryManager] connected]) { 
    6880        [[TGAccessoryManager sharedTGAccessoryManager] stopStream]; 
     
    7789    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFilePath error:&error]; 
    7890    if (!audioPlayer) { 
    79         NSLog(@"Failed to initialize audio player: %@", [error debugDescription]); 
     91        [self logMessage:[NSString stringWithFormat:@"Failed to initialize audio player: %@", [error debugDescription]]]; 
    8092    } else { 
    8193        [audioPlayer prepareToPlay]; 
     
    8698{ 
    8799    log.text = [[NSString alloc] initWithFormat:@"%@\n%@", str, log.text]; 
     100} 
     101 
     102- (void) logDataReceived:(NSDictionary *) data 
     103{ 
     104    NSNumber *sig = [data valueForKey:POOR_SIGNAL_KEY]; 
     105    if (sig != NULL) { 
     106        int val = (200 - [sig intValue]) / 2; 
     107        [self logMessage:[NSString stringWithFormat:@"Signal strength: %u%%, Attention: %@%%, Meditation: %@%%", 
     108                          val, [data valueForKey:ATTENTION_KEY], [data valueForKey:MEDITATION_KEY]]]; 
     109    } 
     110 
    88111} 
    89112 
     
    96119} 
    97120 
    98 - (void) updatedSignalReceived:(NSDictionary *) data 
    99 { 
     121- (void) updatedSignalReceived:(id) data 
     122{ 
     123    if (LOGGING) { 
     124        [self logDataReceived: data]; 
     125    } 
    100126    [self showSignalStrength:(NSNumber *)[data valueForKey:POOR_SIGNAL_KEY]]; 
    101127    [self setAttentionLevel:(NSNumber *)[data valueForKey:ATTENTION_KEY]]; 
     
    105131} 
    106132 
     133// The headset was switched on, start the data stream 
    107134- (void)accessoryDidConnect:(EAAccessory *)accessory { 
    108     [self logMessage:[NSString stringWithFormat:@"%@ was connected to this device.", [accessory name]]]; 
    109 } 
    110  
     135    [self logMessage:[NSString stringWithFormat:@"%@ was connected to this device. Starting data stream...", [accessory name]]]; 
     136    if ([[TGAccessoryManager sharedTGAccessoryManager] accessory] != nil) { 
     137        [[TGAccessoryManager sharedTGAccessoryManager] startStream]; 
     138    } 
     139} 
     140 
     141// The headset was switched off (or the Bluetooth signal was dropped). 
     142// Reset the outputs back to zero 
    111143- (void)accessoryDidDisconnect { 
    112144    [self logMessage:@"An accessory was disconnected."]; 
     145    [self resetOutputToZero]; 
    113146} 
    114147 
     
    147180{ 
    148181    if (value != nil) { 
    149         self.signal.progress = (200 - [value intValue]) / 100; 
     182        self.signal.progress = (200.0 - [value intValue]) / 200.0; 
    150183    } 
    151184} 
Note: See TracChangeset for help on using the changeset viewer.