mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
CameraTrigger: Feedback fixes
This commit is contained in:
@@ -143,8 +143,6 @@ PARAM_DEFINE_FLOAT(TRIG_DISTANCE, 25.0f);
|
|||||||
/**
|
/**
|
||||||
* PWM output to trigger shot.
|
* PWM output to trigger shot.
|
||||||
*
|
*
|
||||||
* @reboot_required true
|
|
||||||
*
|
|
||||||
* @min 1000
|
* @min 1000
|
||||||
* @max 2000
|
* @max 2000
|
||||||
* @unit us
|
* @unit us
|
||||||
|
|||||||
@@ -9,19 +9,11 @@
|
|||||||
#include "pwm.h"
|
#include "pwm.h"
|
||||||
|
|
||||||
|
|
||||||
// TODO : make these parameters later
|
|
||||||
//#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():
|
CameraInterfacePWM::CameraInterfacePWM():
|
||||||
CameraInterface()
|
CameraInterface()
|
||||||
{
|
{
|
||||||
|
param_get(param_find("TRIG_PWM_SHOOT"), &_pwm_camera_shoot);
|
||||||
|
param_get(param_find("TRIG_PWM_NEUTRAL"), &_pwm_camera_neutral);
|
||||||
get_pins();
|
get_pins();
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
@@ -49,7 +41,7 @@ void CameraInterfacePWM::setup()
|
|||||||
// Set neutral pulsewidths
|
// Set neutral pulsewidths
|
||||||
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
||||||
if (_pins[i] >= 0) {
|
if (_pins[i] >= 0) {
|
||||||
up_pwm_trigger_set(_pins[i], math::constrain(pwm_camera_neutral, 0, 2000));
|
up_pwm_trigger_set(_pins[i], math::constrain(_pwm_camera_neutral, 0, 2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +52,7 @@ void CameraInterfacePWM::trigger(bool trigger_on_true)
|
|||||||
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
for (unsigned i = 0; i < arraySize(_pins); i++) {
|
||||||
if (_pins[i] >= 0) {
|
if (_pins[i] >= 0) {
|
||||||
// Set all valid pins to shoot or neutral levels
|
// 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, 0, 2000));
|
up_pwm_trigger_set(_pins[i], math::constrain(trigger_on_true ? _pwm_camera_shoot : _pwm_camera_neutral, 0, 2000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public:
|
|||||||
void info();
|
void info();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int32_t _pwm_camera_shoot = 0;
|
||||||
|
int32_t _pwm_camera_neutral = 0;
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user