Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/OpenIPC/msposd into rockchip
Browse files Browse the repository at this point in the history
  • Loading branch information
henkwiedig committed Dec 22, 2024
2 parents cd8d626 + 07fb941 commit b9b5373
Show file tree
Hide file tree
Showing 18 changed files with 234 additions and 177 deletions.
5 changes: 0 additions & 5 deletions .devcontainer/devcontainer.json

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:
- name: Build
run: |
sudo apt-get update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get -y install git make wget gcc libevent-dev libcsfml-dev file g++ cpio unzip rsync bc bzip2
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC sudo apt-get -y install git make wget gcc libevent-dev libcsfml-dev file g++ cpio unzip rsync bc bzip2 libcairo-dev
./build.sh goke
./build.sh hisi
./build.sh star6b0
./build.sh star6e
./build.sh x86
./build.sh rockchip
./build.sh native
./build.sh rockchip
- name: Upload binary
uses: actions/upload-artifact@v4
Expand All @@ -36,8 +36,8 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
msposd
- name: Versioned release
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -48,8 +48,8 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
msposd
- name: Upload latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
Expand All @@ -61,5 +61,5 @@ jobs:
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
msposd
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ msposd_goke
msposd_hisi
msposd_star6b0
msposd_star6e
msposd_x86
msposd_rockchip
msposd
serial_monitor.c
version.h
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "gcc build",
"type": "shell",
"command": "./build.sh x86",
"command": "./build.sh native",
"args": [],
"group": {
"kind": "build",
Expand All @@ -21,8 +21,8 @@
"command": "cp",
"args": [
"-f",
"${workspaceFolder}/msposd_x86",
"${workspaceFolder}/msposd"
"${workspaceFolder}/msposd",
"${workspaceFolder}/msposd_x"
],
"problemMatcher": [],
"detail": "Copy msposd to workspace folder",
Expand Down
12 changes: 2 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ version.h:
all: version.h

clean:
rm -f *.o msposd_x86 msposd_goke msposd_hisi msposd_star6b0 msposd_star6e msposd_rockchip
rm -f *.o msposd msposd_goke msposd_hisi msposd_star6b0 msposd_star6e msposd_rockchip

goke: version.h
$(eval SDK = ./sdk/gk7205v300)
Expand All @@ -45,18 +45,10 @@ star6e: version.h
$(eval LIB = -lcam_os_wrapper -lm -lmi_rgn -lmi_sys -lmi_venc)
$(BUILD)

jetson: version.h
$(eval SDK = ./sdk/gk7205v300)
$(eval CFLAGS += -D_x86 -D_jetson)
$(eval LIB = -lcsfml-graphics -lcsfml-window -lcsfml-system `pkg-config --libs cairo x11` -lm)
$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)

x86: version.h
native: version.h
$(eval SDK = ./sdk/gk7205v300)
$(eval CFLAGS += -D_x86)
$(eval LIB = -lcsfml-graphics -lcsfml-window -lcsfml-system `pkg-config --libs cairo x11` -lm)

