Ignore:
Timestamp:
01/10/14 20:42:19 (7 years ago)
Author:
Steve Castellotti <sc@…>
Branches:
master, Servo
Children:
a2742af
Parents:
2246ba0
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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 
Note: See TracChangeset for help on using the changeset viewer.