-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IMPROVEMENTS: display flight controller information on the GUI and do…
…wnload parameters early on the process This allows other processes to depend on parameter values
- Loading branch information
1 parent
e2796c6
commit 61020f2
Showing
5 changed files
with
170 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator | ||
(C) 2024 Amilcar do Carmo Lucas, IAV GmbH | ||
SPDX-License-Identifier: GPL-3 | ||
''' | ||
|
||
|
||
class BackendFlightcontrollerInfo: | ||
def __init__(self): | ||
self.system_id = None | ||
self.component_id = None | ||
self.autopilot_type = None | ||
self.vehicle_type = None | ||
self.mav_type = None | ||
self.firmware_version = None | ||
self.hardware_version = None | ||
self.git_hash = None | ||
self.os_git_hash = None | ||
self.vendor_id = None | ||
self.vendor = None | ||
self.product_id = None | ||
self.product = None | ||
self.capabilities = None | ||
|
||
def set_system_and_component_ids(self, system_id, component_id): | ||
self.system_id = system_id | ||
self.component_id = component_id | ||
|
||
def set_autopilot_type(self, autopilot_type): | ||
self.autopilot_type = autopilot_type | ||
|
||
def set_vehicle_type(self, vehicle_type): | ||
self.vehicle_type = vehicle_type | ||
|
||
def set_mav_type(self, mav_type): | ||
self.mav_type = mav_type | ||
|
||
def set_firmware_version(self, version): | ||
self.firmware_version = version | ||
|
||
def set_hardware_version(self, hardware_version): | ||
self.hardware_version = hardware_version | ||
|
||
def set_git_hash(self, git_hash): | ||
self.git_hash = git_hash | ||
|
||
def set_os_git_hash(self, os_git_hash): | ||
self.os_git_hash = os_git_hash | ||
|
||
def set_vendor(self, vendor_id, vendor): | ||
self.vendor_id = vendor_id | ||
self.vendor = vendor | ||
|
||
def set_product(self, product_id, product): | ||
self.product_id = product_id | ||
self.product = product | ||
|
||
def set_capabilities(self, capabilities): | ||
self.capabilities = capabilities |
77 changes: 77 additions & 0 deletions
77
MethodicConfigurator/frontend_tkinter_flightcontroller_info.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
This file is part of Ardupilot methodic configurator. https://github.com/ArduPilot/MethodicConfigurator | ||
(C) 2024 Amilcar do Carmo Lucas, IAV GmbH | ||
SPDX-License-Identifier: GPL-3 | ||
''' | ||
|
||
import tkinter as tk | ||
|
||
from backend_flightcontroller import FlightController | ||
#from backend_flightcontroller_info import BackendFlightcontrollerInfo | ||
|
||
#from frontend_tkinter_base import show_tooltip | ||
from frontend_tkinter_base import ProgressWindow | ||
from frontend_tkinter_base import BaseWindow | ||
|
||
from version import VERSION | ||
|
||
|
||
class FlightControllerInfoWindow(BaseWindow): | ||
def __init__(self, flight_controller: FlightController): | ||
super().__init__() | ||
self.root.title("ArduPilot methodic configurator " + VERSION + " - Flight Controller Info") | ||
self.root.geometry("500x350") # Adjust the window size as needed | ||
self.flight_controller = flight_controller | ||
|
||
# Create a frame to hold all the labels and text fields | ||
self.info_frame = tk.Frame(self.root) | ||
self.info_frame.pack(padx=20, pady=20) | ||
|
||
# Dictionary mapping attribute names to their descriptions | ||
attribute_descriptions = { | ||
"Autopilot Type": "autopilot_type", | ||
"Vehicle Type": "vehicle_type", | ||
"Firmware Version": "firmware_version", | ||
"Hardware Version": "hardware_version", | ||
"Git Hash": "git_hash", | ||
"OS Git Hash": "os_git_hash", | ||
"Vendor ID": "vendor_id", | ||
"Vendor Name": "vendor", | ||
"Product ID": "product_id", | ||
"Product Name": "product", | ||
"System ID": "system_id", | ||
"Component ID": "component_id", | ||
"MAV Type": "mav_type", | ||
"Capabilities": "capabilities" | ||
} | ||
|
||
# Dynamically create labels and text fields for each attribute | ||
for row_nr, (description, attr_name) in enumerate(attribute_descriptions.items()): | ||
label = tk.Label(self.info_frame, text=f"{description}:") | ||
label.grid(row=row_nr, column=0, sticky="w") | ||
|
||
text_field = tk.Entry(self.info_frame, width=60) | ||
text_field.grid(row=row_nr, column=1, sticky="w") | ||
|
||
# Check if the attribute exists and has a non-empty value before inserting | ||
attr_value = getattr(flight_controller.info, attr_name, "") | ||
if attr_value: | ||
text_field.insert(tk.END, attr_value) | ||
else: | ||
text_field.insert(tk.END, "N/A") # Insert "Not Available" if the attribute is missing or empty | ||
text_field.configure(state="readonly") | ||
|
||
self.root.after(50, self.download_flight_controller_parameters()) # 50 milliseconds | ||
self.root.mainloop() | ||
|
||
def download_flight_controller_parameters(self): | ||
param_download_progress_window = ProgressWindow(self.root, "Downloading FC parameters", | ||
"Downloaded {} of {} parameters") | ||
self.flight_controller.fc_parameters = self.flight_controller.download_params( | ||
param_download_progress_window.update_progress_bar) | ||
param_download_progress_window.destroy() # for the case that '--device test' and there is no real FC connected | ||
self.root.destroy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters