Skip to content

Commit

Permalink
FEATURE: Optionally annotate parameter documentation and metadata as …
Browse files Browse the repository at this point in the history
…comments into the intermediate parameter files
  • Loading branch information
amilcarlucas committed Apr 26, 2024
1 parent 48d7d7a commit 6a37630
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions MethodicConfigurator/frontend_tkinter_parameter_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def __init__(self, current_file: str, flight_controller: FlightController,
self.at_least_one_changed_parameter_written = False
self.file_selection_combobox = None
self.show_only_differences = None
self.annotate_params_into_files = None
self.parameter_editor_table = None
self.reset_progress_window = None
self.param_read_progress_window = None
Expand Down Expand Up @@ -546,6 +547,7 @@ def __create_conf_widgets(self, version: str):

def __create_parameter_area_widgets(self):
self.show_only_differences = tk.BooleanVar(value=False)
self.annotate_params_into_files = tk.BooleanVar(value=False)

# Create a Scrollable parameter editor table
self.parameter_editor_table = ParameterEditorTable(self.root, self.local_filesystem)
Expand All @@ -556,14 +558,26 @@ def __create_parameter_area_widgets(self):
buttons_frame = tk.Frame(self.root)
buttons_frame.pack(side="bottom", fill="x", expand=False, pady=(10, 10))

# Create checkbox for toggling parameter display
only_changed_checkbox = ttk.Checkbutton(buttons_frame, text="See only changed parameters",
# Create a frame for the checkboxes
checkboxes_frame = tk.Frame(buttons_frame)
checkboxes_frame.pack(side=tk.LEFT, padx=(8, 8))

# Create a checkbox for toggling parameter display
only_changed_checkbox = ttk.Checkbutton(checkboxes_frame, text="See only changed parameters",
variable=self.show_only_differences,
command=self.on_show_only_changed_checkbox_change)
only_changed_checkbox.pack(side=tk.LEFT, padx=(8, 8))
only_changed_checkbox.pack(side=tk.TOP, anchor=tk.NW)
show_tooltip(only_changed_checkbox, "Toggle to show only parameters that will change if/when written to the flight "
"controller")

annotate_params_checkbox = ttk.Checkbutton(checkboxes_frame, text="Annotate docs into .param files",
state='normal' if self.local_filesystem.doc_dict else 'disabled',
variable=self.annotate_params_into_files)
annotate_params_checkbox.pack(side=tk.TOP, anchor=tk.NW)
show_tooltip(annotate_params_checkbox, "Annotate ArduPilot parameter documentation metadata into the intermediate "
"parameter files\n"
"The files will be bigger, but all the existing parameter documentation will be included inside")

# Create write button
write_selected_button = tk.Button(buttons_frame, text="Write selected params to FC, and advance to next param file",
command=self.on_write_selected_click)
Expand Down Expand Up @@ -818,7 +832,7 @@ def write_changes_to_intermediate_parameter_file(self):
if messagebox.askyesno("One or more parameters have been edited",
f"Do you want to write the changes to the {self.current_file} file?"):
self.local_filesystem.export_to_param(self.local_filesystem.file_parameters[self.current_file],
self.current_file, annotate_doc=False)
self.current_file, annotate_doc=self.annotate_params_into_files.get())
self.parameter_editor_table.set_at_least_one_param_edited(False)

def write_summary_files(self):
Expand Down

0 comments on commit 6a37630

Please sign in to comment.