Changeset fc960da in orbit


Ignore:
Timestamp:
01/10/14 20:42:19 (6 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo
Children:
a2742af
Parents:
2246ba0
Message:
Location:
iOS/Orbit
Files:
5 added
8 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/AppDelegate.h

    r876e42b rfc960da  
    1414#import "SignalConverter.h" 
    1515 
    16 @interface AppDelegate : UIResponder <UIApplicationDelegate> 
     16#import "AppDelegateProtocol.h" 
     17 
     18@class HistoryAppDataObject; 
     19 
     20@interface AppDelegate : UIResponder <UIApplicationDelegate> { 
     21   HistoryAppDataObject* theAppDataObject; 
     22} 
     23 
     24//@interface ViewControllerDataSharingAppDelegate : NSObject <UIApplicationDelegate, AppDelegateProtocol> 
     25//{ 
     26//   UIWindow *window; 
     27//   UINavigationController *navigationController; 
     28//      ExampleAppDataObject* theAppDataObject; 
     29//      IBOutlet SecondViewController* theSecondViewController; 
     30//} 
    1731 
    1832@property (strong, nonatomic) UIWindow *window; 
     
    2034@property (nonatomic, retain) SignalConverter *signalConverter; 
    2135 
     36@property (nonatomic, retain) HistoryAppDataObject* theAppDataObject; 
     37 
    2238@end 
  • iOS/Orbit/Orbit/AppDelegate.m

    r876e42b rfc960da  
    1313#import "SignalConverter.h" 
    1414 
     15#import "AppDelegateProtocol.h" 
     16#import "HistoryAppDataObject.h" 
     17 
    1518@implementation AppDelegate 
    1619 
    1720@synthesize signalConverter; 
     21@synthesize theAppDataObject; 
    1822 
    1923- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
     
    5357} 
    5458 
    55 //- (CMMotionManager *)motionManager 
    56 //{ 
    57 //   if (!motionManager) motionManager = [[CMMotionManager alloc] init]; 
    58 //   return motionManager; 
    59 //} 
     59#pragma mark - 
     60#pragma mark Memory management 
     61 
     62- (id) init; 
     63{ 
     64        self.theAppDataObject = [[HistoryAppDataObject alloc] init]; 
     65//      [theAppDataObject release]; 
     66        return [super init]; 
     67} 
    6068 
    6169@end 
  • iOS/Orbit/Orbit/SignalConverter.h

    r2246ba0 rfc960da  
    6363- (void) prepareAudio; 
    6464 
     65//- (int[30]) getAttentionHistory; 
     66- (int) getAttentionHistory:(int) index; 
     67 
    6568@end 
  • iOS/Orbit/Orbit/SignalConverter.m

    r2246ba0 rfc960da  
    1212#import "SignalConverter.h" 
    1313 
     14#import "HistoryAppDataObject.h" 
     15#import "AppDelegateProtocol.h" 
     16 
    1417#define AUDIO_FILE_NAME @"throttle_hover_ios.wav" // @"iOS_noflip.wav" 
    1518#define POOR_SIGNAL_KEY @"poorSignal" 
     
    3336     
    3437    int historyAttention[30]; 
    35     int historyAttentionIndex; 
    3638    int historyMeditation[30]; 
    37     int historyMeditationIndex; 
    38      
    39 //    _historyAttention = [NSArray arrayWithObjects:[NSNumber numberWithFloat:6.9]]; 
    40      
    41  
     39    int historyIndex; 
    4240     
    4341} 
     
    6159        pitch = 31; 
    6260         
    63         historyAttentionIndex = 0; 
    64         historyMeditationIndex = 0; 
     61        historyIndex = 0; 
    6562         
    6663        // initialise the audio session - this should only be done once 
     
    6865        AudioSessionSetActive(YES); 
    6966         
    70 //        NSArray *tempFood = [[NSArray alloc] initWithArray:[self returnOtherArray]]; 
    71 //        NSArray *tempFood = [[NSArray alloc] arrayWithObjects:[NSNumber numberWithFloat:6.9]]]; 
    72          
    73 //        _historyAttention = tempFood; 
    74          
    7567#if USE_AUDIO_GENERATOR 
    7668        audioPlayer = [[AudioGenerator alloc] init]; 
     
    7870    } 
    7971    return self; 
     72} 
     73 
     74#pragma mark - 
     75#pragma mark instance methods 
     76 
     77- (HistoryAppDataObject*) theAppDataObject; 
     78{ 
     79    id<AppDelegateProtocol> theDelegate = (id<AppDelegateProtocol>) [UIApplication sharedApplication].delegate; 
     80    HistoryAppDataObject* theDataObject; 
     81    theDataObject = (HistoryAppDataObject*) theDelegate.theAppDataObject; 
     82    return theDataObject; 
    8083} 
    8184 
     
    129132    [self setMeditationLevel:(NSNumber *)[data valueForKey:MEDITATION_KEY]]; 
    130133     
    131     historyAttention[historyAttentionIndex] = attentionLevel; 
    132     historyMeditation[historyMeditationIndex] = meditationLevel; 
    133      
    134     historyAttentionIndex = historyAttentionIndex + 1; 
    135     historyMeditationIndex = historyMeditationIndex + 1; 
    136      
    137     if (historyAttentionIndex == 30) { 
    138         NSLog(@"Attention Array Full"); 
    139         historyAttentionIndex = 0; 
    140         historyMeditationIndex = 0; 
     134    historyAttention[historyIndex] = attentionLevel; 
     135    historyMeditation[historyIndex] = meditationLevel; 
     136     
     137    historyIndex = historyIndex + 1; 
     138     
     139    HistoryAppDataObject* theDataObject = [self theAppDataObject]; 
     140    theDataObject.lastAttention = attentionLevel; 
     141    theDataObject.lastMeditation = meditationLevel; 
     142 
     143     
     144    if (historyIndex == 30) { 
     145        NSLog(@"History Arrays Full"); 
     146        historyIndex = 0; 
    141147         
    142148        for (int i=0; i<30; i++){ 
    143             NSLog(@"%d: %d", i, historyAttention[i]); 
     149            NSLog(@"%d: %d", i, historyMeditation[i]); 
    144150        } 
    145151         
     
    407413} 
    408414 
     415- (int) getAttentionHistory:(int) index 
     416{ 
     417    return historyAttention[index]; 
     418} 
     419 
    409420@end 
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    r2246ba0 rfc960da  
    1515#import "SignalConverter.h" 
    1616 
    17 #import "StatisticsViewController.h" 
     17//#import "StatisticsViewController.h" 
     18 
     19//#import "HistoryAppDataObject.h" 
     20//#import "AppDelegateProtocol.h" 
    1821 
    1922#define STATUS_DEFAULT 0 
     
    3033 
    3134@synthesize attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, testButton, statusImage, signalPercent, attentionPercent, meditationPercent, powerPercent; 
     35 
     36//- (HistoryAppDataObject*) theAppDataObject; 
     37//{ 
     38//      id<AppDelegateProtocol> theDelegate = (id<AppDelegateProtocol>) [UIApplication sharedApplication].delegate; 
     39//      HistoryAppDataObject* theDataObject; 
     40//      theDataObject = (HistoryAppDataObject*) theDelegate.theAppDataObject; 
     41//      return theDataObject; 
     42//} 
    3243 
    3344- (void)viewDidLoad 
  • iOS/Orbit/Orbit/controllers/StatisticsViewController.h

    r2246ba0 rfc960da  
    44// 
    55//  Copyright (c) 2013 Puzzlebox Productions, LLC. All rights reserved. 
    6 //  Originally created by Steve Castellotti. 
     6// 
     7//  With thanks to Ray Wenderlich 
     8//  http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2 
    79// 
    810//  This code is released under the GNU Public License (GPL) version 2 
  • iOS/Orbit/Orbit/controllers/StatisticsViewController.m

    r2246ba0 rfc960da  
    44// 
    55//  Copyright (c) 2013 Puzzlebox Productions, LLC. All rights reserved. 
    6 //  Originally created by Steve Castellotti. 
    76// 
    87//  With thanks to Ray Wenderlich 
    98//  http://www.raywenderlich.com/13271/how-to-draw-graphs-with-core-plot-part-2 
    109// 
    11 // 
    1210//  This code is released under the GNU Public License (GPL) version 2 
    1311//  For more information please refer to http://www.gnu.org/copyleft/gpl.html 
     
    1614#import "StatisticsViewController.h" 
    1715#import "AppDelegate.h" 
     16 
     17#import "SignalConverter.h" 
     18 
     19#import "HistoryAppDataObject.h" 
     20#import "AppDelegateProtocol.h" 
    1821 
    1922@implementation StatisticsViewController 
     
    2730//} 
    2831 
     32//#pragma mark - 
     33//#pragma mark instance methods 
     34 
     35- (HistoryAppDataObject*) theAppDataObject; 
     36{ 
     37        id<AppDelegateProtocol> theDelegate = (id<AppDelegateProtocol>) [UIApplication sharedApplication].delegate; 
     38        HistoryAppDataObject* theDataObject; 
     39        theDataObject = (HistoryAppDataObject*) theDelegate.theAppDataObject; 
     40        return theDataObject; 
     41} 
     42 
    2943- (void)didReceiveMemoryWarning 
    3044{ 
     
    3852   [self initPlot]; 
    3953} 
     54 
     55//- (void)viewWillAppear:(BOOL)animated 
     56//{ 
     57////    HistoryAppDataObject* theDataObject = [self theAppDataObject]; 
     58////    theInputView.text = theDataObject.string1; 
     59////    theSlider.value = theDataObject.float1; 
     60//} 
    4061 
    4162#pragma mark - Chart behavior 
     
    4667   [self configureAxes]; 
    4768   // Block for .5 seconds 
    48 //   [NSThread sleepForTimeInterval:5]; 
    49 //   [self reloadData]; 
     69   //   [NSThread sleepForTimeInterval:.5]; 
     70   //   [self reloadData]; 
    5071} 
    5172 
     
    376397        NSInteger valueCount = [[self secondsInHistory] count]; 
    377398    
     399   HistoryAppDataObject* theDataObject = [self theAppDataObject]; 
     400    
    378401        switch (fieldEnum) { 
    379402                case CPTScatterPlotFieldX: 
     
    385408                case CPTScatterPlotFieldY: 
    386409         if (index < valueCount) { 
    387             //         return [NSDecimalNumber one]; 
    388             //                          return [NSNumber numberWithUnsignedInteger:index]; 
    389             return [[NSNumber alloc]initWithInt:(random() % 100)]; 
     410             
     411//            return [[NSNumber alloc]initWithInt:(random() % 100)]; 
     412             
     413            NSNumber *value = [[NSNumber alloc]initWithInt:(random() % 100)]; 
     414            NSLog(@"Random: %d", (int) value); 
     415            NSLog(@"lastAttention: %d", theDataObject.lastAttention); 
     416            return value; 
     417             
    390418         } 
    391419          
  • iOS/Orbit/orbit.xcodeproj/project.pbxproj

    rc1a500d rfc960da  
    5555                5218A6AC1872C562003DDE17 /* tutorial-11-steering-tilt_sensor_off.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 5218A6AB1872C562003DDE17 /* tutorial-11-steering-tilt_sensor_off.jpg */; }; 
    5656                5218A6AF187389C1003DDE17 /* StatisticsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 5218A6AD187389C1003DDE17 /* StatisticsViewController.m */; }; 
     57                5218A733187550DA003DDE17 /* AppDataObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 5218A730187550DA003DDE17 /* AppDataObject.m */; }; 
     58                5218A734187550DA003DDE17 /* HistoryAppDataObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 5218A732187550DA003DDE17 /* HistoryAppDataObject.m */; }; 
    5759                524B4A3D17AF6E72009076BA /* step05-4.html in Resources */ = {isa = PBXBuildFile; fileRef = 524B4A3C17AF6E72009076BA /* step05-4.html */; }; 
    5860                5255A29017CAEA1C00AD4349 /* tab_welcome-30x30.png in Resources */ = {isa = PBXBuildFile; fileRef = 5255A28E17CAEA1C00AD4349 /* tab_welcome-30x30.png */; }; 
     
    194196                5218A6AD187389C1003DDE17 /* StatisticsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = StatisticsViewController.m; path = controllers/StatisticsViewController.m; sourceTree = "<group>"; }; 
    195197                5218A6AE187389C1003DDE17 /* StatisticsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StatisticsViewController.h; path = controllers/StatisticsViewController.h; sourceTree = "<group>"; }; 
     198                5218A72E187550DA003DDE17 /* AppDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegateProtocol.h; sourceTree = "<group>"; }; 
     199                5218A72F187550DA003DDE17 /* AppDataObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDataObject.h; sourceTree = "<group>"; }; 
     200                5218A730187550DA003DDE17 /* AppDataObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDataObject.m; sourceTree = "<group>"; }; 
     201                5218A731187550DA003DDE17 /* HistoryAppDataObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryAppDataObject.h; sourceTree = "<group>"; }; 
     202                5218A732187550DA003DDE17 /* HistoryAppDataObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HistoryAppDataObject.m; sourceTree = "<group>"; }; 
    196203                524B4A3C17AF6E72009076BA /* step05-4.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "step05-4.html"; path = "tutorial/step05-4.html"; sourceTree = "<group>"; }; 
    197204                5255A28E17CAEA1C00AD4349 /* tab_welcome-30x30.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tab_welcome-30x30.png"; sourceTree = "<group>"; }; 
     
    477484                                28174C6F167F2EA900104752 /* AppDelegate.h */, 
    478485                                28174C70167F2EA900104752 /* AppDelegate.m */, 
     486                                5218A72E187550DA003DDE17 /* AppDelegateProtocol.h */, 
    479487                                28174C78167F2EAA00104752 /* MainStoryboard.storyboard */, 
    480488                                2815BC08167F428B00F7E6DA /* Libraries */, 
     
    495503                                288B4BC8178F016F007D588D /* SignalConverter.m */, 
    496504                                288B4BCA178F0842007D588D /* SignalConverterDelegate.h */, 
     505                                5218A72F187550DA003DDE17 /* AppDataObject.h */, 
     506                                5218A730187550DA003DDE17 /* AppDataObject.m */, 
     507                                5218A731187550DA003DDE17 /* HistoryAppDataObject.h */, 
     508                                5218A732187550DA003DDE17 /* HistoryAppDataObject.m */, 
    497509                        ); 
    498510                        path = Orbit; 
     
    844856                                28174C71167F2EA900104752 /* AppDelegate.m in Sources */, 
    845857                                289C7CCF178C36A9005C08EC /* TutorialViewController.m in Sources */, 
     858                                5218A734187550DA003DDE17 /* HistoryAppDataObject.m in Sources */, 
    846859                                5218A6AF187389C1003DDE17 /* StatisticsViewController.m in Sources */, 
     860                                5218A733187550DA003DDE17 /* AppDataObject.m in Sources */, 
    847861                                289C7D0E178D757F005C08EC /* FlightViewController.m in Sources */, 
    848862                                288B4BC3178ECD0B007D588D /* AdvancedViewController.m in Sources */, 
Note: See TracChangeset for help on using the changeset viewer.