@@ -251,6 +251,7 @@ def __init__(self, version: str, local_filesystem: LocalFilesystem) -> None:
251251 _vehicle_components_strings = _ ("Number of cells" )
252252 _vehicle_components_strings = _ ("Capacity mAh" )
253253 _vehicle_components_strings = _ ("ESC" )
254+ _vehicle_components_strings = _ ("RPM Telemetry" )
254255 _vehicle_components_strings = _ ("Motors" )
255256 _vehicle_components_strings = _ ("Poles" )
256257 _vehicle_components_strings = _ ("Propellers" )
@@ -298,6 +299,19 @@ def update_json_data(self) -> None:
298299 "Notes" : self .data ["Components" ]["Flight Controller" ]["Notes" ],
299300 }
300301
302+ # To update old JSON files that do not have these new
303+ # "ESC.RPM Telemetry.Connection" and "ESC.RPM Telemetry.Protocol" fields
304+ if "ESC" not in self .data ["Components" ]:
305+ self .data ["Components" ]["ESC" ] = {}
306+ if "RPM Telemetry" not in self .data ["Components" ]["ESC" ]:
307+ self .data ["Components" ]["ESC" ] = {
308+ "Product" : self .data ["Components" ]["ESC" ]["Product" ],
309+ "Firmware" : self .data ["Components" ]["ESC" ]["Firmware" ],
310+ "FC Connection" : self .data ["Components" ]["ESC" ]["FC Connection" ],
311+ "RPM Telemetry" : {"Connection" : "None" , "Protocol" : "None" },
312+ "Notes" : self .data ["Components" ]["ESC" ]["Notes" ],
313+ }
314+
301315 def set_vehicle_type_and_version (self , vehicle_type : str , version : str ) -> None :
302316 self ._set_component_value_and_update_ui (("Flight Controller" , "Firmware" , "Type" ), vehicle_type )
303317 if version :
@@ -480,26 +494,61 @@ def __set_motor_poles_from_fc_parameters(self, fc_parameters: dict) -> None:
480494 elif "SERVO_FTW_MASK" in fc_parameters and fc_parameters ["SERVO_FTW_MASK" ] and "SERVO_FTW_POLES" in fc_parameters :
481495 self .data ["Components" ]["Motors" ]["Specifications" ]["Poles" ] = fc_parameters ["SERVO_FTW_POLES" ]
482496
483- def update_esc_protocol_combobox_entries (self , esc_connection_type : str ) -> None :
497+ def update_esc_protocol_combobox_entries (self , esc_connection_type : str ) -> None : # noqa: PLR0915
484498 """Updates the ESC Protocol combobox entries based on the selected ESC Type."""
485499 if len (esc_connection_type ) > 3 and esc_connection_type [:3 ] == "CAN" :
486500 protocols = ["DroneCAN" ]
501+ rpm_connections = [esc_connection_type ]
487502 elif len (esc_connection_type ) > 6 and esc_connection_type [:6 ] == "SERIAL" :
488503 protocols = [value ["protocol" ] for value in serial_protocols_dict .values () if value ["component" ] == "ESC" ]
504+ rpm_connections = [esc_connection_type ]
489505 elif "MOT_PWM_TYPE" in self .local_filesystem .doc_dict :
490506 protocols = list (self .local_filesystem .doc_dict ["MOT_PWM_TYPE" ]["values" ].values ())
507+ rpm_connections = ["None" , "I/O Only" , * serial_ports , * can_ports ]
491508 elif "Q_M_PWM_TYPE" in self .local_filesystem .doc_dict :
492509 protocols = list (self .local_filesystem .doc_dict ["Q_M_PWM_TYPE" ]["values" ].values ())
510+ rpm_connections = ["None" , "I/O Only" , * serial_ports , * can_ports ]
493511 else :
494512 protocols = []
513+ rpm_connections = []
495514
515+ protocol = ""
496516 protocol_path = ("ESC" , "FC Connection" , "Protocol" )
497517 if protocol_path in self .entry_widgets :
498518 protocol_combobox = self .entry_widgets [protocol_path ]
499519 protocol_combobox ["values" ] = protocols # Update the combobox entries
500520 if protocol_combobox .get () not in protocols and isinstance (protocol_combobox , ttk .Combobox ):
501521 protocol_combobox .set (protocols [0 ] if protocols else "" )
502522 protocol_combobox .update_idletasks () # re-draw the combobox ASAP
523+ protocol = protocol_combobox .get ()
524+ if protocol in ["Normal" , "OneShot" , "OneShot125" , "Brushed" , "PWMRange" ]:
525+ rpm_connections = ["None" ]
526+ elif "DShot" in protocol :
527+ rpm_connections = ["None" , "Main Out/AIO" , * serial_ports ]
528+
529+ rpm_connection_path = ("ESC" , "RPM Telemetry" , "Connection" )
530+ if rpm_connection_path in self .entry_widgets :
531+ rpm_connection_combobox = self .entry_widgets [rpm_connection_path ]
532+ rpm_connection_combobox ["values" ] = rpm_connections # Update the combobox entries
533+ if rpm_connection_combobox .get () not in rpm_connections and isinstance (rpm_connection_combobox , ttk .Combobox ):
534+ rpm_connection_combobox .set (rpm_connections [0 ] if rpm_connections else "" )
535+ rpm_connection_combobox .update_idletasks () # re-draw the combobox ASAP
536+
537+ if len (esc_connection_type ) > 3 and esc_connection_type [:3 ] == "CAN" :
538+ rpm_protocols = ["None" , "DroneCAN" ]
539+ elif len (esc_connection_type ) > 6 and esc_connection_type [:6 ] == "SERIAL" :
540+ rpm_protocols = ["None" , protocol ]
541+ elif "MOT_PWM_TYPE" in self .local_filesystem .doc_dict or "Q_M_PWM_TYPE" in self .local_filesystem .doc_dict :
542+ rpm_protocols = ["None" , "Dshot" , "BDshot" ]
543+ else :
544+ rpm_protocols = []
545+ rpm_protocol_path = ("ESC" , "RPM Telemetry" , "Protocol" )
546+ if rpm_protocol_path in self .entry_widgets :
547+ rpm_protocol_combobox = self .entry_widgets [rpm_protocol_path ]
548+ rpm_protocol_combobox ["values" ] = rpm_protocols # Update the combobox entries
549+ if rpm_protocol_combobox .get () not in rpm_protocols and isinstance (rpm_protocol_combobox , ttk .Combobox ):
550+ rpm_protocol_combobox .set (rpm_protocols [0 ] if rpm_protocols else "" )
551+ rpm_protocol_combobox .update_idletasks () # re-draw the combobox ASAP
503552
504553 def add_entry_or_combobox (
505554 self , value : float , entry_frame : ttk .Frame , path : tuple [str , str , str ]
@@ -554,6 +603,12 @@ def get_combobox_values(param_name: str) -> list:
554603 ("GNSS Receiver" , "FC Connection" , "Type" ): {
555604 "values" : ["None" , * self .serial_ports , * self .can_ports ],
556605 },
606+ ("ESC" , "RPM Telemetry" , "Connection" ): {
607+ "values" : ["None" , "" , * self .serial_ports , * self .can_ports ],
608+ },
609+ ("ESC" , "RPM Telemetry" , "Protocol" ): {
610+ "values" : ["None" , "DSHot" , "BDSHot" ],
611+ },
557612 ("GNSS Receiver" , "FC Connection" , "Protocol" ): {
558613 "values" : get_combobox_values ("GPS_TYPE" ),
559614 },
0 commit comments