Skip to content

feat(radio): allow disabling USB charge while the radio is running (on compatible hardware)#7564

Open
3djc wants to merge 2 commits into
mainfrom
3djc/usb-charge-control-main
Open

feat(radio): allow disabling USB charge while the radio is running (on compatible hardware)#7564
3djc wants to merge 2 commits into
mainfrom
3djc/usb-charge-control-main

Conversation

@3djc

@3djc 3djc commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes

Some users have reported issues when using sims on laptops when radio batteries are not fully charged, especially on newer radio can charge quite fast from USB port.

This adds a setting to prevent the radio from charging when USB mode are used (SD/JOY/VCP)

Capture d’écran 2026-07-16 à 09 37 26

Default charge is on, like on this picture, to behave like existing radio, turning it off will disable charge.

This is currently available only on TX15 and TX16SMK3

Test conducted by RM have shown with a PD charger
Unplugged 0.0w
Plugged with charging on 11.6w
Plugged with charging off 2.4w

When radio is off, charging occurs normally, whatever the setting is.

Summary by CodeRabbit

  • New Features
    • Added a USB charging control option for RadioMaster TX15 and TX16SMK3 radios.
    • Users can disable charging while USB is connected in SD card, Joystick, or VCP mode.
    • The preference is saved and restored automatically across connections and configuration transfers.
  • User Interface
    • Added the USB charging option to radio and Companion setup screens.
    • Added the new setting label across supported interface languages.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a persisted USB charging-disable setting for TX15 and TX16SMK3 radios, with firmware GPIO control, radio and Companion UI options, YAML serialization, build flags, simulator support, and translation strings.

Changes

USB charge control

