Skip to content

feat(v16): add CI1302 voice control (VGR/VFL, motion control, menu navigation) - #7501

Open
helloradiosky wants to merge 3 commits into
EdgeTX:mainfrom
helloradiosky:hrs-V16-Voice-control-3.0
Open

feat(v16): add CI1302 voice control (VGR/VFL, motion control, menu navigation)#7501
helloradiosky wants to merge 3 commits into
EdgeTX:mainfrom
helloradiosky:hrs-V16-Voice-control-3.0

Conversation

@helloradiosky

@helloradiosky helloradiosky commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary of changes:
Adds CI1302 voice-module support for HelloRadioSky V16 (PCB=X10, PCBREV=V16).
Voice recognition runs on the external CI1302 module over UART. The firmware exposes voice features through virtual switches, mixer sources, and optional menu navigation — with thin integration hooks in shared code guarded by VOICE_CONTROL_SENSOR.

image image image image

Summary by CodeRabbit

  • New Features
    • Added voice-control support for compatible Horus radios, including virtual VGR/VFL switches and voice-selectable sources/switches.
    • Voice commands can trigger radio menu/keyboard actions, and voice-driven motion control can apply gyro-assisted stick correction when enabled.
    • Added new voice audio prompts (“Hello radio” and “Okay”).
  • Bug Fixes
    • Improved suppression of overlapping “switch moved” and function audio when voice control is active.
    • Refined voice-aware source/switch availability to match reported voice switch behavior.

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

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: 97e18767-584a-42fa-b2b3-947385e1a59b

📥 Commits

Reviewing files that changed from the base of the PR and between fb1fa5c and 68a9aa8.

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

📝 Walkthrough

Walkthrough

The PR adds VOICE_CONTROL_SENSOR support for the CI1302 voice module, including build wiring, driver integration, virtual voice switches, UI input injection, mixer/YAML/source handling, and audio suppression paths.

Changes

Voice control sensor integration

Layer / File(s) Summary
Build flags and public symbols
radio/src/targets/horus/CMakeLists.txt, radio/src/targets/horus/hal.h, radio/src/dataconstants.h, radio/src/edgetx.h, radio/src/audio.h, radio/src/audio.cpp, radio/src/drivers/CI1302.h, radio/src/drivers/CI1302_voice_integration.h
VOICE_CONTROL_SENSOR is enabled in Horus build wiring, and new voice source/sound enums, audio helpers, and CI1302 public headers are added.
CI1302 driver and startup hooks
radio/src/targets/horus/board.cpp, radio/src/edgetx.cpp, radio/src/drivers/CI1302.cpp
CI1302 voice frame parsing, motion control, virtual voice switches, menu routing, and USART I/O are implemented, and board/periodic hooks call the integration entry points.
Voice keypad injection
radio/src/gui/colorlcd/LvglWrapper.h, radio/src/gui/colorlcd/LvglWrapper.cpp
A deferred LVGL ENTER request is added and consumed by the UI loop to inject keyboard input.
Voice sources in mixer, YAML, and UI
radio/src/gui/gui_common.cpp, radio/src/gui/colorlcd/controls/sourcechoice.cpp, radio/src/mixer.cpp, radio/src/storage/yaml/yaml_datastructs_funcs.cpp, radio/src/strhelpers.cpp
Voice mix sources are exposed through GUI filtering, source labels, mixer values, YAML parsing/writing, and source-string formatting.
Voice switches and audio suppression
radio/src/datastructs_model.cpp, radio/src/functions.cpp, radio/src/hal/switch_driver.cpp, radio/src/switches.cpp
Model switch types, switch availability, switch driver lookups, and switch/function audio playback paths consult CI1302 voice helpers.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90+ minutes

Suggested labels

hardware support, firmware, enhancement ✨

Suggested reviewers

  • pfeerick
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.13% 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 and concisely summarizes the main CI1302 voice-control feature for v16.
Description check ✅ Passed The description includes the required Summary of changes section and is on-topic, though the Fixes # field is left blank.
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 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.

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

🧹 Nitpick comments (3)
radio/src/drivers/CI1302.cpp (2)

244-252: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate command-byte macros.

VOICE_CMD_TELEMETRYVOICE_CMD_SYSTEM_MENU duplicate the values already defined at Lines 59, 73, 52, 53, 54, 47, 48, 49, 50 (VOICE_Telemetry, etc.). Two parallel sets risk drifting out of sync. Consider reusing the original macros in voiceControlGuiHandleCmd.

