Skip to content

Render Betaflight VTX temperature element#103

Open
etiaro wants to merge 4 commits into
OpenIPC:mainfrom
etiaro:main
Open

Render Betaflight VTX temperature element#103
etiaro wants to merge 4 commits into
OpenIPC:mainfrom
etiaro:main

Conversation

@etiaro

@etiaro etiaro commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Betaflight does not allow to enter a custom vtx elements like INAV does, but it has VTX temperature widget that can be filled with reading on the VTX msposd. Tested on OpenIPC Thinker (Sigmastar).

Assisted-By: OpenAI GPT-5.6 Terra

@tipoman9

Copy link
Copy Markdown
Collaborator

I don't get the benefit of this PR. Can you explain or show a snapshot of the end result? VTx temp can easily be shown over the OSD if you have !TMW! text somewhere on the OSD, just set PilotName or CraftName to it and you will have a nice widget over the position of the !TMW! text. https://github.com/OpenIPC/msposd#custom-osd-elements
image

@henkwiedig

Copy link
Copy Markdown
Collaborator

He is refering to the betaflight msp_dp_sys command: https://betaflight.com/docs/development/API/DisplayPort#msp_dp_sys

// System elements rendered by VTX or Goggles
typedef enum {
    DISPLAYPORT_SYS_GOGGLE_VOLTAGE = 0,
    DISPLAYPORT_SYS_VTX_VOLTAGE = 1,
    DISPLAYPORT_SYS_BITRATE = 2,
    DISPLAYPORT_SYS_DELAY = 3,
    DISPLAYPORT_SYS_DISTANCE = 4,
    DISPLAYPORT_SYS_LQ = 5,
    DISPLAYPORT_SYS_GOGGLE_DVR = 6,
    DISPLAYPORT_SYS_VTX_DVR = 7,
    DISPLAYPORT_SYS_WARNINGS = 8,
    DISPLAYPORT_SYS_VTX_TEMP = 9,
    DISPLAYPORT_SYS_FAN_SPEED = 10,
    DISPLAYPORT_SYS_COUNT,
} displayPortSystemElement_e;
image

@tipoman9

tipoman9 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

@etiaro
Seems you've discovered and fixed several bugs, one of them quite nasty (a resource leak):

  1. event/hotkey leak. FlushDrawing() declared a local struct event *x11_event that shadowed the global, so the X11 hookup guard never latched — every frame re-registered the X11 event and re-grabbed hotkeys, leaking one event per frame indefinitely.

  2. Fix double free of the libevent event_base on shutdown. handle_data() freed base and then called CloseMSP() → Close(), which freed base again — a double free/use-after-free on every normal shutdown. Reordered so Close() runs first and base is freed exactly once, afterward.

  3. UDP mode: stop corrupting stdin's terminal settings. In UDP-only mode serial_fd stayed at its default value of 0 (stdin), so the UART termios setup (cfmakeraw, etc.) was applied to stdin, breaking the invoking terminal. Default changed to -1 and the termios block now only runs when a real UART fd is open.

Could we keep these bug fixes in a separate commit and avoid the unrelated indentation/style-only changes? That would make the PR much easier to review and the commit history easier to follow. Claude created it for me here

Could you please exclude msposd.c and render_gs.c from this commit, leaving only osd.c? Since osd.c contains all the code needed for the Betaflight widget, I think that would keep this change focused. I'll be happy to approve it once that's done.

Thank you for your effort!

etiaro added 3 commits July 24, 2026 21:39
Store the X11 event in the global guard so frames do not repeatedly create events or re-grab hotkeys.

Assisted-by: OpenAI GPT-5.6 Terra
Tear down renderer resources before freeing the shared event base, and make renderer cleanup safe for both XShm and fallback paths.

Assisted-by: OpenAI GPT-5.6 Terra
Use -1 for the absent UART descriptor and configure termios only after opening a real serial port.

Assisted-by: OpenAI GPT-5.6 Terra
@etiaro

etiaro commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Sure, sorry, I planned to commit those fixes in separate PR and included accidentally, but I'll leave them here as you requested.

I introduced also the bitrate display and added a little more generic approach, for now I don't know about a good source for the remaining values (not that they could be filled on GS when GS-rendering).

Thanks for quick response.

Translate locally sourced DisplayPort system elements into draw-string messages and render the current bitrate and hottest available board or Wi-Fi temperature with the Betaflight temperature glyph.

Assisted-by: OpenAI GPT-5.6 Terra
@etiaro
etiaro marked this pull request as draft July 24, 2026 20:03
@etiaro
etiaro marked this pull request as ready for review July 24, 2026 20:07
@tipoman9

Copy link
Copy Markdown
Collaborator

but I'll leave them here as you requested.

Actually I meant the opposite ;-)
Could you please exclude msposd.c and render_gs.c from this commit, leaving only osd.c?

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