forked from Archive/PX4-Autopilot
fix camera_trigger gpio: _pins[i] == 0 is valid
Because _pins[i] is set from parameter value - 1
This commit is contained in:
parent
a38b94c7dd
commit
229b1274d0
|
@ -22,8 +22,8 @@ CameraInterfaceGPIO::~CameraInterfaceGPIO()
|
|||
void CameraInterfaceGPIO::setup()
|
||||
{
|
||||
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
||||
// Pin range is ranges from 1 to 6
|
||||
if (_pins[i] > 0 && _pins[i] < (int)arraySize(_gpios)) {
|
||||
// Pin range is from 0 to 5
|
||||
if (_pins[i] >= 0 && _pins[i] < (int)arraySize(_gpios)) {
|
||||
px4_arch_configgpio(_gpios[_pins[i]]);
|
||||
px4_arch_gpiowrite(_gpios[_pins[i]], !_polarity);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void CameraInterfaceGPIO::trigger(bool enable)
|
|||
{
|
||||
if (enable) {
|
||||
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
||||
if (_pins[i] >= 0) {
|
||||
if (_pins[i] >= 0 && _pins[i] < (int)arraySize(_gpios)) {
|
||||
// ACTIVE_LOW == 1
|
||||
px4_arch_gpiowrite(_gpios[_pins[i]], _polarity);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ void CameraInterfaceGPIO::trigger(bool enable)
|
|||
|
||||
} else {
|
||||
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
||||
if (_pins[i] >= 0) {
|
||||
if (_pins[i] >= 0 && _pins[i] < (int)arraySize(_gpios)) {
|
||||
// ACTIVE_LOW == 1
|
||||
px4_arch_gpiowrite(_gpios[_pins[i]], !_polarity);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue