Skip to content

feat(firmware): add a special function to trigger key lock#7565

Open
philmoz wants to merge 3 commits into
mainfrom
philmoz/key-lock-sf
Open

feat(firmware): add a special function to trigger key lock#7565
philmoz wants to merge 3 commits into
mainfrom
philmoz/key-lock-sf

Conversation

@philmoz

@philmoz philmoz commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Use case : I want to automatically lock the radio keys when I arm the model to prevent accidental key presses

The key lock feature is a fantastic enhancement (thanks @3djc); but still requires the user to manually activate the key combo.

This PR adds a new special/global function to control the key lock feature.
The 'No Keys' special function works like this:

  • when the function goes active the keys will be locked (if not already locked)
  • when the function goes inactive the keys will be unlocked (it not already unlocked)
  • when the function state does not change nothing happen (even if the key combo is used)

The key combo is always active so it is not possible to lock oneself out of the radio.
If the keys are unlocked after being locked by the special function, the special function will not re-lock them until its state changes.

This PR also make the popup messages more meaningful and fit better on B&W screens.
screenshot_gx12_26-07-17_09-40-34
screenshot_tx15_26-07-17_09-39-50

Summary by CodeRabbit

  • New Features

    • Added a configurable “Disable Keys” special function (only when key-lock hardware support is available).
    • Implemented UI-driven evaluation so the key-lock state can follow custom-function switches.
    • Added YAML support for the “DISABLE_KEYS” function name.
  • UI Improvements

    • Updated labels to “No Keys” and revised the keys-locked warning to include an unlock hint.
    • Improved warning popups to show the main message plus supplementary unlock information across supported screen types.

@philmoz philmoz added this to the 3.0 milestone Jul 16, 2026
@philmoz philmoz added enhancement ✨ New feature or request UX-UI Related to user experience (UX) or user interface (UI) behaviour labels Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch philmoz/key-lock-sf

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.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 38eb4194-e9f8-45eb-b288-da041d3a75df

📥 Commits

Reviewing files that changed from the base of the PR and between f9c7510 and 04b4f27.

📒 Files selected for processing (1)
  • radio/src/gui/colorlcd/model/special_functions.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • radio/src/gui/colorlcd/model/special_functions.cpp

📝 Walkthrough

Walkthrough

Adds a conditionally compiled FUNC_DISABLE_KEYS custom function with firmware evaluation, key-lock synchronization, YAML and translation support, popup information handling, generated ordering updates, and Color LCD special-function page refactoring.

Changes

Disable Keys contracts and serialization

Layer / File(s) Summary
Function identifiers and generated registration
companion/src/firmwares/*, radio/src/dataconstants.h, radio/src/cfn_sort.cpp, tools/cfn_sorter.*
Adds Disable Keys identifiers, labels, conditional sorting entries, and generated-table support.
YAML persistence
companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp, radio/src/storage/yaml/*
Maps FUNC_DISABLE_KEYS to DISABLE_KEYS across YAML tables and updates the YAML build dependency.
Translations
radio/src/translations/i18n/*, radio/src/translations/string_list.h, radio/src/translations/sim_string_list.h
Adds the Disable Keys label and updates key-lock message formatting.

Key-lock runtime flow

Layer / File(s) Summary
UI-function evaluation
radio/src/functions.cpp, radio/src/edgetx.*
Separates UI custom-function evaluation, tracks UI-active functions, evaluates Disable Keys periodically, and synchronizes key-lock state.
Key-lock APIs and availability
radio/src/keys.*, radio/src/gui/gui_common.cpp, radio/src/lua/api_general.cpp
Adds setKeyLockedState, gates key-lock behavior on lock-key definitions, and conditionally exposes availability and Lua constants.
Lock notification popup
radio/src/main.cpp, radio/src/gui/common/stdlcd/popups_common.*
Passes auxiliary unlock information through wait popups and maintains it during notifications.

Color LCD special-function page

Layer / File(s) Summary
FunctionEditPage implementation
radio/src/gui/colorlcd/model/special_functions.*
Moves FunctionEditPage implementation into the source file, adds inline widget helpers, and retains parameter and lifecycle behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RadioTick
  participant evalUIFunctions
  participant KeyLock
  participant Popup
  RadioTick->>evalUIFunctions: Evaluate radio and model UI functions
  evalUIFunctions->>KeyLock: setKeyLockedState(active)
  KeyLock-->>Popup: Emit lock toggle event
  Popup->>Popup: Display lock message and unlock information
Loading

Possibly related PRs

Suggested labels: translation, B&W

🚥 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 accurately summarizes the main change: adding a special function to control key lock.
Description check ✅ Passed The description clearly explains the feature and behavior, though it skips the template's Fixes # line and Summary of changes heading.
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.
✨ 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 philmoz/key-lock-sf

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.

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

🤖 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/functions.cpp`:
- Around line 198-209: Update the aggregate active-function processing around
CFN_FUNC(cfn) and setKeyLockedState: compute the previous and new aggregate
states once across global and model functions, then synchronize the lock from
that transition even when a No Keys row is disabled, cleared, or replaced.
Remove per-row comparisons that depend on iteration order, while preserving
newActiveFunctions updates for FUNCTION_DISABLE_KEYS.

In `@radio/src/gui/common/stdlcd/popups_common.cpp`:
- Around line 253-257: Update POPUP_WAIT to reset warningInfoFlags when
installing new wait-popup information, alongside warningInfoText and
warningInfoLength, so the popup does not inherit styling from the previous
popup.

In `@radio/src/keys.cpp`:
- Around line 202-207: Synchronize cross-task access to s_keys_locked and
s_keys_lock_notify between setKeyLockedState() and consumeKeysLockToggleEvent().
Use the project’s existing synchronization mechanism consistently for both reads
and writes, or marshal setKeyLockedState() updates onto the key task, ensuring
key-lock toggle notifications cannot be lost.

In `@radio/src/translations/i18n/fi.h`:
- Line 244: Translate the new function label and key-lock unlock message in all
affected locale files: radio/src/translations/i18n/fi.h at 244-244 and 576-576,
radio/src/translations/i18n/fr.h at 247-247 and 580-580, and
radio/src/translations/i18n/he.h at 247-247 and 580-580. Use Finnish, French,
and Hebrew text respectively, and verify RTL rendering of the unlock-message
placeholders in he.h.

In `@radio/src/translations/i18n/it.h`:
- Line 244: Localize the key-lock UI strings in all affected catalog entries: in
radio/src/translations/i18n/it.h lines 244 and 577, provide Italian text for
TR_SF_DISABLE_KEYS and both popup variants; in radio/src/translations/i18n/jp.h
lines 244 and 576, provide Japanese text for TR_SF_DISABLE_KEYS and both popup
variants. Replace only the remaining English strings while preserving the
existing translation keys and formatting.

In `@radio/src/translations/i18n/pt.h`:
- Line 245: Translate the new key-lock function label and lock popup strings in
radio/src/translations/i18n/pt.h at lines 245 and 577,
radio/src/translations/i18n/ru.h at lines 247 and 579, and
radio/src/translations/i18n/se.h at lines 247 and 579. Replace the English text
with accurate Portuguese, Russian, and Swedish translations while preserving all
%s+%s placeholders and the existing TR_BW_COL(...) layout.

In `@tools/cfn_sorter.cpp`:
- Line 131: Update the FUNC_DISABLE_KEYS guard entry in the cfn sorter
definitions to include CFN_ONLY alongside the existing hardware-key condition,
then regenerate radio/src/cfn_sort.cpp so CFN-only builds emit the same function
consistently.
🪄 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: 56437c16-5f46-49f7-b90d-8b671b8cb5d8

📥 Commits

Reviewing files that changed from the base of the PR and between e184cf3 and 432376b.

📒 Files selected for processing (56)
  • companion/src/firmwares/customfunctiondata.cpp
  • companion/src/firmwares/customfunctiondata.h
  • companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
  • radio/src/cfn_sort.cpp
  • radio/src/dataconstants.h
  • radio/src/edgetx.h
  • radio/src/functions.cpp
  • radio/src/gui/colorlcd/model/special_functions.cpp
  • radio/src/gui/colorlcd/model/special_functions.h
  • radio/src/gui/common/stdlcd/popups_common.cpp
  • radio/src/gui/common/stdlcd/popups_common.h
  • radio/src/gui/gui_common.cpp
  • radio/src/keys.cpp
  • radio/src/keys.h
  • radio/src/lua/api_general.cpp
  • radio/src/main.cpp
  • radio/src/storage/yaml/CMakeLists.txt
  • radio/src/storage/yaml/yaml_datastructs_128x64.cpp
  • radio/src/storage/yaml/yaml_datastructs_c14.cpp
  • radio/src/storage/yaml/yaml_datastructs_f16.cpp
  • radio/src/storage/yaml/yaml_datastructs_gx12.cpp
  • radio/src/storage/yaml/yaml_datastructs_st16.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15pro.cpp
  • radio/src/storage/yaml/yaml_datastructs_t20.cpp
  • radio/src/storage/yaml/yaml_datastructs_t22.cpp
  • radio/src/storage/yaml/yaml_datastructs_tpro.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/storage/yaml/yaml_datastructs_x10.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9d.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9e.cpp
  • radio/src/targets/simu/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
  • tools/cfn_sorter.cpp
💤 Files with no reviewable changes (1)
  • radio/src/gui/colorlcd/model/special_functions.h

Comment thread radio/src/functions.cpp Outdated
Comment thread radio/src/gui/common/stdlcd/popups_common.cpp
Comment thread radio/src/keys.cpp
Comment on lines +202 to +207
void setKeyLockedState(bool state)
{
if (g_eeGeneral.keyLockEnabled && s_keys_locked != state) {
s_keys_locked = state;
s_keys_lock_notify = true;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== File outline ==\n'
ast-grep outline radio/src/keys.cpp --view expanded || true

printf '\n== Relevant symbols ==\n'
rg -n "setKeyLockedState|consumeKeysLockToggleEvent|s_keys_locked|s_keys_lock_notify|evalFunctions|keyLockEnabled" radio/src/keys.cpp radio/src -S

printf '\n== keys.cpp excerpt ==\n'
sed -n '1,320p' radio/src/keys.cpp

printf '\n== threading / task context search ==\n'
rg -n "mixer thread|Mixer|threaded|key poll|polling|consumeKeysLockToggleEvent|evalFunctions\(" radio/src -S

Repository: EdgeTX/edgetx

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== functions.cpp around evalFunctions ==\n'
sed -n '150,240p' radio/src/functions.cpp

printf '\n== main.cpp around consumeKeysLockToggleEvent ==\n'
sed -n '260,320p' radio/src/main.cpp

printf '\n== mixer task scheduling ==\n'
sed -n '100,230p' radio/src/tasks/mixer_task.cpp

printf '\n== keys.cpp lock state area ==\n'
sed -n '180,220p' radio/src/keys.cpp

printf '\n== any synchronization around key lock state ==\n'
rg -n "critical|mutex|lock|atomic|s_keys_lock|consumeKeysLockToggleEvent|setKeyLockedState" radio/src -S | sed -n '1,200p'

Repository: EdgeTX/edgetx

Length of output: 27066


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== keys.cpp around keysPollingCycle and lock toggling ==\n'
sed -n '500,575p' radio/src/keys.cpp

printf '\n== call sites of keysPollingCycle ==\n'
rg -n "keysPollingCycle\(" radio/src -S

printf '\n== call sites of checkKeysLock ==\n'
rg -n "checkKeysLock\(" radio/src -S

Repository: EdgeTX/edgetx

Length of output: 3258


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== edgetx.cpp around the main loop ==\n'
sed -n '180,260p' radio/src/edgetx.cpp

printf '\n== task definitions / scheduler references ==\n'
rg -n "task_running\(|createTask|xTask|Thread|mixerTask\(|mainTask|guiTask|checkKeysLock\(" radio/src -S

printf '\n== mixer_task.cpp top and task startup refs ==\n'
sed -n '1,120p' radio/src/tasks/mixer_task.cpp

Repository: EdgeTX/edgetx

Length of output: 47386


Avoid sharing key-lock flags across tasks unsafely. setKeyLockedState() runs from the mixer task, while consumeKeysLockToggleEvent() is read on the main task. Protect s_keys_locked and s_keys_lock_notify with the same synchronization or marshal the update onto the key task to avoid lost toggles.

🤖 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/keys.cpp` around lines 202 - 207, Synchronize cross-task access to
s_keys_locked and s_keys_lock_notify between setKeyLockedState() and
consumeKeysLockToggleEvent(). Use the project’s existing synchronization
mechanism consistently for both reads and writes, or marshal setKeyLockedState()
updates onto the key task, ensuring key-lock toggle notifications cannot be
lost.

#define TR_SF_SCREENSHOT "Screenshot"
#define TR_SF_RACING_MODE "RacingMode"
#define TR_SF_DISABLE_TOUCH "No Touch"
#define TR_SF_DISABLE_KEYS "No Keys"

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

Translate the new feature strings in every affected locale.

The new function label and key-lock popup remain English across all three locale files, leaving users with untranslated UI.

  • radio/src/translations/i18n/fi.h#L244-L244,576-576: add Finnish translations for the function label and unlock message.
  • radio/src/translations/i18n/fr.h#L247-L247,580-580: add French translations for the function label and unlock message.
  • radio/src/translations/i18n/he.h#L247-L247,580-580: add Hebrew translations and verify RTL rendering of the unlock placeholders.
📍 Affects 3 files
  • radio/src/translations/i18n/fi.h#L244-L244 (this comment)
  • radio/src/translations/i18n/fr.h#L247-L247
  • radio/src/translations/i18n/he.h#L247-L247
🤖 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/fi.h` at line 244, Translate the new function
label and key-lock unlock message in all affected locale files:
radio/src/translations/i18n/fi.h at 244-244 and 576-576,
radio/src/translations/i18n/fr.h at 247-247 and 580-580, and
radio/src/translations/i18n/he.h at 247-247 and 580-580. Use Finnish, French,
and Hebrew text respectively, and verify RTL rendering of the unlock-message
placeholders in he.h.

#define TR_SF_SCREENSHOT "Screenshot"
#define TR_SF_RACING_MODE "Modo Racing"
#define TR_SF_DISABLE_TOUCH "Disab. touch"
#define TR_SF_DISABLE_KEYS "No Keys"

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 key-lock strings in each catalog.

The new function label and popup wording remain English in both locale files, leaving Italian and Japanese users with untranslated UI text.

  • radio/src/translations/i18n/it.h#L244-L244: provide an Italian translation for TR_SF_DISABLE_KEYS.
  • radio/src/translations/i18n/it.h#L577-L577: translate both Italian key-lock popup variants.
  • radio/src/translations/i18n/jp.h#L244-L244: provide a Japanese translation for TR_SF_DISABLE_KEYS.
  • radio/src/translations/i18n/jp.h#L576-L576: translate both Japanese key-lock popup variants.
📍 Affects 2 files
  • radio/src/translations/i18n/it.h#L244-L244 (this comment)
  • radio/src/translations/i18n/it.h#L577-L577
  • radio/src/translations/i18n/jp.h#L244-L244
  • radio/src/translations/i18n/jp.h#L576-L576
🤖 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/it.h` at line 244, Localize the key-lock UI
strings in all affected catalog entries: in radio/src/translations/i18n/it.h
lines 244 and 577, provide Italian text for TR_SF_DISABLE_KEYS and both popup
variants; in radio/src/translations/i18n/jp.h lines 244 and 576, provide
Japanese text for TR_SF_DISABLE_KEYS and both popup variants. Replace only the
remaining English strings while preserving the existing translation keys and
formatting.

#define TR_SF_SCREENSHOT "Capt. Tela"
#define TR_SF_RACING_MODE "ModCorrida"
#define TR_SF_DISABLE_TOUCH "No Touch"
#define TR_SF_DISABLE_KEYS "No Keys"

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

Translate the new key-lock strings in every affected locale.

The new function label and lock popup remain English in the Portuguese, Russian, and Swedish locales.

  • radio/src/translations/i18n/pt.h#L245-L245,577-577: add Portuguese translations.
  • radio/src/translations/i18n/ru.h#L247-L247,579-579: add Russian translations.
  • radio/src/translations/i18n/se.h#L247-L247,579-579: add Swedish translations.

Preserve the %s+%s placeholders and TR_BW_COL(...) layout.

📍 Affects 3 files
  • radio/src/translations/i18n/pt.h#L245-L245 (this comment)
  • radio/src/translations/i18n/ru.h#L247-L247
  • radio/src/translations/i18n/se.h#L247-L247
🤖 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 245, Translate the new key-lock
function label and lock popup strings in radio/src/translations/i18n/pt.h at
lines 245 and 577, radio/src/translations/i18n/ru.h at lines 247 and 579, and
radio/src/translations/i18n/se.h at lines 247 and 579. Replace the English text
with accurate Portuguese, Russian, and Swedish translations while preserving all
%s+%s placeholders and the existing TR_BW_COL(...) layout.

Comment thread tools/cfn_sorter.cpp
{ TR_SF_RGBLEDS, "FUNC_RGB_LED", FUNC_RGB_LED, "" },
{ TR_SF_LCD_TO_VIDEO, "FUNC_LCD_TO_VIDEO", FUNC_LCD_TO_VIDEO, "defined(VIDEO_SWITCH)" },
{ TR_SF_PUSH_CUST_SWITCH, "FUNC_PUSH_CUST_SWITCH", FUNC_PUSH_CUST_SWITCH, "defined(FUNCTION_SWITCHES)" },
{ TR_SF_DISABLE_KEYS, "FUNC_DISABLE_KEYS", FUNC_DISABLE_KEYS, "defined(KEYS_LOCK_KEY1) && defined(KEYS_LOCK_KEY2)" },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n -C2 'FUNC_DISABLE_KEYS|CFN_ONLY|KEYS_LOCK_KEY[12]' \
  tools/cfn_sorter.cpp radio/src/dataconstants.h radio/src/cfn_sort.cpp

Repository: EdgeTX/edgetx

Length of output: 8679


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the generator logic and nearby table entries.
sed -n '1,220p' tools/cfn_sorter.cpp

printf '\n--- dataconstants excerpt ---\n'
sed -n '720,750p' radio/src/dataconstants.h

printf '\n--- generated sorter excerpt ---\n'
sed -n '120,140p' radio/src/cfn_sort.cpp

Repository: EdgeTX/edgetx

Length of output: 6868


Add CFN_ONLY to this guard

radio/src/dataconstants.h already includes FUNC_DISABLE_KEYS for CFN_ONLY, but tools/cfn_sorter.cpp still emits it only under the hardware-key condition. That leaves the generated sorter out of sync for CFN-only builds; add || defined(CFN_ONLY) here and regenerate radio/src/cfn_sort.cpp.

🤖 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 `@tools/cfn_sorter.cpp` at line 131, Update the FUNC_DISABLE_KEYS guard entry
in the cfn sorter definitions to include CFN_ONLY alongside the existing
hardware-key condition, then regenerate radio/src/cfn_sort.cpp so CFN-only
builds emit the same function consistently.

@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/functions.cpp`:
- Around line 486-505: Remove the per-row locked-state comparison and
setKeyLockedState call from evalUIFunctions in radio/src/functions.cpp at lines
486-505, retaining only the aggregate newActiveFunctions update. In
radio/src/edgetx.cpp at lines 220-224, after both evalUIFunctions calls
complete, synchronize the lock once using
isFunctionActive(FUNCTION_DISABLE_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: 8644be62-616b-46df-b65c-ae1e5b26e1c8

📥 Commits

Reviewing files that changed from the base of the PR and between 432376b and 83a3d55.

📒 Files selected for processing (15)
  • radio/src/cfn_sort.cpp
  • radio/src/dataconstants.h
  • radio/src/edgetx.cpp
  • radio/src/edgetx.h
  • radio/src/functions.cpp
  • radio/src/gui/common/stdlcd/popups_common.cpp
  • radio/src/keys.h
  • radio/src/storage/yaml/yaml_datastructs_nb4p.cpp
  • radio/src/storage/yaml/yaml_datastructs_nv14.cpp
  • radio/src/storage/yaml/yaml_datastructs_pa01.cpp
  • radio/src/storage/yaml/yaml_datastructs_pl18.cpp
  • radio/src/storage/yaml/yaml_datastructs_pl18u.cpp
  • radio/src/storage/yaml/yaml_datastructs_xlite.cpp
  • radio/src/storage/yaml/yaml_datastructs_xlites.cpp
  • tools/cfn_sorter.sh
💤 Files with no reviewable changes (1)
  • radio/src/dataconstants.h
🚧 Files skipped from review as they are similar to previous changes (2)
  • radio/src/keys.h
  • radio/src/cfn_sort.cpp

Comment thread radio/src/functions.cpp
@philmoz
philmoz force-pushed the philmoz/key-lock-sf branch from 83a3d55 to 41e6bb7 Compare July 21, 2026 08:24
@pfeerick pfeerick changed the title feat(firmware): add a special function to trigger key lock. feat(firmware): add a special function to trigger key lock Jul 21, 2026
@philmoz
philmoz force-pushed the philmoz/key-lock-sf branch from 41e6bb7 to f9c7510 Compare July 25, 2026 11:06

@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: 3

🧹 Nitpick comments (1)
radio/src/gui/colorlcd/model/special_functions.cpp (1)

470-474: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Move strModules out of the switch body.

A declaration between } and the next case label is legal here only because it's static const; hoisting it to file/function scope avoids the trap and reads better.

🤖 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/gui/colorlcd/model/special_functions.cpp` around lines 470 - 474,
Move the static strModules declaration out of the switch body to the surrounding
function or file scope, then keep FUNC_SET_FAILSAFE using the same array and
bounds without changing its behavior.
🤖 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/gui/colorlcd/model/special_functions.cpp`:
- Around line 375-385: Update the choice text handler associated with choice so
its STR_CHANS boundary uses the same adcGetMaxInputs(ADC_INPUT_MAIN)-derived
maximum used when constructing the range, ensuring the final option consistently
renders as STR_CHANS.
- Around line 680-688: Update the fallback selection in the CFN_FUNC assignment
block so the final valid enum entry, FUNC_MAX - 1, can be selected when
available. Adjust the loop boundary and corresponding post-loop guard
consistently, while preserving the existing search for the first assignable
function.

In `@radio/src/translations/i18n/ko.h`:
- Line 244: Translate the new key-lock strings in
radio/src/translations/i18n/ko.h lines 244 and 586 and
radio/src/translations/i18n/pt.h lines 245 and 577: localize TR_SF_DISABLE_KEYS
and both lock-popup variants in each locale, preserving the %s+%s placeholders
and existing TR_BW_COL(...) layout.

---

Nitpick comments:
In `@radio/src/gui/colorlcd/model/special_functions.cpp`:
- Around line 470-474: Move the static strModules declaration out of the switch
body to the surrounding function or file scope, then keep FUNC_SET_FAILSAFE
using the same array and bounds without changing its behavior.
🪄 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: fa89165d-456d-4ec4-a17a-9fcc9e24680c

📥 Commits

Reviewing files that changed from the base of the PR and between 41e6bb7 and f9c7510.

📒 Files selected for processing (64)
  • companion/src/firmwares/customfunctiondata.cpp
  • companion/src/firmwares/customfunctiondata.h
  • companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
  • radio/src/cfn_sort.cpp
  • radio/src/dataconstants.h
  • radio/src/edgetx.cpp
  • radio/src/edgetx.h
  • radio/src/functions.cpp
  • radio/src/gui/colorlcd/model/special_functions.cpp
  • radio/src/gui/colorlcd/model/special_functions.h
  • radio/src/gui/common/stdlcd/popups_common.cpp
  • radio/src/gui/common/stdlcd/popups_common.h
  • radio/src/gui/gui_common.cpp
  • radio/src/keys.cpp
  • radio/src/keys.h
  • radio/src/lua/api_general.cpp
  • radio/src/main.cpp
  • radio/src/storage/yaml/CMakeLists.txt
  • radio/src/storage/yaml/yaml_datastructs_128x64.cpp
  • radio/src/storage/yaml/yaml_datastructs_c14.cpp
  • radio/src/storage/yaml/yaml_datastructs_f16.cpp
  • radio/src/storage/yaml/yaml_datastructs_gx12.cpp
  • radio/src/storage/yaml/yaml_datastructs_nb4p.cpp
  • radio/src/storage/yaml/yaml_datastructs_nv14.cpp
  • radio/src/storage/yaml/yaml_datastructs_pa01.cpp
  • radio/src/storage/yaml/yaml_datastructs_pl18.cpp
  • radio/src/storage/yaml/yaml_datastructs_pl18u.cpp
  • radio/src/storage/yaml/yaml_datastructs_st16.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15pro.cpp
  • radio/src/storage/yaml/yaml_datastructs_t20.cpp
  • radio/src/storage/yaml/yaml_datastructs_t22.cpp
  • radio/src/storage/yaml/yaml_datastructs_tpro.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/storage/yaml/yaml_datastructs_x10.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9d.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp
  • radio/src/storage/yaml/yaml_datastructs_x9e.cpp
  • radio/src/storage/yaml/yaml_datastructs_xlite.cpp
  • radio/src/storage/yaml/yaml_datastructs_xlites.cpp
  • 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
  • tools/cfn_sorter.cpp
  • tools/cfn_sorter.sh
💤 Files with no reviewable changes (1)
  • radio/src/gui/colorlcd/model/special_functions.h
🚧 Files skipped from review as they are similar to previous changes (58)
  • radio/src/translations/sim_string_list.h
  • tools/cfn_sorter.cpp
  • radio/src/storage/yaml/yaml_datastructs_128x64.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15pro.cpp
  • radio/src/gui/common/stdlcd/popups_common.h
  • radio/src/translations/i18n/de.h
  • radio/src/storage/yaml/yaml_datastructs_pa01.cpp
  • radio/src/translations/i18n/en.h
  • companion/src/firmwares/customfunctiondata.h
  • radio/src/translations/i18n/pl.h
  • radio/src/storage/yaml/yaml_datastructs_tpro.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx15.cpp
  • companion/src/firmwares/edgetx/yaml_customfunctiondata.cpp
  • radio/src/translations/i18n/ru.h
  • radio/src/storage/yaml/yaml_datastructs_c14.cpp
  • radio/src/storage/yaml/yaml_datastructs_tx16smk3.cpp
  • radio/src/translations/i18n/he.h
  • radio/src/storage/yaml/yaml_datastructs_x9dp2019.cpp
  • companion/src/firmwares/customfunctiondata.cpp
  • tools/cfn_sorter.sh
  • radio/src/translations/i18n/jp.h
  • radio/src/storage/yaml/yaml_datastructs_t20.cpp
  • radio/src/translations/i18n/ua.h
  • radio/src/edgetx.cpp
  • radio/src/storage/yaml/yaml_datastructs_f16.cpp
  • radio/src/translations/i18n/es.h
  • radio/src/storage/yaml/yaml_datastructs_pl18.cpp
  • radio/src/translations/i18n/tw.h
  • radio/src/storage/yaml/yaml_datastructs_t22.cpp
  • radio/src/translations/i18n/cz.h
  • radio/src/translations/i18n/it.h
  • radio/src/storage/yaml/yaml_datastructs_xlite.cpp
  • radio/src/dataconstants.h
  • radio/src/storage/yaml/yaml_datastructs_xlites.cpp
  • radio/src/translations/i18n/se.h
  • radio/src/storage/yaml/yaml_datastructs_x9e.cpp
  • radio/src/storage/yaml/yaml_datastructs_nb4p.cpp
  • radio/src/translations/i18n/fr.h
  • radio/src/storage/yaml/yaml_datastructs_x9d.cpp
  • radio/src/lua/api_general.cpp
  • radio/src/storage/yaml/yaml_datastructs_gx12.cpp
  • radio/src/storage/yaml/yaml_datastructs_nv14.cpp
  • radio/src/keys.h
  • radio/src/translations/i18n/da.h
  • radio/src/storage/yaml/CMakeLists.txt
  • radio/src/storage/yaml/yaml_datastructs_pl18u.cpp
  • radio/src/translations/i18n/fi.h
  • radio/src/gui/gui_common.cpp
  • radio/src/translations/i18n/nl.h
  • radio/src/translations/string_list.h
  • radio/src/main.cpp
  • radio/src/translations/i18n/cn.h
  • radio/src/edgetx.h
  • radio/src/storage/yaml/yaml_datastructs_x10.cpp
  • radio/src/storage/yaml/yaml_datastructs_t15.cpp
  • radio/src/gui/common/stdlcd/popups_common.cpp
  • radio/src/functions.cpp
  • radio/src/cfn_sort.cpp

Comment thread radio/src/gui/colorlcd/model/special_functions.cpp
Comment thread radio/src/gui/colorlcd/model/special_functions.cpp
Comment thread radio/src/translations/i18n/ko.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request needs:translation UX-UI Related to user experience (UX) or user interface (UI) behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant