fix(sport): add Betaflight Pitch/Roll sensor unit and precision (#7116) - #7612
Open
bultodepapas wants to merge 3 commits into
Open
fix(sport): add Betaflight Pitch/Roll sensor unit and precision (#7116)#7612bultodepapas wants to merge 3 commits into
bultodepapas wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds explicit metadata for Betaflight S.Port DIY Pitch/Roll sensors so they display with degrees and one decimal place, and introduces a unit test to validate discovery and value handling.
Changes:
- Register S.Port data IDs
0x5230(Pitch) and0x5240(Roll) in the FrSky S.Port sensor table withUNIT_DEGREEand precision1. - Add a test that feeds synthetic S.Port frames for these IDs and asserts correct unit/precision and raw value storage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| radio/src/telemetry/frsky_sport.cpp | Adds Pitch/Roll DIY sensor definitions with degree unit and 0.1 precision. |
| radio/src/tests/frsky.cpp | Adds a test covering Betaflight Pitch/Roll sensor discovery and signed values. |
Suppressed comments (1)
radio/src/tests/frsky.cpp:544
- Same as above: the
uint16_t*/int32_t*casts here can cause unaligned writes and strict-aliasing UB, and depend on host endianness. Writing the packet bytes explicitly avoids platform-dependent failures.
packet[0] = 0x52;
packet[1] = 0x10;
*((uint16_t *)(packet+2)) = 0x5240; // Roll
*((int32_t *)(packet+4)) = -124; // -12.4 deg
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
3djc
reviewed
Aug 6, 2026
Collaborator
There was a problem hiding this comment.
Several issues with this:
- don't hardcode sensor id, add them to the table in corresponding .h file.
- 0x5100 to 0x52FF is dedicated to DIY, that is free for anyone to use as they which. You are fixing 2 values in that range that others might be using for other purposes
- shouldn't the fix be for Betaflight to use existing ACCX and ACCY sensor id, making sure they don't break someone else implementation ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7116
Summary
Betaflight S.Port telemetry sends Pitch (
0x5230) and Roll (0x5240) sensors with the value encoded as degrees * 10. These IDs fall in the DIY range (0x5100-0x52FF) and were discovered without any unit or precision, so the radio displayed-as unit and0.-as precision.Fix
Added the two Betaflight angle sensors to the
sportSensorstable infrsky_sport.cpp:0x5230→ Pitch,UNIT_DEGREE, precision 1 (value / 10)0x5240→ Roll,UNIT_DEGREE, precision 1 (value / 10)So a raw value of
532is now displayed as53.2degrees.Tests
Added
FrSkySPORT.BetaflightAngleSensorsinradio/src/tests/frsky.cppverifying that:0x5230discovers a sensor withUNIT_DEGREE/ precision 1 and stores the raw value0x5240discovers the Roll sensor likewise (including negative values)