Skip to content

refactor(system): introduce FL_PLATFORM_HAS_*_MEMORY canonical names (closes #3000) - #3019

Merged
zackees merged 1 commit into
masterfrom
feat/3000-fl-platform-memory-macros
Jun 14, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/3000-fl-platform-memory-macros

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Summary

The memory-tier classification macros are named SKETCH_HAS_*_MEMORY, but they describe platform memory capacity, not anything about a user sketch. The name was misleading — and worse, it implied that sketches could/should override the value when in practice it is silicon-derived (with a build-flag escape hatch).

This PR promotes FL_PLATFORM_HAS_*_MEMORY to the canonical spelling and re-derives the legacy SKETCH_HAS_*_MEMORY names as deprecated aliases. Both spellings continue to evaluate identically; external user sketches keep compiling unchanged.

Changes (single file — src/fl/system/sketch_macros.h)

  • FL_PLATFORM_HAS_TINY_MEMORY / FL_PLATFORM_HAS_LARGE_MEMORY / FL_PLATFORM_HAS_HUGE_MEMORY are now the source-of-truth defines (plus the _OVERRIDDEN variants).
  • Override detection accepts either spelling on the build-flag side — -DSKETCH_HAS_LARGE_MEMORY=1 and -DFL_PLATFORM_HAS_LARGE_MEMORY=1 are equivalent inputs, and setting one defines the other plus the _OVERRIDDEN marker.
  • SKETCH_HAS_*_MEMORY / SKETCH_HAS_*_MEMORY_OVERRIDDEN / SKETCH_HAS_LOTS_OF_MEMORY / SKETCH_HAS_VERY_LARGE_MEMORY are preserved as backward-compat aliases via #ifndef + #define chains pointing at the canonical FL_PLATFORM_HAS_* names.

The ~50 internal callers in src/, examples/, tests/, and ci/ that still spell the macro SKETCH_HAS_*_MEMORY are intentionally NOT touched in this PR — they keep working via the alias path. Each subsystem will migrate to the canonical name in its own focused follow-up PR, where the diff is reviewable in isolation. The issue body's explicit requirement that the rename "MUST keep the old SKETCH_HAS_* names working as deprecated aliases" is satisfied by this single-file change today.

Open question from the issue (FL_PLATFORM_HAS_* vs FL_HAS_*)

Went with the issue's recommendation (FL_PLATFORM_HAS_*) because the tier is a property of the target platform/MCU, and the FL_PLATFORM_ prefix matches other platform-detection macros. If a maintainer prefers FL_HAS_*, the alias chain means that future rename is also non-breaking — just re-point the SKETCH_HAS_* aliases to the new name.

Test plan

  • bash lint — clean.
  • bash test fl_log --cpp — passes (uses FASTLED_LOG_RUNTIME_ENABLED which is gated on SKETCH_HAS_LARGE_MEMORY via the alias).
  • bash test power --cpp — passes (power_mgt.cpp.hpp keys off SKETCH_HAS_LARGE_MEMORY via the alias).
  • bash autoresearch lpc845brk --upload-port COM10 --skip-lint --timeout 5 — LPC845 firmware still builds (text 62.16 KB / 64 KB; same byte-for-byte as before, confirming the aliases are zero-overhead) and the bring-up RPC test passes on real hardware.

Closes #3000.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Standardized platform memory configuration macros to new canonical naming convention
    • Maintained full backward compatibility with legacy macro names
    • Added support for explicit build-flag override detection and reporting
    • Restructured memory tier detection logic for improved platform compatibility

…loses #3000)

The memory-tier classification macros are named `SKETCH_HAS_*_MEMORY`,
but they describe *platform* memory capacity, not anything about a
user sketch. The name was misleading — and worse, it implied that
sketches could/should override the value when in practice it is
silicon-derived (with a build-flag escape hatch).

This commit promotes `FL_PLATFORM_HAS_*_MEMORY` to the canonical
spelling and re-derives the legacy `SKETCH_HAS_*_MEMORY` names as
deprecated aliases. Both spellings continue to evaluate identically;
external user sketches keep compiling unchanged.

Changes (single file — `src/fl/system/sketch_macros.h`):

  * `FL_PLATFORM_HAS_TINY_MEMORY` is now the source of truth (was
    `SKETCH_HAS_TINY_MEMORY`).
  * `FL_PLATFORM_HAS_LARGE_MEMORY` is now the source of truth (was
    `SKETCH_HAS_LARGE_MEMORY`).
  * `FL_PLATFORM_HAS_HUGE_MEMORY` is now the source of truth (was
    `SKETCH_HAS_HUGE_MEMORY`).
  * `FL_PLATFORM_HAS_*_MEMORY_OVERRIDDEN` likewise.
  * Override detection accepts **either** spelling on the build-flag
    side — `-DSKETCH_HAS_LARGE_MEMORY=1` and
    `-DFL_PLATFORM_HAS_LARGE_MEMORY=1` are equivalent inputs, and
    setting one defines the other plus the `_OVERRIDDEN` marker.
  * `SKETCH_HAS_*_MEMORY` / `SKETCH_HAS_*_MEMORY_OVERRIDDEN` /
    `SKETCH_HAS_LOTS_OF_MEMORY` / `SKETCH_HAS_VERY_LARGE_MEMORY` are
    preserved as backward-compat aliases via `#ifndef` + `#define`
    chains pointing at the canonical FL_PLATFORM_HAS_* names.

The ~50 internal callers in `src/`, `examples/`, `tests/`, and `ci/`
that still spell the macro `SKETCH_HAS_*_MEMORY` are intentionally
NOT touched in this PR — they keep working via the alias path. Each
subsystem (audio, log, system, channels, platforms, examples, CI
tooling) will migrate to the canonical name in its own focused
follow-up PR, where the diff is reviewable in isolation. The issue
body's explicit requirement that the rename "MUST keep the old
SKETCH_HAS_* names working as deprecated aliases" is satisfied
by this single-file change today; the migration of internal users
is a series of mechanical follow-ups that can land independently.

Open question from the issue body (`FL_PLATFORM_HAS_*` vs
`FL_HAS_*`): I went with the issue's recommendation
(`FL_PLATFORM_HAS_*`) because the tier is a property of the target
platform/MCU, and the `FL_PLATFORM_` prefix matches other
platform-detection macros. If a maintainer prefers `FL_HAS_*`, the
alias chain means that future rename is also non-breaking — just
re-point the SKETCH_HAS_* aliases to the new name and either
maintain both `FL_PLATFORM_HAS_*` and `FL_HAS_*` as duplicates or
deprecate one in favour of the other.

Closes #3000.

Test plan:

  * `bash lint` — clean.
  * `bash test fl_log --cpp` — passes (uses
    `FASTLED_LOG_RUNTIME_ENABLED` which is gated on
    `SKETCH_HAS_LARGE_MEMORY` via the alias).
  * `bash test power --cpp` — passes (`power_mgt.cpp.hpp` keys off
    `SKETCH_HAS_LARGE_MEMORY` via the alias).
  * `bash autoresearch lpc845brk --upload-port COM10 --skip-lint
    --timeout 5` — LPC845 firmware still builds (text 62.16 KB /
    64 KB; same byte-for-byte as before, confirming the aliases are
    zero-overhead) and the bring-up RPC test passes on real
    hardware.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@zackees
zackees merged commit bde26da into master Jun 14, 2026
7 of 8 checks passed
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7bdb71bb-3951-42be-9c52-4e145f637b65

📥 Commits

Reviewing files that changed from the base of the PR and between ed7f5e2 and 5bbbf6c.

📒 Files selected for processing (1)
  • src/fl/system/sketch_macros.h

📝 Walkthrough

Walkthrough

sketch_macros.h introduces canonical FL_PLATFORM_HAS_{TINY,LARGE,HUGE}_MEMORY macros as the new primary names for platform memory-tier classification. Tier detection, build-flag override handling, *_OVERRIDDEN flags, and compile-time invariant checks are rewritten around these canonical names. Legacy SKETCH_HAS_* macros are preserved as deprecated backward-compatible aliases mirroring the new values.

Changes

Memory Tier Macro Rename (sketch_macros.h)

Layer / File(s) Summary
Canonical FL_PLATFORM_HAS_* tier detection and overrides
src/fl/system/sketch_macros.h
Rewrites three-tier classification logic around new FL_PLATFORM_HAS_{TINY,LARGE,HUGE}_MEMORY macros; build-flag overrides accept either FL_PLATFORM_HAS_* or SKETCH_HAS_* spelling and set the corresponding *_OVERRIDDEN flags.
Updated compile-time invariant checks
src/fl/system/sketch_macros.h
#error guards are updated to reference FL_PLATFORM_HAS_HUGE_MEMORY requires FL_PLATFORM_HAS_LARGE_MEMORY, and FL_PLATFORM_HAS_TINY_MEMORY cannot coincide with FL_PLATFORM_HAS_LARGE_MEMORY.
Backward-compatible SKETCH_HAS_* aliases
src/fl/system/sketch_macros.h
SKETCH_HAS_{TINY,LARGE,HUGE}_MEMORY and their *_OVERRIDDEN variants are defined as #ifndef-guarded mirrors of the canonical macros; SKETCH_HAS_LOTS_OF_MEMORY and SKETCH_HAS_VERY_LARGE_MEMORY are retained mapping to the large/huge canonical macros.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • FastLED/FastLED#2267: Directly modifies the same memory-tier classification logic in sketch_macros.h, including the "tiny" tier invariants and override macros that this PR renames.
  • FastLED/FastLED#3012: Modifies sketch_macros.h memory-tier macros including SKETCH_HAS_LARGE_MEMORY overrides, which gates FL_MATH_USE_LIBM in the math layer.

Poem

🐇 Hop, hop, a macro reborn,
SKETCH_HAS_* names now gently worn,
FL_PLATFORM_HAS_* takes the lead,
Old aliases still there to heed,
The compiler knows what memory we've got,
Tiny, large, or huge — the right slot! ✨

✨ 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 feat/3000-fl-platform-memory-macros

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rename SKETCH_HAS_*_MEMORY macros to FL_PLATFORM_HAS_*_MEMORY

1 participant