source: orbit/iOS/Orbit/Orbit/controllers/AdvancedViewController.m @ de10cbc

ServoTab_Interfacepyramid
Last change on this file since de10cbc was de10cbc, checked in by Jonathon Horsman <jonathon@…>, 7 years ago

Add a test button on flight tab
Add a reset button on advanced tab
Correctly detect device volume
Add more tutorial HTML

  • Property mode set to 100644
File size: 1.8 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
30- (IBAction) pitchChanged:(id) sender
31{
32    pitchPercent.text = [self percentStringFromSlider:pitch];
33    [self adjustValues];
34}
35
36- (IBAction) yawChanged:(id) sender
37{
38    yawPercent.text = [self percentStringFromSlider:yaw];
39    [self adjustValues];
40}
41
42- (IBAction) throttleChanged:(id) sender
43{
44    throttlePercent.text = [self percentStringFromSlider:throttle];
45    [self adjustValues];
46}
47
48- (NSString *) percentStringFromSlider:(UISlider *) slider
49{
50    return [NSString stringWithFormat:@"%i%%", (int)((slider.value - 0.5) * 200)]; // between -100% and 100%
51}
52
53- (void) adjustValues
54{
55    [signalConverter setYaw:[self yawValue]throttle:[self throttleValue] pitch:[self pitchValue]];
56}
57
58- (int) yawValue
59{
60    return round(yaw.value * 100);
61}
62
63- (int) pitchValue
64{
65    return round(pitch.value * 100);
66}
67
68- (int) throttleValue
69{
70    return round(throttle.value * 100);
71}
72
73- (IBAction) resetButtonPressed:(id)button
74{
75    pitch.value = 0.5;
76    yaw.value = 0.5;
77    throttle.value = 0.5;
78    NSString *zero = @"0%";
79    throttlePercent.text = zero;
80    yawPercent.text = zero;
81    pitchPercent.text = zero;
82    [self adjustValues];
83}
84
85@end
Note: See TracBrowser for help on using the repository browser.