Skip to content

feat: transport driver orientation from config.yaml - default 0 rotation. - #355

Open
caveman99 wants to merge 1 commit into
masterfrom
framebuffer-rotate
Open

feat: transport driver orientation from config.yaml - default 0 rotation.#355
caveman99 wants to merge 1 commit into
masterfrom
framebuffer-rotate

Conversation

@caveman99

@caveman99 caveman99 commented Jul 27, 2026

Copy link
Copy Markdown
Member

This is needed for meshtasticd to specify framebuffer orientation from the confg.yaml.

Summary by CodeRabbit

  • New Features
    • Added support for configuring framebuffer display rotation through the MESHTASTIC_FB_ROTATION environment variable.
    • Rotation values are constrained to supported orientations for consistent display behavior.

@caveman99
caveman99 requested a review from mverch67 July 27, 2026 10:02
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Framebuffer initialization now reads MESHTASTIC_FB_ROTATION, parses its integer value, constrains it to LVGL rotation values, and applies the rotation after framebuffer setup.

Changes

Framebuffer rotation

Layer / File(s) Summary
Environment-driven rotation setup
source/graphics/driver/FBDriver.cpp
FBDriver::init reads MESHTASTIC_FB_ROTATION and applies the masked rotation through LVGL when non-zero.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

I’m a rabbit with a spinning screen,
Four neat turns in a framebuffer dream.
An env var hops, the pixels align,
LVGL twirls them right on time.
Squeak—rotation is fine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title captures the main theme of framebuffer orientation and default rotation, which matches the PR's intended change.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@source/graphics/driver/FBDriver.cpp`:
- Around line 39-44: Update the MESHTASTIC_FB_ROTATION parsing in the
framebuffer rotation initialization to accept only values 0 through 3, removing
the rot & 3 masking behavior. Map each valid value explicitly to its
corresponding lv_display_rotation_t constant, while malformed or out-of-range
values fall back to 0° or emit a warning.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6709c46e-417f-43d7-85b9-df760a4afd17

📥 Commits

Reviewing files that changed from the base of the PR and between ef573c3 and 0f23495.

📒 Files selected for processing (1)
  • source/graphics/driver/FBDriver.cpp

Comment on lines +39 to +44
/* Config-driven rotation: (0/1/2/3 = 0/90/180/270)
* from the YAML (Display.Rotate + OffsetRotate)*/
const char *fbrot = getenv("MESHTASTIC_FB_ROTATION");
int rot = fbrot ? atoi(fbrot) : 0;
if (rot)
lv_display_set_rotation(display, (lv_display_rotation_t)(rot & 3));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate FBDriver.cpp and relevant references =="
git ls-files | grep -F 'source/graphics/driver/FBDriver.cpp' || true
rg -n "MESHTASTIC_FB_ROTATION|lv_display_set_rotation|Display\.Rotate|OffsetRotate" .

echo
echo "== relevant source section =="
if [ -f source/graphics/driver/FBDriver.cpp ]; then
  nl -ba source/graphics/driver/FBDriver.cpp | sed -n '1,120p'
fi

echo
echo "== deterministic atoi/rotation behavior probe =="
python3 - <<'PY'
def current(mask):
    vals = ["", None, "0", "1", "2", "3", "4", "5", "-1", "abc"]
    for v in vals:
        import ctypes
        # ctypes.c_int.from_buffer_copy mirrors standard atoi-ish semantics for these literal examples? 
        # Use Python int cast for signed textual values; invalid ASCII values are not covered by atoi probe.
        if v is None:
            rot = 3
        else:
            intlike = int(v) if (v.lstrip("-").isdigit() or (v.startswith("-") and v[1:].isdigit())) else 0
            rot = intlike & mask
        print(f"value={v!r:7} rot={rot}")
    print("rotation_t enum likely 0..3")
current(3)
PY

Repository: meshtastic/device-ui

Length of output: 742


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== locate FBDriver.cpp and relevant references =="
git ls-files | grep -F 'source/graphics/driver/FBDriver.cpp' || true
rg -n "MESHTASTIC_FB_ROTATION|lv_display_set_rotation|Display\.Rotate|OffsetRotate" .

echo
echo "== relevant source section =="
if [ -f source/graphics/driver/FBDriver.cpp ]; then
  nl -ba source/graphics/driver/FBDriver.cpp | sed -n '1,120p'
fi

