delete SYS_CTRL_ALLOC

This commit is contained in:
Daniel Agar
2022-09-09 09:14:09 -04:00
parent 13f9eabd70
commit 15fece7e14
17 changed files with 46 additions and 245 deletions
@@ -127,44 +127,6 @@ PARAM_DEFINE_FLOAT(TRIG_ACT_TIME, 40.0f);
*/
PARAM_DEFINE_INT32(TRIG_MODE, 0);
/**
* Camera trigger pin
*
* Selects which FMU pin is used (range: AUX1-AUX8 on Pixhawk controllers with an I/O board,
* MAIN1-MAIN8 on controllers without an I/O board).
*
* The PWM interface takes two pins per camera, while relay
* triggers on every pin individually. Example: Value 56 would trigger on pins 5 and 6.
* For GPIO mode Pin 6 will be triggered followed by 5. With a value of 65 pin 5 will
* be triggered followed by 6. Pins may be non contiguous. I.E. 16 or 61.
* In GPIO mode the delay pin to pin is < .2 uS.
*
* @min 1
* @max 12345678
* @decimal 0
* @reboot_required true
* @group Camera trigger
*/
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 2147483647
* @decimal 0
* @reboot_required true
* @group Camera trigger
*/
PARAM_DEFINE_INT32(TRIG_PINS_EX, 0);
/**
* Camera trigger distance
*
@@ -42,79 +42,17 @@ void CameraInterface::get_pins()
_pins[i] = -1;
}
param_t p_ctrl_alloc = param_find("SYS_CTRL_ALLOC");
int32_t ctrl_alloc = 0;
unsigned pin_index = 0;
if (p_ctrl_alloc != PARAM_INVALID) {
param_get(p_ctrl_alloc, &ctrl_alloc);
}
for (unsigned i = 0; i < 16 && pin_index < arraySize(_pins); ++i) {
char param_name[17];
snprintf(param_name, sizeof(param_name), "%s_%s%d", PARAM_PREFIX, "FUNC", i + 1);
param_t function_handle = param_find(param_name);
int32_t function;
if (ctrl_alloc == 1) {
unsigned pin_index = 0;
for (unsigned i = 0; i < 16 && pin_index < arraySize(_pins); ++i) {
char param_name[17];
snprintf(param_name, sizeof(param_name), "%s_%s%d", PARAM_PREFIX, "FUNC", i + 1);
param_t function_handle = param_find(param_name);
int32_t function;
if (function_handle != PARAM_INVALID && param_get(function_handle, &function) == 0) {
if (function == 2000) { // Camera_Trigger
_pins[pin_index++] = i;
}
}
}
} else {
// Get parameter handle
param_t p_pin = param_find("TRIG_PINS");
param_t 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");
return;
}
int32_t pin_list = 0;
int32_t 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
unsigned i = 0;
int single_pin;
while ((single_pin = pin_list % 10)) {
_pins[i] = single_pin - 1;
if (_pins[i] < 0) {
_pins[i] = -1;
}
pin_list /= 10;
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;
}
if (function_handle != PARAM_INVALID && param_get(function_handle, &function) == 0) {
if (function == 2000) { // Camera_Trigger
_pins[pin_index++] = i;
}
}
}