@@ -213,7 +213,7 @@ def validate(target, layout, device, type):
213213 for field in dict (filter (ignore_undef_pins , layout .items ())):
214214 # Ensure that the layout field is a valid field from the hardware list
215215 if field not in hardware_fields .keys ():
216- print (f'device "{ target } " has an unknown field name { field } ' )
216+ print (f'ERROR: device "{ target } " has an unknown field name { field } ' )
217217 had_error = True
218218 else :
219219 had_error |= validate_pin_uniqueness (target , layout , field )
@@ -244,15 +244,15 @@ def validate_field_grouping(target, layout, field, field_group):
244244 if field in group [0 ]:
245245 for must in group [0 ] + group [1 ]:
246246 if must not in layout :
247- print (f'device "{ target } " because "{ field } " is defined all other related fields must also be defined { must } ' )
247+ print (f'ERROR: device "{ target } " because "{ field } " is defined all other related fields must also be defined { must } ' )
248248 print (f'\t { group [0 ] + group [1 ]} ' )
249249 had_error = True
250250 found = True if group [2 ] == [] else False
251251 for one in group [2 ]:
252252 if one in layout :
253253 found = True
254254 if not found :
255- print (f'device "{ target } " because "{ field } " is defined at least one of the following fields must also be { group [2 ]} ' )
255+ print (f'ERROR: device "{ target } " because "{ field } " is defined at least one of the following fields must also be { group [2 ]} ' )
256256 had_error = True
257257 return had_error
258258
@@ -267,7 +267,7 @@ def validate_pin_uniqueness(target, layout, field):
267267 if field in duplicate and used_pins [pin ] in duplicate :
268268 allowed = True
269269 if not allowed :
270- print (f'device "{ target } " PIN { pin } "{ field } " is already assigned to "{ used_pins [pin ]} "' )
270+ print (f'ERROR: device "{ target } " PIN { pin } "{ field } " is already assigned to "{ used_pins [pin ]} "' )
271271 had_error = True
272272 else :
273273 used_pins [pin ] = field
@@ -284,32 +284,32 @@ def validate_power_config(target, layout):
284284 power_default = layout ['power_default' ]
285285 power_high = layout ['power_high' ]
286286 if power_min > power_max :
287- print (f'device "{ target } " power_min must be less than or equal to power_max' )
287+ print (f'ERROR: device "{ target } " power_min must be less than or equal to power_max' )
288288 had_error = True
289289 if power_default < power_min or power_default > power_max :
290- print (f'device "{ target } " power_default must lie between power_min and power_max' )
290+ print (f'ERROR: device "{ target } " power_default must lie between power_min and power_max' )
291291 had_error = True
292292 if power_high < power_min or power_high > power_max :
293- print (f'device "{ target } " power_high must lie between power_min and power_max' )
293+ print (f'ERROR: device "{ target } " power_high must lie between power_min and power_max' )
294+ had_error = True
295+ if power_values and power_max - power_min + 1 > len (power_values ):
296+ print (f'ERROR: device "{ target } " power_values must have the correct number of entries to match all values from power_min to power_max' )
297+ had_error = True
298+ if power_values_dual and power_max - power_min + 1 > len (power_values_dual ):
299+ print (f'ERROR: device "{ target } " power_values_dual must have the correct number of entries to match all values from power_min to power_max' )
294300 had_error = True
295- if power_values and power_max - power_min + 1 != len (power_values ):
296- print (f'device "{ target } " power_values must have the correct number of entries to match all values from power_min to power_max' )
297- had_error = power_max - power_min + 1 > len (power_values )
298- if power_values_dual and power_max - power_min + 1 != len (power_values_dual ):
299- print (f'device "{ target } " power_values_dual must have the correct number of entries to match all values from power_min to power_max' )
300- had_error = power_max - power_min + 1 > len (power_values_dual )
301301 if layout ['power_control' ] == 3 and 'power_apc2' not in layout :
302- print (f'device "{ target } " defines power_control as DACWRITE and power_apc2 is undefined' )
302+ print (f'ERROR: device "{ target } " defines power_control as DACWRITE and power_apc2 is undefined' )
303303 had_error = True
304304 if 'power_values2' in layout :
305305 if len (layout ['power_values2' ]) != len (power_values ):
306- print (f'device "{ target } " power_values2 must have the same number of entries as power_values' )
306+ print (f'ERROR: device "{ target } " power_values2 must have the same number of entries as power_values' )
307307 had_error = True
308308 if layout ['power_control' ] != 3 :
309- print (f'device "{ target } " power_values2 is defined so power_control must be set to 3 (DACWRITE)' )
309+ print (f'ERROR: device "{ target } " power_values2 is defined so power_control must be set to 3 (DACWRITE)' )
310310 had_error = True
311311 if 'power_apc2' not in layout :
312- print (f'device "{ target } " power_values2 is defined so the power_apc2 pin must also be defined' )
312+ print (f'ERROR: device "{ target } " power_values2 is defined so the power_apc2 pin must also be defined' )
313313 had_error = True
314314 return had_error
315315
@@ -318,10 +318,10 @@ def validate_backpack(target, layout):
318318 had_error = False
319319 if 'passthrough_baud' in layout :
320320 if layout ['serial_rx' ] == layout ['serial_tx' ] and layout ['passthrough_baud' ] != 230400 :
321- print (f'device "{ target } " an external module with a backpack should set the baud rate to 230400' )
321+ print (f'ERROR: device "{ target } " an external module with a backpack should set the baud rate to 230400' )
322322 had_error = True
323323 if layout ['serial_rx' ] != layout ['serial_tx' ] and layout ['passthrough_baud' ] != 460800 :
324- print (f'device "{ target } " an internal module with a backpack should set the baud rate to 460800' )
324+ print (f'ERROR: device "{ target } " an internal module with a backpack should set the baud rate to 460800' )
325325 had_error = True
326326 return had_error
327327
@@ -330,18 +330,18 @@ def validate_joystick(target, layout):
330330 had_error = False
331331 if 'joystick' in layout or 'joystick_values' in layout :
332332 if 'joystick' not in layout :
333- print (f'device "{ target } " joystick_values is defined so the joystick pin must also be defined' )
333+ print (f'ERROR: device "{ target } " joystick_values is defined so the joystick pin must also be defined' )
334334 had_error = True
335335 elif 'joystick_values' not in layout :
336- print (f'device "{ target } " joystick is defined so the joystick_values must also be defined' )
336+ print (f'ERROR: device "{ target } " joystick is defined so the joystick_values must also be defined' )
337337 had_error = True
338338 elif len (layout ['joystick_values' ]) != 6 :
339- print (f'device "{ target } " joystick_values must have 6 values defined' )
339+ print (f'ERROR: device "{ target } " joystick_values must have 6 values defined' )
340340 had_error = True
341341 else :
342342 for value in layout ['joystick_values' ]:
343343 if value < 0 or value > 4095 :
344- print (f'device "{ target } " joystick_values must be between 0 and 4095 inclusive' )
344+ print (f'ERROR: device "{ target } " joystick_values must be between 0 and 4095 inclusive' )
345345 had_error = True
346346 return had_error
347347
@@ -354,7 +354,7 @@ def validate_pwm_outputs(target, layout):
354354 field in layout and \
355355 layout [field ] in layout ['pwm_outputs' ] and \
356356 field not in allowable_pwm_shared :
357- print (f'device "{ target } " pwm_output pin { layout [field ]} is not allowed to be shared with { field } ' )
357+ print (f'ERROR: device "{ target } " pwm_output pin { layout [field ]} is not allowed to be shared with { field } ' )
358358 had_error = True
359359 return had_error
360360
@@ -363,10 +363,10 @@ def validate_pin_function(target, layout, field, platform):
363363 if hardware_fields [field ].value > FieldType .PIN .value :
364364 function = get_pin_function (platform , layout [field ])
365365 if function is None :
366- print (f'device "{ target } " has an invalid pin number for { field } , { layout [field ]} ' )
366+ print (f'ERROR: device "{ target } " has an invalid pin number for { field } , { layout [field ]} ' )
367367 return True
368368 if hardware_fields [field ] == FieldType .INPUT and not (function & 1 ):
369- print (f'device "{ target } " pin for { field } must be assigned to a pin that supports INPUT' )
369+ print (f'ERROR: device "{ target } " pin for { field } must be assigned to a pin that supports INPUT' )
370370 return True
371371 return False
372372
@@ -375,5 +375,5 @@ def validate_vtx_amp_pwm(target, layout, platform):
375375 if platform == 'esp32' and 'vtx_amp_pwm' in layout :
376376 function = get_pin_function (platform , layout ['vtx_amp_pwm' ])
377377 if function is not None and function & 8 != 8 :
378- print (f'device "{ target } " "vtx_amp_pwm" is preferred to be a DAC pin if possible, but PWM output is supported' )
378+ print (f'NOTICE: device "{ target } " "vtx_amp_pwm" is preferred to be a DAC pin if possible, but PWM output is supported' )
379379 return False
0 commit comments