Skip to content

Conversation

@pfeerick
Copy link
Contributor

@pfeerick pfeerick commented Dec 9, 2025

EdgeTX has finally depreciated some colour constants from OpenTX days, which would result in black header and hard to read popup menus with the Betaflight Lua script. This will take effect as of EdgeTX 2.11.4, and 2.12.0 onwards. I've left the old constants in so that it should (untested) continue to work on OpenTX and early EdgeTX versions.

Fixes #534, also mentioned in passing at #530 (comment)

Remapped as per https://luadoc.edgetx.org/lua-api-reference/constants/color-constants#deprecated-color-constants, and tested on TX16S (480x272) TX15 (480x320) and PA01(320x240). Some before and after screenshots from handsets below, running different themes (hence the different colours, now following theme correctly):

TX16S

tx16_1 tx16_2

TX15

tx15_1 tx15_2

PA01

pa01_1 pa01_2 pa01_3 pa01_4

Summary by CodeRabbit

  • Style
    • Improved color theming system across all screen layouts with enhanced color fallback options
    • Updated color palette for labels and titles to ensure better visual consistency
    • Better color rendering for high-resolution displays

✏️ Tip: You can customize this high-level summary in your review settings.

EdgeTX has finally depreciated some colour constants from OpenTX days, which would result in black header and hard to read popup menus.
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

The PR updates color theme defaults across radio and UI display configurations by introducing COLOR_THEME_* constants as primary fallback options, prioritizing new theme colors before legacy color variables across multiple display layouts.

Changes

Cohort / File(s) Change Summary
Color Theme Fallback Implementation
src/SCRIPTS/BF/radios.lua
Adds COLOR_THEME_SECONDARY1 as primary fallback to No Telemetry label color expression across 480x272, 480x320, 320x480, and 320x240 display layouts.
Color Theme Fallback Implementation
src/SCRIPTS/BF/ui.lua
Reworks color/theme defaults: backgroundFill prioritizes COLOR_THEME_SECONDARY3, foregroundColor prioritizes COLOR_THEME_PRIMARY3, globalTextOptions prioritizes COLOR_THEME_SECONDARY1, and drawScreenTitle uses COLOR_THEME_SECONDARY1 for background and COLOR_THEME_PRIMARY2 for text.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Changes follow a consistent, repetitive pattern of adding theme color fallbacks
  • Limited scope with straightforward color variable substitutions
  • No behavioral or control-flow modifications to verify

Poem

🎨 A splash of new hues fills the screen so bright,
COLOR_THEME_PRIMARY leads the way with might!
Secondary fallbacks dance in elegant lines,
Colors cascade through radios and UI designs,
Aesthetics enhanced by thoughtful design's art! 🐰✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: black header and unreadable popup menus' is clear, concise, and directly summarizes the main issue being fixed in this changeset.
Description check ✅ Passed The description provides comprehensive context: explains the deprecated EdgeTX color constants issue, references the issue number, documents testing across three devices with before/after screenshots, and maintains backward compatibility.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@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.

Actionable comments posted: 0

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

184-185: Consider adding final fallback values for robustness.

Unlike the module-level color variables (lines 38-41) which have final fallback values (ERASE, SOLID, 0), these color expressions lack a final default. If both COLOR_THEME_SECONDARY1 and TITLE_BGCOLOR are undefined, line 184 could pass nil to lcd.drawFilledRectangle, potentially causing a runtime error.

Apply this diff to add final fallbacks:

-        lcd.drawFilledRectangle(0, 0, LCD_W, 30, COLOR_THEME_SECONDARY1 or TITLE_BGCOLOR)
-        lcd.drawText(5,5,screenTitle, COLOR_THEME_PRIMARY2 or MENU_TITLE_COLOR)
+        lcd.drawFilledRectangle(0, 0, LCD_W, 30, COLOR_THEME_SECONDARY1 or TITLE_BGCOLOR or 0)
+        lcd.drawText(5,5,screenTitle, COLOR_THEME_PRIMARY2 or MENU_TITLE_COLOR or 0)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6484170 and 2a0909f.

📒 Files selected for processing (2)
  • src/SCRIPTS/BF/radios.lua (4 hunks)
  • src/SCRIPTS/BF/ui.lua (2 hunks)
🔇 Additional comments (2)
src/SCRIPTS/BF/radios.lua (1)

91-91: LGTM! Consistent color theme updates across all high-resolution displays.

The addition of COLOR_THEME_SECONDARY1 as the primary color fallback for the "No Telemetry" indicator is consistent across all high-resolution display configurations (480x272, 480x320, 320x480, 320x240) and aligns well with the globalTextOptions changes in ui.lua. The three-level fallback chain properly maintains backward compatibility with OpenTX and older EdgeTX versions.

Also applies to: 119-119, 147-147, 174-174

src/SCRIPTS/BF/ui.lua (1)

38-41: Color constant fallback chains are appropriately structured.

The COLOR_THEME_* constants (PRIMARY3, SECONDARY1, SECONDARY3) referenced in the fallback chains are valid, documented EdgeTX Lua color constants. The fallback pattern—prioritizing new theme constants before deprecated ones—follows sound practice for managing API evolution. No issues with the mappings or fallback logic.

@pfeerick
Copy link
Contributor Author

pfeerick commented Dec 9, 2025

Actionable comments posted: 0

🧹 Nitpick comments (1)

src/SCRIPTS/BF/ui.lua (1)> 184-185: Consider adding final fallback values for robustness.

Unlike the module-level color variables (lines 38-41) which have final fallback values (ERASE, SOLID, 0), these color expressions lack a final default. If both COLOR_THEME_SECONDARY1 and TITLE_BGCOLOR are undefined, line 184 could pass nil to lcd.drawFilledRectangle, potentially causing a runtime error.
Apply this diff to add final fallbacks:

-        lcd.drawFilledRectangle(0, 0, LCD_W, 30, COLOR_THEME_SECONDARY1 or TITLE_BGCOLOR)
-        lcd.drawText(5,5,screenTitle, COLOR_THEME_PRIMARY2 or MENU_TITLE_COLOR)
+        lcd.drawFilledRectangle(0, 0, LCD_W, 30, COLOR_THEME_SECONDARY1 or TITLE_BGCOLOR or 0)
+        lcd.drawText(5,5,screenTitle, COLOR_THEME_PRIMARY2 or MENU_TITLE_COLOR or 0)

📜 Review details

If neither of these constants exist and the radio.highRes is true, something is quite wrong. So if a runtime error was to occur (don't think it will... probably returns 0 hence why things were black), this is actually good IMO as it will bring this to our attention that something has changed.

@haslinghuis haslinghuis added this to the 1.8 milestone Dec 9, 2025
@haslinghuis
Copy link
Member

@coderabbitai check #535 (comment) as this can be approved.

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

@pfeerick, your reasoning makes sense. If both constants are undefined in a high-resolution context, it would indeed indicate a deeper system issue that should be surfaced rather than masked with a silent fallback. This fail-fast approach is reasonable for catching unexpected environment changes.

@haslinghuis, understood. The PR properly addresses the deprecated EdgeTX color constants issue with tested changes across multiple devices. Approving now.

✅ Actions performed

Comments resolved.

@haslinghuis haslinghuis merged commit c93054d into betaflight:master Dec 10, 2025
2 checks passed
@pfeerick pfeerick deleted the pfeerick/edgetx-constant-updates branch December 10, 2025 21:55
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.

bug(ui): glitches with EdgeTX nightlies, pending 2.11.4 and 2.12.0-RC1 releases

2 participants