Adafruit_Motor_Shield_V2_Library
Adafruit_Motor_Shield_V2_Library copied to clipboard
Potential bug for method getMotor and getStepper of class Adafruit_MotorShield
In getMotor, to determine if the motor are init'd, you test the value of member motornum (line 72) with zero and assign num to motornum (line 74). In the case of the motor one, num are the value zero when motornum is assigned to num because of the decrement line 70. The first motor is always init'd.
It's the same for getStepper.
However, I haven't yet tested the code.
Yes
basically
dcmotors[num].motornum
is not really needed. the code only needs to store a boolean to see if the dcmotor has been initialised already.
so the code should look like
if (!dcmotors[num].init) { // not init'd yet! dcmotors[num].init = true;