Skip to content

Commit

Permalink
Merge pull request #6 from DynamicPerception/mitch
Browse files Browse the repository at this point in the history
Version 3.7
  • Loading branch information
rabidrebeldog committed May 11, 2016
2 parents 21b6731 + 151630b commit 59d8c87
Show file tree
Hide file tree
Showing 11 changed files with 682 additions and 366 deletions.
13 changes: 11 additions & 2 deletions Joystick/AppExecutive.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@
@property (nonatomic, strong) NSArray * slideIncreaseValues;
@property (nonatomic, strong) NSArray * slideDecreaseValues;

// device

@property (strong, atomic) NMXDevice * device;
@property (strong, atomic) NMXDeviceManager * deviceManager;
@property (nonatomic, readonly) NSUserDefaults * defaults;

//Randall additions

@property (nonatomic, readonly) UIColor * appBlueColor;

@property (strong, atomic) NSNumber *selectedMotorFrame;
Expand Down Expand Up @@ -176,4 +175,14 @@
- (BOOL) validFocusNumber: (NSNumber *) number;
- (BOOL) validTriggerNumber: (NSNumber *) number;

#pragma mark program delay methods

- (void) setProgramDelayTime: (NSTimeInterval) delay;
- (NSDate *) getDelayTimerStartTime;
- (NSTimeInterval) getProgramDelayTime;
- (NSTimeInterval) getTimeSinceDelayStarted;
- (void) setOriginalProgramDelay: (NSTimeInterval)delay;
- (NSTimeInterval) getOriginalProgramDelay;


@end
54 changes: 54 additions & 0 deletions Joystick/AppExecutive.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ @implementation AppExecutive
NSString static *kDefaultsSlideIncreaseValues = @"kDefaultsSlideIncreaseValues";
NSString static *kDefaultsSlideDecreaseValues = @"kDefaultsSlideDecreaseValues";

NSString static *kDefaultsProgramDelayTime = @"programDelayTimer";
NSString static *kDefaultsProgramDelayTimeSetAt = @"programDelayTimerSetAtTime";
NSString static *kDefaultsOriginalProgramDelayTime = @"programOriginalDelayTimer";

#define kDefaultsMotorSledMicrosteps @"MotorSledMicrosteps"
#define kDefaultsMotorPanMicrosteps @"MotorPanMicrosteps"
#define kDefaultsMotorTiltMicrosteps @"MotorTiltMicrosteps"
Expand Down Expand Up @@ -755,6 +759,56 @@ - (NSString *) stringWithHandleForDeviceName: (NSString *) deviceName {
return deviceName;
}

- (void) setProgramDelayTime: (NSTimeInterval) delay
{
[self.defaults setObject: [NSNumber numberWithDouble:delay] forKey: kDefaultsProgramDelayTime];
[self.defaults setObject: [NSDate date] forKey: kDefaultsProgramDelayTimeSetAt];
[self.defaults synchronize];
}

- (NSDate *) getDelayTimerStartTime
{
NSDate *date = [self.defaults objectForKey: kDefaultsProgramDelayTimeSetAt];

if (NULL == date)
{
NSAssert(0, @"Could not find the delay timer start time");
date = [NSDate date];
}

return date;
}

- (NSTimeInterval) getTimeSinceDelayStarted
{
NSDate *timerStartTime = [self getDelayTimerStartTime];
NSTimeInterval ti = [[NSDate date] timeIntervalSinceDate: timerStartTime];

return ti;
}

- (NSTimeInterval) getProgramDelayTime
{
NSTimeInterval delayTime = [[self getNumberForKey: kDefaultsProgramDelayTime] doubleValue];
return delayTime;
}

- (void) setOriginalProgramDelay: (NSTimeInterval)delay
{
[self.defaults setObject: [NSNumber numberWithDouble:delay] forKey: kDefaultsOriginalProgramDelayTime];
[self.defaults synchronize];
}

// MM : this is a workaround for a firmware v. .61 bug where, in KF mode, the delay time is encapsulated into
// the percentage done calculation coming back from the controller. We use the original program delay
// to get that out of there and calculate a correct %
- (NSTimeInterval) getOriginalProgramDelay
{
NSTimeInterval delayTime = [[self getNumberForKey: kDefaultsOriginalProgramDelayTime] doubleValue];
return delayTime;
}



//------------------------------------------------------------------------------

Expand Down
128 changes: 64 additions & 64 deletions Joystick/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

12 changes: 1 addition & 11 deletions Joystick/DeviceSettingsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,7 @@ - (IBAction) handleEmailLogFileButton: (UIButton *) sender {
}

- (IBAction)setSlaveMode:(UISwitch *)sender {
if ([sender isOn] && (![sender isSelected]))
{
[self.appExecutive.device cameraSetSlaveMode: YES];
[sender setSelected:YES];

}
else if ((![sender isOn]) && [sender isSelected])
{
[self.appExecutive.device cameraSetSlaveMode: NO];
[sender setSelected:NO];
}
[self.appExecutive.device cameraSetSlaveMode: [sender isOn]];
}


Expand Down
93 changes: 67 additions & 26 deletions Joystick/DurationViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#import "JoyButton.h"
#import "NMXDevice.h"

#define MAX_HOURS 99
#define MAX_DAYS 9

//------------------------------------------------------------------------------

Expand All @@ -37,6 +37,9 @@ @implementation DurationViewController

#pragma mark Static Variables

NSArray static *daysNumbers = nil;
NSArray static *daysStrings = nil;

NSArray static *hoursNumbers = nil;
NSArray static *hoursStrings = nil;

Expand Down Expand Up @@ -84,19 +87,35 @@ + (void) initialize {
NSMutableArray *mutableNumbers = [NSMutableArray array];
NSMutableArray *mutableStrings = [NSMutableArray array];

for (NSInteger index = 0; index <= MAX_HOURS; index++)
[mutableNumbers addObject: [NSNumber numberWithInteger: index]];
for (NSInteger index = 0; index <= MAX_DAYS; index++)
{
[mutableNumbers addObject: [NSNumber numberWithInteger: index]];
[mutableStrings addObject: [NSString stringWithFormat: @"%ldd", (long)index]];
}

daysNumbers = [NSArray arrayWithArray: mutableNumbers];
daysStrings = [NSArray arrayWithArray: mutableStrings];

for (NSInteger index = 0; index <= MAX_HOURS; index++)
[mutableStrings removeAllObjects];
[mutableNumbers removeAllObjects];

for (NSInteger index = 0; index <= 23; index++)
{
[mutableNumbers addObject: [NSNumber numberWithInteger: index]];
[mutableStrings addObject: [NSString stringWithFormat: @"%02ldh", (long)index]];
}

hoursNumbers = [NSArray arrayWithArray: mutableNumbers];
hoursStrings = [NSArray arrayWithArray: mutableStrings];

[mutableStrings removeAllObjects];
[mutableNumbers removeAllObjects];

for (NSInteger index = 0; index < 60; index++)
{
[mutableStrings addObject: [NSString stringWithFormat: @"%02ldm", (long)index]];
[mutableNumbers addObject: [NSNumber numberWithInteger: index]];
}

minutesNumbers = [NSArray arrayWithArray: mutableNumbers];
minutesStrings = [NSArray arrayWithArray: mutableStrings];
Expand All @@ -118,11 +137,13 @@ + (NSString *) stringForDuration: (NSInteger) duration {

NSInteger wholeseconds = duration / 1000;

NSInteger days = wholeseconds / (3600*24);
wholeseconds -= days * (3600*24);
NSInteger hours = wholeseconds / 3600;
NSInteger minutes = (wholeseconds % 3600) / 60;
NSInteger seconds = wholeseconds % 60;

NSString * string = [NSString stringWithFormat: @"%02ld:%02ld:%02ld", (long)hours, (long)minutes, (long)seconds];
NSString * string = [NSString stringWithFormat: @"%ld:%02ld:%02ld:%02ld", (long)days, (long)hours, (long)minutes, (long)seconds];

return string;
}
Expand Down Expand Up @@ -168,24 +189,29 @@ - (void) viewWillAppear: (BOOL) animated {
NSNumber * number = [self.userInfo objectForKey: kDurationInfoKeyNumber];
NSInteger duration = [number integerValue];
NSInteger wholeseconds = duration / 1000;
NSInteger days = wholeseconds / (3600*24);
wholeseconds -= days * (3600*24);
NSInteger hours = wholeseconds / 3600;
NSInteger minutes = (wholeseconds % 3600) / 60;
NSInteger seconds = wholeseconds % 60;

if (hours > MAX_HOURS)
if (days > MAX_DAYS)
{
hours = MAX_HOURS;
days = MAX_DAYS;
hours = 23;
minutes = 59;
seconds = 59;
}


NSInteger daysRow = [daysNumbers indexOfObject: [NSNumber numberWithInteger: days]];
NSInteger hoursRow = [hoursNumbers indexOfObject: [NSNumber numberWithInteger: hours]];
NSInteger minutesRow = [minutesNumbers indexOfObject: [NSNumber numberWithInteger: minutes]];
NSInteger secondsRow = [secondsNumbers indexOfObject: [NSNumber numberWithInteger: seconds]];

[self.picker selectRow: hoursRow inComponent: 0 animated: NO];
[self.picker selectRow: minutesRow inComponent: 1 animated: NO];
[self.picker selectRow: secondsRow inComponent: 2 animated: NO];
[self.picker selectRow: daysRow inComponent: 0 animated: NO];
[self.picker selectRow: hoursRow inComponent: 1 animated: NO];
[self.picker selectRow: minutesRow inComponent: 2 animated: NO];
[self.picker selectRow: secondsRow inComponent: 3 animated: NO];

self.title.text = [self.userInfo objectForKey: kDurationInfoKeyTitle];
}
Expand Down Expand Up @@ -217,18 +243,20 @@ - (IBAction) handleOkButton: (id) sender {

DDLogDebug(@"Dismiss Duration Picker Button");

NSNumber * numberForHours = [hoursNumbers objectAtIndex: [self.picker selectedRowInComponent: 0]];
NSNumber * numberForMinutes = [minutesNumbers objectAtIndex: [self.picker selectedRowInComponent: 1]];
NSNumber * numberForSeconds = [secondsNumbers objectAtIndex: [self.picker selectedRowInComponent: 2]];
NSNumber * numberForDays = [daysNumbers objectAtIndex: [self.picker selectedRowInComponent: 0]];
NSNumber * numberForHours = [hoursNumbers objectAtIndex: [self.picker selectedRowInComponent: 1]];
NSNumber * numberForMinutes = [minutesNumbers objectAtIndex: [self.picker selectedRowInComponent: 2]];
NSNumber * numberForSeconds = [secondsNumbers objectAtIndex: [self.picker selectedRowInComponent: 3]];

NSInteger days = [numberForDays integerValue];
NSInteger hours = [numberForHours integerValue];
NSInteger minutes = [numberForMinutes integerValue];
NSInteger seconds = [numberForSeconds integerValue];
NSInteger duration = 1000 * (hours * 3600 + minutes * 60 + seconds);
NSInteger duration = 1000 * (days * (3600*24) + hours * 3600 + minutes * 60 + seconds);

if (isMotorSegue)
{
duration = 1000 * (hours * 3600 + minutes * 60);
duration = 1000 * (days * (3600*24) + hours * 3600 + minutes * 60);

//post notification

Expand All @@ -248,9 +276,20 @@ - (IBAction) handleOkButton: (id) sender {
NSArray * objects = @[name, number, string];
NSDictionary * info = [NSDictionary dictionaryWithObjects: objects forKeys: keys];

duration = 1000 * (hours * 3600 + minutes * 60 + seconds);

[self.delegate updateDurationInfo: info];

if ([appExecutive.frameCountNumber integerValue] > USHRT_MAX)
{
self.appExecutive.frameCountNumber = [NSNumber numberWithInteger: USHRT_MAX];

UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Duration Setting"
message: @"New duration exceeds frame count limit. Duration has been adjusted to a legal value."
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];

}
}

if (self.appExecutive.is3P)
Expand Down Expand Up @@ -285,7 +324,7 @@ - (CGFloat) pickerView: (UIPickerView *) pickerView widthForComponent: (NSIntege

switch (component)
{
case 0: case 1: case 2:
case 0: case 1: case 2: case 3:
return 70.0;

default:
Expand All @@ -302,9 +341,10 @@ - (NSAttributedString *) pickerView: (UIPickerView *) pickerView attributedTitle

switch (component)
{
case 0: string = [hoursStrings objectAtIndex: row]; break;
case 1: string = [minutesStrings objectAtIndex: row]; break;
case 2: string = [secondsStrings objectAtIndex: row]; break;
case 0: string = [daysStrings objectAtIndex: row]; break;
case 1: string = [hoursStrings objectAtIndex: row]; break;
case 2: string = [minutesStrings objectAtIndex: row]; break;
case 3: string = [secondsStrings objectAtIndex: row]; break;

default: break;
}
Expand All @@ -324,16 +364,17 @@ - (void) pickerView: (UIPickerView *) pickerView didSelectRow: (NSInteger) row i

- (NSInteger) numberOfComponentsInPickerView: (UIPickerView *) pickerView {

return 3;
return 4;
}

- (NSInteger) pickerView: (UIPickerView *) pickerView numberOfRowsInComponent: (NSInteger) component {

switch (component)
{
case 0: return hoursStrings.count;
case 1: return minutesStrings.count;
case 2: return secondsStrings.count;
case 0: return daysStrings.count;
case 1: return hoursStrings.count;
case 2: return minutesStrings.count;
case 3: return secondsStrings.count;

default: break;
}
Expand Down
4 changes: 2 additions & 2 deletions Joystick/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.6</string>
<string>3.7</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>5</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
1 change: 1 addition & 0 deletions Joystick/NMXDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef enum : unsigned char {
- (void) motorSet: (int) motorNumber ContinuousSpeed: (float) speed;
- (void) motorMove: (int) motorNumber Direction: (unsigned char) direction Steps: (UInt32) steps;
- (UInt16) motorQueryBacklash: (int) motorNumber;
- (void) takeUpBacklashKeyFrameProgram;
- (int) motorQueryCurrentPosition: (int) motorNumber;
- (bool) motorQueryRunning: (int) motorNumber;
- (UInt32) motorQueryShotsTotalTravelTime: (int) motorNumber;
Expand Down
Loading

0 comments on commit 59d8c87

Please sign in to comment.