From 04c2d0fe97e5362c9f3cd4f763fc096266c45b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Mi=C5=A1i=C4=87?= Date: Mon, 13 Jun 2022 11:27:23 +0200 Subject: [PATCH] drivers/pwm_out: set default failsafe values --- src/drivers/drv_pwm_output.h | 5 +++++ src/drivers/pwm_out/PWMOut.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/drivers/drv_pwm_output.h b/src/drivers/drv_pwm_output.h index 43721f9cb0..d6096d1f52 100644 --- a/src/drivers/drv_pwm_output.h +++ b/src/drivers/drv_pwm_output.h @@ -86,6 +86,11 @@ struct pwm_output_values { */ #define PWM_MOTOR_OFF 900 +/** + * Default value for a servo stop + */ +#define PWM_SERVO_STOP 1500 + /** * Default minimum PWM in us */ diff --git a/src/drivers/pwm_out/PWMOut.cpp b/src/drivers/pwm_out/PWMOut.cpp index f32f579597..27d1a9ed70 100644 --- a/src/drivers/pwm_out/PWMOut.cpp +++ b/src/drivers/pwm_out/PWMOut.cpp @@ -613,6 +613,14 @@ void PWMOut::update_params() int32_t pwm_fail_new = _mixing_output.failsafeValue(i); param_set(param_find(str), &pwm_fail_new); } + + } else { + if (pwm_default_channel_mask & 1 << i) { + _mixing_output.failsafeValue(i) = PWM_MOTOR_OFF; + + } else { + _mixing_output.failsafeValue(i) = PWM_SERVO_STOP; + } } } else {