fix center parameter metadata

This commit is contained in:
Beat Küng 2026-03-05 11:29:33 +01:00
parent f466574804
commit df498a776a
5 changed files with 14 additions and 58 deletions

View File

@ -180,7 +180,6 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
channel_labels = [process_channel_label(module_name, label, no_prefix)
for label in group['channel_labels']]
standard_params = group.get('standard_params', [])
center = group.get('center', None)
extra_function_groups = group.get('extra_function_groups', [])
pwm_timer_param = group.get('pwm_timer_param', None)
if 'timer_config_file' in group:
@ -190,7 +189,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
timer_groups = get_timer_groups(timer_config_file, verbose)
timer_output_groups, timer_params = get_output_groups(timer_groups,
param_prefix, channel_labels,
standard_params, center, extra_function_groups, pwm_timer_param,
standard_params, extra_function_groups, pwm_timer_param,
verbose=verbose)
output_groups.extend(timer_output_groups)
else:
@ -234,15 +233,15 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
per_channel_params = []
param_prefix = process_param_prefix(group['param_prefix'])
standard_params = group.get('standard_params', {})
center = group.get('center', None)
standard_params_array = [
( 'function', 'Function', 'FUNC', False ),
( 'disarmed', 'Disarmed', 'DIS', False ),
( 'min', 'Minimum', 'MIN', False ),
( 'max', 'Maximum', 'MAX', False ),
( 'failsafe', 'Failsafe', 'FAIL', True ),
( 'function', 'Function', 'FUNC', False, True ),
( 'disarmed', 'Disarmed', 'DIS', False, True ),
( 'min', 'Minimum', 'MIN', False, True ),
( 'center', 'Center\n(for Servos)', 'CENT', False, False ),
( 'max', 'Maximum', 'MAX', False, True ),
( 'failsafe', 'Failsafe', 'FAIL', True, True ),
]
for key, label, param_suffix, advanced in standard_params_array:
for key, label, param_suffix, advanced, has_function in standard_params_array:
show_if = None
if key in standard_params and 'show_if' in standard_params[key]:
show_if = standard_params[key]['show_if']
@ -251,20 +250,12 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
param = {
'label': label,
'name': param_prefix+'_'+param_suffix+'${i}',
'function': key,
}
if has_function: param['function'] = key
if advanced: param['advanced'] = True
if show_if: param['show-if'] = show_if
per_channel_params.append(param)
if center is not None:
center_param = {
'label': 'Center\n(for Servos)',
'name': param_prefix+'_CENT${i}',
}
if 'show_if' in center:
center_param['show-if'] = center['show_if']
per_channel_params.append(center_param)
param = {
'label': 'Rev Range\n(for Servos)',
'name': param_prefix+'_REV',

View File

@ -202,7 +202,6 @@ def get_actuator_output_params(yaml_config, output_functions,
channel_labels = [process_channel_label(module_name, label, no_prefix)
for label in group['channel_labels']]
standard_params = group.get('standard_params', [])
center = group.get('center', None)
extra_function_groups = group.get('extra_function_groups', [])
pwm_timer_param = group.get('pwm_timer_param', None)
if 'timer_config_file' in group:
@ -212,7 +211,7 @@ def get_actuator_output_params(yaml_config, output_functions,
timer_groups = get_timer_groups(timer_config_file, verbose)
timer_output_groups, timer_params = get_output_groups(timer_groups,
param_prefix, channel_labels,
standard_params, center, extra_function_groups, pwm_timer_param,
standard_params, extra_function_groups, pwm_timer_param,
verbose=verbose)
all_params.update(timer_params)
output_groups.extend(timer_output_groups)
@ -226,7 +225,6 @@ def get_actuator_output_params(yaml_config, output_functions,
no_prefix = not group.get('channel_label_module_name_prefix', True)
channel_label = process_channel_label(module_name, group['channel_label'], no_prefix)
standard_params = group.get('standard_params', {})
center_param = group.get('center', None)
instance_start = group.get('instance_start', 1)
instance_start_label = group.get('instance_start_label', instance_start)
if len(param_prefix) > 9: # 16 - len('_FAIL') - 2 (2 digits for index)
@ -301,6 +299,7 @@ When set to -1 (default), the value depends on the function (see {:}).
standard_params_array = [
( 'disarmed', 'Disarmed', 'DIS', disarmed_description ),
( 'min', 'Minimum', 'MIN', minimum_description ),
( 'center', 'Center', 'CENT', center_description ),
( 'max', 'Maximum', 'MAX', maximum_description ),
( 'failsafe', 'Failsafe', 'FAIL', failsafe_description ),
]
@ -313,7 +312,7 @@ When set to -1 (default), the value depends on the function (see {:}).
if standard_params[key]['max'] >= 1<<16:
raise Exception('maximum value for {:} expected <= {:} (got {:})'.format(key, 1<<16, standard_params[key]['max']))
if key == 'failsafe':
if key == 'failsafe' or key == 'center':
standard_params[key]['default'] = -1
standard_params[key]['min'] = -1
@ -332,33 +331,6 @@ When set to -1 (default), the value depends on the function (see {:}).
}
add_local_param(param_prefix+'_'+param_suffix+'${i}', param)
# center param is handled after standard params
if center_param is not None:
# values must be in range of an uint16_t
if center_param['min'] < 0:
raise Exception('minimum value for center expected >= 0 (got {:})'.format(center_param['min']))
if center_param['max'] >= 1<<16:
raise Exception('maximum value for center expected <= {:} (got {:})'.format(1<<16, center_param['max']))
center_param['default'] = -1
center_param['min'] = -1
param = {
'description': {
'short': channel_label+' ${i} Center Value',
'long': center_description
},
'type': 'int32',
'instance_start': instance_start,
'instance_start_label': instance_start_label,
'num_instances': num_channels,
'min': center_param['min'],
'max': center_param['max'],
'default': center_param['default'],
}
add_local_param(param_prefix+'_CENT${i}', param)
# add reverse range param
for param_prefix in all_param_prefixes:
groups = all_param_prefixes[param_prefix]

View File

@ -141,7 +141,6 @@ def get_timer_groups(timer_config_file, verbose=False):
def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
channel_labels=["PWM Main", "PWM Capture"],
standard_params=[],
center=None,
extra_function_groups=[], pwm_timer_param=None,
verbose=False):
""" convert the timer groups into an output_groups section of module.yaml
@ -183,9 +182,6 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
'channel_label_module_name_prefix': False,
}
if center is not None:
group['center'] = deepcopy(center)
if pwm_timer_param is not None:
pwm_timer_param_cp = deepcopy(pwm_timer_param)
timer_param_name = param_prefix+'_TIM'+str(timer_index)
@ -203,9 +199,6 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
for standard_param in group['standard_params']:
group['standard_params'][standard_param]['show_if'] = timer_param_name + '>=-1'
if 'center' in group:
group['center']['show_if'] = timer_param_name + '>=-1'
# indicate support for changing motor spin direction
group['supported_actions'] = {
'set_spin_direction1': {

View File

@ -8,7 +8,7 @@ actuator_output:
min: { min: 800, max: 1400, default: 1100 }
max: { min: 1600, max: 2200, default: 1900 }
failsafe: { min: 800, max: 2200 }
center: { min: 800, max: 2200}
center: { min: 800, max: 2200}
custom_params:
- name: 'DUTY_EN'
label: "Duty-Cycle\n Mode"

View File

@ -9,7 +9,7 @@ actuator_output:
min: { min: 800, max: 1400, default: 1000 }
max: { min: 1600, max: 2200, default: 2000 }
failsafe: { min: 800, max: 2200 }
center: { min: 800, max: 2200}
center: { min: 800, max: 2200}
extra_function_groups: [ pwm_fmu ]
pwm_timer_param:
description: