Skip to content

Commit 7bbb79d

Browse files
committed
Merge pull request #7 from DynamicPerception/mitch
Mitch
2 parents 59d8c87 + 361cde0 commit 7bbb79d

8 files changed

Lines changed: 53 additions & 51 deletions

Joystick/DeviceTableViewCell.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ - (void) didConnect: (NMXDevice *) device
141141
NSString *deviceImage = [self getImageForDeviceStatus: device];
142142
self.imageView.image = [UIImage imageNamed: deviceImage];
143143

144-
if ((NMXRunStatusStopped != queryStatus) || NMXRunStatusStopped != queryStatusKeyFrame)
144+
if ((NMXRunStatusRunning & queryStatus) || NMXRunStatusRunning & queryStatusKeyFrame)
145145
{
146146
[self.tableView navigateToMainViewWithDevice: self.device];
147147
}

Joystick/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>5</string>
22+
<string>6</string>
2323
<key>LSRequiresIPhoneOS</key>
2424
<true/>
2525
<key>UIMainStoryboardFile</key>

Joystick/MainViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ - (void) viewDidAppear: (BOOL) animated {
882882
int queryStatusKeyFrame = [device queryKeyFrameProgramRunState];
883883
int queryStatus = [device mainQueryRunStatus];
884884

885-
if (NMXRunStatusStopped != queryStatus || NMXRunStatusStopped != queryStatusKeyFrame)
885+
if (NMXRunStatusRunning & queryStatus || NMXRunStatusRunning & queryStatusKeyFrame)
886886
{
887887
if (NMXRunStatusKeyframe & queryStatusKeyFrame)
888888
{
@@ -910,7 +910,7 @@ - (void) viewDidAppear: (BOOL) animated {
910910
[self enterJoystickMode];
911911
}
912912

913-
if (NMXRunStatusStopped == queryStatus)
913+
if ((NMXRunStatusRunning & queryStatus) == 0)
914914
{
915915
[NSTimer scheduledTimerWithTimeInterval:0.10 target:self selector:@selector(startStopQueryTimer) userInfo:nil repeats:NO];
916916
}

Joystick/MotorRampingViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ - (void) viewWillAppear: (BOOL) animated {
497497

498498
//NSLog(@"viewWillAppear ramping");
499499

500-
if (NMXRunStatusStopped != [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
501-
NMXRunStatusStopped != [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
500+
if (NMXRunStatusRunning & [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
501+
NMXRunStatusRunning & [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
502502
{
503503
NSLog(@"gotoreview");
504504
[self showVoltage];

Joystick/NMXDevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ typedef enum : unsigned char {
4242

4343
typedef enum : unsigned char {
4444

45-
NMXRunStatusUnknown = -1,
46-
NMXRunStatusStopped = 0,
45+
NMXRunStatusUnknown = 0xFF,
4746
NMXRunStatusRunning = 1 << 0,
4847
NMXRunStatusPaused = 1 << 1,
4948
NMXRunStatusKeyframe = 1 << 2,
5049
NMXRunStatusDelayTimer= 1 << 3,
5150
NMXRunStatusKeepAlive = 1 << 4,
5251
NMXRunStatusPingPong = 1 << 5,
52+
5353
} NMXRunStatus;
5454

5555

Joystick/NMXDevice.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,10 +1016,10 @@ - (NMXRunStatus) runStatusFromOldRunStatus:(_Deprecated_NMXRunStatus) runStatus
10161016
switch (runStatus)
10171017
{
10181018
case _Deprecated_NMXRunStatusStopped :
1019-
newStatus = NMXRunStatusStopped;
1019+
newStatus = 0;
10201020
break;
10211021
case _Deprecated_NMXRunStatusPaused :
1022-
newStatus = NMXRunStatusPaused;
1022+
newStatus = NMXRunStatusPaused | NMXRunStatusRunning;
10231023
break;
10241024
case _Deprecated_NMXRunStatusRunning:
10251025
newStatus = NMXRunStatusRunning;
@@ -1045,10 +1045,10 @@ - (NMXRunStatus) runStatusFromOldKeyframRunStatus:(_Deprecated_NMXKeyFrameRunSta
10451045
switch (runStatus)
10461046
{
10471047
case _Deprecated_NMXKeyFrameRunStatusStopped :
1048-
newStatus = NMXRunStatusStopped;
1048+
newStatus = 0;
10491049
break;
10501050
case _Deprecated_NMXKeyFrameRunStatusPaused :
1051-
newStatus = NMXRunStatusPaused;
1051+
newStatus = NMXRunStatusPaused | NMXRunStatusRunning;
10521052
break;
10531053
case _Deprecated_NMXKeyFrameRunStatusRunning:
10541054
newStatus = NMXRunStatusRunning;
@@ -2361,7 +2361,7 @@ - (UInt32) queryKeyFrameProgramRunState {
23612361

23622362
runState = [self runStatusFromOldKeyframRunStatus:(_Deprecated_NMXKeyFrameRunStatus)runState];
23632363

2364-
if (runState != NMXRunStatusStopped)
2364+
if (runState & NMXRunStatusRunning)
23652365
{
23662366
runState |= NMXRunStatusKeyframe; // We are running in keyframe mode so set the bit flag
23672367
}

Joystick/ReviewStatusViewController.m

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ - (void) setupAfterConnection {
11381138
{
11391139
[self transitionToState: ControllerStatePauseProgram];
11401140
}
1141-
else if (runStatus == NMXRunStatusStopped)
1141+
else
11421142
{
11431143
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
11441144
}
@@ -1912,18 +1912,6 @@ - (void) handleKeyFrameStatusTimer: (NSTimer *) sender {
19121912
{
19131913
NSLog(@"handleKeyframeStatusTimer runStatus: NMXRunStatusPaused");
19141914
}
1915-
else if (runStatus == NMXRunStatusStopped)
1916-
{
1917-
NSLog(@"handleKeyframeStatusTimer runStatus: NMXRunStatusStopped");
1918-
1919-
[keyframeTimer invalidate];
1920-
keyframeTimer = nil;
1921-
1922-
[self clearFields];
1923-
keepAliveView.hidden = YES;
1924-
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
1925-
1926-
}
19271915
else if (runStatus & NMXRunStatusKeepAlive)
19281916
{
19291917
NSLog(@"keep alive");
@@ -1952,11 +1940,23 @@ - (void) handleKeyFrameStatusTimer: (NSTimer *) sender {
19521940
playhead.frame.size.width,
19531941
playhead.frame.size.height);
19541942
}
1955-
else
1943+
else if (runStatus & NMXRunStatusUnknown)
19561944
{
19571945
NSLog(@"something else");
19581946
[self killStatusTimerOnDisconnect];
19591947
}
1948+
else
1949+
{
1950+
NSLog(@"handleKeyframeStatusTimer runStatus: Stopped");
1951+
1952+
[keyframeTimer invalidate];
1953+
keyframeTimer = nil;
1954+
1955+
[self clearFields];
1956+
keepAliveView.hidden = YES;
1957+
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
1958+
1959+
}
19601960
}
19611961

19621962
- (void) handleStatusTimer: (NSTimer *) sender {
@@ -1968,27 +1968,6 @@ - (void) handleStatusTimer: (NSTimer *) sender {
19681968

19691969
// This state should only happen from the user hitting pause, and we already handle that transition...
19701970
}
1971-
else if (runStatus == NMXRunStatusStopped) {
1972-
NSLog(@"handleStatusTimer runStatus: NMXRunStatusStopped");
1973-
1974-
// Due to a firmware bug. We want to make sure we are really stopped...
1975-
1976-
runStatus = [device mainQueryRunStatus];
1977-
1978-
if (NMXRunStatusStopped == runStatus)
1979-
{
1980-
[self.statusTimer invalidate];
1981-
self.statusTimer = nil;
1982-
1983-
[self clearFields];
1984-
keepAliveView.hidden = YES;
1985-
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
1986-
}
1987-
else
1988-
{
1989-
DDLogWarn(@"Saw a FAKE stopped response");
1990-
}
1991-
}
19921971
else if (runStatus & NMXRunStatusDelayTimer) {
19931972

19941973
self.totalRunTime = [device mainQueryTotalRunTime];
@@ -2185,7 +2164,7 @@ - (void) handleStatusTimer: (NSTimer *) sender {
21852164
}
21862165

21872166
}
2188-
else {
2167+
else if (runStatus == NMXRunStatusUnknown) {
21892168
NSLog(@"something else: %i",runStatus);
21902169

21912170
[self.statusTimer invalidate];
@@ -2202,6 +2181,29 @@ - (void) handleStatusTimer: (NSTimer *) sender {
22022181
});
22032182

22042183
}
2184+
else {
2185+
NSLog(@"handleStatusTimer runStatus: Stopped");
2186+
2187+
// Due to a firmware bug. We want to make sure we are really stopped...
2188+
2189+
runStatus = [device mainQueryRunStatus];
2190+
2191+
if ((runStatus & NMXRunStatusPaused) == 0 &&
2192+
(runStatus & NMXRunStatusRunning) == 0)
2193+
{
2194+
[self.statusTimer invalidate];
2195+
self.statusTimer = nil;
2196+
2197+
[self clearFields];
2198+
keepAliveView.hidden = YES;
2199+
[self transitionToState: ControllerStateMotorRampingOrSendMotors];
2200+
}
2201+
else
2202+
{
2203+
DDLogWarn(@"Saw a FAKE stopped response");
2204+
}
2205+
}
2206+
22052207
}
22062208

22072209
- (void) calculatePingPongReverse

Joystick/SetupViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ - (void) viewWillAppear: (BOOL) animated {
357357
object: nil];
358358
//NSLog(@"viewwillappear setup");
359359

360-
if (NMXRunStatusStopped != [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
361-
NMXRunStatusStopped != [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
360+
if (NMXRunStatusRunning & [[AppExecutive sharedInstance].device mainQueryRunStatus] ||
361+
NMXRunStatusRunning & [[AppExecutive sharedInstance].device queryKeyFrameProgramRunState])
362362
{
363363
//NSLog(@"randall load status not stopped setupVC: %i",[[AppExecutive sharedInstance].device queryKeyFrameProgramRunState]);
364364

0 commit comments

Comments
 (0)