Skip to content

ModuleService: KConfig for supported Module sets (BUT-207)#51

Open
klajocm wants to merge 1 commit into
masterfrom
BUT-207-moduleservice-kconfig-supported-module-sets
Open

ModuleService: KConfig for supported Module sets (BUT-207)#51
klajocm wants to merge 1 commit into
masterfrom
BUT-207-moduleservice-kconfig-supported-module-sets

Conversation

@klajocm
Copy link
Copy Markdown
Contributor

@klajocm klajocm commented May 26, 2026

Summary

In ModuleService, group the supported modules by module set rather than presenting a flat list, and gate the detection logic so sub-address pins / I2C probes for un-selected sets are never compiled in or touched during detection.

KConfig changes

The Supported modules menu now contains three top-level set selectors (menuconfigs):

  • Rick and Morty modules (CMF_MODULES_RM) — gates the existing RM_TempHum / RM_LED / RM_Motion / RM_CO2 / RM_IR / RM_PerfBoard modules. Enabling the set is now a prerequisite for picking any individual RM module (depends on CMF_MODULES_RM).
  • Rover I2C modules (CMF_MODULES_ROVER_I2C) — empty sub-menu for now.
  • Wacky robot tokens (CMF_MODULES_TOKEN) — empty sub-menu for now.

The CONFIG_RM_* per-module symbols are kept verbatim, so existing per-module #ifdef gates in ModuleDefs.cpp / ModuleType.h etc. continue to work unchanged.

Detection / pin handling

ModuleService::checkAddr():

  • SubAddress::Type::RM branch is wrapped in #ifdef CONFIG_CMF_MODULES_RM
  • SubAddress::Type::RM_I2C branch is wrapped in #ifdef CONFIG_CMF_MODULES_RM (RM-family I2C modules)
  • SubAddress::Type::Rover_I2C branch is split out into its own block under #ifdef CONFIG_CMF_MODULES_ROVER_I2C
  • SubAddress::Type::Token branch is wrapped in #ifdef CONFIG_CMF_MODULES_TOKEN
  • The ReadRMAddress / ReadTokenAddress cached optionals are also #ifdef-gated so unused-variable warnings don't pop up when a set is off.

ModuleService::registerSubAddressPinsInput() (detection-time pin registration) no longer registers all six sub-address pins unconditionally — it now only registers the pins each enabled set actually needs to read during detection:

  • CMF_MODULES_TOKEN → all 6 sub-address pins (strict superset of the RM set)
  • CMF_MODULES_RM (without Token) → pins 3..5 only (the 3-bit RM sub-address)
  • I2C-only sets (RM_I2C, Rover_I2C) → no sub-address pins are registered for detection

Pins that no enabled set relies on stay unregistered until registerSubAddressPinsModule() (called on module insert) claims them per the detected Module's PinModeMap.

Test plan

  • idf.py build passes with the existing RM-set sdkconfig (CONFIG_CMF_MODULES_RM=y).
  • Verify that with CONFIG_CMF_MODULES_RM and all individual RM_* modules disabled, neither RM sub-address pins (3..5) nor RM I2C probes are reachable at runtime.
  • Verify that with CONFIG_CMF_MODULES_TOKEN=y and CONFIG_CMF_MODULES_RM=n, pins 0..5 are registered for detection but pins 3..5 are not double-registered.
  • Sanity-test on hardware with a real RM module inserted/removed.

Tracked in: BUT-207. Companion firmware-side KConfig defaults are bumped in ButterBot-Firmware.

Group supported modules under set-level menus in KConfig
(Rick and Morty, Rover I2C, Wacky robot tokens) and gate the
detection logic so sub-address pins / I2C probes for un-selected
sets are never compiled in or touched during detection.
Sub-address pins that no enabled set needs stay unregistered
until a detected Module claims them via its PinModeMap.
@MiLeG MiLeG self-requested a review May 26, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant