Commit acf848ba authored by Matthias Grob's avatar Matthias Grob Committed by Lorenz Meier
Browse files

PWM: Draft implementation to respect PWM_OUT when loading defaults

parent 50b0f0e3
......@@ -226,6 +226,8 @@ then
fi
fi
param set PWM_AUX_OUT ${PWM_AUX_OUT}
if [ $MIXER_AUX != none -a $AUX_MODE = none -a -e $OUTPUT_AUX_DEV ]
then
#
......@@ -268,6 +270,8 @@ then
fi
fi
param set PWM_MAIN_OUT ${PWM_OUT}
if [ $EXTRA_MIXER_MODE != none ]
then
......
......@@ -663,6 +663,7 @@ void PWMOut::update_params()
int32_t pwm_max_default = PWM_DEFAULT_MAX;
int32_t pwm_disarmed_default = 0;
int32_t pwm_rate_default = 50;
int32_t pwm_default_channels = 0;
const char *prefix;
......@@ -673,6 +674,7 @@ void PWMOut::update_params()
param_get(param_find("PWM_MAIN_MAX"), &pwm_max_default);
param_get(param_find("PWM_MAIN_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_MAIN_RATE"), &pwm_rate_default);
param_get(param_find("PWM_MAIN_OUT"), &pwm_default_channels);
} else if (_class_instance == CLASS_DEVICE_SECONDARY) {
prefix = "PWM_AUX";
......@@ -681,6 +683,7 @@ void PWMOut::update_params()
param_get(param_find("PWM_AUX_MAX"), &pwm_max_default);
param_get(param_find("PWM_AUX_DISARM"), &pwm_disarmed_default);
param_get(param_find("PWM_AUX_RATE"), &pwm_rate_default);
param_get(param_find("PWM_AUX_OUT"), &pwm_default_channels);
} else if (_class_instance == CLASS_DEVICE_TERTIARY) {
prefix = "PWM_EXTRA";
......@@ -695,6 +698,14 @@ void PWMOut::update_params()
return;
}
uint32_t single_ch = 0;
uint32_t pwm_default_channel_mask = 0;
while ((single_ch = pwm_default_channels % 10)) {
pwm_default_channel_mask |= 1 << (single_ch - 1);
pwm_default_channels /= 10;
}
// update the counter
// this is needed to decide if disarmed PWM output should be turned on or not
int num_disarmed_set = 0;
......@@ -716,7 +727,7 @@ void PWMOut::update_params()
param_set(param_find(str), &pwm_min_new);
}
} else {
} else if (pwm_default_channel_mask & 1 << i) {
_mixing_output.minValue(i) = pwm_min_default;
}
}
......@@ -736,7 +747,7 @@ void PWMOut::update_params()
param_set(param_find(str), &pwm_max_new);
}
} else {
} else if (pwm_default_channel_mask & 1 << i) {
_mixing_output.maxValue(i) = pwm_max_default;
}
}
......@@ -773,7 +784,7 @@ void PWMOut::update_params()
param_set(param_find(str), &pwm_dis_new);
}
} else {
} else if (pwm_default_channel_mask & 1 << i) {
_mixing_output.disarmedValue(i) = pwm_disarmed_default;
}
}
......
......@@ -6,6 +6,17 @@ parameters:
- group: PWM Outputs
definitions:
PWM_AUX_OUT:
description:
short: PWM channels used as ESC outputs
long: |
Number representing the channels e.g. 134 - Channel 1, 3 and 4.
Global e.g. PWM_AUX_MIN/MAX/DISARM limits only apply to these channels.
type: int32
min: 0
max: 123456789
default: 0
PWM_AUX_RATE:
description:
short: PWM aux output frequency
......
......@@ -6,6 +6,17 @@ parameters:
- group: PWM Outputs
definitions:
PWM_MAIN_OUT:
description:
short: PWM channels used as ESC outputs
long: |
Number representing the channels e.g. 134 - Channel 1, 3 and 4.
Global e.g. PWM_MAIN_MIN/MAX/DISARM limits only apply to these channels.
type: int32
min: 0
max: 123456789
default: 0
PWM_MAIN_RATE:
description:
short: PWM main output frequency
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment