Skip to content

Commit

Permalink
BUGFIX: also restore the ['Motors']['Specifications']['Poles'] from F…
Browse files Browse the repository at this point in the history
…C if possible
  • Loading branch information
amilcarlucas committed Aug 15, 2024
1 parent e147a53 commit c9b9263
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion MethodicConfigurator/ArduCopter_configuration_steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
},
"derived_parameters": {
"MOT_PWM_TYPE": { "New Value": "vehicle_components['ESC']['FC Connection']['Protocol']", "Change Reason": "Specified in component editor window" },
"SERVO_BLH_POLES": { "New Value": "vehicle_components['Motors']['Specifications']['Poles']", "Change Reason": "Specified in component editor window" }
"SERVO_BLH_POLES": { "New Value": "vehicle_components['Motors']['Specifications']['Poles']", "Change Reason": "Specified in component editor window" },
"SERVO_FTW_POLES": { "New Value": "vehicle_components['Motors']['Specifications']['Poles']", "Change Reason": "Specified in component editor window" }
},
"rename_connection": "vehicle_components['ESC']['FC Connection']['Type']",
"old_filenames": []
Expand Down
10 changes: 9 additions & 1 deletion MethodicConfigurator/frontend_tkinter_component_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def set_values_from_fc_parameters(self, fc_parameters: dict, doc: dict):
gnss_protocols = self.reverse_key_search(doc, "SERIAL1_PROTOCOL", ["GPS"], [5])
esc_protocols = self.reverse_key_search(doc, "SERIAL1_PROTOCOL", ["ESC Telemetry", "FETtecOneWire", "Torqeedo", "CoDevESC"],
[16, 38, 39, 41])
dshot_protocols = self.reverse_key_search(doc, "MOT_PWM_TYPE", ["OneShot", "OneShot125", "DShot150",
"DShot300", "DShot600", "DShot1200"], [1, 2, 4, 5, 6, 7])
for serial in self.serial_ports:
if serial + "_PROTOCOL" in fc_parameters:
serial_protocol = fc_parameters[serial + "_PROTOCOL"]
Expand All @@ -144,6 +146,12 @@ def set_values_from_fc_parameters(self, fc_parameters: dict, doc: dict):
self.data['Components']['Battery Monitor']['FC Connection']['Type'] = "Analog"
self.data['Components']['Battery Monitor']['FC Connection']['Protocol'] = \
doc['BATT_MONITOR']['values'][str(fc_parameters["BATT_MONITOR"]).rstrip('0').rstrip('.')]
if "MOT_PWM_TYPE" in fc_parameters and fc_parameters["MOT_PWM_TYPE"] in dshot_protocols:
if "SERVO_BLH_POLES" in fc_parameters:
self.data['Components']['Motors']['Specifications']['Poles'] = fc_parameters["SERVO_BLH_POLES"]
else:
if "SERVO_FTW_MASK" in fc_parameters and fc_parameters["SERVO_FTW_MASK"] and "SERVO_FTW_POLES" in fc_parameters:
self.data['Components']['Motors']['Specifications']['Poles'] = fc_parameters["SERVO_FTW_POLES"]

def add_entry_or_combobox(self, value, entry_frame, path):

Expand Down Expand Up @@ -203,7 +211,7 @@ def get_combobox_values(param_name: str) -> list:
"values": ['Main Out', 'AIO'] + self.serial_ports + self.can_ports,
},
('ESC', 'FC Connection', 'Protocol'): {
"values": get_combobox_values('MOT_PWM_TYPE'),
"values": get_combobox_values('MOT_PWM_TYPE')# + ['FETtecOneWire', 'Torqeedo', 'CoDevESC'],
},
('GNSS receiver', 'FC Connection', 'Type'): {
"values": self.serial_ports + self.can_ports,
Expand Down

0 comments on commit c9b9263

Please sign in to comment.