Skip to content

feat: add 800x480 template#540

Merged
haslinghuis merged 3 commits intobetaflight:masterfrom
pfeerick:pfeerick/tx16mk3
Apr 16, 2026
Merged

feat: add 800x480 template#540
haslinghuis merged 3 commits intobetaflight:masterfrom
pfeerick:pfeerick/tx16mk3

Conversation

@pfeerick
Copy link
Copy Markdown
Contributor

@pfeerick pfeerick commented Apr 15, 2026

Fixes #537

Adds layout for the 800x480 resolution colour screen RadioMaster TX16 MK3. In implementing it, I realised some magic numbers were being used rather than the template values, so fixed that as well - but if wanted I can split that to a seperate PR.

Both BF Config and BF CMS scripts have been tested on TX16S MK3 hardware. The CMS is always going to be shocking as we don't have fixed width fonts, thus trying to account for widest character makes smallest (i.e. W vs I) janky at best, and this is somewhat comparable with the 480x272 TX16S display.

screen-2000-01-26-182033 screen-2000-01-26-183921 screen-2000-01-26-191242 screen-2000-01-26-191247 screen-2000-01-26-194048

Summary by CodeRabbit

  • New Features

    • Added support for 800x480 resolution displays with tailored layout templates
    • Added MSP and CMS configuration options for the new resolution, including high-resolution UI adjustments
  • Refactor

    • UI layout now uses template-driven configuration values for consistent, flexible sizing and spacing

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

📝 Walkthrough

Walkthrough

Adds support for an 800x480 display by introducing a new layout template, registering the resolution in radio configurations, and updating the UI to load and use template-driven layout values instead of hardcoded constants.

Changes

Cohort / File(s) Summary
Template Configuration
src/SCRIPTS/BF/TEMPLATES/800x480.lua
New Lua module exporting layout values: margin, indent, lineSpacing, listSpacing (line,field), and tableSpacing (row,col,header).
Radio Configuration
src/SCRIPTS/BF/radios.lua
Added ["800x480"] entry to supportedRadios with msp using the new template and highRes=true, plus cms sizing/refresh settings. Minor whitespace normalization in other entries.
UI Implementation
src/SCRIPTS/BF/ui.lua
Loads template via radio.template and replaces hardcoded title/menu layout constants with template values (lineSpacing, margin) for title bar, text origin, and menu spacing.

Sequence Diagram(s)

sequenceDiagram
    participant RadioConfig
    participant TemplateLoader
    participant UI
    participant Renderer

    RadioConfig->>TemplateLoader: radio.template path (e.g., TEMPLATES/800x480.lua)
    TemplateLoader-->>RadioConfig: return template table (margin, lineSpacing, ...)
    RadioConfig->>UI: set radio.template and radio.highRes
    UI->>TemplateLoader: assert(loadScript(radio.template))()
    TemplateLoader-->>UI: template values
    UI->>Renderer: draw title/menu using template.margin and template.lineSpacing
    Renderer-->>UI: rendered frame
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I found a wider meadow bright,
Templates snug for pixel light,
No more hardcoded hops and skips—
Layouts now spring from tidy scripts,
I nibble bugs and dance with bytes ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new 800x480 template for display resolution support.
Linked Issues check ✅ Passed The PR successfully addresses issue #537 by adding 800x480 template support for RadioMaster TX16 MK3, enabling script compatibility with that hardware.
Out of Scope Changes check ✅ Passed All changes are in-scope: new template file, radio configuration updates, and UI refactoring to use template values instead of magic numbers are all necessary for the 800x480 support objective.
Description check ✅ Passed The PR description includes the issue number (#537), explains the changes made, acknowledges refactoring of magic numbers, mentions testing on hardware, and includes screenshots demonstrating functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/SCRIPTS/BF/radios.lua (1)

149-150: Consider scaling yMaxLimit to 800x480 height to avoid early scrolling.

yMaxLimit = 280 is quite low for a 480px-tall screen and can make navigation scroll earlier than necessary.

♻️ Suggested adjustment
-            yMaxLimit = 280,
+            yMaxLimit = LCD_H - 45,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/SCRIPTS/BF/radios.lua` around lines 149 - 150, The yMaxLimit value is too
small for a 480px-tall layout causing early scrolling; update the yMaxLimit
constant used in the radios UI block (currently `yMaxLimit = 280`) to scale to a
800x480 height (e.g., increase it to a value appropriate for 480px, such as
~420–460) so the scroll range matches the screen height; locate the
`yMinLimit`/`yMaxLimit` pair in the radios.lua UI configuration and adjust
`yMaxLimit` accordingly while keeping `yMinLimit = 35` unchanged.
src/SCRIPTS/BF/ui.lua (1)

1-1: The load order assumptions are verified as correct; the suggested hardening is optional.

radio is guaranteed to be initialized (line 12) before ui.lua loads (line 16), ensuring radio.template exists at module load time. This same pattern is safely used across 20+ files throughout the codebase.

The suggested hardening improves error diagnostics only; it is not required:

Optional: Improve error messages
-local template = assert(loadScript(radio.template))()
+local templateLoader = assert(loadScript(radio.template), "Failed to load template script: "..tostring(radio.template))
+local template = assert(templateLoader(), "Template script returned nil: "..tostring(radio.template))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/SCRIPTS/BF/ui.lua` at line 1, The current module assumes radio.template
exists and uses assert(loadScript(radio.template))(), which can yield an
unhelpful error; to harden diagnostics, first assert radio and radio.template
are non-nil (e.g., assert(radio and radio.template, "radio.template not
initialized")), then call local loader = loadScript(radio.template) and
assert(loader, "loadScript failed for radio.template"), finally invoke template
= loader(); reference the symbols radio, radio.template, loadScript, and
template in your changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/SCRIPTS/BF/radios.lua`:
- Around line 149-150: The yMaxLimit value is too small for a 480px-tall layout
causing early scrolling; update the yMaxLimit constant used in the radios UI
block (currently `yMaxLimit = 280`) to scale to a 800x480 height (e.g., increase
it to a value appropriate for 480px, such as ~420–460) so the scroll range
matches the screen height; locate the `yMinLimit`/`yMaxLimit` pair in the
radios.lua UI configuration and adjust `yMaxLimit` accordingly while keeping
`yMinLimit = 35` unchanged.

In `@src/SCRIPTS/BF/ui.lua`:
- Line 1: The current module assumes radio.template exists and uses
assert(loadScript(radio.template))(), which can yield an unhelpful error; to
harden diagnostics, first assert radio and radio.template are non-nil (e.g.,
assert(radio and radio.template, "radio.template not initialized")), then call
local loader = loadScript(radio.template) and assert(loader, "loadScript failed
for radio.template"), finally invoke template = loader(); reference the symbols
radio, radio.template, loadScript, and template in your changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6fdcfc20-6d40-4bef-81f3-df57656dd03b

📥 Commits

Reviewing files that changed from the base of the PR and between c93054d and 05f4e89.

📒 Files selected for processing (3)
  • src/SCRIPTS/BF/TEMPLATES/800x480.lua
  • src/SCRIPTS/BF/radios.lua
  • src/SCRIPTS/BF/ui.lua

@haslinghuis haslinghuis merged commit bddf481 into betaflight:master Apr 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not work on radiomaster tx16s mk3

2 participants