$(eval BUILD = $(CC) $(SRCS) -I $(SDK)/include -L $(DRV) $(CFLAGS) $(LIB) -levent_core -O0 -g -o $(OUTPUT))
$(BUILD)

Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,33 +137,38 @@ Prebuild binaries for x86, SigmaStar, Goke and Hisilicon are at release/ folder.
curl -L -o /usr/bin/msposd https://github.com/OpenIPC/msposd/releases/download/latest/msposd_star6e
chmod 755 /usr/bin/msposd
```
Copy the font files for your flight controller firmware INAV/ Betaflight/ ArduPilot from here https://github.com/openipc/msposd/tree/main/fonts

***Since Nov 2024 ***
Program automatically selects the appropriate font file for the FC software used.
font_inav.png/font_inav_hd.png | font_btfl.png/font_btfl_hd.png | font_ardu.png/font_ardu_hd.png files must be present in ```/usr/share/fonts/```


***If you prefer, you can copy only the fong files for the FC software you plan to use***
Copy the font files for your flight controller firmware INAV/ Betaflight/ ArduPilot from here https://github.com/openipc/msposd/tree/main/fonts
**For INAV**:
```
mkdir /usr/share/fonts
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/inav/font.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/inav/font_hd.png
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_inav.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_inav_hd.png
```

**For Betaflight**: preinstalled in OpenIPC firmware since Oct 2024
```
mkdir /usr/share/fonts
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/betaflight/font.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/betaflight/font_hd.png
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_btfl.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_btfl_hd.png
```


**For Ardupilot**:
Set
```SERIALx_PROTOCOL = 42``` replace x with the UART number.
```OSD_TYPE = 5```
To use betaflight fonts, set ```MSP_OPTIONS = 5``` and copy fonts for betaflight as shown above.
If you prefer to use ardupilot "native" fonts (more icons), then set ```MSP_OPTIONS = 4``` and copy the fonts below.
If you prefer to use ardupilot "native" fonts (more icons), then set ```MSP_OPTIONS = 0``` and copy the fonts below.
```
mkdir /usr/share/fonts
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/ardupilot/font.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/ardupilot/font_hd.png
curl -k -L -o /usr/share/fonts/font.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_ardu.png
curl -k -L -o /usr/share/fonts/font_hd.png https://raw.githubusercontent.com/openipc/msposd/main/fonts/font_ardu_hd.png
```

Start msposd or reference it in OpenIPC boot scripts.
Expand Down
21 changes: 10 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
DL="https://github.com/OpenIPC/firmware/releases/download/toolchain/toolchain"

if [ "$#" -ne 1 ]; then
echo "Usage: $0 [goke|hisi|star6b0|star6e|native]"
exit 1
fi

if [[ "$1" == *"star6b0" ]]; then
CC=sigmastar-infinity6b0
Expand All @@ -13,15 +17,16 @@ elif [[ "$1" == *"hisi" ]]; then
fi

GCC=$PWD/toolchain/$CC/bin/arm-linux-gcc
OUT=msposd_$1
OUT=msposd

if [[ "$1" != *"jetson"* && "$1" != *"x86"* && "$1" != *"rockhip"* ]]; then
if [[ "$1" != *"native"* && "$1" != *"rockhip"* ]]; then
if [ ! -e toolchain/$CC ]; then
wget -c -q --show-progress $DL.$CC.tgz -P $PWD
mkdir -p toolchain/$CC
tar -xf toolchain.$CC.tgz -C toolchain/$CC --strip-components=1 || exit 1
rm -f $CC.tgz
fi
OUT=msposd_$1
fi

if [ ! -e firmware ]; then
Expand All @@ -40,15 +45,9 @@ elif [ "$1" = "star6b0" ]; then
elif [ "$1" = "star6e" ]; then
DRV=$PWD/firmware/general/package/sigmastar-osdrv-infinity6e/files/lib
make -B CC=$GCC DRV=$DRV TOOLCHAIN=$PWD/toolchain/$CC OUTPUT=$OUT $1
elif [ "$1" = "jetson" ]; then
DRV=$PWD
make DRV=$DRV OUTPUT=$OUT $1
elif [ "$1" = "x86" ]; then
DRV=$PWD
make DRV=$DRV OUTPUT=$OUT $1
elif [ "$1" = "rockchip" ]; then
./build_rockchip.sh $1
else
echo "Usage: $0 [goke|hisi|star6b0|star6e|jetson|x86|rockchip]"
exit 1
fi
DRV=$PWD
make DRV=$DRV OUTPUT=$OUT $1
fi
Binary file removed fonts/ardupilot/font.png
Binary file not shown.
Binary file added fonts/font_ardu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
43 changes: 32 additions & 11 deletions msposd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#define MAX_MTU 9000
#include "osd/util/settings.h"

//This needs to be patched in the kernel to work
#define UART_FCR_TRIGGER_RX_L3 0x10000

bool vtxMenuActive = false;
bool armed = true; // assume armed until we are told otherwise from the fc
Expand Down Expand Up @@ -961,7 +963,7 @@ static bool ReadSerialSimple(int showstat){
stat_UDP_MSPframes=0;
}

uint8_t data[1024];
uint8_t data[2048];
// Read from the serial port once per interval
int packet_len = read(serial_fd, data, sizeof(data));
if (packet_len < 0)
Expand All @@ -971,18 +973,23 @@ static bool ReadSerialSimple(int showstat){
stat_bytes+=packet_len;
ttl_packets++;
ttl_bytes+=packet_len;

//support for very low refresh rate, we will lose some FC data, may end up with distorted OSD? But we need to read all data in the beginning to identify the FC !
if (packet_len==sizeof(data) && bitmapFnt.pData!=NULL)
tcflush(serial_fd, TCIOFLUSH);

if (ParseMSP){
for(int i=0;i<packet_len;i++)
msp_process_data(rx_msp_state, data[i]);
//continue;
msp_process_data(rx_msp_state, data[i]);
}
}


static void send_variant_request2(int serial_fd) {
uint8_t buffer[6];
int res=0;

if (AbortNow)
return;
if (enable_simple_uart ){
int rate_divider=MSP_PollRate / (1000 / MinTimeBetweenScreenRefresh);
if (rate_divider<1 || rate_divider>MSP_PollRate)
Expand Down Expand Up @@ -1010,20 +1017,24 @@ static void send_variant_request2(int serial_fd) {
construct_msp_command(buffer, MSP_CMD_FC_VARIANT, NULL, 0, MSP_OUTBOUND);
res = write(serial_fd, &buffer, sizeof(buffer));

if (mspVTXenabled) {
//Sending several request right one after another does not work well on INAV ...
if (bitmapFnt.pData!=NULL && mspVTXenabled) {//no need to poll when no fonts are still loaded
// Poll for mspVTX
construct_msp_command(buffer, MSP_GET_VTX_CONFIG, NULL, 0, MSP_OUTBOUND);
res = write(serial_fd, &buffer, sizeof(buffer));
}
}
//usleep(20*1000);
VariantCounter=0;
}

//Sending several request right one after another does not work well on INAV ...
if (MSP_PollRate - 2 == VariantCounter ){//poll every one second, but one by one!
//poll for FC_STATUS
construct_msp_command(buffer, MSP_CMD_STATUS, NULL, 0, MSP_OUTBOUND);
res = write(serial_fd, &buffer, sizeof(buffer));

//usleep(20*1000);
VariantCounter=0;
}


//construct_msp_command(buffer, MSP_CMD_BATTERY_STATE, NULL, 0, MSP_OUTBOUND);
//res = write(serial_fd, &buffer, sizeof(buffer));

Expand Down Expand Up @@ -1094,8 +1105,18 @@ static int handle_data(const char *port_name, int baudrate,
options.c_iflag &= 0; // disable software flow controll
options.c_oflag &= 0;


if (enable_simple_uart)
options.c_iflag |= ( UART_FCR_TRIGGER_RX_L3 ); //#define UART_FCR_TRIGGER_RX_L3 0x10000 will work only on patched kernel driver

cfmakeraw(&options);
tcsetattr(serial_fd, TCSANOW, &options);
#ifdef _x86
usleep(500*1000);//flush all data in the Rx buffer
int tttt=tcflush(serial_fd, TCIOFLUSH);
#endif
if (enable_simple_uart)
tcflush(serial_fd, TCIOFLUSH);

// tell the fc what vtx config we support
if (mspVTXenabled) {
Expand All @@ -1115,7 +1136,7 @@ static int handle_data(const char *port_name, int baudrate,
struct sockaddr_in sin_in = {
.sin_family = AF_INET,
};


base = event_base_new();

Expand Down Expand Up @@ -1190,7 +1211,7 @@ static int handle_data(const char *port_name, int baudrate,
event_base_dispatch(base);
err:

if (temp_tmr ) {
if (temp_tmr ) {
event_del(temp_tmr);
event_free(temp_tmr);
}
Expand Down
Loading

0 comments on commit b9b5373

Please sign in to comment.