diff --git a/src/drivers/camera_trigger/camera_trigger_params.c b/src/drivers/camera_trigger/camera_trigger_params.c index 3b17756f0f..0b9f56d6d1 100644 --- a/src/drivers/camera_trigger/camera_trigger_params.c +++ b/src/drivers/camera_trigger/camera_trigger_params.c @@ -139,3 +139,29 @@ PARAM_DEFINE_INT32(TRIG_PINS, 56); * @group Camera trigger */ PARAM_DEFINE_FLOAT(TRIG_DISTANCE, 25.0f); + +/** + * PWM output to trigger shot. + * + * @reboot_required true + * + * @min 1000 + * @max 2000 + * @unit us + * @group Camera trigger + * @reboot_required true + */ +PARAM_DEFINE_INT32(TRIG_PWM_SHOOT, 1900); + + +/** + * PWM neutral output on trigger pin. + * + * @min 1000 + * @max 2000 + * @unit us + * @group Camera trigger + * @reboot_required true + */ +PARAM_DEFINE_INT32(TRIG_PWM_NEUTRAL, 1500); + diff --git a/src/drivers/camera_trigger/interfaces/src/pwm.cpp b/src/drivers/camera_trigger/interfaces/src/pwm.cpp index 04ca8f7251..2612c1fd21 100644 --- a/src/drivers/camera_trigger/interfaces/src/pwm.cpp +++ b/src/drivers/camera_trigger/interfaces/src/pwm.cpp @@ -2,13 +2,22 @@ #include #include +#include + #include "drivers/drv_pwm_trigger.h" #include "pwm.h" + // TODO : make these parameters later -#define PWM_CAMERA_SHOOT 1900 -#define PWM_CAMERA_NEUTRAL 1500 +//#define PWM_CAMERA_SHOOT 1900 +//#define PWM_CAMERA_NEUTRAL 1500 + +int32_t pwm_camera_shoot = 0; +param_get(param_find("TRIG_PWM_SHOOT"), &pwm_camera_shoot); +int32_t pwm_camera_neutral = 0; +param_get(param_find("TRIG_PWM_NEUTRAL"), &pwm_camera_neutral); + CameraInterfacePWM::CameraInterfacePWM(): CameraInterface() @@ -40,7 +49,7 @@ void CameraInterfacePWM::setup() // Set neutral pulsewidths for (unsigned i = 0; i < arraySize(_pins); i++) { if (_pins[i] >= 0) { - up_pwm_trigger_set(_pins[i], math::constrain(PWM_CAMERA_NEUTRAL, PWM_CAMERA_NEUTRAL, 2000)); + up_pwm_trigger_set(_pins[i], math::constrain(pwm_camera_neutral, 0, 2000)); } } @@ -51,7 +60,7 @@ void CameraInterfacePWM::trigger(bool trigger_on_true) for (unsigned i = 0; i < arraySize(_pins); i++) { if (_pins[i] >= 0) { // Set all valid pins to shoot or neutral levels - up_pwm_trigger_set(_pins[i], math::constrain(trigger_on_true ? PWM_CAMERA_SHOOT : PWM_CAMERA_NEUTRAL, 1000, 2000)); + up_pwm_trigger_set(_pins[i], math::constrain(trigger_on_true ? pwm_camera_shoot : pwm_camera_neutral, 0, 2000)); } } }