feat: Flysky Noble 4 Plus (NB4+) support
Flysky Noble 4 Plus (NB4+) Support
Development progress:
- [x] LCD drver
- [x] touch driver
- [x] ST, TH
- [x] pots
- [x] switches
- [x] trims
- [x] encoder (the hardware has 2 encoders, once mapped one currently, need some input to how to make use 2nd encoder)
- [x] audio
- [x] battery charging
- [x] internal module (STM32F030 MCU nothing good can be supported)
- [x] external module (Bluetooth USART3 port, mapped as internal module that can support MULTI/AFHDS3/CRSF)
- [x] modding documentation https://github.com/EdgeTX/edgetx/wiki/Flysky-NB4--Hardware-Mod-for-Complete-EdgeTX-Support
Known hardware limitations:
- No on board RTC support, missing battery and a few cap, diode, crystal components. (PL18 is a lot simpler, just need to add a battery)
- NOR flash is small (Only 8MB on board, can change the chip to maximum 128MB, same as PL18 mod)
- DAC sound output work out of the box without modding ^.^
@pfeerick Seems a test failed after I did a rebase, do you know why?
One reason is because you never had the tests running before for this handset. Can't check the test output ATM so not sure if it is still that or something new.
Three failures I can see straight away...
- simu/switch_driver.cpp:40 fails
assert(swtch < switchGetMaxSwitches() + switchGetMaxFctSwitches());
These two fail due to there being no switches made available to Lua, and it is plausible that the test is somewhat flawed, as it assumes they will always be SA, SB, although perhaps internally they need to be, regardless of what is printed on the case. The list is auto-generated via radio/util/hw_defs/lua_mixsrc.jinja
[----------] 5 tests from Lua
0ms: luaInit
0ms: lsScripts 0x611000003c40
+++[ RUN ] Lua.Switches
/__w/edgetx/edgetx/radio/src/tests/lua.cpp:190: Failure
Value of: __luaExecStr("if MIXSRC_SA == nil then error('failed') end")
Actual: false (lua error: [string "if MIXSRC_SA == nil then error('failed') end"]:1: failed)
Expected: true
[ RUN ] Lua.Switches
/__w/edgetx/edgetx/radio/src/tests/lua.cpp:191: Failure
Value of: __luaExecStr("if MIXSRC_SB == nil then error('failed') end")
Actual: false (lua error: [string "if MIXSRC_SB == nil then error('failed') end"]:1: failed)
Expected: true
The resulting file should look something like this (from the TX16S):
static const LuaSingleField _lua_inputs[] = {
// main inputs
{ MIXSRC_FIRST_STICK + 0, "rud", "Rudder" },
{ MIXSRC_FIRST_STICK + 1, "ele", "Elevator" },
{ MIXSRC_FIRST_STICK + 2, "thr", "Throttle" },
{ MIXSRC_FIRST_STICK + 3, "ail", "Aileron" },
// flex inputs
{ MIXSRC_FIRST_POT + 0, "s1", "Potentiometer S1" },
{ MIXSRC_FIRST_POT + 1, "6pos", "Multipos Switch" },
{ MIXSRC_FIRST_POT + 2, "s2", "Potentiometer S2" },
{ MIXSRC_FIRST_POT + 3, "ls", "Left slider" },
{ MIXSRC_FIRST_POT + 4, "rs", "Right slider" },
{ MIXSRC_FIRST_POT + 5, "ext1", "Ext 1" },
{ MIXSRC_FIRST_POT + 6, "ext2", "Ext 2" },
{ MIXSRC_FIRST_POT + 7, "ext3", "Ext 3" },
{ MIXSRC_FIRST_POT + 8, "ext4", "Ext 4" },
// switches
{ MIXSRC_FIRST_SWITCH + 0, "SA", "SA" },
{ MIXSRC_FIRST_SWITCH + 1, "SB", "SB" },
{ MIXSRC_FIRST_SWITCH + 2, "SC", "SC" },
{ MIXSRC_FIRST_SWITCH + 3, "SD", "SD" },
{ MIXSRC_FIRST_SWITCH + 4, "SE", "SE" },
{ MIXSRC_FIRST_SWITCH + 5, "SF", "SF" },
{ MIXSRC_FIRST_SWITCH + 6, "SG", "SG" },
{ MIXSRC_FIRST_SWITCH + 7, "SH", "SH" },
{ MIXSRC_FIRST_SWITCH + 8, "SI", "SI" },
{ MIXSRC_FIRST_SWITCH + 9, "SJ", "SJ" },
// trims
{ MIXSRC_FIRST_TRIM + 0, "trim-rud", "Rudder trim" },
{ MIXSRC_FIRST_TRIM + 1, "trim-ele", "Elevator trim" },
{ MIXSRC_FIRST_TRIM + 2, "trim-thr", "Throttle trim" },
{ MIXSRC_FIRST_TRIM + 3, "trim-ail", "Aileron trim" },
{ MIXSRC_FIRST_TRIM + 4, "trim-t5", "Aux trim T5" },
{ MIXSRC_FIRST_TRIM + 5, "trim-t6", "Aux trim T6" },
but instead looks like this
root@b361112a0ffa:/workspaces/edgetx/build-nb4p# cat native/radio/src/lua_inputs.inc
//
// WARNING: DO NOT EDIT THIS FILE
// This file has been generated from the target's JSON hardware description
//
static const LuaSingleField _lua_inputs[] = {
// main inputs
{ MIXSRC_FIRST_STICK + 0, "ste", "Steering" },
{ MIXSRC_FIRST_STICK + 1, "thr", "Throttle" },
// flex inputs
{ MIXSRC_FIRST_POT + 0, "s1", "Potentiometer 1" },
{ MIXSRC_FIRST_POT + 1, "s2", "Potentiometer 2" },
{ MIXSRC_FIRST_POT + 2, "ext1", "Ext 1" },
{ MIXSRC_FIRST_POT + 3, "ext2", "Ext 2" },
{ MIXSRC_FIRST_POT + 4, "ext3", "Ext 3" },
{ MIXSRC_FIRST_POT + 5, "ext4", "Ext 4" },
// switches
// trims
{ MIXSRC_FIRST_TRIM + 0, "trim-ste", "Steering trim" },
{ MIXSRC_FIRST_TRIM + 1, "trim-thr", "Throttle trim" },
};
Maybe the switches are implemented by the switch driver instead of simple hardware mapping and the auto generated file did not have switches included, let me look into this and see how this can be resolved.
@raphaelcoeffic Can you give some advice to solve this?
@pfeerick I checked the BT port mapped with int module, it works with ELRS in 5.25M
Was the internal module not working prior to that logic fix? As I was trying to get a previously working receiver with the nb4 yesterday, and having no luck :( Appeared to be no response from internal module...
On Thu, 22 Aug 2024, 2:00 pm richardclli, @.***> wrote:
@pfeerick https://github.com/pfeerick I checked the BT port mapped with int module, it works with ELRS in 5.25M
— Reply to this email directly, view it on GitHub https://github.com/EdgeTX/edgetx/pull/5095#issuecomment-2303627144, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJ66KK5TFY4NF2W32Q4CQTZSVO6DAVCNFSM6AAAAABIT2CIUKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTGYZDOMJUGQ . You are receiving this because you were mentioned.Message ID: @.***>
@pfeerick NB4+ internal module is just the same as FRM301 module in PL18, the protocol is not supported by EdgeTX. It can be flashed to ELRS tough, but because of limited RAM, only ELRS 3.0.1 is possible, and required to flash with debug interface.
The current config maps the int module to the BT UART that can be accessed in the bottom and connect to a customized base with ELRS/MPM.
Ah, ok, I missed that bit 😆 Wasn't interested in ELRS on this just yet... as was expecting this to work with the stock internal RF first and foremost... so ouch.
@raphaelcoeffic Any ideas for a proper way to solve the unit test?
@pfeerick Looks like that some tests will failed when no. of switches = 2
Finally walked through all code generation dependencies. Need the naming of switches matched to have proper switch config generated and the test cannot pass without proper switch config. And one test case failed because it required more than 2 switches and in which nb4p did not have that much in current implementation.
Haha, some tests harcoded the switch names to SA, SB, etc. So..... the other way round.......
@pfeerick @raphaelcoeffic Please review to see if you have any concerns on the changes in code generation scripts.
Does this radio have a trainer port? As trainer thinks it can show master/slave jack settings.
Do the trim hats have anything more than the up/down outputs (electrically) - one axis does something, does the other do anything, and what about pressing on them - i.e. any TODOs there?
Some trims are not working I get "missing or bad radio data" at every boot I was not able to enter the bootloader TR1 and TR2 have only one axis working TR3 and TR4 do not work I think the steering wheel should be reversed
- Bootloader - you use the two buttons on each side the centre grip - SW1/SW2
- bad or missing data - is the SPI flash formatted?
- T3 should work - it is the main input rotary encoder - you can use it + SW1 and SW2 for UI input - scroll, enter, exit
- T4 is the unused rotary encoder I referenced above
I did not format the flash, did it now, works better than before
Bootloader - you use the two buttons on each side the centre grip - SW1/SW2
bad or missing data - is the SPI flash formatted?
T3 should work - it is the main input rotary encoder - you can use it + SW1 and SW2 for UI input - scroll, enter, exit
T4 is the unused rotary encoder I referenced above
ok, then I think we should merge this,
能够用于nb4普通版吗
能够用于nb4普通版吗
其實不算真的能用,要外接高頻頭,有一定的限制 https://github.com/EdgeTX/edgetx/wiki/Flysky-NB4--Hardware-Mod-for-Complete-EdgeTX-Support