camera_trigger:Support more than 8 channles

This commit is contained in:
David Sidrane
2021-06-10 11:31:27 -07:00
committed by Lorenz Meier
parent 615e1f3e29
commit e0fab172a4
7 changed files with 100 additions and 34 deletions

View File

@@ -376,6 +376,8 @@ else
fi fi
if param greater -s TRIG_MODE 0 if param greater -s TRIG_MODE 0
then
if param compare TRIG_PINS_EX 0
then then
# We ONLY support trigger on pins 5+6 or 7+8 when simultanously using AUX for actuator output. # We ONLY support trigger on pins 5+6 or 7+8 when simultanously using AUX for actuator output.
if param compare TRIG_PINS 56 if param compare TRIG_PINS 56
@@ -394,6 +396,13 @@ else
set AUX_MODE none set AUX_MODE none
fi fi
fi fi
else
if param compare TRIG_PINS_EX 12288
then
set FMU_MODE pwm12
set AUX_MODE pwm12
fi
fi
camera_trigger start camera_trigger start
camera_feedback start camera_feedback start

View File

@@ -148,6 +148,24 @@ PARAM_DEFINE_INT32(TRIG_MODE, 0);
*/ */
PARAM_DEFINE_INT32(TRIG_PINS, 56); PARAM_DEFINE_INT32(TRIG_PINS, 56);
/**
* Camera trigger pin extended
*
* This Bit mask selects which FMU pin is used (range: AUX9-AUX32)
* If the value is not 0 it takes precedence over TRIG_PINS.
*
* If bits above 8 are set that value is used as the selector for trigger pins.
* greater then 8. 0x00000300 Would be Pins 9,10. If the value is
*
*
* @min 0
* @max 4294967040
* @decimal 0
* @reboot_required true
* @group Camera trigger
*/
PARAM_DEFINE_INT32(TRIG_PINS_EX, 0);
/** /**
* Camera trigger distance * Camera trigger distance
* *

View File

@@ -36,23 +36,37 @@
void CameraInterface::get_pins() void CameraInterface::get_pins()
{ {
// Get parameter handle // Get parameter handle
_p_pin = param_find("TRIG_PINS"); _p_pin = param_find("TRIG_PINS");
if (_p_pin == PARAM_INVALID) { _p_pin_ex = param_find("TRIG_PINS_EX");
if (_p_pin == PARAM_INVALID && _p_pin_ex == PARAM_INVALID) {
PX4_ERR("param TRIG_PINS not found"); PX4_ERR("param TRIG_PINS not found");
return; return;
} }
int pin_list;
param_get(_p_pin, &pin_list);
// Set all pins as invalid // Set all pins as invalid
for (unsigned i = 0; i < arraySize(_pins); i++) { for (unsigned i = 0; i < arraySize(_pins); i++) {
_pins[i] = -1; _pins[i] = -1;
} }
int pin_list = 0;
int pin_list_ex = 0;
if (_p_pin_ex != PARAM_INVALID) {
param_get(_p_pin_ex, &pin_list_ex);
}
if (_p_pin != PARAM_INVALID) {
param_get(_p_pin, &pin_list);
}
if (pin_list_ex == 0) {
// Convert number to individual channels // Convert number to individual channels
unsigned i = 0; unsigned i = 0;
int single_pin; int single_pin;
@@ -68,4 +82,15 @@ void CameraInterface::get_pins()
i++; i++;
} }
} else {
unsigned int p = 0;
for (unsigned int i = 0; i < arraySize(_pins); i++) {
int32_t v = (pin_list_ex & (1 << i)) ? i : -1;
if (v > 0) {
_pins[p++] = v;
}
}
}
} }

View File

@@ -98,7 +98,8 @@ protected:
void get_pins(); void get_pins();
param_t _p_pin{PARAM_INVALID}; param_t _p_pin{PARAM_INVALID};
param_t _p_pin_ex{PARAM_INVALID};
int _pins[6] {}; int _pins[32] {};
}; };

View File

@@ -80,7 +80,11 @@ void CameraInterfaceGPIO::info()
PX4_INFO_RAW("GPIO trigger mode, pins enabled: "); PX4_INFO_RAW("GPIO trigger mode, pins enabled: ");
for (unsigned i = 0; i < arraySize(_pins); ++i) { for (unsigned i = 0; i < arraySize(_pins); ++i) {
PX4_INFO_RAW("[%d]", _pins[i]); if (_pins[i] < 0) {
continue;
}
PX4_INFO_RAW("[%d]", _pins[i] + 1);
} }
PX4_INFO_RAW(", polarity : %s\n", _trigger_invert ? "ACTIVE_LOW" : "ACTIVE_HIGH"); PX4_INFO_RAW(", polarity : %s\n", _trigger_invert ? "ACTIVE_LOW" : "ACTIVE_HIGH");

View File

@@ -56,7 +56,7 @@ public:
void info(); void info();
private: private:
static const int num_gpios = DIRECT_PWM_OUTPUT_CHANNELS > 6 ? 6 : DIRECT_PWM_OUTPUT_CHANNELS; static const int num_gpios = 32;
void setup(); void setup();

View File

@@ -91,8 +91,17 @@ void CameraInterfacePWM::trigger(bool trigger_on_true)
void CameraInterfacePWM::info() void CameraInterfacePWM::info()
{ {
PX4_INFO("PWM trigger mode (generic), pins enabled : [%d][%d][%d][%d][%d][%d]", PX4_INFO_RAW("PWM trigger mode, pins enabled: ");
_pins[5], _pins[4], _pins[3], _pins[2], _pins[1], _pins[0]);
for (unsigned i = 0; i < arraySize(_pins); ++i) {
if (_pins[i] < 0) {
continue;
}
PX4_INFO_RAW("[%d]", _pins[i] + 1);
}
PX4_INFO_RAW("\n");
} }
#endif /* ifdef __PX4_NUTTX */ #endif /* ifdef __PX4_NUTTX */