Skip to content

Commit

Permalink
integrate new program feasibility query
Browse files Browse the repository at this point in the history
  • Loading branch information
rabidrebeldog committed Mar 28, 2016
1 parent bce1148 commit 975a369
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Joystick/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>11</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
Expand Down
24 changes: 22 additions & 2 deletions Joystick/MotorRampingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1552,8 +1552,28 @@ - (IBAction) handleNextButton: (UIButton *) sender {

[MBProgressHUD hideHUDForView:self.view animated:YES];

[self performSegueWithIdentifier: kSegueToReviewStatusViewController sender: self];

if (appExecutive.is3P == NO)
{
if ((NO == [device motorQueryFeasibility: device.sledMotor]) ||
(NO == [device motorQueryFeasibility: device.panMotor]) ||
(NO == [device motorQueryFeasibility: device.tiltMotor]))
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Too Fast For Motors"
message: @"Reduce ramping or lead in/out time"
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
}
else
{
[self performSegueWithIdentifier: kSegueToReviewStatusViewController sender: self];
}
}
else
{
[self performSegueWithIdentifier: kSegueToReviewStatusViewController sender: self];
}
});
});
}
Expand Down
1 change: 1 addition & 0 deletions Joystick/NMXDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ typedef enum : unsigned char {
- (void) motorSet:(int)motorNumber ProgramStopPoint: (UInt32) position;
- (void) motorSendToStartPoint: (int) motorNumber;
- (unsigned char) motorAutoSetMicrosteps: (int) motorNumber;
- (bool) motorQueryFeasibility: (int) motorNumber;
- (void) motorSetStartHere: (int) motorNumber;
- (void) motorSetStopHere: (int) motorNumber;
- (void) motorSet:(int)motorNumber SetLeadInShotsOrTime: (UInt32) leadIn;
Expand Down
27 changes: 25 additions & 2 deletions Joystick/NMXDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define kDefaultsMotorPanInvert @"MotorPanInvert"
#define kDefaultsMotorTiltInvert @"MotorTiltInvert"

#define kCurrentSupportedFirmwareVersion 52
#define kCurrentSupportedFirmwareVersion 54


typedef enum : unsigned char {
Expand Down Expand Up @@ -87,7 +87,8 @@
NMXCommandMotorQueryTravelShotsOrTravelTime = 113,
NMXCommandMotorQueryLeadInShotsOrTime = 114,
NMXCommandMotorQuerySleep = 117,
NMXCommandMotorQueryLeadOutShotsOrTime = 119
NMXCommandMotorQueryLeadOutShotsOrTime = 119,
NMXCommandMotorQueryProgramFeasibility = 120,

} NMXCommandMotor;

Expand Down Expand Up @@ -910,6 +911,28 @@ - (unsigned char) motorAutoSetMicrosteps: (int) motorNumber {
return microsteps;
}

- (bool) motorQueryFeasibility: (int) motorNumber {

if (_fwVersion < 54 )
{
return YES;
}

unsigned char isFeasible;
unsigned char newDataBytes[16];
[self setupBuffer: newDataBytes subAddress: motorNumber command: NMXCommandMotorQueryProgramFeasibility dataLength: 0];
NSData *newData = [NSData dataWithBytes: newDataBytes length: 10];

[self sendCommand: newData WithDesc: @"Query Feasibility" WaitForResponse: true WithTimeout: 3.0];

if ([self waitForResponse])
{
isFeasible = [[self extractReturnedNumber] UInt8Value];
}

return isFeasible;
}

- (void) mainSetStartHere {

unsigned char newDataBytes[16];
Expand Down
31 changes: 28 additions & 3 deletions Joystick/SetupViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -772,10 +772,35 @@ - (IBAction) handleJoystickButton: (UIButton *) sender {
}

- (void) checkProgramAndHandleNext {

NMXDevice * device = [AppExecutive sharedInstance].device;

// If we transition too fast, the hardware gets unhappy...
usleep(100);
[self performSegueWithIdentifier: kSegueToMotorRampingViewController sender: self];
if (appExecutive.is3P == NO) {

if ((NO == [device motorQueryFeasibility: device.sledMotor]) ||
(NO == [device motorQueryFeasibility: device.panMotor]) ||
(NO == [device motorQueryFeasibility: device.tiltMotor]))
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Too Fast For Motors"
message: @"Increase shot duration"
delegate: self
cancelButtonTitle: @"OK"
otherButtonTitles: nil];
[alert show];
}
else
{
// If we transition too fast, the hardware gets unhappy...
usleep(100);
[self performSegueWithIdentifier: kSegueToMotorRampingViewController sender: self];
}
}
else
{
// If we transition too fast, the hardware gets unhappy...
usleep(100);
[self performSegueWithIdentifier: kSegueToMotorRampingViewController sender: self];
}
}

- (IBAction) handleNextButton: (UIButton *) sender {
Expand Down

0 comments on commit 975a369

Please sign in to comment.