Skip to content

Commit 4b2ea5b

Browse files
authored
[Bug] fix reverse, expected pin for reverse was one off
- Adjust the reverse functions to recognize the count is off by 1 for reverse pin spot for PWM on the I2C extenders within the function. - This library has parity with v2.3.0 of the wrapped Adafruit I2C library
1 parent 403f12a commit 4b2ea5b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/I2C_Array_ESC.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,12 @@ void I2C_Array_ESC::reverse(int pin)
206206
// check whether we are in reverse mode
207207
if (REVERSE_MODE == false)
208208
{
209-
I2C_Servo.setPWM(pin, 4096, 0); // turns pin fully on
209+
I2C_Servo.setPWM(pin+1, 4096, 0); // turns pin+1 fully on
210210
REVERSE_MODE = true; // we are now in reverse mode
211211
}
212212
else
213213
{
214-
I2C_Servo.setPWM(pin, 0, 4096); // turns pin fully off
214+
I2C_Servo.setPWM(pin+1, 0, 4096); // turns pin+1 fully off
215215
REVERSE_MODE = false; // We are no longer in reverse mode
216216
}
217217

@@ -231,15 +231,15 @@ void I2C_Array_ESC::reverseArray(void)
231231
{
232232
for (int count=0; count<8; count++) // cycle through the ESCs
233233
{
234-
I2C_Servo.setPWM(oPin[count], 4096, 0); // turns pin fully on
234+
I2C_Servo.setPWM(oPin[count+1], 4096, 0); // turns pins+1 fully on
235235
}
236236
REVERSE_MODE = true; // we are now in reverse mode
237237
}
238238
else
239239
{
240240
for (int count=0; count<8; count++) // cycle through the ESCs
241241
{
242-
I2C_Servo.setPWM(oPin[count], 0, 4096); // turns pin fully off
242+
I2C_Servo.setPWM(oPin[count+1], 0, 4096); // turns pins+1 fully off
243243
}
244244
REVERSE_MODE = false; // We are no longer in reverse mode
245245
}
@@ -251,7 +251,7 @@ void I2C_Array_ESC::reverseArray(void)
251251
/*
252252
* Wrap the Adafruit_PWMServoDriver functions
253253
* These are 1-to-1 mappings and need to be checked when the wapped Library changes
254-
* Updated with adafruit/Adafruit-PWM-Servo-Driver-Library v2.2.0
254+
* Updated with adafruit/Adafruit-PWM-Servo-Driver-Library v2.3.0
255255
*/
256256

257257
void I2C_Array_ESC::begin(uint8_t prescale)

0 commit comments

Comments
 (0)