From 35ce6d1b73ce40f34a7bb06731d6ef5d5d317b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Fri, 17 Sep 2021 11:58:05 +0200 Subject: [PATCH] pca9685_pwm_out: add dynamic mixing support --- src/drivers/pca9685_pwm_out/CMakeLists.txt | 2 ++ src/drivers/pca9685_pwm_out/main.cpp | 12 ++++++++---- src/drivers/pca9685_pwm_out/module.yaml | 12 ++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/drivers/pca9685_pwm_out/module.yaml diff --git a/src/drivers/pca9685_pwm_out/CMakeLists.txt b/src/drivers/pca9685_pwm_out/CMakeLists.txt index dfb2a46375..00f581d1f7 100644 --- a/src/drivers/pca9685_pwm_out/CMakeLists.txt +++ b/src/drivers/pca9685_pwm_out/CMakeLists.txt @@ -37,6 +37,8 @@ px4_add_module( SRCS main.cpp PCA9685.cpp + MODULE_CONFIG + module.yaml DEPENDS mixer mixer_module diff --git a/src/drivers/pca9685_pwm_out/main.cpp b/src/drivers/pca9685_pwm_out/main.cpp index 391e198455..7031615d62 100644 --- a/src/drivers/pca9685_pwm_out/main.cpp +++ b/src/drivers/pca9685_pwm_out/main.cpp @@ -124,8 +124,10 @@ PCA9685Wrapper::PCA9685Wrapper(int schd_rate_limit) : _cycle_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")), _schd_rate_limit(schd_rate_limit) { - _mixing_output.setAllMinValues(PWM_DEFAULT_MIN); - _mixing_output.setAllMaxValues(PWM_DEFAULT_MAX); + if (!_mixing_output.useDynamicMixing()) { + _mixing_output.setAllMinValues(PWM_DEFAULT_MIN); + _mixing_output.setAllMaxValues(PWM_DEFAULT_MAX); + } } PCA9685Wrapper::~PCA9685Wrapper() @@ -173,6 +175,10 @@ void PCA9685Wrapper::updateParams() void PCA9685Wrapper::updatePWMParams() { + if (_mixing_output.useDynamicMixing()) { + return; + } + // update pwm params const char *pname_format_pwm_ch_max[2] = {"PWM_MAIN_MAX%d", "PWM_AUX_MAX%d"}; const char *pname_format_pwm_ch_min[2] = {"PWM_MAIN_MIN%d", "PWM_AUX_MIN%d"}; @@ -369,7 +375,6 @@ bool PCA9685Wrapper::updateOutputs(bool stop_motors, uint16_t *outputs, unsigned void PCA9685Wrapper::Run() { if (should_exit()) { - PX4_INFO("PCA9685 stopping."); ScheduleClear(); _mixing_output.unregister(); unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance); @@ -457,7 +462,6 @@ void PCA9685Wrapper::Run() perf_end(_cycle_perf); } -// TODO int PCA9685Wrapper::ioctl(cdev::file_t *filep, int cmd, unsigned long arg) { int ret = OK; diff --git a/src/drivers/pca9685_pwm_out/module.yaml b/src/drivers/pca9685_pwm_out/module.yaml new file mode 100644 index 0000000000..20b955cf78 --- /dev/null +++ b/src/drivers/pca9685_pwm_out/module.yaml @@ -0,0 +1,12 @@ +module_name: PCA9685 Output +actuator_output: + output_groups: + - param_prefix: PCA9685 + channel_label: 'PCA9685' + standard_params: + disarmed: { min: 800, max: 2200, default: 900 } + min: { min: 800, max: 1400, default: 1000 } + max: { min: 1600, max: 2200, default: 2000 } + failsafe: { min: 800, max: 2200 } + num_channels: 16 +