🤖 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/drivers/CI1302.cpp` around lines 244 - 252, The command-byte macros
in the CI1302 driver duplicate existing values already defined by the earlier
VOICE_* symbols, which creates two parallel sets that can drift out of sync.
Remove the redundant VOICE_CMD_* definitions and update voiceControlGuiHandleCmd
to reuse the original command constants (such as VOICE_Telemetry,
VOICE_SensorStatus, VOICE_ChannelMonitor, VOICE_InternalModule,
VOICE_ExternalModule, VOICE_Confirm, VOICE_Cancel, VOICE_ModelMenu, and
VOICE_SystemMenu) wherever these command bytes are compared or dispatched.

167-174: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

GetVoiceInput loop is effectively an if.

The while body unconditionally return 0 after the first read, so it never iterates. If a single read is intended, an if is clearer; if draining is intended, the return is misplaced.

🤖 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/drivers/CI1302.cpp` around lines 167 - 174, `GetVoiceInput` in
`CI1302.cpp` is written as a loop but only ever performs one read because it
returns immediately inside the body. Update the logic in `GetVoiceInput` to
match the intended behavior: either replace the `while` with an `if` if only one
`voiceGetByte` call should be attempted, or move the `return 0` outside the loop
if the function is meant to keep reading until `voiceGetByte` stops producing
data.
radio/src/targets/horus/hal.h (1)

556-557: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

VOICE_CTRL_BAUD sits outside the RADIO_V16 guard.

If VOICE_CONTROL_SENSOR is ever enabled on a non-V16 target, VOICE_CTRL_BAUD is defined but the USART/GPIO/DMA macros aren't, producing confusing build breaks in CI1302.cpp rather than a clear "unsupported target" failure. Consider moving it inside the RADIO_V16 block (or adding an #else #error``).

♻️ Move baud inside the target guard
 `#if` defined(VOICE_CONTROL_SENSOR)
-  `#define` VOICE_CTRL_BAUD               115200
 `#if` defined(RADIO_V16)
+  `#define` VOICE_CTRL_BAUD               115200
   `#define` VOICE_CONTROL_USART           UART7
🤖 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/targets/horus/hal.h` around lines 556 - 557, `VOICE_CTRL_BAUD` is
defined outside the `RADIO_V16` target guard, which can let
`VOICE_CONTROL_SENSOR` compile partway on unsupported targets and fail later in
`CI1302.cpp`. Move the `VOICE_CTRL_BAUD` definition into the same `RADIO_V16`
guarded section in `hal.h`, or add an explicit `#else `#error`` branch so non-V16
builds fail immediately with a clear unsupported-target message.
🤖 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/audio.cpp`:
- Around line 206-208: The asset list currently uses the mixed-case name "oKay",
which can break the SIMU path’s exact f_stat lookup on case-sensitive
filesystems even though the radio FAT lookup is case-insensitive. Update the
filename entry in the relevant audio asset list used by the radio audio path to
the conventional lowercase "okay" so it matches the documented okay.wav asset
and resolves consistently.

In `@radio/src/drivers/CI1302.cpp`:
- Around line 471-474: The context check in the CI1302 driver is using a raw
ordinal value, which is brittle and unclear; update the conditional in the
relevant branch of the CI1302 handling logic to compare against
GeneralCustomFunctionsContext instead of 2. Keep the rest of the availability
behavior the same, and use the named context symbol so the intent stays clear if
enum values change.

In `@radio/src/drivers/CI1302.h`:
- Around line 25-38: Remove the per-declaration extern "C" keywords from the
voiceControlPowerOn/voiceControlPowerOff/voiceSerialPutc/voiceGetByte/GetVoiceInput/dbgGetByte/voiceSerialPutstr
declarations in CI1302.h and rely on the surrounding __cplusplus extern "C"
block for C linkage; also add the missing <stdint.h> include so the uint8_t and
uint32_t types used by these declarations are defined. Keep the existing
VoiceGearStatus, VoiceFlapStatus, and VoicePowerStatus extern declarations under
the same C-compat guard.

In `@radio/src/strhelpers.cpp`:
- Around line 805-817: The voice source handling in the strhelpers.cpp switch is
currently range-dependent, so CI1302_voiceIntegrationMixSrcName() is only
reached if the enum values for the voice sources live inside the TX-spare gap.
Verify the MixSources enum layout (especially MIXSRC_VGR, MIXSRC_VFL,
MIXSRC_LAST_GVAR, MIXSRC_TX_GPS, and MIXSRC_FIRST_TIMER) and, if these values
can move, update the switch in strhelpers.cpp so voice-name resolution is done
by explicit symbol checks rather than relying on the reserved range.

In `@radio/src/targets/horus/hal.h`:
- Around line 563-565: The V16 DMA configuration in the HORUS HAL has a stream
conflict: VOICE_CONTROL_DMA_RX_STREAM and EXTMODULE_USART_TX_DMA_STREAM both
resolve to DMA1/LL_DMA_STREAM_3 when VOICE_CONTROL_SENSOR is enabled. Update the
RADIO_V16 branch so one of these users is remapped to a different DMA1 stream or
guarded by mutually exclusive feature conditions, and keep the fix scoped to the
relevant HAL macros such as VOICE_CONTROL_DMA_RX_STREAM and the EXTMODULE USART
TX DMA mapping.

---

Nitpick comments:
In `@radio/src/drivers/CI1302.cpp`:
- Around line 244-252: The command-byte macros in the CI1302 driver duplicate
existing values already defined by the earlier VOICE_* symbols, which creates
two parallel sets that can drift out of sync. Remove the redundant VOICE_CMD_*
definitions and update voiceControlGuiHandleCmd to reuse the original command
constants (such as VOICE_Telemetry, VOICE_SensorStatus, VOICE_ChannelMonitor,
VOICE_InternalModule, VOICE_ExternalModule, VOICE_Confirm, VOICE_Cancel,
VOICE_ModelMenu, and VOICE_SystemMenu) wherever these command bytes are compared
or dispatched.
- Around line 167-174: `GetVoiceInput` in `CI1302.cpp` is written as a loop but
only ever performs one read because it returns immediately inside the body.
Update the logic in `GetVoiceInput` to match the intended behavior: either
replace the `while` with an `if` if only one `voiceGetByte` call should be
attempted, or move the `return 0` outside the loop if the function is meant to
keep reading until `voiceGetByte` stops producing data.

In `@radio/src/targets/horus/hal.h`:
- Around line 556-557: `VOICE_CTRL_BAUD` is defined outside the `RADIO_V16`
target guard, which can let `VOICE_CONTROL_SENSOR` compile partway on
unsupported targets and fail later in `CI1302.cpp`. Move the `VOICE_CTRL_BAUD`
definition into the same `RADIO_V16` guarded section in `hal.h`, or add an
explicit `#else `#error`` branch so non-V16 builds fail immediately with a clear
unsupported-target message.
🪄 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: 2617b34b-a6e2-453f-8342-0cdb4b11ea9b

