@@ -251,6 +251,7 @@ def __init__(self, version: str, local_filesystem: LocalFilesystem) -> None:
251
251
_vehicle_components_strings = _ ("Number of cells" )
252
252
_vehicle_components_strings = _ ("Capacity mAh" )
253
253
_vehicle_components_strings = _ ("ESC" )
254
+ _vehicle_components_strings = _ ("RPM Telemetry" )
254
255
_vehicle_components_strings = _ ("Motors" )
255
256
_vehicle_components_strings = _ ("Poles" )
256
257
_vehicle_components_strings = _ ("Propellers" )
@@ -298,6 +299,19 @@ def update_json_data(self) -> None:
298
299
"Notes" : self .data ["Components" ]["Flight Controller" ]["Notes" ],
299
300
}
300
301
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
+
301
315
def set_vehicle_type_and_version (self , vehicle_type : str , version : str ) -> None :
302
316
self ._set_component_value_and_update_ui (("Flight Controller" , "Firmware" , "Type" ), vehicle_type )
303
317
if version :
@@ -480,26 +494,61 @@ def __set_motor_poles_from_fc_parameters(self, fc_parameters: dict) -> None:
480
494
elif "SERVO_FTW_MASK" in fc_parameters and fc_parameters ["SERVO_FTW_MASK" ] and "SERVO_FTW_POLES" in fc_parameters :
481
495
self .data ["Components" ]["Motors" ]["Specifications" ]["Poles" ] = fc_parameters ["SERVO_FTW_POLES" ]
482
496
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
484
498
"""Updates the ESC Protocol combobox entries based on the selected ESC Type."""
485
499
if len (esc_connection_type ) > 3 and esc_connection_type [:3 ] == "CAN" :
486
500
protocols = ["DroneCAN" ]
501
+ rpm_connections = [esc_connection_type ]
487
502
elif len (esc_connection_type ) > 6 and esc_connection_type [:6 ] == "SERIAL" :
488
503
protocols = [value ["protocol" ] for value in serial_protocols_dict .values () if value ["component" ] == "ESC" ]
504
+ rpm_connections = [esc_connection_type ]
489
505
elif "MOT_PWM_TYPE" in self .local_filesystem .doc_dict :
490
506
protocols = list (self .local_filesystem .doc_dict ["MOT_PWM_TYPE" ]["values" ].values ())
507
+ rpm_connections = ["None" , "I/O Only" , * serial_ports , * can_ports ]
491
508
elif "Q_M_PWM_TYPE" in self .local_filesystem .doc_dict :
492
509
protocols = list (self .local_filesystem .doc_dict ["Q_M_PWM_TYPE" ]["values" ].values ())
510
+ rpm_connections = ["None" , "I/O Only" , * serial_ports , * can_ports ]
493
511
else :
494
512
protocols = []
513
+ rpm_connections = []
495
514
515
+ protocol = ""
496
516
protocol_path = ("ESC" , "FC Connection" , "Protocol" )
497
517
if protocol_path in self .entry_widgets :
498
518
protocol_combobox = self .entry_widgets [protocol_path ]
499
519
protocol_combobox ["values" ] = protocols # Update the combobox entries
500
520
if protocol_combobox .get () not in protocols and isinstance (protocol_combobox , ttk .Combobox ):
501
521
protocol_combobox .set (protocols [0 ] if protocols else "" )
502
522
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
503
552
504
553
def add_entry_or_combobox (
505
554
self , value : float , entry_frame : ttk .Frame , path : tuple [str , str , str ]
@@ -554,6 +603,12 @@ def get_combobox_values(param_name: str) -> list:
554
603
("GNSS Receiver" , "FC Connection" , "Type" ): {
555
604
"values" : ["None" , * self .serial_ports , * self .can_ports ],
556
605
},
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
+ },
557
612
("GNSS Receiver" , "FC Connection" , "Protocol" ): {
558
613
"values" : get_combobox_values ("GPS_TYPE" ),
559
614
},
0 commit comments