mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Use defines instead of hardcoded magic values for maximum number of output channels and rpm filter time constant
This commit is contained in:
parent
8ce6ad6662
commit
b85ad98a98
@ -71,7 +71,7 @@ CameraCapture::CameraCapture() :
|
||||
_p_camera_capture_edge = param_find("CAM_CAP_EDGE");
|
||||
param_get(_p_camera_capture_edge, &_camera_capture_edge);
|
||||
|
||||
for (unsigned i = 0; i < 16 && _capture_channel == -1; ++i) {
|
||||
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS && _capture_channel == -1; ++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);
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "camera_interface.h"
|
||||
#include <drivers/drv_pwm_output.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <board_config.h>
|
||||
|
||||
@ -44,7 +45,7 @@ void CameraInterface::get_pins()
|
||||
|
||||
unsigned pin_index = 0;
|
||||
|
||||
for (unsigned i = 0; i < 16 && pin_index < arraySize(_pins); ++i) {
|
||||
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS && 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);
|
||||
|
||||
@ -63,7 +63,7 @@ bool PPSCapture::init()
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
for (unsigned i = 0; i < 16; ++i) {
|
||||
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS; ++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);
|
||||
|
||||
@ -59,7 +59,7 @@ bool RPMCapture::init()
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
for (unsigned i = 0; i < 16; ++i) {
|
||||
for (unsigned i = 0; i < PWM_OUTPUT_MAX_CHANNELS; ++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);
|
||||
@ -138,7 +138,7 @@ void RPMCapture::Run()
|
||||
// Don't update RPM filter with outliers
|
||||
const float dt = math::min((now - _timestamp_last_update) * 1e-6f, 1.f);
|
||||
_timestamp_last_update = now;
|
||||
_rpm_filter.setParameters(dt, 0.5f);
|
||||
_rpm_filter.setParameters(dt, RPM_FILTER_TIME_CONSTANT);
|
||||
_rpm_filter.update(_rpm_median_filter.apply(rpm_raw));
|
||||
}
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ public:
|
||||
private:
|
||||
static constexpr hrt_abstime RPM_PULSE_TIMEOUT = 1_s;
|
||||
static constexpr float RPM_MAX_VALUE = 50e3f;
|
||||
static constexpr float RPM_FILTER_TIME_CONSTANT = .5f;
|
||||
|
||||
void Run() override;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user