Layer / File(s) Summary
Persisted USB charge setting
companion/src/firmwares/..., radio/src/datastructs_private.h, radio/src/storage/yaml/*
Adds usbChargeDisabled to general and radio settings, serializes it through YAML, and updates TX15/TX16SMK3 radio-data schemas.
Firmware USB charging control
radio/src/targets/*, radio/src/boards/rm-h750/*, radio/src/main.cpp, radio/src/gui/colorlcd/radio/radio_setup.cpp, radio/src/datastructs_private.h
Enables charge-control compilation, drives UCHARGER_EN_GPIO during USB connection changes, updates charging detection, and adds a radio setup toggle.
Companion settings UI
companion/src/generaledit/*
Adds and gates the USB charge checkbox for TX16SMK3 and TX15 radios, persists changes, and repositions related layout elements.
Translation strings
radio/src/translations/*
Adds the USB_CHARGE translation entry and corresponding language macros.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RadioSetup
  participant g_eeGeneral
  participant handleUsbConnection
  participant usbChargerEnableCharge
  participant UCHARGER_EN_GPIO

  RadioSetup->>g_eeGeneral: Store usbChargeDisabled
  handleUsbConnection->>g_eeGeneral: Read usbChargeDisabled
  handleUsbConnection->>usbChargerEnableCharge: Apply charge setting
  usbChargerEnableCharge->>UCHARGER_EN_GPIO: Set or clear control pin
  handleUsbConnection->>usbChargerEnableCharge: Enable charging after unplug
Loading

Suggested labels: translation, UX-UI

🚥 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
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 summarizes the main change: adding support to disable USB charging while the radio runs.
Description check ✅ Passed The description includes a clear summary of changes and key behavioral details, matching the repository template well enough.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 3djc/usb-charge-control-main

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.

@3djc

3djc commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@pfeerick https://github.com/EdgeTX/edgetx/tree/3djc/usb-charge-control is 2.12 ready for backport

@3djc 3djc added backport/2.12 To be backported to a 2.12 release also. enhancement ✨ New feature or request labels Jul 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (2)
companion/src/generaledit/generalsetup.ui (1)

908-921: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider capitalizing "Charge" for consistency.

Other settings in this section use Title Case (e.g., "USB Mode", "Jack Mode", "Hats Mode"). Consider capitalizing "Charge" to maintain visual consistency across the UI panel.

💡 Proposed capitalization fix
      <widget class="QLabel" name="usbChargeLabel">
       <property name="text">
-       <string>USB SD/Joystick/VCP charge</string>
+       <string>USB SD/Joystick/VCP Charge</string>
       </property>
      </widget>
🤖 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 `@companion/src/generaledit/generalsetup.ui` around lines 908 - 921, Update the
usbChargeLabel text in the general setup UI from “USB SD/Joystick/VCP charge” to
use Title Case, “USB SD/Joystick/VCP Charge,” matching the neighboring setting
labels.
radio/src/main.cpp (1)

211-230: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optionally apply the charger setting dynamically.

Currently, the UCHARGER_EN_GPIO state is updated only when the USB mode first starts. If a user changes the "USB SD/Joystick/VCP charge" setting in the Radio Setup menu while already connected in Joystick or VCP mode, the hardware state won't update until the USB is replugged.

You can move the GPIO update logic out of the !usbStarted() block so it runs continuously while USB is active, making the UI setting responsive in real-time.

💡 Proposed refactor to dynamically apply the setting

Remove the GPIO block from its current location inside if (!_usbDisabled && !usbStarted() && usbPlugged()) { ... } and place it immediately after, like this:

-      if (g_eeGeneral.usbChargeDisabled) {
-        gpio_set(UCHARGER_EN_GPIO);
-      } else {
-        gpio_clear(UCHARGER_EN_GPIO);
-      }
     }
   }
+
+#if defined(USB_CHARGE_CONTROL)
+  // Continuously apply the charger-enable state so changes in Radio Setup
+  // take effect immediately without requiring a replug.
+  if (usbStarted() && usbPlugged()) {
+    if (g_eeGeneral.usbChargeDisabled) {
+      gpio_set(UCHARGER_EN_GPIO);
+    } else {
+      gpio_clear(UCHARGER_EN_GPIO);
+    }
+  }
+#endif
 
   if (usbStarted() && !usbPlugged()) {
🤖 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 `@radio/src/main.cpp` around lines 211 - 230, Move the UCHARGER_EN_GPIO update
logic from the USB-start initialization block to the active-USB path after that
block, so it executes continuously while USB is connected. Preserve the existing
usbChargeDisabled-to-gpio_set/gpio_clear mapping and keep the unplug cleanup in
the usbStop path unchanged.
🤖 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 `@radio/src/datastructs.h`:
- Around line 82-86: Update the USB_CHARGE_CONTROL branch’s CHKSIZE assertion
for RadioData to expect 1182 bytes, matching the non-USB branch; do not add a
byte for usbChargeDisabled.

In `@radio/src/translations/i18n/cn.h`:
- Line 987: Replace the English TR_USB_CHARGE value with the approved Chinese
translation in radio/src/translations/i18n/cn.h at lines 987-987 and with the
approved Czech translation in radio/src/translations/i18n/cz.h at lines 985-985,
preserving the existing translation macro structure.

In `@radio/src/translations/i18n/da.h`:
- Line 992: Localize the TR_USB_CHARGE label in radio/src/translations/i18n/da.h
lines 992-992 to “USB SD/Joystick/VCP-opladning” and in
radio/src/translations/i18n/de.h lines 986-986 to “USB-SD/Joystick/VCP-Laden”,
replacing the English fallback in both headers.

In `@radio/src/translations/i18n/es.h`:
- Line 981: Localize the TR_USB_CHARGE label in all affected headers: replace
the English text in radio/src/translations/i18n/es.h lines 981-981 with Spanish,
radio/src/translations/i18n/fi.h lines 981-981 with Finnish, and
radio/src/translations/i18n/tw.h lines 984-984 with Traditional Chinese.

In `@radio/src/translations/i18n/fr.h`:
- Line 985: Replace the English TR_USB_CHARGE value with the approved localized
translations in radio/src/translations/i18n/fr.h:985-985,
radio/src/translations/i18n/he.h:990-990, and
radio/src/translations/i18n/it.h:987-987; keep the key unchanged.

In `@radio/src/translations/i18n/jp.h`:
- Line 986: Update TR_USB_CHARGE in radio/src/translations/i18n/jp.h:986-986,
radio/src/translations/i18n/ko.h:1030-1030, and
radio/src/translations/i18n/nl.h:983-983 with appropriate Japanese, Korean, and
Dutch labels respectively, or add an explicit note in each file if retaining the
English text is intentional.

In `@radio/src/translations/i18n/pl.h`:
- Line 980: Update the TR_USB_CHARGE definition in pl.h to use the appropriate
Polish translation instead of the current English label, while preserving the
existing translation key and formatting.

In `@radio/src/translations/i18n/pt.h`:
- Line 988: Translate the TR_USB_CHARGE label in
radio/src/translations/i18n/pt.h:988-988,
radio/src/translations/i18n/ru.h:989-989, and
radio/src/translations/i18n/se.h:988-988, replacing the English text with the
appropriate locale-specific translations while preserving the existing macro
name and format.

In `@radio/src/translations/i18n/ua.h`:
- Line 988: Update the TR_USB_CHARGE translation in the Ukrainian header from
English to an approved Ukrainian label, while preserving the technical mode
names USB, SD, Joystick, and VCP unchanged.

---

Nitpick comments:
In `@companion/src/generaledit/generalsetup.ui`:
- Around line 908-921: Update the usbChargeLabel text in the general setup UI
from “USB SD/Joystick/VCP charge” to use Title Case, “USB SD/Joystick/VCP
Charge,” matching the neighboring setting labels.

In `@radio/src/main.cpp`:
- Around line 211-230: Move the UCHARGER_EN_GPIO update logic from the USB-start
initialization block to the active-USB path after that block, so it executes
continuously while USB is connected. Preserve the existing
usbChargeDisabled-to-gpio_set/gpio_clear mapping and keep the unplug cleanup in
the usbStop path unchanged.
🪄 Autofix (Beta)

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: 69fc4b60-ffab-47bd-af95-5511e6812de1

📥 Commits

Reviewing files that changed from the base of the PR and between 640fc18 and 66d175b.

📒 Files selected for processing (35)
  • companion/src/firmwares/edgetx/yaml_generalsettings.cpp
  • companion/src/firmwares/generalsettings.h
  • companion/src/generaledit/generalsetup.cpp
  • companion/src/generaledit/generalsetup.h
  • companion/src/generaledit/generalsetup.ui
  • radio/src/boards/rm-h750/usb_charger_driver.cpp
  • radio/src/datastructs.h
  • radio/src/datastructs_private.h
  • radio/src/gui/colorlcd/radio/radio_setup.cpp
  • radio/src/main.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/targets/tx15/CMakeLists.txt
  • radio/src/targets/tx16smk3/CMakeLists.txt
  • radio/src/translations/i18n/cn.h
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/i18n/da.h
  • radio/src/translations/i18n/de.h
  • radio/src/translations/i18n/en.h
  • radio/src/translations/i18n/es.h
  • radio/src/translations/i18n/fi.h
  • radio/src/translations/i18n/fr.h
  • radio/src/translations/i18n/he.h
  • radio/src/translations/i18n/it.h
  • radio/src/translations/i18n/jp.h
  • radio/src/translations/i18n/ko.h
  • radio/src/translations/i18n/nl.h
  • radio/src/translations/i18n/pl.h
  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/se.h
  • radio/src/translations/i18n/tw.h
  • radio/src/translations/i18n/ua.h
  • radio/src/translations/sim_string_list.h
  • radio/src/translations/string_list.h

Comment thread radio/src/datastructs.h Outdated
Comment on lines +82 to +86
#if defined(USB_CHARGE_CONTROL)
CHKSIZE(RadioData, 1183); // +1 byte for usbChargeDisabled
#else
CHKSIZE(RadioData, 1182);
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Keep the RadioData size at 1182 bytes.

usbChargeDisabled:1 fills the remaining bit after the preceding 7-bit allocation unit; it should not add a byte. The 1183 assertion will fail for USB-charge-control builds unless the target compiler lays out these fields differently.

🐛 Proposed fix
-  `#if` defined(USB_CHARGE_CONTROL)
-    CHKSIZE(RadioData, 1183);  // +1 byte for usbChargeDisabled
-  `#else`
-    CHKSIZE(RadioData, 1182);
-  `#endif`
+  CHKSIZE(RadioData, 1182);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#if defined(USB_CHARGE_CONTROL)
CHKSIZE(RadioData, 1183); // +1 byte for usbChargeDisabled
#else
CHKSIZE(RadioData, 1182);
#endif
CHKSIZE(RadioData, 1182);
🤖 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 `@radio/src/datastructs.h` around lines 82 - 86, Update the USB_CHARGE_CONTROL
branch’s CHKSIZE assertion for RadioData to expect 1182 bytes, matching the
non-USB branch; do not add a byte for usbChargeDisabled.

#define TR_SENSOR "传感器"
#define TR_COUNTRY_CODE "国别码"
#define TR_USBMODE "USB模式"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

Localize TR_USB_CHARGE in every affected language header.

The new setting currently displays English text in both localized UIs:

  • radio/src/translations/i18n/cn.h#L987-L987: replace the English value with approved Chinese text.
  • radio/src/translations/i18n/cz.h#L985-L985: replace the English value with approved Czech text.
📍 Affects 2 files
  • radio/src/translations/i18n/cn.h#L987-L987 (this comment)
  • radio/src/translations/i18n/cz.h#L985-L985
🤖 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 `@radio/src/translations/i18n/cn.h` at line 987, Replace the English
TR_USB_CHARGE value with the approved Chinese translation in
radio/src/translations/i18n/cn.h at lines 987-987 and with the approved Czech
translation in radio/src/translations/i18n/cz.h at lines 985-985, preserving the
existing translation macro structure.

#define TR_SENSOR "SENSOR"
#define TR_COUNTRY_CODE "Lande kode"
#define TR_USBMODE "USB tilstand"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

Localize the new setting label in non-English headers. Both files currently show the English fallback to users.

  • radio/src/translations/i18n/da.h#L992-L992: use USB SD/Joystick/VCP-opladning.
  • radio/src/translations/i18n/de.h#L986-L986: use USB-SD/Joystick/VCP-Laden.
📍 Affects 2 files
  • radio/src/translations/i18n/da.h#L992-L992 (this comment)
  • radio/src/translations/i18n/de.h#L986-L986
🤖 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 `@radio/src/translations/i18n/da.h` at line 992, Localize the TR_USB_CHARGE
label in radio/src/translations/i18n/da.h lines 992-992 to “USB
SD/Joystick/VCP-opladning” and in radio/src/translations/i18n/de.h lines 986-986
to “USB-SD/Joystick/VCP-Laden”, replacing the English fallback in both headers.

#define TR_SENSOR "SENSOR"
#define TR_COUNTRY_CODE "Código país"
#define TR_USBMODE "Modo USB"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

Localize TR_USB_CHARGE in every affected language header.

The new setting label currently remains English in all three localized headers:

  • radio/src/translations/i18n/es.h#L981-L981: add Spanish text.
  • radio/src/translations/i18n/fi.h#L981-L981: add Finnish text.
  • radio/src/translations/i18n/tw.h#L984-L984: add Traditional Chinese text.
📍 Affects 3 files
  • radio/src/translations/i18n/es.h#L981-L981 (this comment)
  • radio/src/translations/i18n/fi.h#L981-L981
  • radio/src/translations/i18n/tw.h#L984-L984
🤖 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 `@radio/src/translations/i18n/es.h` at line 981, Localize the TR_USB_CHARGE
label in all affected headers: replace the English text in
radio/src/translations/i18n/es.h lines 981-981 with Spanish,
radio/src/translations/i18n/fi.h lines 981-981 with Finnish, and
radio/src/translations/i18n/tw.h lines 984-984 with Traditional Chinese.

#define TR_SENSOR "CAPTEUR"
#define TR_COUNTRY_CODE TR("Zone géo.", "Zone géographique")
#define TR_USBMODE "Mode USB"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

Provide localized values for TR_USB_CHARGE.

The new key is currently English in all three locale headers, so the Radio Settings option remains untranslated for French, Hebrew, and Italian users.

  • radio/src/translations/i18n/fr.h#L985-L985: replace the English value with the approved French translation.
  • radio/src/translations/i18n/he.h#L990-L990: replace the English value with the approved Hebrew translation.
  • radio/src/translations/i18n/it.h#L987-L987: replace the English value with the approved Italian translation.
📍 Affects 3 files
  • radio/src/translations/i18n/fr.h#L985-L985 (this comment)
  • radio/src/translations/i18n/he.h#L990-L990
  • radio/src/translations/i18n/it.h#L987-L987
🤖 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 `@radio/src/translations/i18n/fr.h` at line 985, Replace the English
TR_USB_CHARGE value with the approved localized translations in
radio/src/translations/i18n/fr.h:985-985,
radio/src/translations/i18n/he.h:990-990, and
radio/src/translations/i18n/it.h:987-987; keep the key unchanged.

#define TR_SENSOR "センサー"
#define TR_COUNTRY_CODE "カントリーコード"
#define TR_USBMODE "USBモード"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

printf '\n== TR_USB_CHARGE occurrences ==\n'
rg -n 'TR_USB_CHARGE' radio/src/translations/i18n

printf '\n== Nearby lines in affected files ==\n'
for f in radio/src/translations/i18n/jp.h radio/src/translations/i18n/ko.h radio/src/translations/i18n/nl.h; do
  echo "--- $f"
  # show a small window around the matching line if present
  line=$(rg -n 'TR_USB_CHARGE' "$f" | head -n1 | cut -d: -f1 || true)
  if [ -n "${line:-}" ]; then
    start=$((line-3)); [ "$start" -lt 1 ] && start=1
    end=$((line+3))
    sed -n "${start},${end}p" "$f" | cat -n
  fi
done

printf '\n== File size hints ==\n'
wc -l radio/src/translations/i18n/jp.h radio/src/translations/i18n/ko.h radio/src/translations/i18n/nl.h

Repository: EdgeTX/edgetx

Length of output: 3686


Translate TR_USB_CHARGE in these locale files. jp.h, ko.h, and nl.h still show the English fallback here; add localized labels or leave a note if the English text is intentional.

📍 Affects 3 files
  • radio/src/translations/i18n/jp.h#L986-L986 (this comment)
  • radio/src/translations/i18n/ko.h#L1030-L1030
  • radio/src/translations/i18n/nl.h#L983-L983
🤖 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 `@radio/src/translations/i18n/jp.h` at line 986, Update TR_USB_CHARGE in
radio/src/translations/i18n/jp.h:986-986,
radio/src/translations/i18n/ko.h:1030-1030, and
radio/src/translations/i18n/nl.h:983-983 with appropriate Japanese, Korean, and
Dutch labels respectively, or add an explicit note in each file if retaining the
English text is intentional.

#define TR_SENSOR "SENSOR"
#define TR_COUNTRY_CODE "Kod regionu"
#define TR_USBMODE "Tryb USB"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

Add the Polish translation.

This new label is still English in pl.h, so Polish users will see an untranslated setting. For example:

Proposed fix
-#define TR_USB_CHARGE                 "USB SD/Joystick/VCP charge"
+#define TR_USB_CHARGE                 "Ładowanie USB SD/Dżojstika/VCP"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"
`#define` TR_USB_CHARGE "Ładowanie USB SD/Dżojstika/VCP"
🤖 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 `@radio/src/translations/i18n/pl.h` at line 980, Update the TR_USB_CHARGE
definition in pl.h to use the appropriate Polish translation instead of the
current English label, while preserving the existing translation key and
formatting.

#define TR_SENSOR "SENSOR"
#define TR_COUNTRY_CODE "Código pais"
#define TR_USBMODE "Modo USB"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

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

for f in radio/src/translations/i18n/pt.h radio/src/translations/i18n/ru.h radio/src/translations/i18n/se.h; do
  echo "===== $f ====="
  grep -n -C 2 'TR_USB_CHARGE' "$f" || true
  echo
done

echo "===== repository-wide TR_USB_CHARGE occurrences ====="
rg -n 'TR_USB_CHARGE' radio/src/translations/i18n || true

echo "===== nearby translation names in these files ====="
for f in radio/src/translations/i18n/pt.h radio/src/translations/i18n/ru.h radio/src/translations/i18n/se.h; do
  echo "--- $f ---"
  grep -n -E 'TR_USB_CHARGE|TR_USB_' "$f" | sed -n '1,30p'
done

Repository: EdgeTX/edgetx

Length of output: 4353


Translate TR_USB_CHARGE in the locale headers. The new label is still English in these translated files, so users will see untranslated UI text.

  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/se.h
📍 Affects 3 files
  • radio/src/translations/i18n/pt.h#L988-L988 (this comment)
  • radio/src/translations/i18n/ru.h#L989-L989
  • radio/src/translations/i18n/se.h#L988-L988
🤖 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 `@radio/src/translations/i18n/pt.h` at line 988, Translate the TR_USB_CHARGE
label in radio/src/translations/i18n/pt.h:988-988,
radio/src/translations/i18n/ru.h:989-989, and
radio/src/translations/i18n/se.h:988-988, replacing the English text with the
appropriate locale-specific translations while preserving the existing macro
name and format.

#define TR_SENSOR "СЕНСОР"
#define TR_COUNTRY_CODE "Код країни"
#define TR_USBMODE "Режим USB"
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Localize the Ukrainian label.

TR_USB_CHARGE is user-facing but remains in English in the Ukrainian header. Provide an approved Ukrainian translation while preserving the technical mode names.

Suggested fix
-#define TR_USB_CHARGE                 "USB SD/Joystick/VCP charge"
+#define TR_USB_CHARGE                 "Заряджання USB SD/Джойстик/VCP"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#define TR_USB_CHARGE "USB SD/Joystick/VCP charge"
`#define` TR_USB_CHARGE "Заряджання USB SD/Джойстик/VCP"
🤖 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 `@radio/src/translations/i18n/ua.h` at line 988, Update the TR_USB_CHARGE
translation in the Ukrainian header from English to an approved Ukrainian label,
while preserving the technical mode names USB, SD, Joystick, and VCP unchanged.

@pfeerick pfeerick changed the title feat(radio): allows users to disable USB charge while radio is running on radio with suitable hardware feat(radio): allow disabling USB charge while the radio is running on compatible hardware Jul 16, 2026
@pfeerick pfeerick added this to the 2.12.3 milestone Jul 16, 2026
@3djc
3djc force-pushed the 3djc/usb-charge-control-main branch from 66d175b to 6ac0799 Compare July 16, 2026 11:01

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@radio/src/translations/i18n/cn.h`:
- Around line 573-576: Update the translations for TR_KEY_LOCK_FMT,
TR_KEYS_LOCKED, TR_KEYS_LOCKED_FMT, TR_KEYS_UNLOCKED, and TR_USB_CHARGE in cn.h
to approved Chinese UI text. Preserve both %s placeholders and their ordering in
the two formatted strings, and remove all remaining English text for these keys.
🪄 Autofix (Beta)

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: 201ffab9-4987-4aea-87a1-273196f7eb51

📥 Commits

Reviewing files that changed from the base of the PR and between 66d175b and 6ac0799.

📒 Files selected for processing (35)
  • companion/src/firmwares/edgetx/yaml_generalsettings.cpp
  • companion/src/firmwares/generalsettings.h
  • companion/src/generaledit/generalsetup.cpp
  • companion/src/generaledit/generalsetup.h
  • companion/src/generaledit/generalsetup.ui
  • radio/src/boards/rm-h750/usb_charger_driver.cpp
  • radio/src/datastructs.h
  • radio/src/datastructs_private.h
  • radio/src/gui/colorlcd/radio/radio_setup.cpp
  • radio/src/main.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/targets/tx15/CMakeLists.txt
  • radio/src/targets/tx16smk3/CMakeLists.txt
  • radio/src/translations/i18n/cn.h
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/i18n/da.h
  • radio/src/translations/i18n/de.h
  • radio/src/translations/i18n/en.h
  • radio/src/translations/i18n/es.h
  • radio/src/translations/i18n/fi.h
  • radio/src/translations/i18n/fr.h
  • radio/src/translations/i18n/he.h
  • radio/src/translations/i18n/it.h
  • radio/src/translations/i18n/jp.h
  • radio/src/translations/i18n/ko.h
  • radio/src/translations/i18n/nl.h
  • radio/src/translations/i18n/pl.h
  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/se.h
  • radio/src/translations/i18n/tw.h
  • radio/src/translations/i18n/ua.h
  • radio/src/translations/sim_string_list.h
  • radio/src/translations/string_list.h
🚧 Files skipped from review as they are similar to previous changes (32)
  • companion/src/generaledit/generalsetup.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/pl.h
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/sim_string_list.h
  • radio/src/translations/i18n/se.h
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/translations/i18n/fr.h
  • radio/src/translations/i18n/ua.h
  • radio/src/translations/string_list.h
  • radio/src/translations/i18n/de.h
  • radio/src/translations/i18n/tw.h
  • radio/src/translations/i18n/it.h
  • radio/src/translations/i18n/es.h
  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/jp.h
  • radio/src/translations/i18n/nl.h
  • radio/src/datastructs_private.h
  • radio/src/translations/i18n/da.h
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/datastructs.h
  • radio/src/translations/i18n/en.h
  • radio/src/gui/colorlcd/radio/radio_setup.cpp
  • companion/src/firmwares/generalsettings.h
  • radio/src/translations/i18n/he.h
  • radio/src/translations/i18n/ko.h
  • radio/src/targets/tx16smk3/CMakeLists.txt
  • radio/src/translations/i18n/fi.h
  • companion/src/firmwares/edgetx/yaml_generalsettings.cpp
  • radio/src/boards/rm-h750/usb_charger_driver.cpp
  • radio/src/main.cpp
  • companion/src/generaledit/generalsetup.ui

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

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 `@radio/src/translations/i18n/cn.h`:
- Around line 573-576: Update the translations for TR_KEY_LOCK_FMT,
TR_KEYS_LOCKED, TR_KEYS_LOCKED_FMT, TR_KEYS_UNLOCKED, and TR_USB_CHARGE in cn.h
to approved Chinese UI text. Preserve both %s placeholders and their ordering in
the two formatted strings, and remove all remaining English text for these keys.
🪄 Autofix (Beta)

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: 201ffab9-4987-4aea-87a1-273196f7eb51

📥 Commits

Reviewing files that changed from the base of the PR and between 66d175b and 6ac0799.

📒 Files selected for processing (35)
  • companion/src/firmwares/edgetx/yaml_generalsettings.cpp
  • companion/src/firmwares/generalsettings.h
  • companion/src/generaledit/generalsetup.cpp
  • companion/src/generaledit/generalsetup.h
  • companion/src/generaledit/generalsetup.ui
  • radio/src/boards/rm-h750/usb_charger_driver.cpp
  • radio/src/datastructs.h
  • radio/src/datastructs_private.h
  • radio/src/gui/colorlcd/radio/radio_setup.cpp
  • radio/src/main.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/targets/tx15/CMakeLists.txt
  • radio/src/targets/tx16smk3/CMakeLists.txt
  • radio/src/translations/i18n/cn.h
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/i18n/da.h
  • radio/src/translations/i18n/de.h
  • radio/src/translations/i18n/en.h
  • radio/src/translations/i18n/es.h
  • radio/src/translations/i18n/fi.h
  • radio/src/translations/i18n/fr.h
  • radio/src/translations/i18n/he.h
  • radio/src/translations/i18n/it.h
  • radio/src/translations/i18n/jp.h
  • radio/src/translations/i18n/ko.h
  • radio/src/translations/i18n/nl.h
  • radio/src/translations/i18n/pl.h
  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/se.h
  • radio/src/translations/i18n/tw.h
  • radio/src/translations/i18n/ua.h
  • radio/src/translations/sim_string_list.h
  • radio/src/translations/string_list.h
🚧 Files skipped from review as they are similar to previous changes (32)
  • companion/src/generaledit/generalsetup.h
  • radio/src/translations/i18n/ru.h
  • radio/src/translations/i18n/pl.h
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/sim_string_list.h
  • radio/src/translations/i18n/se.h
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/translations/i18n/fr.h
  • radio/src/translations/i18n/ua.h
  • radio/src/translations/string_list.h
  • radio/src/translations/i18n/de.h
  • radio/src/translations/i18n/tw.h
  • radio/src/translations/i18n/it.h
  • radio/src/translations/i18n/es.h
  • radio/src/translations/i18n/pt.h
  • radio/src/translations/i18n/jp.h
  • radio/src/translations/i18n/nl.h
  • radio/src/datastructs_private.h
  • radio/src/translations/i18n/da.h
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/datastructs.h
  • radio/src/translations/i18n/en.h
  • radio/src/gui/colorlcd/radio/radio_setup.cpp
  • companion/src/firmwares/generalsettings.h
  • radio/src/translations/i18n/he.h
  • radio/src/translations/i18n/ko.h
  • radio/src/targets/tx16smk3/CMakeLists.txt
  • radio/src/translations/i18n/fi.h
  • companion/src/firmwares/edgetx/yaml_generalsettings.cpp
  • radio/src/boards/rm-h750/usb_charger_driver.cpp
  • radio/src/main.cpp
  • companion/src/generaledit/generalsetup.ui
🛑 Comments failed to post (1)
radio/src/translations/i18n/cn.h (1)

573-576: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Localize the new Chinese UI strings.

TR_KEY_LOCK_FMT, TR_KEYS_LOCKED, TR_KEYS_LOCKED_FMT, TR_KEYS_UNLOCKED, and TR_USB_CHARGE still contain English text in cn.h. Replace them with approved Chinese translations while preserving the %s placeholders in TR_KEY_LOCK_FMT and TR_KEYS_LOCKED_FMT. The TR_USB_CHARGE portion repeats the prior review finding.

Also applies to: 991-991

🤖 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 `@radio/src/translations/i18n/cn.h` around lines 573 - 576, Update the
translations for TR_KEY_LOCK_FMT, TR_KEYS_LOCKED, TR_KEYS_LOCKED_FMT,
TR_KEYS_UNLOCKED, and TR_USB_CHARGE in cn.h to approved Chinese UI text.
Preserve both %s placeholders and their ordering in the two formatted strings,
and remove all remaining English text for these keys.

@pfeerick pfeerick changed the title feat(radio): allow disabling USB charge while the radio is running on compatible hardware feat(radio): allow disabling USB charge while the radio is running (on compatible hardware) Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants