From 0ecf63ec6de869ec878a5c354e8971e8e5f4a54f Mon Sep 17 00:00:00 2001 From: "Dr.-Ing. Amilcar do Carmo Lucas" Date: Sat, 29 Nov 2025 15:45:01 +0100 Subject: [PATCH 1/4] feat(battery cell_voltages): Add support for NiCd and NiMH chemistries --- .../battery_cell_voltages.py | 14 ++++++++++++++ tests/test_battery_cell_voltages.py | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ardupilot_methodic_configurator/battery_cell_voltages.py b/ardupilot_methodic_configurator/battery_cell_voltages.py index 741e0f159..99117d123 100644 --- a/ardupilot_methodic_configurator/battery_cell_voltages.py +++ b/ardupilot_methodic_configurator/battery_cell_voltages.py @@ -53,6 +53,20 @@ "recommended_low": 3.5, "recommended_crit": 3.2, }, + "NiCd": { + "absolute_max": 1.45, + "absolute_min": 1.0, + "recommended_max": 1.4, + "recommended_low": 1.2, + "recommended_crit": 1.1, + }, + "NiMH": { + "absolute_max": 1.45, + "absolute_min": 1.0, + "recommended_max": 1.4, + "recommended_low": 1.2, + "recommended_crit": 1.1, + }, # Add more chemistries as needed } diff --git a/tests/test_battery_cell_voltages.py b/tests/test_battery_cell_voltages.py index 967c72277..709f3f674 100755 --- a/tests/test_battery_cell_voltages.py +++ b/tests/test_battery_cell_voltages.py @@ -18,7 +18,7 @@ class TestBatteryCell(unittest.TestCase): # pylint: disable=missing-class-docstring def test_chemistries(self) -> None: - expected_chemistries = ("LiIon", "LiIonSS", "LiIonSSHV", "Lipo", "LipoHV", "LipoHVSS") + expected_chemistries = ("LiIon", "LiIonSS", "LiIonSSHV", "Lipo", "LipoHV", "LipoHVSS", "NiCd", "NiMH") chemistries = BatteryCell.chemistries() assert chemistries == expected_chemistries @@ -30,7 +30,7 @@ def test_limit_max_voltage(self) -> None: def test_limit_min_voltage(self) -> None: assert BatteryCell.limit_min_voltage("LiIon") == 2.5 assert BatteryCell.limit_min_voltage("LipoHV") == 3.0 - assert BatteryCell.limit_min_voltage("NonExistentChemistry") == 2.4 + assert BatteryCell.limit_min_voltage("NonExistentChemistry") == 1.0 def test_recommended_max_voltage(self) -> None: assert BatteryCell.recommended_max_voltage("LiIon") == 4.1 From a72ff0d8e404929a6b9f875b83d1af4bfa47bf51 Mon Sep 17 00:00:00 2001 From: "Dr.-Ing. Amilcar do Carmo Lucas" Date: Sat, 29 Nov 2025 20:39:41 +0100 Subject: [PATCH 2/4] feat(usage popups): Make font size usage more consistent Uses 150% scaling on all usage popups fonts --- .../frontend_tkinter_component_editor_base.py | 6 +++--- .../frontend_tkinter_rich_text.py | 2 +- .../frontend_tkinter_usage_popup_window.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py b/ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py index 6e3484f35..8b3bc9b66 100755 --- a/ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py @@ -308,7 +308,7 @@ def _display_component_editor_usage_instructions(self, parent: tk.Tk) -> None: height=6, bd=0, background=style.lookup("TLabel", "background"), - font=create_scaled_font(get_safe_font_config(), 1.2), + font=create_scaled_font(get_safe_font_config(), 1.5), ) # pylint: enable=duplicate-code instructions_text.insert(tk.END, _("1. Describe the properties of the vehicle components in the window below.\n")) @@ -552,9 +552,9 @@ def _confirm_component_properties(self) -> bool: validation_popup_window = BaseWindow(cast("tk.Tk", self.root)) style = ttk.Style() - # Create a 20% larger font + # Create a 50% larger font font_config = get_safe_font_config() - larger_font = create_scaled_font(font_config, 1.2) + larger_font = create_scaled_font(font_config, 1.5) confirmation_text = RichText( validation_popup_window.main_frame, diff --git a/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py b/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py index 5585863e5..d83b4ee8a 100644 --- a/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py @@ -47,7 +47,7 @@ class RichText(tk.Text): # pylint: disable=too-many-ancestors def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - default_font = safe_font_nametofont() + default_font = kwargs.get("font", None) or safe_font_nametofont() if default_font: # Use the actual font configuration if available bold_font = tkFont.Font(**default_font.configure()) # type: ignore[arg-type] diff --git a/ardupilot_methodic_configurator/frontend_tkinter_usage_popup_window.py b/ardupilot_methodic_configurator/frontend_tkinter_usage_popup_window.py index 9af300162..d126e909c 100644 --- a/ardupilot_methodic_configurator/frontend_tkinter_usage_popup_window.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_usage_popup_window.py @@ -192,7 +192,7 @@ def display_workflow_explanation(parent: Optional[tk.Tk] = None) -> BaseWindow: height=1, bd=0, background=ttk.Style(popup_window.root).lookup("TLabel", "background"), - font=create_scaled_font(get_safe_font_config(), 1.2), + font=create_scaled_font(get_safe_font_config(), 1.5), ) instructions.insert(tk.END, _("This is not a ground control station and it has a different workflow:")) UsagePopupWindow.setup_window( @@ -219,7 +219,7 @@ def display_workflow_explanation(parent: Optional[tk.Tk] = None) -> BaseWindow: height=1, bd=0, background=ttk.Style(popup_window.root).lookup("TLabel", "background"), - font=create_scaled_font(get_safe_font_config(), 1.2), + font=create_scaled_font(get_safe_font_config(), 1.5), ) rich_text.insert(tk.END, _("see ")) rich_text.insert_clickable_link( From 3d786d037bdf82e9af3866e416db29561a6f0f36 Mon Sep 17 00:00:00 2001 From: "Dr.-Ing. Amilcar do Carmo Lucas" Date: Sat, 29 Nov 2025 20:42:04 +0100 Subject: [PATCH 3/4] ci(tests): fix test_popup_shows_correct_title_and_content test in CI It stopped working because of a regression in ubuntu-latest last week --- tests/test_frontend_tkinter_usage_popup_window.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_frontend_tkinter_usage_popup_window.py b/tests/test_frontend_tkinter_usage_popup_window.py index 4944ccf61..365f6b34c 100755 --- a/tests/test_frontend_tkinter_usage_popup_window.py +++ b/tests/test_frontend_tkinter_usage_popup_window.py @@ -10,6 +10,8 @@ SPDX-License-Identifier: GPL-3.0-or-later """ +import os +import sys import tkinter as tk from tkinter import ttk from unittest.mock import MagicMock, patch @@ -199,7 +201,17 @@ def test_popup_shows_correct_title_and_content(self, tk_root, popup_window, rich # Assert: Window configured correctly for user assert popup_window.root.title() == "Test Title" - assert popup_window.root.geometry().startswith("574x41") + # On Windows (including CI runners on windows) Tk reports a different + # geometry so we expect the larger size there. On GitHub Actions + # (ubuntu-latest) use the GitHub-specific env var. Otherwise keep the + # local expected geometry. + if sys.platform.startswith("win"): + expected_geometry = "814x594" + elif os.getenv("CI", "").lower() in ("true", "1"): + expected_geometry = "654x490" + else: + expected_geometry = "574x41" + assert popup_window.root.geometry().startswith(expected_geometry) # Assert: UI elements created for user interaction children = popup_window.main_frame.winfo_children() From c17c3eb266592edffd83d901b1e12a7a355fc4d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 29 Nov 2025 19:48:56 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ardupilot_methodic_configurator/frontend_tkinter_rich_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py b/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py index d83b4ee8a..b9680ac85 100644 --- a/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py +++ b/ardupilot_methodic_configurator/frontend_tkinter_rich_text.py @@ -47,7 +47,7 @@ class RichText(tk.Text): # pylint: disable=too-many-ancestors def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) - default_font = kwargs.get("font", None) or safe_font_nametofont() + default_font = kwargs.get("font") or safe_font_nametofont() if default_font: # Use the actual font configuration if available bold_font = tkFont.Font(**default_font.configure()) # type: ignore[arg-type]