Skip to content

Commit

Permalink
Initial support of NB4+
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli authored and gagarinlg committed Jan 24, 2025
1 parent 35e8b61 commit d651b22
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 28 deletions.
1 change: 1 addition & 0 deletions fw.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
["Flysky NV14", "nv14-"],
["Flysky PL18", "pl18-"],
["Flysky PL18EV", "pl18ev-"],
["Flysky NB4+", "nb4p-"],
["FrSky Horus X10", "x10-"],
["FrSky Horus X10 Express", "x10express-"],
["FrSky Horus X12s", "x12s-"],
Expand Down
8 changes: 6 additions & 2 deletions radio/src/datastructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static inline void check_struct()
CHKSIZE(TimerData, 17);
CHKSIZE(ModelHeader, 131);
CHKSIZE(CustomScreenData, 1892);
#if defined(PCBNV14)
#if defined(PCBNV14) || defined(RADIO_NB4P)
CHKTYPE(TopBarPersistentData, 704);
#else
CHKTYPE(TopBarPersistentData, 1048);
Expand Down Expand Up @@ -107,7 +107,11 @@ static inline void check_struct()
#elif defined(PCBNV14)
CHKSIZE(ModelData, 26463);
#elif defined(PCBPL18)
CHKSIZE(ModelData, 26845);
#if defined(RADIO_NB4P)
CHKSIZE(ModelData, 26499);
#else
CHKSIZE(ModelData, 26845);
#endif
#elif defined(RADIO_T15)
CHKSIZE(ModelData, 26834);
#elif defined(PCBHORUS)
Expand Down
5 changes: 4 additions & 1 deletion radio/src/targets/pl18/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ add_definitions(-DSOFTWARE_VOLUME)
add_definitions(-DSPI_FLASH)
add_definitions(-DSTM32_SUPPORT_32BIT_TIMERS)

if(PCBREV STREQUAL PL18EV)
if(PCBREV STREQUAL NB4P)
set(FLAVOUR nb4p)
add_definitions(-DRADIO_NB4P)
elseif(PCBREV STREQUAL PL18EV)
set(FLAVOUR pl18ev)
add_definitions(-DRADIO_PL18EV)
else()
Expand Down
16 changes: 11 additions & 5 deletions radio/src/targets/pl18/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,17 @@
// SDRAM
#define SDRAM_BANK1

#define PORTRAIT_LCD false
#define LANDSCAPE_LCD true

#define LCD_W 480
#define LCD_H 320
#if defined(RADIO_NB4P)
#define PORTRAIT_LCD true
#define LANDSCAPE_LCD false
#define LCD_W 320
#define LCD_H 480
#else
#define PORTRAIT_LCD false
#define LANDSCAPE_LCD true
#define LCD_W 480
#define LCD_H 320
#endif

#define LCD_PHYS_W 320
#define LCD_PHYS_H 480
Expand Down
39 changes: 27 additions & 12 deletions radio/src/targets/pl18/lcd_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,18 +1150,33 @@ void LCD_ST7796S_Init(void) {
lcdWriteData( 0x96 );

lcdWriteCommand( 0x36 );
lcdWriteData( 0x28 );

lcdWriteCommand( 0x2A );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0xDF );
lcdWriteCommand( 0x2B );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0x3F );
if (LCD_W != LCD_PHYS_W) {
lcdWriteData( 0x28 );

lcdWriteCommand( 0x2A );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0xDF );
lcdWriteCommand( 0x2B );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0x3F );
} else {
lcdWriteData( 0x88 );

lcdWriteCommand( 0x2A );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0x3F );
lcdWriteCommand( 0x2B );
lcdWriteData( 0x00 );
lcdWriteData( 0x00 );
lcdWriteData( 0x01 );
lcdWriteData( 0xDF );
}

lcdWriteCommand( 0x3A );
lcdWriteData( 0x66 );
Expand Down
20 changes: 12 additions & 8 deletions radio/src/targets/pl18/usb_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@

#pragma once

#if defined(RADIO_PL18EV)
#define USB_NAME "FlySky PL18EV"
#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'P', 'L', '1', '8', 'E', 'V', ' ', ' ' /* 8 Bytes */
#else
#define USB_NAME "FlySky PL18"
#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'P', 'L', '1', '8', ' ', ' ', ' ', ' ' /* 8 Bytes */
#if defined(RADIO_NB4P)
#define USB_NAME "FlySky NB4+"
#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'N', 'B', '4', '+', ' ', ' ', ' ', ' ' /* 8 Bytes */
#elif defined(RADIO_PL18EV)
#define USB_NAME "FlySky PL18EV"
#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'P', 'L', '1', '8', 'E', 'V', ' ', ' ' /* 8 Bytes */
#else
#define USB_NAME "FlySky PL18"
#define USB_MANUFACTURER 'F', 'l', 'y', 'S', 'k', 'y', ' ', ' ' /* 8 bytes */
#define USB_PRODUCT 'P', 'L', '1', '8', ' ', ' ', ' ', ' ' /* 8 Bytes */
#endif
62 changes: 62 additions & 0 deletions radio/util/hw_defs/legacy_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,68 @@
}
}
},
{
"targets": {
"nb4p"
},
"inputs": {
"LH": {
"yaml": "Rud",
"lua": "rud",
"description": "Rudder"
},
"LV": {
"yaml": "Ele",
"lua": "ele",
"description": "Elevator"
},
"RV": {
"yaml": "Thr",
"lua": "thr",
"description": "Throttle"
},
"RH": {
"yaml": "Ail",
"lua": "ail",
"description": "Aileron"
},
"P1": {
"yaml": "POT1",
"lua": "s1",
"label": "S1",
"short_label": "1",
"description": "Potentiometer 1"
},
"P2": {
"yaml": "POT2",
"lua": "s2",
"label": "S2",
"short_label": "2",
"description": "Potentiometer 2"
},
"P3": {
"yaml": "POT3",
"lua": "s3",
"label": "S3",
"short_label": "3",
"description": "Potentiometer 3"
},
"SL1": {
"yaml": "LS",
"lua": "ls",
"label": "LS",
"short_label": "L",
"description": "Left slider"
},
"SL2": {
"yaml": "RS",
"lua": "rs",
"label": "RS",
"short_label": "R",
"description": "Right slider"
},
}
},
{
"targets": {"v12", "v14"},
"inputs": {
Expand Down
7 changes: 7 additions & 0 deletions radio/util/hw_defs/pot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
"EXT3": {"default": "MULTIPOS"},
"EXT4": {"default": "MULTIPOS"}
},
"nb4p": {
"P1": {"default": "POT"},
"P2": {"default": "POT"},
"P3": {"default": "POT"},
"SL1": {"default": "SLIDER"},
"SL2": {"default": "SLIDER"}
},
"v12": {
"P1": {"default": "POT_CENTER"},
"P2": {"default": "POT_CENTER"},
Expand Down
10 changes: 10 additions & 0 deletions radio/util/hw_defs/switch_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@
"SI": { "default": "3POS" },
"SJ": { "default": "3POS" }
},
"nb4p": {
"SA": { "default": "2POS" },
"SB": { "default": "3POS" },
"SC": { "default": "2POS" },
"SD": { "default": "3POS" },
"SE": { "default": "3POS" },
"SF": { "default": "2POS" },
"SG": { "default": "3POS" },
"SH": { "default": "TOGGLE" }
},
"lr3pro": {
# left side
"SA": {"default": "3POS", "display": [0, 0]},
Expand Down
3 changes: 3 additions & 0 deletions tools/build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ get_target_build_options() {
pl18ev)
BUILD_OPTIONS+="-DPCB=PL18 -DPCBREV=PL18EV"
;;
nb4p)
BUILD_OPTIONS+="-DPCB=PL18 -DPCBREV=NB4P"
;;
*)
echo "Unknown target: $target_name"
return 1
Expand Down

0 comments on commit d651b22

Please sign in to comment.