Only do the rotary_bits if the previous counts is valid
This saves decrementing it the first time through because it is in the fourth quadrant and the initial value (zero) is in the first.
This commit is contained in:
@ -270,6 +270,7 @@ struct __MoDriv {
|
|||||||
int rotary_count; /**< count of rotations */
|
int rotary_count; /**< count of rotations */
|
||||||
char ao_id[256];
|
char ao_id[256];
|
||||||
bool legacy_fsm; /**< flag for legacy_fsm new code */
|
bool legacy_fsm; /**< flag for legacy_fsm new code */
|
||||||
|
bool status_valid; /**< flag for status has been set from controller */
|
||||||
bool doStats; /**< flag to request stats collection */
|
bool doStats; /**< flag to request stats collection */
|
||||||
double S_x;
|
double S_x;
|
||||||
double S_y;
|
double S_y;
|
||||||
@ -1800,7 +1801,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
|
|||||||
self->currSteps = iSteps;
|
self->currSteps = iSteps;
|
||||||
if (self->bias_bits > 0)
|
if (self->bias_bits > 0)
|
||||||
iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1);
|
iCounts = (iCounts + self->bias_bias) & ((1 << self->bias_bits) - 1);
|
||||||
if (self->rotary_bits > 0) {
|
if (self->rotary_bits > 0 && self->status_valid) {
|
||||||
int shift = 2;
|
int shift = 2;
|
||||||
int mask = (1 << shift) - 1;
|
int mask = (1 << shift) - 1;
|
||||||
int old_bits = (self->currCounts >> (self->rotary_bits - shift)) & mask;
|
int old_bits = (self->currCounts >> (self->rotary_bits - shift)) & mask;
|
||||||
@ -1848,6 +1849,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
|
|||||||
else
|
else
|
||||||
self->stopCode = 1;
|
self->stopCode = 1;
|
||||||
}
|
}
|
||||||
|
self->status_valid = true;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user