Skip to content

Commit

Permalink
CameraTrigger: Feedback fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee authored and bkueng committed Jan 8, 2019
1 parent 68148c5 commit 541b962
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/drivers/camera_trigger/camera_trigger_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ PARAM_DEFINE_FLOAT(TRIG_DISTANCE, 25.0f);
/**
* PWM output to trigger shot.
*
* @reboot_required true
*
* @min 1000
* @max 2000
* @unit us
Expand Down
16 changes: 4 additions & 12 deletions src/drivers/camera_trigger/interfaces/src/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,11 @@
#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():
CameraInterface()
{
param_get(param_find("TRIG_PWM_SHOOT"), &_pwm_camera_shoot);
param_get(param_find("TRIG_PWM_NEUTRAL"), &_pwm_camera_neutral);
get_pins();
setup();
}
Expand Down Expand Up @@ -49,7 +41,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, 0, 2000));
up_pwm_trigger_set(_pins[i], math::constrain(_pwm_camera_neutral, 0, 2000));
}
}

Expand All @@ -60,7 +52,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, 0, 2000));
up_pwm_trigger_set(_pins[i], math::constrain(trigger_on_true ? _pwm_camera_shoot : _pwm_camera_neutral, 0, 2000));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/drivers/camera_trigger/interfaces/src/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CameraInterfacePWM : public CameraInterface
void info();

private:

int32_t _pwm_camera_shoot = 0;
int32_t _pwm_camera_neutral = 0;
void setup();

};
Expand Down

0 comments on commit 541b962

Please sign in to comment.