feat: add 800x480 template#540
Conversation
For radios such as the RM TX16S MK3
📝 WalkthroughWalkthroughAdds 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/SCRIPTS/BF/radios.lua (1)
149-150: Consider scalingyMaxLimitto 800x480 height to avoid early scrolling.
yMaxLimit = 280is 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.
radiois guaranteed to be initialized (line 12) beforeui.lualoads (line 16), ensuringradio.templateexists 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
📒 Files selected for processing (3)
src/SCRIPTS/BF/TEMPLATES/800x480.luasrc/SCRIPTS/BF/radios.luasrc/SCRIPTS/BF/ui.lua
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.
Summary by CodeRabbit
New Features
Refactor