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 */
|
||||
char ao_id[256];
|
||||
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 */
|
||||
double S_x;
|
||||
double S_y;
|
||||
@ -1800,7 +1801,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
|
||||
self->currSteps = iSteps;
|
||||
if (self->bias_bits > 0)
|
||||
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 mask = (1 << shift) - 1;
|
||||
int old_bits = (self->currCounts >> (self->rotary_bits - shift)) & mask;
|
||||
@ -1848,6 +1849,7 @@ static int rspStatus(pDMC2280Driv self, const char* text) {
|
||||
else
|
||||
self->stopCode = 1;
|
||||
}
|
||||
self->status_valid = true;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user