Skip to content

feat: add DeviceUIConfig.screen_rotation - #1026

Open
attakygit wants to merge 1 commit into
meshtastic:masterfrom
Attaky-Module:feat/device-ui-screen-rotation
Open

feat: add DeviceUIConfig.screen_rotation#1026
attakygit wants to merge 1 commit into
meshtastic:masterfrom
Attaky-Module:feat/device-ui-screen-rotation

Conversation

@attakygit

@attakygit attakygit commented Jul 31, 2026

Copy link
Copy Markdown

What does this PR do?

Adds a persisted screen rotation to DeviceUIConfig so the color UI can offer
orientation as a runtime setting instead of a build-time choice.

Today a device that can render both the 320x240 and the 240x320 layout has to
pick one at compile time via VIEW_320x240 / VIEW_240x320. There is nowhere
to store a user's choice, so the only way to change orientation is to reflash.

The device-ui side that consumes this field is implemented and hardware-tested;
see the companion PR linked below.

The field

ScreenRotation screen_rotation = 20;

enum ScreenRotation {
  ROTATION_0   = 0;
  ROTATION_90  = 1;
  ROTATION_180 = 2;
  ROTATION_270 = 3;
}

Quarter turns relative to the device's built-in display orientation, not
absolute panel rotations.

  • ROTATION_0 is the existing behaviour. Every device that never sets this
    field keeps rendering exactly as it does today, and the default value of an
    unset proto3 enum is 0, so no migration is involved.
  • The 0..3 quarter-turn numbering matches LVGL's LV_DISPLAY_ROTATION_* and the
    masking already used for MESHTASTIC_FB_ROTATION in device-ui Deprecate MyNodeInfo fields: max_channels, message_timeout_msec, has_wifi, channel_utilization, and air_util_tx #355 — same
    concept, same numbering, different transport.
  • It is read at boot. Changing it needs a restart, because an LVGL layout tree
    cannot be rebuilt in place once the view has cached its object pointers. The
    comment says so.

Why in the proto rather than firmware-side

Open question for you, and I'm happy either way:

DeviceUIConfig is where every other persisted MUI setting already lives
(brightness, theme, language, touch calibration), and it reaches the firmware
through the existing storeUIConfig path, so device-ui needs no new plumbing
and the phone app could surface it later.

The alternative is a firmware-owned byte with device-ui exposing a small
load/store hook. That avoids touching the wire format entirely, at the cost of a
private file, no app visibility, and a GIT_TAG/submodule bump chain to get the
generated bindings anywhere.

If you'd rather not spend a field number on this, say so and I'll redo it the
firmware-owned way — the device-ui implementation is unaffected apart from where
it reads and writes the value.

Checklist

  • All top level messages commented (no new messages)
  • All enum members have unique descriptions
  • buf format clean

Companion PR

device-ui implementation: meshtastic/device-ui#359

Summary by CodeRabbit

  • New Features
    • Added support for selecting color UI screen rotation: 0°, 90°, 180°, or 270°.
    • Device display orientation can now be configured through device settings.

The color UI has no way to persist a screen rotation, so a device that can
render both a landscape and a portrait layout has to pick one at build time.

The value is a quarter-turn count relative to the device's built-in display
orientation, so ROTATION_0 means every existing device keeps behaving exactly
as it does today. It is read at boot, which is why changing it requires a
restart: a layout tree cannot be rebuilt in place once the view has cached its
object pointers.
@CLAassistant

CLAassistant commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The device UI protobuf now supports color UI screen rotation. The configuration includes a screen_rotation field, and the ScreenRotation enum defines 0°, 90°, 180°, and 270° orientations.

Changes

Screen rotation configuration

Layer / File(s) Summary
Rotation configuration contract
meshtastic/device_ui.proto
DeviceUIConfig now includes screen_rotation. The new ScreenRotation enum defines four quarter-turn orientations. The setting applies after restart.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding DeviceUIConfig.screen_rotation.
Description check ✅ Passed The description explains the change, rationale, behavior, compatibility, testing, checklist status, and companion PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

2 participants