Changeset 4010dcc in orbit
- Timestamp:
- 12/22/12 16:16:44 (7 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- 6fdeffc
- Parents:
- 66477ef
- Location:
- iOS/Orbit
- Files:
-
- 1 added
- 1 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
iOS/Orbit/Orbit.xcodeproj/project.pbxproj
r66477ef r4010dcc 12 12 2815BC13167F48BB00F7E6DA /* libTGAccessory.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2815BC10167F48A000F7E6DA /* libTGAccessory.a */; }; 13 13 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 */; };15 14 28174C61167F2EA900104752 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C60167F2EA900104752 /* UIKit.framework */; }; 16 15 28174C63167F2EA900104752 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28174C62167F2EA900104752 /* Foundation.framework */; }; … … 27 26 282F2B331681D0FC00B9A99A /* ic_launcher-57x57.png in Resources */ = {isa = PBXBuildFile; fileRef = 282F2B321681D0FC00B9A99A /* ic_launcher-57x57.png */; }; 28 27 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 */; }; 29 29 /* End PBXBuildFile section */ 30 30 … … 36 36 2815BC12167F48A000F7E6DA /* TGAccessoryManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TGAccessoryManager.h; sourceTree = "<group>"; }; 37 37 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>"; };39 38 28174C5C167F2EA900104752 /* Orbit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Orbit.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 39 28174C60167F2EA900104752 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; … … 56 55 282F2B321681D0FC00B9A99A /* ic_launcher-57x57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "ic_launcher-57x57.png"; sourceTree = "<group>"; }; 57 56 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>"; }; 58 58 /* End PBXFileReference section */ 59 59 … … 144 144 28174C74167F2EA900104752 /* Default@2x.png */, 145 145 28174C76167F2EA900104752 /* Default-568h@2x.png */, 146 28 15BC18167F54B500F7E6DA /* throttle_hover_android_common.wav */,146 285D3D371685D9B1005A534D /* throttle_max_ios_common.wav */, 147 147 ); 148 148 name = "Supporting Files"; … … 205 205 28174C77167F2EA900104752 /* Default-568h@2x.png in Resources */, 206 206 28174C7A167F2EAA00104752 /* MainStoryboard.storyboard in Resources */, 207 2815BC19167F54B600F7E6DA /* throttle_hover_android_common.wav in Resources */,208 207 282F2B331681D0FC00B9A99A /* ic_launcher-57x57.png in Resources */, 209 208 282F2B361681D10200B9A99A /* ic_launcher-114x114.png in Resources */, 209 285D3D381685D9B1005A534D /* throttle_max_ios_common.wav in Resources */, 210 210 ); 211 211 runOnlyForDeploymentPostprocessing = 0; -
iOS/Orbit/Orbit/ViewController.m
r66477ef r4010dcc 10 10 #import <AVFoundation/AVFoundation.h> 11 11 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" 13 15 #define POOR_SIGNAL_KEY @"poorSignal" 14 16 #define ATTENTION_KEY @"eSenseAttention" … … 45 47 } 46 48 49 // Start the data stream from the bluetooth headset if it's attached, and reset the display output 47 50 - (void) appForegrounded 48 51 { 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]]; 50 55 [[TGAccessoryManager sharedTGAccessoryManager] startStream]; 51 56 } 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 55 61 - (void) resetViews 62 { 63 [self resetOutputToZero]; 64 self.log.text = @""; 65 } 66 67 - (void) resetOutputToZero 56 68 { 57 69 [self showSignalStrength:[NSNumber numberWithInt:200]]; … … 59 71 [self setMeditationLevel:[NSNumber numberWithInt:0]]; 60 72 [self showPowerLevel]; 61 self.log.text = @"";62 73 } 63 74 … … 65 76 { 66 77 [self stopDemo]; 78 [self resetViews]; 67 79 if ([[TGAccessoryManager sharedTGAccessoryManager] connected]) { 68 80 [[TGAccessoryManager sharedTGAccessoryManager] stopStream]; … … 77 89 audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFilePath error:&error]; 78 90 if (!audioPlayer) { 79 NSLog(@"Failed to initialize audio player: %@", [error debugDescription]);91 [self logMessage:[NSString stringWithFormat:@"Failed to initialize audio player: %@", [error debugDescription]]]; 80 92 } else { 81 93 [audioPlayer prepareToPlay]; … … 86 98 { 87 99 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 88 111 } 89 112 … … 96 119 } 97 120 98 - (void) updatedSignalReceived:(NSDictionary *) data 99 { 121 - (void) updatedSignalReceived:(id) data 122 { 123 if (LOGGING) { 124 [self logDataReceived: data]; 125 } 100 126 [self showSignalStrength:(NSNumber *)[data valueForKey:POOR_SIGNAL_KEY]]; 101 127 [self setAttentionLevel:(NSNumber *)[data valueForKey:ATTENTION_KEY]]; … … 105 131 } 106 132 133 // The headset was switched on, start the data stream 107 134 - (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 111 143 - (void)accessoryDidDisconnect { 112 144 [self logMessage:@"An accessory was disconnected."]; 145 [self resetOutputToZero]; 113 146 } 114 147 … … 147 180 { 148 181 if (value != nil) { 149 self.signal.progress = (200 - [value intValue]) / 100;182 self.signal.progress = (200.0 - [value intValue]) / 200.0; 150 183 } 151 184 }
Note: See TracChangeset
for help on using the changeset viewer.