Skip to content

Feat/full flight mode list funtional#3680

Closed
clanga-paintec wants to merge 13 commits intoArduPilot:masterfrom
clanga-paintec:feat/Full_Flight_Mode_List_Funtional
Closed

Feat/full flight mode list funtional#3680
clanga-paintec wants to merge 13 commits intoArduPilot:masterfrom
clanga-paintec:feat/Full_Flight_Mode_List_Funtional

Conversation

@clanga-paintec
Copy link

No description provided.

GridFlight and others added 13 commits March 12, 2026 09:02
Enables launch.json and tasks.json to be shared so all team members
get the same build/debug setup out of the box.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…d-write-verify-btn

feat: branding GridFlight y botón Escribir+Verificar
…ource files

## Motivation

Four GridFlight customizations had been placed directly inside ArduPilot source
files (MainV2.cs, FlightPlanner.cs, FlightPlanner.Designer.cs). This created
four merge-conflict risks on every upstream ArduPilot update:

1. Logo scaling block in MainV2.cs (~20 lines) — would break if ArduPilot
   refactored the MenuArduPilot initialization order.
2. MenuArduPilot_Click URL override in MainV2.cs — would silently revert to
   ardupilot.org on any upstream change to that method.
3. btnLeerEscribir_Click handler in FlightPlanner.cs — would stop compiling if
   ArduPilot renamed BUT_write_Click or BUT_read_Click.
4. btnLeerEscribir definition in FlightPlanner.Designer.cs — would be
   permanently deleted the moment anyone opened the form in Visual Studio and
   saved, because the Designer regenerates the file automatically.

## Why migration is now possible

All required access points are already public in ArduPilot:
- MenuArduPilot          → public field (MainV2.Designer.cs)
- Host.MainForm.FlightPlanner → public field (MainV2.cs:582)
- FlightPlanner.panel5, BUT_write, BUT_read → public fields (FlightPlanner.Designer.cs)
- BUT_write_Click / BUT_read_Click → public methods (FlightPlanner.cs:606, 645)
- FlightPlanner is instantiated (MainV2.cs:855) before LoadAll() (MainV2.cs:3199),
  so it is fully available when Loaded() runs — confirmed by PluginHost.GetWPs()
  which already calls FlightPlanner.BUT_read_Click directly (Plugin.cs:248).

## Changes

### New files — GridFlight/ (zero ArduPilot source touched)
- GridFlight/BrandingPlugin.cs
    Scales logo2.png onto MenuArduPilot (same logic as the removed MainV2 block).
    Uses reflection on ToolStripItem's internal EventHandlerList to replace the
    ardupilot.org Click handler with gridflight.tech. Graceful fallback if the
    reflection API changes in a future .NET version.
- GridFlight/WriteVerifyPlugin.cs
    Creates the "Write and Verify" button programmatically and adds it to
    FlightPlanner.panel5 in Loaded(). Click handler calls BUT_write_Click then
    BUT_read_Click directly (public methods), so no brittle UI simulation.
- GridFlight/ElevationGraphShortcut.cs  (tracked for the first time)
- GridFlight/HideSetupMenuItemsPlugin.cs (tracked for the first time)
- GridFlight/assets/logo2.png  (moved from repo root)

### ArduPilot source — removals only (no new logic added)
- MainV2.cs: removed logo scaling block; restored MenuArduPilot_Click to
  ardupilot.org (the original upstream behaviour).
- FlightPlanner.cs: removed btnLeerEscribir_Click handler.
- FlightPlanner.Designer.cs: removed 4 references to btnLeerEscribir
  (constructor instantiation, panel5.Controls.Add, InitializeComponent body,
  and field declaration). File is now safe to regenerate from Visual Studio.
- FlightPlanner.resx: removed 9 orphaned btnLeerEscribir resource entries.

### Asset organisation
- logo2.png moved from repo root → GridFlight/assets/logo2.png.
- MissionPlanner.csproj updated to reference new path (CopyToOutputDirectory: Always).
- Program.cs updated to load from GridFlight/assets/logo2.png at runtime.

## Result
`grep -r "GRIDFLIGHT CUSTOMIZATION" .` now returns zero results in ArduPilot
source files. All GridFlight behaviour lives exclusively in GridFlight/.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…trol

These are local development context files (AI instructions and architecture
docs) that should not be part of the shared repository history.

- Added both to .gitignore
- Removed CLAUDE.md from git index (git rm --cached) since it was already
  tracked from a previous commit. The file remains on disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
## Why

