Changeset 0ab8242 in orbit
- Timestamp:
- 08/01/13 08:33:40 (9 years ago)
- Branches:
- master, RawEEG, Servo, Tab_Interface, pyramid
- Children:
- c1c6a1d
- Parents:
- 4da9757 (diff), ce0a7ee (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 12 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
iOS/Orbit/Orbit/AppDelegate.m
r9015b1e rce0a7ee 21 21 { 22 22 // Override point for customization after application launch. 23 NSLog(@"didFinsihLaunching - signal convertor init");24 23 signalConverter = [[SignalConverter alloc] init]; 25 // [[TGAccessoryManager sharedTGAccessoryManager] setupManagerWithInterval:0.05];26 // [[TGAccessoryManager sharedTGAccessoryManager] setDelegate:(ViewController *)self.window.rootViewController];27 24 return YES; 28 25 } … … 32 29 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 33 30 // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 34 // ViewController *rootController = (ViewController *)self.window.rootViewController;35 // [rootController appClosed];36 31 [signalConverter appStopped]; 37 NSLog(@"Application will resign active - appClosed");38 32 } 39 33 … … 57 51 { 58 52 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 59 NSLog(@"Application will terminate - teardownManager");60 53 [[TGAccessoryManager sharedTGAccessoryManager] teardownManager]; 61 54 } -
iOS/Orbit/Orbit/SignalConverter.h
r9015b1e rce0a7ee 12 12 #import "TGAccessoryDelegate.h" 13 13 #import "SignalConverterDelegate.h" 14 #import "AudioGenerator.h" 14 15 15 16 @interface SignalConverter : NSObject <TGAccessoryDelegate> { 16 A VAudioPlayer *audioPlayer;17 AudioGenerator *audioPlayer; 17 18 } 18 19 … … 24 25 25 26 - (void) setValuesForAttention:(float) attention meditation:(float) meditation; 26 - (void) prepare;27 27 - (BOOL) startProcessing; 28 28 - (void) stopProcessing; … … 30 30 - (BOOL) isBluetoothReady; 31 31 - (BOOL) isVolumeMax; 32 - (void) setYaw:(int)y throttle:(int)t pitch:(int)p; 32 33 33 34 @end -
iOS/Orbit/Orbit/SignalConverter.m
r9015b1e rce0a7ee 27 27 28 28 int signalStrength, attentionLevel, meditationLevel; // the latest readings from the headset 29 int yaw, throttle, pitch; 29 30 } 30 31 … … 39 40 [[TGAccessoryManager sharedTGAccessoryManager] setupManagerWithInterval:0.05]; 40 41 [[TGAccessoryManager sharedTGAccessoryManager] setDelegate:self]; 42 audioPlayer = [[AudioGenerator alloc] init]; 43 44 // defaults 45 throttle = 80; 46 yaw = 78; 47 pitch = 31; 41 48 } 42 49 return self; … … 48 55 meditationThreshold = meditation; 49 56 [self calculatePowerValues]; 50 }51 52 - (void) prepare53 {54 NSURL *audioFilePath = [[NSBundle mainBundle] URLForResource:AUDIO_FILE_NAME withExtension:nil];55 audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFilePath error:nil];56 if (audioPlayer) {57 [audioPlayer prepareToPlay];58 }59 57 } 60 58 … … 142 140 { 143 141 float volume = [[AVAudioSession sharedInstance] outputVolume]; 144 // Float32 volume;145 // UInt32 dataSize = sizeof(Float32);146 //147 // AudioSessionGetProperty (148 // kAudioSessionProperty_CurrentHardwareOutputVolume,149 // &dataSize,150 // &volume151 // );152 142 return volume == 1.0; 153 143 } … … 171 161 { 172 162 [self appStopped]; 173 [self prepare];174 163 } 175 164 … … 187 176 } 188 177 178 - (void) setYaw:(int)y throttle:(int)t pitch:(int)p 179 { 180 yaw = y; 181 throttle = t; 182 pitch = p; 183 } 184 189 185 - (void) playAudio 190 186 { 191 // audioPlayer.volume = [self currentPowerLevel];192 187 if ([self currentPowerLevel] > 0) { 193 audioPlayer.volume = 1.0; 194 [audioPlayer play]; 188 [audioPlayer playWithThrottle:throttle yaw:yaw pitch:pitch]; 195 189 } else { 196 190 [audioPlayer stop]; 197 [self prepare];198 191 199 192 } … … 229 222 } 230 223 231 // calculate the checksum for the generated code used to generate the WAV array232 - (int) codeChecksum:(int)code233 {234 int checksum = 0;235 for (int i = 0; i < 7; i++) {236 checksum += (code >> 4*i) & 15;237 }238 return 16 - (checksum & 15);239 }240 241 // Generate the code used to create the WAV file based on the given throttle, yaw and pitch.242 // Copied from AudioService.java in the Android app243 // throttle: 0~127, nothing will happen if this value is below 30.244 // yaw: 0~127, normally 78 will keep orbit from rotating.245 // pitch: 0~63, normally 31 will stop the top propeller.246 // channel: 1=Channel A, 0=Channel B 2= Channel C, depend on which channel you want to pair to the orbit. You can fly at most 3 orbit in a same room.247 - (int) generateCodeFromThrottle: (int)throttle yaw: (int)yaw pitch: (int)pitch channel: (int)channel248 {249 int code = (throttle << 21) + 1048576 + (yaw << 12) + (pitch << 4) + (((channel >> 1) & 1) << 19) + ((channel & 1) << 11);250 return code;// + codeChecksum(code);251 }252 253 224 @end -
iOS/Orbit/Orbit/controllers/AdvancedViewController.m
rab9d63b rce0a7ee 8 8 9 9 #import "AdvancedViewController.h" 10 #import "SignalConverter.h" 11 #import "AppDelegate.h" 10 12 11 13 @interface AdvancedViewController () … … 13 15 @end 14 16 15 @implementation AdvancedViewController 17 @implementation AdvancedViewController { 18 SignalConverter *signalConverter; 19 } 16 20 17 21 @synthesize pitch, pitchPercent, yaw, yawPercent, throttle, throttlePercent; 22 23 - (void)viewDidLoad 24 { 25 [super viewDidLoad]; 26 AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 27 signalConverter = appDelegate.signalConverter; 28 } 18 29 19 30 - (IBAction) pitchChanged:(id) sender 20 31 { 21 32 pitchPercent.text = [self percentStringFromSlider:pitch]; 33 [self adjustValues]; 22 34 } 23 35 … … 25 37 { 26 38 yawPercent.text = [self percentStringFromSlider:yaw]; 39 [self adjustValues]; 27 40 } 28 41 … … 30 43 { 31 44 throttlePercent.text = [self percentStringFromSlider:throttle]; 45 [self adjustValues]; 32 46 } 33 47 … … 37 51 } 38 52 53 - (void) adjustValues 54 { 55 56 } 57 39 58 @end -
iOS/Orbit/Orbit/controllers/FlightViewController.m
r9015b1e rce0a7ee 23 23 @implementation FlightViewController { 24 24 SignalConverter *signalConverter; 25 int deviceStatus; 25 int deviceStatus; 26 26 } 27 27 … … 37 37 [self.attentionThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 38 38 [self.meditationThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 39 [signalConverter prepare];40 39 } 41 40 … … 151 150 } else if ([signalConverter startProcessing]) { 152 151 [self logMessage:@"Searching for device"]; 153 // [self updateStatusImage:STATUS_CONNECTING];154 152 connectButton.title = @"Disconnect"; 155 153 } else { -
iOS/Orbit/Orbit/controllers/SupportViewController.m
rab9d63b rce0a7ee 33 33 } 34 34 35 - (void)didReceiveMemoryWarning36 {37 [super didReceiveMemoryWarning];38 // Dispose of any resources that can be recreated.39 }40 41 35 #pragma mark UIWebViewDelegate methods 42 36 43 - (void)webViewDid StartLoad:(UIWebView *)webView37 - (void)webViewDidFinishLoad:(UIWebView *)webView 44 38 { 45 39 retryButton.hidden = YES; -
iOS/Orbit/Orbit/controllers/TutorialViewController.m
rab9d63b rce0a7ee 11 11 @implementation TutorialViewController 12 12 13 @synthesize webView; 13 14 14 15 - (void)viewDidLoad 15 16 { 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]; 16 20 [super viewDidLoad]; 17 18 21 } 19 22 @end -
iOS/Orbit/Orbit/en.lproj/MainStoryboard.storyboard
r9015b1e rce0a7ee 46 46 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 47 47 </view> 48 <tabBarItem key="tabBarItem" title="Support" i d="cac-uP-cgJ"/>48 <tabBarItem key="tabBarItem" title="Support" image="help.png" id="cac-uP-cgJ"/> 49 49 <connections> 50 50 <outlet property="retryButton" destination="ito-kx-zLv" id="yP6-IV-eHf"/> … … 195 195 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 196 196 </view> 197 <tabBarItem key="tabBarItem" title="Advanced" i d="cd7-uP-s8P"/>197 <tabBarItem key="tabBarItem" title="Advanced" image="advanced.png" id="cd7-uP-s8P"/> 198 198 <connections> 199 199 <outlet property="pitch" destination="pE4-wd-89x" id="Sbm-iD-GAE"/> … … 382 382 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 383 383 </view> 384 <tabBarItem key="tabBarItem" title="Flight" i d="ysb-Df-cyR"/>384 <tabBarItem key="tabBarItem" title="Flight" image="plane.png" id="ysb-Df-cyR"/> 385 385 <navigationItem key="navigationItem" id="iTN-dz-EXc"/> 386 386 <connections> … … 423 423 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 424 424 <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/> 425 <dataDetectorType key="dataDetectorTypes"/> 425 426 <connections> 426 427 <outlet property="delegate" destination="Wc6-MU-jew" id="cBE-hV-4Fe"/> … … 430 431 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> 431 432 </view> 432 <tabBarItem key="tabBarItem" title="Tutorial" id="JJR-hA-hnf"/> 433 <tabBarItem key="tabBarItem" title="Tutorial" image="tutorial.png" id="JJR-hA-hnf"/> 434 <connections> 435 <outlet property="webView" destination="yFF-oy-BYh" id="UOH-dC-3Mk"/> 436 </connections> 433 437 </viewController> 434 438 <placeholder placeholderIdentifier="IBFirstResponder" id="phY-I4-vyg" userLabel="First Responder" sceneMemberID="firstResponder"/> … … 459 463 </scenes> 460 464 <resources> 465 <image name="advanced.png" width="20" height="20"/> 466 <image name="help.png" width="20" height="20"/> 467 <image name="plane.png" width="20" height="20"/> 461 468 <image name="status_0.png" width="238" height="213"/> 469 <image name="tutorial.png" width="20" height="20"/> 462 470 </resources> 463 471 <classes> -
iOS/Orbit/orbit.xcodeproj/project.pbxproj
r9015b1e rce0a7ee 8 8 9 9 /* Begin PBXBuildFile section */ 10 280D2AB517A802DB002D6863 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = 280D2AB417A802DB002D6863 /* index.html */; }; 11 280D2ABE17A81714002D6863 /* advanced.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2AB617A81714002D6863 /* advanced.png */; }; 12 280D2ABF17A81714002D6863 /* advanced@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2AB717A81714002D6863 /* advanced@2x.png */; }; 13 280D2AC017A81714002D6863 /* help.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2AB817A81714002D6863 /* help.png */; }; 14 280D2AC117A81714002D6863 /* help@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2AB917A81714002D6863 /* help@2x.png */; }; 15 280D2AC217A81714002D6863 /* plane.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2ABA17A81714002D6863 /* plane.png */; }; 16 280D2AC317A81714002D6863 /* plane@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2ABB17A81714002D6863 /* plane@2x.png */; }; 17 280D2AC417A81714002D6863 /* tutorial.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2ABC17A81714002D6863 /* tutorial.png */; }; 18 280D2AC517A81714002D6863 /* tutorial@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 280D2ABD17A81714002D6863 /* tutorial@2x.png */; }; 10 19 2815BC0E167F42F500F7E6DA /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2815BC0C167F42F500F7E6DA /* Accelerate.framework */; }; 11 20 2815BC0F167F42F500F7E6DA /* ExternalAccessory.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2815BC0D167F42F500F7E6DA /* ExternalAccessory.framework */; }; … … 29 38 2843FE8F1790205900C79D56 /* status_4.png in Resources */ = {isa = PBXBuildFile; fileRef = 2843FE871790205900C79D56 /* status_4.png */; }; 30 39 2843FE901790205900C79D56 /* status_4@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2843FE881790205900C79D56 /* status_4@2x.png */; }; 40 286608E417A7D40F003FA806 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 286608E317A7D40F003FA806 /* AudioToolbox.framework */; }; 31 41 288B4BC0178EB112007D588D /* status_0@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 288B4BBF178EB112007D588D /* status_0@2x.png */; }; 32 42 288B4BC3178ECD0B007D588D /* AdvancedViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 288B4BC2178ECD0B007D588D /* AdvancedViewController.m */; }; … … 39 49 28C10EF1168760CA00ECFD59 /* HOW_TO_USE.txt in Resources */ = {isa = PBXBuildFile; fileRef = 28C10EF0168760CA00ECFD59 /* HOW_TO_USE.txt */; }; 40 50 28F901301799436F003FB5ED /* CoreBluetooth.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F9012F1799436F003FB5ED /* CoreBluetooth.framework */; }; 51 28F90133179973EC003FB5ED /* AudioGenerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 28F90132179973EC003FB5ED /* AudioGenerator.m */; }; 41 52 52922BA817004D1400A39146 /* libCorePlot-CocoaTouch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 52922BA717004D1400A39146 /* libCorePlot-CocoaTouch.a */; }; 42 53 52FA364416899B5D004C280A /* ic_launcher-57x57.png in Resources */ = {isa = PBXBuildFile; fileRef = 52FA364316899B5D004C280A /* ic_launcher-57x57.png */; }; … … 46 57 47 58 /* Begin PBXFileReference section */ 59 280D2AB417A802DB002D6863 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = "<group>"; }; 60 280D2AB617A81714002D6863 /* advanced.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = advanced.png; sourceTree = "<group>"; }; 61 280D2AB717A81714002D6863 /* advanced@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "advanced@2x.png"; sourceTree = "<group>"; }; 62 280D2AB817A81714002D6863 /* help.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = help.png; sourceTree = "<group>"; }; 63 280D2AB917A81714002D6863 /* help@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "help@2x.png"; sourceTree = "<group>"; }; 64 280D2ABA17A81714002D6863 /* plane.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = plane.png; sourceTree = "<group>"; }; 65 280D2ABB17A81714002D6863 /* plane@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "plane@2x.png"; sourceTree = "<group>"; }; 66 280D2ABC17A81714002D6863 /* tutorial.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tutorial.png; sourceTree = "<group>"; }; 67 280D2ABD17A81714002D6863 /* tutorial@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tutorial@2x.png"; sourceTree = "<group>"; }; 48 68 2815BC0C167F42F500F7E6DA /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 49 69 2815BC0D167F42F500F7E6DA /* ExternalAccessory.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ExternalAccessory.framework; path = System/Library/Frameworks/ExternalAccessory.framework; sourceTree = SDKROOT; }; … … 74 94 2843FE871790205900C79D56 /* status_4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = status_4.png; sourceTree = "<group>"; }; 75 95 2843FE881790205900C79D56 /* status_4@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "status_4@2x.png"; sourceTree = "<group>"; }; 96 286608E317A7D40F003FA806 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 76 97 288B4BBF178EB112007D588D /* status_0@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "status_0@2x.png"; sourceTree = "<group>"; }; 77 98 288B4BC1178ECD0A007D588D /* AdvancedViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AdvancedViewController.h; path = controllers/AdvancedViewController.h; sourceTree = "<group>"; }; … … 90 111 28C10EF0168760CA00ECFD59 /* HOW_TO_USE.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HOW_TO_USE.txt; sourceTree = "<group>"; }; 91 112 28F9012F1799436F003FB5ED /* CoreBluetooth.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreBluetooth.framework; path = System/Library/Frameworks/CoreBluetooth.framework; sourceTree = SDKROOT; }; 113 28F90131179973EC003FB5ED /* AudioGenerator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AudioGenerator.h; sourceTree = "<group>"; }; 114 28F90132179973EC003FB5ED /* AudioGenerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AudioGenerator.m; sourceTree = "<group>"; }; 92 115 52922BA717004D1400A39146 /* libCorePlot-CocoaTouch.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = "libCorePlot-CocoaTouch.a"; sourceTree = "<group>"; }; 93 116 52922BA917004D4400A39146 /* CorePlot-CocoaTouch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CorePlot-CocoaTouch.h"; sourceTree = "<group>"; }; … … 176 199 buildActionMask = 2147483647; 177 200 files = ( 201 286608E417A7D40F003FA806 /* AudioToolbox.framework in Frameworks */, 178 202 28F901301799436F003FB5ED /* CoreBluetooth.framework in Frameworks */, 179 203 52922BA817004D1400A39146 /* libCorePlot-CocoaTouch.a in Frameworks */, … … 192 216 193 217 /* Begin PBXGroup section */ 218 280D2AB317A802C7002D6863 /* Tutorial */ = { 219 isa = PBXGroup; 220 children = ( 221 280D2AB417A802DB002D6863 /* index.html */, 222 ); 223 name = Tutorial; 224 sourceTree = "<group>"; 225 }; 194 226 2815BC08167F428B00F7E6DA /* Libraries */ = { 195 227 isa = PBXGroup; … … 208 240 isa = PBXGroup; 209 241 children = ( 242 280D2AB317A802C7002D6863 /* Tutorial */, 243 286608E317A7D40F003FA806 /* AudioToolbox.framework */, 210 244 28F9012F1799436F003FB5ED /* CoreBluetooth.framework */, 211 245 289C7D0F178D7A21005C08EC /* Images */, … … 263 297 288B4BC8178F016F007D588D /* SignalConverter.m */, 264 298 288B4BCA178F0842007D588D /* SignalConverterDelegate.h */, 299 28F90131179973EC003FB5ED /* AudioGenerator.h */, 300 28F90132179973EC003FB5ED /* AudioGenerator.m */, 265 301 ); 266 302 path = Orbit; … … 282 318 isa = PBXGroup; 283 319 children = ( 320 280D2AB617A81714002D6863 /* advanced.png */, 321 280D2AB717A81714002D6863 /* advanced@2x.png */, 322 280D2AB817A81714002D6863 /* help.png */, 323 280D2AB917A81714002D6863 /* help@2x.png */, 324 280D2ABA17A81714002D6863 /* plane.png */, 325 280D2ABB17A81714002D6863 /* plane@2x.png */, 326 280D2ABC17A81714002D6863 /* tutorial.png */, 327 280D2ABD17A81714002D6863 /* tutorial@2x.png */, 284 328 289C7D14178D7A34005C08EC /* status_0.png */, 285 329 288B4BBF178EB112007D588D /* status_0@2x.png */, … … 445 489 2843FE8F1790205900C79D56 /* status_4.png in Resources */, 446 490 2843FE901790205900C79D56 /* status_4@2x.png in Resources */, 491 280D2AB517A802DB002D6863 /* index.html in Resources */, 492 280D2ABE17A81714002D6863 /* advanced.png in Resources */, 493 280D2ABF17A81714002D6863 /* advanced@2x.png in Resources */, 494 280D2AC017A81714002D6863 /* help.png in Resources */, 495 280D2AC117A81714002D6863 /* help@2x.png in Resources */, 496 280D2AC217A81714002D6863 /* plane.png in Resources */, 497 280D2AC317A81714002D6863 /* plane@2x.png in Resources */, 498 280D2AC417A81714002D6863 /* tutorial.png in Resources */, 499 280D2AC517A81714002D6863 /* tutorial@2x.png in Resources */, 447 500 ); 448 501 runOnlyForDeploymentPostprocessing = 0; … … 463 516 288B4BC6178ED362007D588D /* SupportViewController.m in Sources */, 464 517 288B4BC9178F016F007D588D /* SignalConverter.m in Sources */, 518 28F90133179973EC003FB5ED /* AudioGenerator.m in Sources */, 465 519 ); 466 520 runOnlyForDeploymentPostprocessing = 0; -
android/.classpath
rd6fbdfb r4f3fd92 8 8 <classpathentry kind="src" path="src"/> 9 9 <classpathentry kind="src" path="gen"/> 10 <classpathentry exported="true" kind="lib" path="libs/androidplot-core-0.6.0.jar"/> 10 11 <classpathentry kind="output" path="bin/classes"/> 11 12 </classpath> -
android/AndroidManifest.xml
rc298bcb r81fb7d8 2 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 3 package="info.puzzlebox.orbit" 4 android:versionCode=" 2"5 android:versionName="1.2. 0" >4 android:versionCode="3" 5 android:versionName="1.2.2" > 6 6 7 7 <uses-sdk 8 8 android:minSdkVersion="8" 9 android:targetSdkVersion="1 5" />9 android:targetSdkVersion="17" /> 10 10 11 11 <uses-permission android:name="android.permission.BLUETOOTH" /> … … 17 17 android:icon="@drawable/ic_launcher" 18 18 android:label="@string/app_name" 19 android:theme="@style/AppTheme" > 19 android:theme="@style/AppTheme" 20 android:allowBackup="true" > 21 20 22 <activity 21 23 android:name=".OrbitActivity" -
android/res/layout-large/activity_main.xml
r5c11ea9 r81fb7d8 45 45 android:layout_height="wrap_content" 46 46 android:max="100" 47 android:progress=" 82"47 android:progress="0" 48 48 android:progressDrawable="@xml/progress_drawable" 49 49 android:thumb="@xml/thumb_drawable" /> … … 124 124 android:text="@string/checkbox_advanced_options" /> 125 125 </LinearLayout> 126 127 <com.androidplot.xy.XYPlot 128 android:id="@+id/eegRawHistoryPlot" 129 android:layout_width="fill_parent" 130 android:layout_height="200dp" 131 android:layout_marginLeft="0dp" 132 android:layout_marginRight="0dp" 133 android:layout_marginTop="0dp" 134 android:layout_weight="1" 135 title="EEG Raw Wave" /> 126 136 127 137 <LinearLayout -
android/res/layout-small/activity_main.xml
r8358488 r81fb7d8 45 45 android:layout_height="wrap_content" 46 46 android:max="100" 47 android:progress=" 82"47 android:progress="0" 48 48 android:progressDrawable="@xml/progress_drawable" 49 49 android:thumb="@xml/thumb_drawable" /> … … 127 127 android:text="@string/checkbox_advanced_options" /> 128 128 </LinearLayout> 129 130 <com.androidplot.xy.XYPlot 131 android:id="@+id/eegRawHistoryPlot" 132 android:layout_width="fill_parent" 133 android:layout_height="100dp" 134 android:layout_marginLeft="0dp" 135 android:layout_marginRight="0dp" 136 android:layout_marginTop="0dp" 137 android:layout_weight="1" 138 title="EEG Raw Wave" /> 129 139 130 140 <LinearLayout -
android/res/layout-xlarge/activity_main.xml
r8358488 r81fb7d8 45 45 android:layout_height="wrap_content" 46 46 android:max="100" 47 android:progress=" 82"47 android:progress="0" 48 48 android:progressDrawable="@xml/progress_drawable" 49 49 android:thumb="@xml/thumb_drawable" /> … … 124 124 android:text="@string/checkbox_advanced_options" /> 125 125 </LinearLayout> 126 127 <com.androidplot.xy.XYPlot 128 android:id="@+id/eegRawHistoryPlot" 129 android:layout_width="fill_parent" 130 android:layout_height="200dp" 131 android:layout_marginLeft="0dp" 132 android:layout_marginRight="0dp" 133 android:layout_marginTop="0dp" 134 android:layout_weight="1" 135 title="EEG Raw Wave" /> 126 136 127 137 <LinearLayout -
android/res/layout/activity_main.xml
r5c11ea9 r81fb7d8 45 45 android:layout_height="wrap_content" 46 46 android:max="100" 47 android:progress=" 82"47 android:progress="0" 48 48 android:progressDrawable="@xml/progress_drawable" 49 49 android:thumb="@xml/thumb_drawable" /> … … 127 127 android:text="@string/checkbox_advanced_options" /> 128 128 </LinearLayout> 129 130 <com.androidplot.xy.XYPlot 131 android:id="@+id/eegRawHistoryPlot" 132 android:layout_width="fill_parent" 133 android:layout_height="100dp" 134 android:layout_marginLeft="0dp" 135 android:layout_marginRight="0dp" 136 android:layout_marginTop="0dp" 137 android:layout_weight="1" 138 title="EEG Raw Wave" /> 129 139 130 140 <LinearLayout -
android/src/info/puzzlebox/orbit/OrbitActivity.java
rd6fbdfb r4da9757 14 14 * all USB Serial support to OrbitUSBActivity. 15 15 */ 16 17 import java.text.DecimalFormat; 18 import java.util.Arrays; 16 19 17 20 import android.media.AudioManager; … … 55 58 import com.neurosky.thinkgear.TGDevice; 56 59 60 import com.androidplot.xy.*; 61 57 62 58 63 public class OrbitActivity extends Activity implements SeekBar.OnSeekBarChangeListener { … … 68 73 boolean eegConnecting = false; 69 74 boolean demoFlightMode = false; 75 Number[] rawEEG = new Number[512]; 76 int arrayIndex = 0; 70 77 71 78 … … 97 104 int viewSpaceGenerateAudioWidth = 120; 98 105 106 private static final int EEG_RAW_HISTORY_SIZE = 512; // number of points to plot in EEG history 107 private XYPlot eegRawHistoryPlot = null; 108 private SimpleXYSeries eegRawHistorySeries = null; 109 110 99 111 LinearLayout layoutControl; 100 112 LinearLayout layoutAudioService; … … 154 166 int maximumPower = 100; // maximum power for the helicopter throttle 155 167 String currentCommand = "neutral"; 156 final boolean rawEnabled = false; 168 // final boolean rawEnabled = false; 169 final boolean rawEnabled = true; 157 170 158 171 … … 228 241 progressBarPower.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.progress_horizontal)); 229 242 243 244 // setup the Raw EEG History plot 245 eegRawHistoryPlot = (XYPlot) findViewById(R.id.eegRawHistoryPlot); 246 eegRawHistorySeries = new SimpleXYSeries("Raw EEG"); 247 248 // Use index value as xVal, instead of explicit, user provided xVals. 249 // eegRawHistorySeries.useImplicitXVals(); 250 251 // Setup the boundary mode, boundary values only applicable in FIXED mode. 252 eegRawHistoryPlot.setDomainBoundaries(0, EEG_RAW_HISTORY_SIZE, BoundaryMode.FIXED); 253 // eegRawHistoryPlot.setDomainBoundaries(0, EEG_RAW_HISTORY_SIZE, BoundaryMode.AUTO); 254 // eegRawHistoryPlot.setRangeBoundaries(-32767, 32767, BoundaryMode.FIXED); 255 // eegRawHistoryPlot.setRangeBoundaries(-32767, 32767, BoundaryMode.AUTO); 256 eegRawHistoryPlot.setRangeBoundaries(-256, 256, BoundaryMode.GROW); 257 258 eegRawHistoryPlot.addSeries(eegRawHistorySeries, new LineAndPointFormatter(Color.rgb(200, 100, 100), Color.BLACK, null, null)); 259 260 // Thin out domain and range tick values so they don't overlap 261 eegRawHistoryPlot.setDomainStepValue(5); 262 eegRawHistoryPlot.setTicksPerRangeLabel(3); 263 264 // eegRawHistoryPlot.setRangeLabel("Amplitude"); 265 266 // Sets the dimensions of the widget to exactly contain the text contents 267 eegRawHistoryPlot.getDomainLabelWidget().pack(); 268 eegRawHistoryPlot.getRangeLabelWidget().pack(); 269 270 // Only display whole numbers in labels 271 eegRawHistoryPlot.getGraphWidget().setDomainValueFormat(new DecimalFormat("0")); 272 eegRawHistoryPlot.getGraphWidget().setRangeValueFormat(new DecimalFormat("0")); 273 274 // Hide domain and range labels 275 eegRawHistoryPlot.getGraphWidget().setDomainLabelWidth(0); 276 eegRawHistoryPlot.getGraphWidget().setRangeLabelWidth(0); 277 278 // Hide legend 279 eegRawHistoryPlot.getLegendWidget().setVisible(false); 280 281 // setGridPadding(float left, float top, float right, float bottom) 282 eegRawHistoryPlot.getGraphWidget().setGridPadding(0, 0, 0, 0); 283 284 // eegRawHistoryPlot.getGraphWidget().setDrawMarkersEnabled(false); 285 286 // final PlotStatistics histStats = new PlotStatistics(1000, false); 287 // eegRawHistoryPlot.addListener(histStats); 288 289 230 290 seekBarAttention = (SeekBar)findViewById(R.id.seekBarAttention); 231 291 seekBarAttention.setOnSeekBarChangeListener(this); … … 266 326 tv.setMovementMethod(new ScrollingMovementMethod()); 267 327 tv.setText(""); 268 appendTextAndScroll("Android version: " + Integer.valueOf(android.os.Build.VERSION.SDK ) + "\n" );328 appendTextAndScroll("Android version: " + Integer.valueOf(android.os.Build.VERSION.SDK_INT) + "\n" ); 269 329 appendTextAndScroll("Remember to set volume at maximum!\n"); 270 330 … … 445 505 // viewSpaceGenerateAudioWidth = LayoutParams.MATCH_PARENT; 446 506 507 @SuppressWarnings("deprecation") 447 508 int width = getWindowManager().getDefaultDisplay().getWidth(); 448 int height = getWindowManager().getDefaultDisplay().getHeight();509 // int height = getWindowManager().getDefaultDisplay().getHeight(); 449 510 450 511 viewSpaceGenerateAudioWidth = width / 4; // approximate center of screen … … 487 548 488 549 if (checkBoxGenerateAudio.isChecked()) { 550 489 551 layoutAudioService.setVisibility(View.VISIBLE); 490 552 layoutInvertControlSignal.setVisibility(View.VISIBLE); … … 496 558 497 559 } else { 560 498 561 layoutAudioService.setVisibility(View.GONE); 499 562 layoutInvertControlSignal.setVisibility(View.GONE); … … 506 569 } 507 570 571 eegRawHistoryPlot.setVisibility(View.VISIBLE); 508 572 layoutAdvancedOptions.setVisibility(View.VISIBLE); 573 imageViewStatus.setVisibility(View.GONE); 509 574 tv.setVisibility(View.VISIBLE); 510 575 511 576 } else { 512 577 578 eegRawHistoryPlot.setVisibility(View.GONE); 513 579 layoutAudioService.setVisibility(View.GONE); 514 580 layoutAdvancedOptions.setVisibility(View.GONE); 581 imageViewStatus.setVisibility(View.VISIBLE); 515 582 tv.setVisibility(View.GONE); 516 583 … … 689 756 break; 690 757 case TGDevice.MSG_RAW_DATA: 691 //raw1 = msg.arg1; 692 //tv.append("Got raw: " + msg.arg1 + "\n"); 758 759 rawEEG[arrayIndex] = msg.arg1; 760 arrayIndex = arrayIndex + 1; 761 762 if (arrayIndex == EEG_RAW_HISTORY_SIZE - 1) 763 updateEEGRawHistory(); 764 693 765 break; 694 766 case TGDevice.MSG_HEART_RATE: … … 938 1010 * which is used to fly the helicopter 939 1011 */ 940 941 942 943 944 945 946 947 1012 1013 // Set Attention and Meditation to zero if we've lost signal 1014 if (eegSignal < 100) { 1015 eegAttention = 0; 1016 eegMeditation = 0; 1017 progressBarAttention.setProgress(eegAttention); 1018 progressBarMeditation.setProgress(eegMeditation); 1019 } 948 1020 949 1021 eegPower = calculateSpeed(); … … 976 1048 977 1049 } // updatePower 1050 1051 1052 // ################################################################ 1053 1054 public void updateEEGRawHistory() { 1055 1056 eegRawHistoryPlot.removeSeries(eegRawHistorySeries); 1057 1058 eegRawHistorySeries = new SimpleXYSeries(Arrays.asList(rawEEG), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "Raw EEG"); 1059 1060 // LineAndPointFormatter format = new LineAndPointFormatter(Color.rgb(200, 100, 100), Color.BLACK, null, null); 1061 // LineAndPointFormatter format = new LineAndPointFormatter(Color.rgb(200, 100, 100), Color.TRANSPARENT, null, null); 1062 LineAndPointFormatter format = new LineAndPointFormatter(Color.rgb(0, 0, 0), Color.TRANSPARENT, null, null); 1063 1064 // format.getFillPaint().setAlpha(220); 1065 1066 eegRawHistoryPlot.addSeries(eegRawHistorySeries, format); 1067 1068 1069 // redraw the Plots: 1070 eegRawHistoryPlot.redraw(); 1071 1072 rawEEG = new Number[512]; 1073 arrayIndex = 0; 1074 1075 } 978 1076 979 1077
Note: See TracChangeset
for help on using the changeset viewer.