source: orbit/iOS/Orbit/Orbit/controllers/AdvancedViewController.m @ 505e3d5

ServoTab_Interfacepyramid
Last change on this file since 505e3d5 was 505e3d5, checked in by Steve Castellotti <sc@…>, 7 years ago

Advanced:

  • Warning message encouraging joining development community
  • Property mode set to 100644
File size: 2.0 KB
Line 
1//
2//  AdvancedViewController.m
3//  orbit
4//
5//  Created by Jonathon Horsman on 11/07/2013.
6//  Copyright (c) 2013 Puzzlebox Productions, LLC. All rights reserved.
7//
8
9#import "AdvancedViewController.h"
10#import "SignalConverter.h"
11#import "AppDelegate.h"
12
13@interface AdvancedViewController ()
14
15@end
16
17@implementation AdvancedViewController {
18    SignalConverter *signalConverter;
19}
20
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   
29   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Help Wanted" message:@"Please join our Open Source development community to help us port this feature! See link to Forums under Support tab" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
30   [alert show];
31}
32
33- (IBAction) pitchChanged:(id) sender
34{
35    pitchPercent.text = [self percentStringFromSlider:pitch];
36    [self adjustValues];
37}
38
39- (IBAction) yawChanged:(id) sender
40{
41    yawPercent.text = [self percentStringFromSlider:yaw];
42    [self adjustValues];
43}
44
45- (IBAction) throttleChanged:(id) sender
46{
47    throttlePercent.text = [self percentStringFromSlider:throttle];
48    [self adjustValues];
49}
50
51- (NSString *) percentStringFromSlider:(UISlider *) slider
52{
53    return [NSString stringWithFormat:@"%i%%", (int)((slider.value - 0.5) * 200)]; // between -100% and 100%
54}
55
56- (void) adjustValues
57{
58    [signalConverter setYaw:[self yawValue]throttle:[self throttleValue] pitch:[self pitchValue]];
59}
60
61- (int) yawValue
62{
63    return round(yaw.value * 100);
64}
65
66- (int) pitchValue
67{
68    return round(pitch.value * 100);
69}
70
71- (int) throttleValue
72{
73    return round(throttle.value * 100);
74}
75
76- (IBAction) resetButtonPressed:(id)button
77{
78    pitch.value = 0.5;
79    yaw.value = 0.5;
80    throttle.value = 0.5;
81    NSString *zero = @"0%";
82    throttlePercent.text = zero;
83    yawPercent.text = zero;
84    pitchPercent.text = zero;
85    [self adjustValues];
86}
87
88@end
Note: See TracBrowser for help on using the repository browser.