Ignore:
Timestamp:
08/19/13 12:44:51 (8 years ago)
Author:
Jonathon Horsman <jonathon@…>
Branches:
master, Servo, Tab_Interface, pyramid
Children:
1472980, 548a60f
Parents:
6d0d67b
Message:

Set thresholds when first loaded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • iOS/Orbit/Orbit/controllers/FlightViewController.m

    r359a504 r8a0f920f  
    2323@implementation FlightViewController { 
    2424    SignalConverter *signalConverter; 
    25     int deviceStatus;     
     25    int deviceStatus; 
     26    BOOL warned; 
    2627} 
    2728 
    28 @synthesize status, attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, testButton, statusImage, signalPercent, attentionPercent, meditationPercent, powerPercent; 
     29@synthesize attention, meditation, signal, power, attentionThreshold, meditationThreshold, connectButton, testButton, statusImage, signalPercent, attentionPercent, meditationPercent, powerPercent; 
    2930 
    3031- (void)viewDidLoad 
     
    3536     
    3637    signalConverter.delegate = self; 
    37     [self.attentionThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 
    38     [self.meditationThreshold addTarget:self action:@selector(sliderChanged) forControlEvents:UIControlEventValueChanged]; 
     38    [self setThresholds]; 
     39    [self.attentionThreshold addTarget:self action:@selector(setThresholds) forControlEvents:UIControlEventValueChanged]; 
     40    [self.meditationThreshold addTarget:self action:@selector(setThresholds) forControlEvents:UIControlEventValueChanged]; 
    3941} 
    4042 
     
    5254    power.progress = 0; 
    5355    powerPercent.text = @"0%"; 
    54     [self logMessage:@"Disconnected"]; 
    5556    [self updateStatusImage:STATUS_DEFAULT]; 
    5657    connectButton.title = @"Connect"; 
     
    6263        [statusImage setImage: [UIImage imageNamed:[NSString stringWithFormat:@"status_%u", statusNo]]]; 
    6364        deviceStatus = statusNo; 
    64         if (statusNo == STATUS_CONNECTED) { 
    65             [self logMessage:@"Check headset fitted properly"]; 
    66         } else if (statusNo == STATUS_PROCESSING) { 
    67             [self logMessage:@"Increase your concentration"]; 
    68         } else if (statusNo == STATUS_ACTIVE) { 
    69             [self logMessage:@"Flying!"]; 
    70         } 
    7165    } 
    7266} 
    7367 
    74 - (void) sliderChanged 
     68- (void) setThresholds 
    7569{ 
    7670    [signalConverter setValuesForAttention:attentionThreshold.value meditation:meditationThreshold.value]; 
    77 } 
    78  
    79 - (void) logMessage:(NSString *) str 
    80 { 
    81     status.text = str; 
    8271} 
    8372 
     
    113102- (void) notifyHeadsetConnect 
    114103{ 
    115     [self logMessage:@"Headset connected"]; 
    116104    [self updateStatusImage:STATUS_CONNECTING]; 
    117105} 
     
    125113- (void) notifyDeviceConnected:(NSString *)name 
    126114{ 
    127     [self logMessage:[NSString stringWithFormat:@"EEG device %@ connected", name]]; 
    128115    [self updateStatusImage:STATUS_CONNECTING]; 
    129116    connectButton.title = @"Disconnect"; 
     
    146133        BOOL headphones = [signalConverter isAudioJackPlugged]; 
    147134         
    148         if (!volumeMax && !headphones) { 
     135        if (!warned && !volumeMax && !headphones) { 
    149136            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Check Volume & Transmitter" message:@"Ensure the volume is at max and the transmitter is plugged into the headphones" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    150137            [alert show]; 
    151         } else if (!volumeMax) { 
     138        } else if (!warned && !volumeMax) { 
    152139            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Turn Up The Volume" message:@"Your device volume must be at the maximum for proper operation" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    153140            [alert show]; 
    154         } else if (!headphones) { 
     141        } else if (!warned && !headphones) { 
    155142            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Plug In The Transmitter" message:@"Ensure the infrared transmitter is plugged into the headphone jack" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 
    156143            [alert show]; 
     
    159146            [alert show]; 
    160147        } else if ([signalConverter startProcessing]) { 
    161             [self logMessage:@"Searching for device"]; 
    162148            connectButton.title = @"Disconnect"; 
    163149        } else { 
     
    165151            [alert show]; 
    166152        } 
     153        warned = YES; 
    167154    } 
    168155} 
Note: See TracChangeset for help on using the changeset viewer.