Skip to content

Conversation

@Guilhem23
Copy link
Contributor

Motivation

Fix critical bugs and improve reliability of NB4+ hardware drivers.

Changes

  • Switch driver: add/fix SW3 support, improved ADC thresholds, multiplexed logic
  • Trim driver: add intermediate positions, hysteresis, improved debouncing
  • Comprehensive hardware mapping comments for maintainability

Validation

  • SW3 now functional and reliable
  • Trims detect intermediate positions, no false triggers
  • No impact on other PL18 boards

Notes

ADC thresholds are based on hardware measurements. If needed, can be made configurable in future PRs.

- Uncomment and fix SW3/SW4 support in switch driver
- Add improved ADC thresholds with hysteresis (400/3500 vs 512/3584)
- Fix multiplexed switch detection on ADC_RAW2 channel
- Add comprehensive hardware mapping documentation
- Prepare SW4 support for future hardware revisions

Resolves critical bug where SW3 was completely non-functional.
Improves reliability by preventing false switch triggers.
…rmediate positions

- Add robust ADC thresholds with hysteresis for reliable trim detection
- Implement intermediate trim positions support
- Add comprehensive documentation and hardware mapping comments
- Improve debouncing logic for stable trim state detection
- Align with EdgeTX hardware driver standards
@pfeerick pfeerick requested a review from richardclli October 14, 2025 10:27
@richardclli
Copy link
Collaborator

Can you describe what do you want to achieve in this PR? Did you modded a NB4+ and want to add sone features?

@Guilhem23
Copy link
Contributor Author

Guilhem23 commented Oct 14, 2025

Hello @richardclli,

This PR improves hardware input detection for the stock FlySky NB4+ (no hardware mods).
It corrects the ADC multiplexing logic so all three switches (SW1, SW2, SW3) and trims are reliably detected.
On NB4+ hardware, the SW3 switch seems to be multiplexed with the trim inputs on the same ADC channel. The previous driver logic did not correctly separate SW3 states from trim positions, causing unreliable detection of SW3 activation, especially when the trim was not centered.

The changes are not yet validated on real NB4+ hardware (My NB4+ still need HW rework waiting for some parts).

Let me know your thoughts

@richardclli
Copy link
Collaborator

I did not test your code yet. But the original code is to map sw1a and sw1b to enter and exit and leaves sw2 and sw3 as normal temporary switches.

Why I bring up the discussion is because I did the nb4p port just for fun and it need some mod on the tx module to make it useful. I am still working on the tx module part.

It will be interesting if someone want to work out more about the nb4p together. So wanna see what plan you have in mind and see what we can achieve together.

@Guilhem23
Copy link
Contributor Author

@richardclli I can definitely help, I have ordered a while ago a NB4+ as spare radio and unfortunately after unpacking it's CN only and Flysky didn't yet came with a solution for me.
I'm not familiar with these RC radio Software but more on microcontroller and embedded development so it should be ok and I'm definitely willing to fix my NB4+ and have a full support for it seems to me that it's a great radio for the price tag.

I'm still trying to find all HW parts to rework my NB4+ to test the SW. Unfortunately I'm unable to find them all in same store so the shipping is way too high, I need to figure this out.

Feel free to share your current status and if you see places where I can help. I will let you know if I find some solutions on missing parts to enable me testing all mods.

Have a great day

@Guilhem23
Copy link
Contributor Author

@richardclli can you please let me know the current status of the TX radio and what needs to be done I will have a look also if you to have some documentation on the schematics and mabe chips used inside it can be usefull to me.
BTW I have joined Discord server to ease communication ;-)

@richardclli
Copy link
Collaborator

Maybe you can find me at our discord channel and we may discuss more there.

@richardclli can you please let me know the current status of the TX radio and what needs to be done I will have a look also if you to have some documentation on the schematics and mabe chips used inside it can be usefull to me.
BTW I have joined Discord server to ease communication ;-)

@Guilhem23
Copy link
Contributor Author

Maybe you can find me at our discord channel and we may discuss more there.

Sure what is your nick there ? Mine is Guilhem23

@pfeerick pfeerick changed the title Feat/nb4p hardware drivers enhancements feat(nb4p): hardware drivers enhancements Oct 18, 2025
@pfeerick
Copy link
Member

@richardclli Can you let me know if you want this PR, changes made, or if it is not suitable.

@Guilhem23
Copy link
Contributor Author

@pfeerick please wait for this one as I need to make the HW rework and try it out. I did this modification blindly and I must try it out

@Guilhem23 Guilhem23 marked this pull request as draft October 18, 2025 09:16
@richardclli
Copy link
Collaborator

@richardclli Can you let me know if you want this PR, changes made, or if it is not suitable.

I think it is not suitable, as he overrides some of my definitions. Will discuss with him to see what is better.

@pfeerick
Copy link
Member

No problem, just let me know when I should pay attention to this PR again ;)

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.

3 participants