echo
echo "== deterministic atoi/rotation behavior probe =="
python3 - <<'PY'
def current(mask):
    vals = ["", None, "0", "1", "2", "3", "4", "5", "-1", "abc"]
    for v in vals:
        if v is None:
            rot = 3
        else:
            intlike = int(v) if (v.lstrip("-").isdigit() or (v.startswith("-") and v[1:].isdigit())) else 0
            rot = intlike & mask
        print(f"value={v!r:7} rot={rot}")
    print("rotation_t enum likely 0..3")
current(3)
PY

Repository: meshtastic/device-ui

Length of output: 742


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== read relevant source section =="
awk 'NR>=1 && NR<=120 { printf("%5d\t%s\n", NR, $0) }' source/graphics/driver/FBDriver.cpp

echo
echo "== LVGL rotation enum/header references in repo =="
rg -n "typedef enum|enum \\{|LV_DISPLAY_ROTATION|lv_display_rotation_t|lv_display_set_rotation" -S . || true

echo
echo "== deterministic mask behavior probe =="
python3 - <<'PY'
def mask_val(s):
    rot = int(s or "0") & 3
    return rot
for s in ["", "0", "1", "2", "3", "4", "5", "99", "-1", "-2", "-3"]:
    try:
        print(f"value={s!r:>6} masked_rotation={mask_val(s)}")
    except Exception as e:
        print(f"value={s!r:>6} parsed_error={e}")
PY

Repository: meshtastic/device-ui

Length of output: 4423


🌐 Web query:

LVGL lv_display_rotation_t LV_DISPLAY_ROTATION_0 90 180 270 lv_display_set_rotation

💡 Result:

In LVGL, the lv_display_rotation_t enumeration defines the available rotation angles for a display, supporting 90-degree increments [1][2]. The available values are: LV_DISPLAY_ROTATION_0 LV_DISPLAY_ROTATION_90 LV_DISPLAY_ROTATION_180 LV_DISPLAY_ROTATION_270 The function lv_display_set_rotation(disp, rotation) is used to configure the display orientation [2][3]. When this function is called, LVGL internally swaps the horizontal and vertical resolutions of the display [1][2]. Important Considerations: 1. Internal Resolution Swap Only: lv_display_set_rotation updates LVGL's internal understanding of the display dimensions but does not automatically perform the actual pixel rotation on your hardware [1][4]. 2. Hardware/Software Requirements: If your display driver or hardware does not natively support rotation, you must handle the pixel transformation yourself [1][4]. This is typically done within the display's Flush Callback function using the lv_draw_sw_rotate function to rotate the buffer [1][5]. 3. Events: Changing the rotation triggers an event (e.g., LV_EVENT_SIZE_CHANGED or LV_EVENT_RESOLUTION_CHANGED, depending on the version) to allow the application to perform necessary hardware reconfigurations [1][4][2]. 4. Area Rotation: The function lv_display_rotate_area(disp, &area) is available to rotate specific rendered areas according to the currently set display rotation [1][4][2].

Citations:


🌐 Web query:

LVGL lv_display_rotation_t underlying enum values 0 1 2 3

💡 Result:

In LVGL, the lv_display_rotation_t enum defines the orientation of a display [1][2]. The underlying integer values associated with these constants are as follows: LV_DISPLAY_ROTATION_0 = 0 LV_DISPLAY_ROTATION_90 = 1 LV_DISPLAY_ROTATION_180 = 2 LV_DISPLAY_ROTATION_270 = 3 These constants are used with functions such as lv_display_set_rotation to specify the desired display orientation [1][3]. Setting a rotation will swap the horizontal and vertical resolutions internally within LVGL [3][4].

Citations:


Reject invalid MESHTASTIC_FB_ROTATION values instead of masking them.

rot & 3 silently maps unsupported values to valid LVGL rotations: 4 becomes , 5 becomes 90°, and -1 becomes 270°. Validate the parsed value in the advertised 0..3 range and map the four constants explicitly; malformed values should fall back to 0 or emit a warning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@source/graphics/driver/FBDriver.cpp` around lines 39 - 44, Update the
MESHTASTIC_FB_ROTATION parsing in the framebuffer rotation initialization to
accept only values 0 through 3, removing the rot & 3 masking behavior. Map each
valid value explicitly to its corresponding lv_display_rotation_t constant,
while malformed or out-of-range values fall back to 0° or emit a warning.

Source: MCP tools

@caveman99 caveman99 changed the title Transport driver orientation from config.yaml - default 0 rotation. feat: transport driver orientation from config.yaml - default 0 rotation. Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

An unexpected error occurred while generating fixes: Repository rule violations found

Required status check "Trunk Check Runner" is expected.

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.

1 participant