Skip to content

test(radio): enshrine rc-soar.com documented mixer behavior#7220

Draft
raphaelcoeffic wants to merge 2 commits intoflatten-ls-statefrom
opentx-clinic-tests
Draft

test(radio): enshrine rc-soar.com documented mixer behavior#7220
raphaelcoeffic wants to merge 2 commits intoflatten-ls-statefrom
opentx-clinic-tests

Conversation

@raphaelcoeffic
Copy link
Copy Markdown
Member

@raphaelcoeffic raphaelcoeffic commented Mar 26, 2026

Summary

Add unit tests that capture documented mixer, flight-mode, and logical switch behavior from rc-soar.com/edgetx, protecting these semantics from regressions during future refactoring.

New behavior tests:

  • Multiplex operators: ADD accumulates, REPL overwrites, MUL multiplies with lines above (order-sensitive)
  • Weight-then-offset formula: output = (source × weight) + offset
  • Cascaded channels bypass output clipping (internal >100% value preserved through channel sources)
  • Cumulative weight through cascaded channels (CH0×80%, CH1=CH0×25% → 20%)
  • Flight mode priority: FM1 > FM2 > … > FM8 > FM0 (fallback)
  • Sticky LS startup behavior: latches immediately if set-condition is true at power-on
  • Sequencer pattern: slow-ramp timebase fed through a custom curve with flat segments producing servo pauses

Test infrastructure cleanup:

  • Add startAfter parameter to findHwSwitch() for finding a second distinct switch
  • Replace 16 manual switch-scanning loops with findHwSwitch() across mixer.cpp, switches.cpp, functions.cpp
  • Remove #if defined(PCBTARANIS) guards from OldTypeStickyCSW and inputWithTrim — now run on all targets with runtime skip

Test plan

  • All 197 tests pass on gx12 (X7 variant, multiple 3-pos switches)
  • All 185 tests pass on nb4p (PL18 variant, limited switches — switch-dependent tests skip gracefully)
  • No existing tests broken

🤖 Generated with Claude Code

@raphaelcoeffic raphaelcoeffic changed the title Opentx clinic tests test(radio): enshrine rc-soar.com documented mixer behavior Mar 26, 2026
Comment on lines +701 to +706
// Sticky LS latches at startup when the set-condition is already satisfied.
// After logicalSwitchesReset(), lastValue.last starts at 0, so the first
// logicalSwitchesTimerTick() sees a 0→1 edge and latches immediately.
// rc-soar.com documents this as NOT latching, but actual firmware behavior
// does latch — this test enshrines the real behavior.
TEST_F(LswTest, StickyLatchesAtStartupWhenSetConditionTrue)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RC-SOAR You probably want to have a look at this. It seems the behaviour you documented diverges from the actual behaviour.

Copy link
Copy Markdown

@RC-SOAR RC-SOAR Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RC-SOAR You probably want to have a look at this. It seems the behaviour you documented diverges from the actual behaviour.

It might be semantics (or my mislading documentation!) - I have assumed that a sticky LS is false at startup but immediately latches if the set-condition is true. Will double check during tests for any changed behaviour.

@raphaelcoeffic raphaelcoeffic force-pushed the flatten-ls-state branch 3 times, most recently from 59bab6f to b7d339f Compare March 28, 2026 06:55
raphaelcoeffic and others added 2 commits March 28, 2026 07:57
…Switch

Add tests enshrining mixer, flight-mode, and channel-cascade semantics
documented at rc-soar.com/edgetx so refactoring does not silently break
real-world user setups:

- MultiplexAdd/Replace/MultiplyBasic/MultiplyOrderSensitive
- WeightThenOffset (output = source * weight + offset)
- CascadedChannelBypassesOutputClipping
- CascadedWeightMultiplication
- FlightModePriority (FM1 > FM2 > ... > FM0 fallback)
- StickyLatchesAtStartupWhenSetConditionTrue
- StickyFalseAtStartupWhenSetConditionFalse

Also replace all manual switch-scanning loops across mixer.cpp,
switches.cpp, and functions.cpp with findHwSwitch(), adding a
startAfter parameter for finding a second distinct switch. Remove
two #if defined(PCBTARANIS) guards from switches.cpp — those tests
now run on all targets with a runtime skip when no suitable switch
is available.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Test the complete sequencer technique: a timebase channel (switch source
with slow up/down) feeds a servo channel through a custom curve. Verifies
that flat curve segments produce pauses where the servo holds position
while the timebase ramps, and that reversing the switch automatically
reverses the sequence through the same curve.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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