📥 Commits

Reviewing files that changed from the base of the PR and between eae6aa1 and 42f8eec.

📒 Files selected for processing (20)
  • radio/src/audio.cpp
  • radio/src/audio.h
  • radio/src/dataconstants.h
  • radio/src/datastructs_model.cpp
  • radio/src/drivers/CI1302.cpp
  • radio/src/drivers/CI1302.h
  • radio/src/drivers/CI1302_voice_integration.h
  • radio/src/edgetx.cpp
  • radio/src/edgetx.h
  • radio/src/functions.cpp
  • radio/src/gui/colorlcd/controls/sourcechoice.cpp
  • radio/src/gui/gui_common.cpp
  • radio/src/hal/switch_driver.cpp
  • radio/src/mixer.cpp
  • radio/src/storage/yaml/yaml_datastructs_funcs.cpp
  • radio/src/strhelpers.cpp
  • radio/src/switches.cpp
  • radio/src/targets/horus/CMakeLists.txt
  • radio/src/targets/horus/board.cpp
  • radio/src/targets/horus/hal.h

Comment thread radio/src/audio.cpp Outdated
Comment thread radio/src/drivers/CI1302.cpp Outdated
Comment thread radio/src/drivers/CI1302.h Outdated
Comment thread radio/src/strhelpers.cpp Outdated
Comment thread radio/src/targets/horus/hal.h Outdated
@helloradiosky helloradiosky changed the title add Motion Control OK feat(v16): add CI1302 voice control (VGR/VFL, motion control, menu navigation) Jun 27, 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: 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/gui/colorlcd/LvglWrapper.cpp`:
- Around line 185-188: The voice-confirm handling in LvglWrapper::handleKeyboard
should not send LV_EVENT_CLICKED directly to the focused object, because that
bypasses the normal keypad/group Enter behavior. Update the Enter-key path so
voice confirm follows the same flow as a physical Enter press, using the
existing keyboard/indev handling logic in get_focus_obj and the surrounding
keyboard event processing instead of dispatching the click event manually.
🪄 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: 9a541dc2-d00f-40c9-b813-7083d50fbcef

📥 Commits

Reviewing files that changed from the base of the PR and between 42f8eec and fb1fa5c.

📒 Files selected for processing (8)
  • radio/src/audio.cpp
  • radio/src/drivers/CI1302.cpp
  • radio/src/drivers/CI1302.h
  • radio/src/drivers/CI1302_voice_integration.h
  • radio/src/gui/colorlcd/LvglWrapper.cpp
  • radio/src/gui/colorlcd/LvglWrapper.h
  • radio/src/strhelpers.cpp
  • radio/src/targets/horus/hal.h
🚧 Files skipped from review as they are similar to previous changes (4)
  • radio/src/drivers/CI1302.h
  • radio/src/drivers/CI1302_voice_integration.h
  • radio/src/audio.cpp
  • radio/src/drivers/CI1302.cpp

Comment thread radio/src/gui/colorlcd/LvglWrapper.cpp
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.

2 participants