@@ -66,8 +66,9 @@ def get_timer_groups(timer_config_file, verbose=False):
66
66
raise Exception ('"{:}" not found in {:}' .format (timers_start_marker , timer_config_file ))
67
67
timer_config = timer_config [timers_start :]
68
68
open_idx , close_idx = find_matching_brackets (('{' , '}' ), timer_config , verbose )
69
- timers = timer_config [open_idx :close_idx ]
70
- for line in timers .splitlines ():
69
+ timers_str = timer_config [open_idx :close_idx ]
70
+ timers = []
71
+ for line in timers_str .splitlines ():
71
72
line = line .strip ()
72
73
if len (line ) == 0 or line .startswith ('//' ):
73
74
continue
@@ -76,6 +77,7 @@ def get_timer_groups(timer_config_file, verbose=False):
76
77
if timer :
77
78
if verbose : print ('found timer def: {:}' .format (timer ))
78
79
dshot_support [timer ] = 'DMA' in line
80
+ timers .append (timer )
79
81
else :
80
82
# Make sure we don't miss anything (e.g. for different syntax) or misparse (e.g. multi-line comments)
81
83
raise Exception ('Unparsed timer in line: {:}' .format (line ))
@@ -112,7 +114,7 @@ def get_timer_groups(timer_config_file, verbose=False):
112
114
if len (channel_timers ) == 0 :
113
115
raise Exception ('No channels found in "{:}"' .format (channels ))
114
116
115
- groups = [(len (list (g )), dshot_support [k ]) for k , g in groupby (channel_timers )]
117
+ groups = [(timers . index ( k ), len (list (g )), dshot_support [k ]) for k , g in groupby (channel_timers )]
116
118
outputs = {
117
119
'types' : channel_types ,
118
120
'groups' : groups
@@ -132,9 +134,8 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
132
134
instance_start = 1
133
135
output_groups = []
134
136
timer_params = {}
135
- timer_index = 0
136
137
instance_start_label = [ 1 , 1 ]
137
- for group_count , dshot_support in timer_groups ['groups' ]:
138
+ for timer_index , group_count , dshot_support in timer_groups ['groups' ]:
138
139
139
140
# check for capture vs normal pins for the label
140
141
types = timer_groups ['types' ][instance_start - 1 :instance_start + group_count - 1 ]
@@ -181,7 +182,6 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
181
182
timer_params [param_prefix + '_TIM' + str (timer_index )] = pwm_timer_param_cp
182
183
instance_start += group_count
183
184
instance_start_label [channel_type_idx ] += group_count
184
- timer_index += 1
185
185
return (output_groups , timer_params )
186
186
187
187
if __name__ == '__main__' :
0 commit comments