Changeset daf54d5 in orbit for iOS/Orbit/Orbit/ViewController.m
- Timestamp:
- 12/25/12 16:52:35 (10 years ago)
- Branches:
- master, RawEEG, Raw_EEG_Plot, Servo, Tab_Interface, pyramid
- Children:
- ae32e69
- Parents:
- 2aabdf3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
iOS/Orbit/Orbit/ViewController.m
r2aabdf3 rdaf54d5 28 28 29 29 int currentAttentionLevel, currentMeditationLevel; // the latest readings from the headset 30 BOOL processingDevice; 30 31 BOOL demoRunning; 31 32 } 32 33 33 @synthesize log, attention, meditation, signal, power, attentionThreshold, meditationThreshold, demoButton;34 @synthesize log, attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, demoButton; 34 35 35 36 - (void)viewDidLoad … … 52 53 - (void) appForegrounded 53 54 { 54 EAAccessory *accessory = [[TGAccessoryManager sharedTGAccessoryManager] accessory];55 if (accessory != nil) {56 [self logMessage:[NSString stringWithFormat:@"App opened with %@ connected. Starting data stream", accessory.name]];57 [[TGAccessoryManager sharedTGAccessoryManager] startStream];58 }55 // EAAccessory *accessory = [[TGAccessoryManager sharedTGAccessoryManager] accessory]; 56 // if (accessory != nil) { 57 // [self logMessage:[NSString stringWithFormat:@"App opened with %@ connected. Starting data stream", accessory.name]]; 58 // [[TGAccessoryManager sharedTGAccessoryManager] startStream]; 59 // } 59 60 [self resetViews]; // just in case it didn't happen on close 60 61 } … … 135 136 // The headset was switched on, start the data stream 136 137 - (void)accessoryDidConnect:(EAAccessory *)accessory { 137 [self logMessage:[NSString stringWithFormat:@"%@ was connected to this device. Starting data stream...", [accessory name]]];138 [self logMessage:[NSString stringWithFormat:@"%@ connected to this device", [accessory name]]]; 138 139 if ([[TGAccessoryManager sharedTGAccessoryManager] accessory] != nil) { 139 140 [[TGAccessoryManager sharedTGAccessoryManager] startStream]; … … 144 145 // Reset the outputs back to zero 145 146 - (void)accessoryDidDisconnect { 146 [self logMessage:@"Accessory was disconnected ."];147 [self logMessage:@"Accessory was disconnected"]; 147 148 [self resetOutputToZero]; 148 149 } … … 221 222 - (void) playAudio 222 223 { 223 audioPlayer.volume = [self currentPowerLevel]; 224 [audioPlayer play]; 224 // audioPlayer.volume = [self currentPowerLevel]; 225 if ([self currentPowerLevel] > 0) { 226 audioPlayer.volume = 100; 227 [audioPlayer play]; 228 } else { 229 [audioPlayer stop]; 230 } 225 231 } 226 232 … … 245 251 [audioPlayer stop]; 246 252 } 253 [self logMessage:@"Demo stopped"]; 247 254 } 248 255 … … 288 295 } 289 296 } 297 298 - (void) startProcessing 299 { 300 processingDevice = YES; 301 [self logMessage:@"Connecting to EEG Headset"]; 302 [connectButton setTitle:@"Disconnect" forState:UIControlStateNormal]; 303 304 EAAccessory *accessory = [[TGAccessoryManager sharedTGAccessoryManager] accessory]; 305 if (accessory != nil) { 306 [self logMessage:[NSString stringWithFormat:@"EEG device %@ connected", accessory.name]]; 307 [[TGAccessoryManager sharedTGAccessoryManager] startStream]; 308 } 309 310 } 311 312 - (void) stopProcessing 313 { 314 processingDevice = NO; 315 [self logMessage:@"Disconnecting from EEG Headset"]; 316 if ([[TGAccessoryManager sharedTGAccessoryManager] connected]) { 317 [[TGAccessoryManager sharedTGAccessoryManager] stopStream]; 318 } 319 [connectButton setTitle:@"Connect" forState:UIControlStateNormal]; 320 321 [self resetOutputToZero]; 322 [audioPlayer stop]; 323 324 } 325 326 - (IBAction) connectButtonPressed:(id) sender { 327 328 if (processingDevice) { 329 [self stopProcessing]; 330 } else { 331 [self startProcessing]; 332 } 333 334 } 290 335 @end
Note: See TracChangeset
for help on using the changeset viewer.