The Setup → Optional Hardware section exposes ~18 items irrelevant to
GridFlight's operational workflow. Showing them adds cognitive overhead
for operators in the field and increases the risk of accidental changes
to hardware configuration.

## How — two complementary mechanisms

### 1. DisplayConfiguration flags (Init())
Most Optional Hardware items are added conditionally in
InitialSetup.HardwareConfig_Load() by checking MainV2.DisplayConfiguration.*
flags (DisplayView.cs). Setting them to false in Init() — which runs
synchronously before the user can navigate to Setup — is enough to
prevent those items from ever appearing in the side menu.

Items hidden this way: RTK/GPS Inject, Sik Radio, CAN GPS Order,
Battery Monitor (×2), DroneCAN/UAVCAN, Joystick, Compass/Motor Cal,
Range Finder, Airspeed, PX4Flow, Optical Flow, OSD, Camera Gimbal,
Antenna Tracker (×2), Bluetooth Setup, Parachute, ESP8266 Setup,
FFT Setup.

Motor Test is intentionally kept visible (displayMotorTest not touched).

### 2. BackstageViewPage.Show = false (Loop())
"CubeID Update" has no DisplayConfiguration flag — it is added
unconditionally in InitialSetup.cs:254. To hide it we use the
BackstageViewPage.Show property (BackstageViewPage.cs:25), which
BackstageView already checks at render time (BackstageView.cs:86, 219).

InitialSetup is lazy-loaded by MainSwitcher (created only when the
user first clicks SETUP). We detect its creation via Loop() at 1 Hz
by checking Host.MainForm.MyView.screens for the "HWConfig" screen.
Once found and activated (Pages.Count > 0), we BeginInvoke on the UI
thread to set Show=false and Refresh(). The loop is then disabled by
setting loopratehz = 0.

InitialSetup.backstageView is declared internal (InitialSetup.Designer.cs:293),
which is accessible here because GridFlight plugins compile into the
same MissionPlanner.exe assembly (PluginLoader.cs:308 — "self" init).

## Zero ArduPilot source touched
grep -r "GRIDFLIGHT CUSTOMIZATION" . → 0 results

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
## Problem

The original implementation used a one-shot loop (loopratehz = 0 after
first trigger) to hide CubeID Update via BackstageViewPage.Show = false.
This worked on the first visit to the SETUP tab but failed on subsequent
visits because MainSwitcher.ShowScreen() disposes and recreates
InitialSetup on every navigation (MainSwitcher.cs:131-135). Each new
instance resets Show=true, and the loop was already stopped.

Additionally, calling backstageView.Refresh() after setting Show=false
did not rebuild the menu. Refresh() triggers OnPaint → DrawMenu(null,
false), which exits early (BackstageView.cs:265-272) when CurrentPage is
null and has no children — leaving the already-rendered CubeID button
intact in pnlMenu.Controls.

## Fixes

1. Permanent loop (1 Hz) with idempotency guard
   Removed loopratehz = 0. The loop now runs indefinitely but only calls
   BeginInvoke when CubeID.Show == true, which happens exactly once per
   SETUP visit. When CubeID is already hidden the loop body is a single
   LINQ query over ~20 items — effectively zero overhead.

2. DrawMenu(SelectedPage, force: true) instead of Refresh()
   force=true bypasses the early-return guard, executes
   pnlMenu.Controls.Clear(), and rebuilds all buttons respecting the
   updated Show=false flag. This is the only path that removes the
   already-painted CubeID button from the panel.

3. Null-safety guards split into two separate statements
   Replaced the combined is not + || pattern (C# 9, not available in
   this project's C# 7.3 target) with an explicit null check via `as`
   cast, followed by a separate backstageView null + Pages.Count guard.
   This also fixes a subtle bug: backstageView?.Pages.Count == 0 returns
   false when backstageView is null (null != 0 in nullable int), which
   would have allowed execution to reach the foreach and throw.

## Zero ArduPilot source touched
grep -r "GRIDFLIGHT CUSTOMIZATION" . → 0 results

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Limitada la lista de vuelos y añadida otra con todos los tipos de vuelo del dron.
Aumentada la fuente de algún número y cambiada la posición de ciertos botones
…second-list-being-funtional)

QA_Actions_Tab
…n-on-every-setup-visit

Fix/gridflight cubeid hidden on every setup visit
Añadido un boton para cambiar el vuelo con toda la lista de vuelos a su izquierda
@clanga-paintec clanga-paintec force-pushed the feat/Full_Flight_Mode_List_Funtional branch from 1804ca1 to 2f4966d Compare March 13, 2026 09:29
@EosBandi EosBandi closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants