Skip to content

Commit 093c0ec

Browse files
committed
По-здраво: code latch за “manual transition session active” до TRANSITION switch OFF edge, за да не сменяме semantics mid-session.
1 parent 7fd7163 commit 093c0ec

5 files changed

Lines changed: 25 additions & 8 deletions

File tree

docs/MixerProfile.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ The use of Transition Mode is recommended to enable further features and future
3131
- If switched OFF before hot-switch completes, the manual transition request is aborted.
3232

3333
This edge-triggered behavior is enabled by `mixer_vtol_manualswitch_autotransition_controller`.
34+
Set `mixer_vtol_manualswitch_autotransition_controller = ON` in both mixer profiles (MC and FW) used for switching to keep manual transition semantics consistent after profile hot-switch.
3435
When `mixer_vtol_manualswitch_autotransition_controller = OFF`, manual transition keeps legacy behavior.
3536
With manual auto-transition enabled, Active Modes `MIXER TRANSITION` now indicates that the internal transition controller/mixing is actually active, not merely that the RC `MIXER TRANSITION` switch is active.
3637
Active Modes `MIXER PROFILE 2` indicates the currently active mixer profile.
@@ -44,6 +45,7 @@ Recommended switch topology (explicit):
4445
- Pos1 = MC (`MIXER PROFILE 2` OFF, `MIXER TRANSITION` OFF)
4546
- Pos2 = Transition trigger (`MIXER PROFILE 2` OFF, `MIXER TRANSITION` ON)
4647
- Pos3 = FW (`MIXER PROFILE 2` ON, `MIXER TRANSITION` OFF)
48+
- Keep `mixer_vtol_manualswitch_autotransition_controller` ON in both profiles used by this mapping.
4749
- Avoid overlapping FW selection and transition trigger in the same position.
4850
- Avoid 2-position setups where one position activates both `MIXER PROFILE 2` and `MIXER TRANSITION`.
4951
- Overlapping mode activation can produce order-dependent behavior (direct profile switch path vs transition-controller path), which is unpredictable and not recommended.

docs/Settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3222,7 +3222,7 @@ If switch another mixer_profile is scheduled by mixer_automated_switch or mixer_
32223222

32233223
### mixer_vtol_manualswitch_autotransition_controller
32243224

3225-
Enables edge-triggered manual VTOL transition controller for `MIXER TRANSITION` when not in waypoint mission. OFF keeps legacy manual transition behavior.
3225+
Enables edge-triggered manual VTOL transition controller for `MIXER TRANSITION` when not in waypoint mission. OFF keeps legacy manual transition behavior. For consistent manual transition semantics, enable this in both mixer profiles.
32263226

32273227
| Default | Min | Max |
32283228
| --- | --- | --- |

docs/VTOL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ This keeps one safety boundary for profile hot-switching and avoids separate tra
307307
Intent: this does not replace legacy manual behavior. Legacy remains available and selectable.
308308
309309
With `mixer_vtol_manualswitch_autotransition_controller = ON`:
310+
- Enable this setting in both mixer profiles (MC and FW) for consistent edge-triggered behavior across profile hot-switches.
310311
- `MIXER TRANSITION` acts as an edge-triggered request.
311312
- A rising edge starts one transition.
312313
- Transition then runs autonomously to completion.
@@ -331,6 +332,7 @@ Important RC mapping constraint:
331332
- Pos1 = MC (`MIXER PROFILE 2` OFF, `MIXER TRANSITION` OFF)
332333
- Pos2 = Transition trigger (`MIXER PROFILE 2` OFF, `MIXER TRANSITION` ON)
333334
- Pos3 = FW (`MIXER PROFILE 2` ON, `MIXER TRANSITION` OFF)
335+
- Keep `mixer_vtol_manualswitch_autotransition_controller` ON in both profiles used by this mapping.
334336
- Do not overlap/merge FW selection and transition trigger in the same switch position.
335337
- Do not use a 2-position mapping where one position enables both `MIXER PROFILE 2` and `MIXER TRANSITION`.
336338
- Mixing these mode conditions can cause race/order-dependent behavior (direct profile switch versus transition state machine), which is unpredictable in flight.

src/main/fc/settings.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ groups:
12981298
field: mixer_config.vtolTransitionDynamicMixer
12991299
type: bool
13001300
- name: mixer_vtol_manualswitch_autotransition_controller
1301-
description: "Enables edge-triggered manual VTOL transition controller for `MIXER TRANSITION` when not in waypoint mission. OFF keeps legacy manual transition behavior."
1301+
description: "Enables edge-triggered manual VTOL transition controller for `MIXER TRANSITION` when not in waypoint mission. OFF keeps legacy manual transition behavior. For consistent manual transition semantics, enable this in both mixer profiles."
13021302
default_value: OFF
13031303
field: mixer_config.manualVtolTransitionController
13041304
type: bool

src/main/flight/mixer_profile.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mixerProfileAT_t mixerProfileAT;
4242
int nextMixerProfileIndex;
4343
static bool manualTransitionModeWasActive;
4444
static bool manualTransitionReadyForEdge = true;
45+
static bool manualTransitionSessionLatched;
4546

4647
PG_REGISTER_ARRAY_WITH_RESET_FN(mixerProfile_t, MAX_MIXER_PROFILE_COUNT, mixerProfiles, PG_MIXER_PROFILE, 3);
4748

@@ -470,19 +471,29 @@ void outputProfileUpdateTask(timeUs_t currentTimeUs)
470471
bool mixerAT_inuse = mixerATIsActive();
471472
const bool transitionModeActive = IS_RC_MODE_ACTIVE(BOXMIXERTRANSITION);
472473
const bool transitionModeRisingEdge = transitionModeActive && !manualTransitionModeWasActive;
474+
const bool transitionModeFallingEdge = !transitionModeActive && manualTransitionModeWasActive;
473475
const bool manualTransitionAllowed = (posControl.navState == NAV_STATE_IDLE) ||
474476
(posControl.navState == NAV_STATE_ALTHOLD_IN_PROGRESS);
475477
const bool missionActive = (navGetCurrentStateFlags() & NAV_AUTO_WP) != 0;
476478
const bool manualControllerConfigured = currentMixerConfig.manualVtolTransitionController && !missionActive;
477-
bool manualControllerEnabled = manualControllerConfigured;
479+
bool manualControllerEnabled = manualControllerConfigured || manualTransitionSessionLatched;
480+
481+
if (manualControllerConfigured && transitionModeRisingEdge) {
482+
manualTransitionSessionLatched = true;
483+
}
484+
485+
if (transitionModeFallingEdge) {
486+
manualTransitionSessionLatched = false;
487+
}
478488

479489
if (mixerAT_inuse && (!ARMING_FLAG(ARMED) || FLIGHT_MODE(FAILSAFE_MODE) || areSensorsCalibrating())) {
480490
abortTransition(false);
491+
manualTransitionSessionLatched = false;
481492
mixerAT_inuse = false;
482493
}
483494

484495
// For manual auto-transition control, suppress direct profile hotswitch while transition trigger is active.
485-
const bool suppressDirectProfileSwitch = manualControllerConfigured && transitionModeActive;
496+
const bool suppressDirectProfileSwitch = manualControllerEnabled && transitionModeActive;
486497
if (!FLIGHT_MODE(FAILSAFE_MODE) && !mixerAT_inuse && !suppressDirectProfileSwitch)
487498
{
488499
if (isModeActivationConditionPresent(BOXMIXERPROFILE)){
@@ -491,7 +502,7 @@ void outputProfileUpdateTask(timeUs_t currentTimeUs)
491502
}
492503

493504
// Recompute after a potential direct profile hot-switch because this flag is per-mixer-profile.
494-
manualControllerEnabled = currentMixerConfig.manualVtolTransitionController && !missionActive;
505+
manualControllerEnabled = (currentMixerConfig.manualVtolTransitionController && !missionActive) || manualTransitionSessionLatched;
495506

496507
if (!manualControllerEnabled) {
497508
// Backward-compatible manual path: level-controlled transition mixing request.
@@ -504,6 +515,7 @@ void outputProfileUpdateTask(timeUs_t currentTimeUs)
504515
manualTransitionReadyForEdge = true;
505516
} else {
506517
if (!transitionModeActive) {
518+
manualTransitionSessionLatched = false;
507519
manualTransitionReadyForEdge = true;
508520
if (!mixerAT_inuse) {
509521
isMixerTransitionMixing_requested = false;
@@ -555,7 +567,8 @@ void outputProfileUpdateTask(timeUs_t currentTimeUs)
555567
(isMixerTransitionMixing_requested ? 1U << 16 : 0U) |
556568
(FLIGHT_MODE(FAILSAFE_MODE) ? 1U << 17 : 0U) |
557569
(manualControllerEnabled ? 1U << 18 : 0U) |
558-
(IS_RC_MODE_ACTIVE(BOXMIXERPROFILE) ? 1U << 19 : 0U);
570+
(IS_RC_MODE_ACTIVE(BOXMIXERPROFILE) ? 1U << 19 : 0U) |
571+
(manualTransitionSessionLatched ? 1U << 20 : 0U);
559572

560573
// VTOL transition debug channels (DEBUG_VTOL_TRANSITION):
561574
// [0] phase, [1] request, [2] packed transition flags, [3] progress x1000,
@@ -631,8 +644,8 @@ bool isMixerTransitionModeReportedActive(void)
631644
return true;
632645
}
633646

634-
// With manual auto-transition enabled, treat the RC box as a trigger/request only.
635-
if (currentMixerConfig.manualVtolTransitionController) {
647+
// With manual auto-transition enabled (or session latched), treat RC as trigger only.
648+
if (currentMixerConfig.manualVtolTransitionController || manualTransitionSessionLatched) {
636649
return false;
637650
}
638651

0 commit comments

Comments
 (0)