feat(nb4p): hardware drivers enhancements
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.
Can you describe what do you want to achieve in this PR? Did you modded a NB4+ and want to add sone features?
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
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.
@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
@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 ;-)
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 ;-)
Maybe you can find me at our discord channel and we may discuss more there.
Sure what is your nick there ? Mine is Guilhem23
@richardclli Can you let me know if you want this PR, changes made, or if it is not suitable.
@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
@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.
No problem, just let me know when I should pay attention to this PR again ;)