Skip to content

feat(esp32): bare-IDF fl::platforms time implementation - #3726

Merged
zackees merged 3 commits into
masterfrom
feat/esp32-idf-native-time
Jul 22, 2026
Merged

zackees merged 3 commits into
masterfrom
feat/esp32-idf-native-time

Conversation

@zackees

@zackees zackees commented Jul 22, 2026 •

Copy link
Copy Markdown
Member

Closes #3716. Part of meta #3715 (ESP Arduino-decoupling).

Problem

platform_time_esp32.cpp.hpp implements fl::platforms::{delay,delayMicroseconds,millis,micros} for ESP32, but the whole file was gated on defined(ARDUINO), and internally called Arduino globals (::millis(), ::micros(), ::delayMicroseconds()). A bare ESP-IDF build (framework=espidf, no Arduino core) has no time implementation at all for these symbols — a link failure. This is the hard blocker for any bare-IDF FastLED build.

Fix

  • Replace ::millis()/::micros() with esp_timer_get_time().
  • Replace ::delayMicroseconds()'s remainder busy-wait with esp_rom_delay_us() (IDF 4.0+) / ets_delay_us() (IDF 3.x), gated on the existing ESP_IDF_VERSION_4_OR_HIGHER predicate from esp_version.h — same pattern already used in watchdog_esp32_idf4.hpp.
  • Drop the defined(ARDUINO) condition entirely; the file now compiles identically under Arduino-ESP32 (which bundles ESP-IDF) and bare ESP-IDF.
  • clockless_block_esp32.h:90's unqualified delayMicroseconds(...) call is now explicitly qualified as fl::delayMicroseconds(...) for clarity (it already resolved to the fl:: facade via unqualified lookup inside namespace fl, since fl::delayMicroseconds forwards to fl::platforms::delayMicroseconds — this makes that intent unambiguous).

Test plan

  • bash test --cpp — 355/355 host tests pass
  • bash lint --cpp — clean
  • bash compile esp32dev --examples Blink — real Arduino-ESP32 3.3.7 (IDF 5.x) build succeeds and links, exercising the new esp_timer_get_time()/esp_rom_delay_us() code path (flash 382KB, ram 143KB — matches prior baseline)
  • True framework=espidf (no Arduino) compile-test — no CI leg exists yet; tracked by ci: bare-IDF (framework=espidf) compile-test legs for IDF 4.4 / 5.x / 6.x (+ FL_NO_ARDUINO ratchet) #3724. This PR is a prerequisite for that leg to pass.

Summary by CodeRabbit

  • Bug Fixes

    • Improved timing and pixel output reliability on ESP32 platforms.
    • Enhanced ESP-IDF native compatibility by using ESP-IDF timing primitives instead of Arduino core time calls.
    • Refined millis()/micros() and delay behavior for more accurate timing, including interrupt-safe microsecond waits.
  • Chores

    • Updated the ESP-IDF component requirements in the build configuration to include additional time-related dependencies.

platform_time_esp32.cpp.hpp was gated on defined(ARDUINO), so a bare
ESP-IDF build had no fl::platforms::{millis,micros,delayMicroseconds}
implementation at all — a link failure. Replace the Arduino global calls
with ESP-IDF native equivalents (esp_timer_get_time, esp_rom_delay_us /
ets_delay_us per the ESP_IDF_VERSION_4_OR_HIGHER predicate, matching the
existing watchdog_esp32_idf4.hpp convention) and drop the ARDUINO gate so
the same code path serves both Arduino-ESP32 and bare ESP-IDF builds.

Also qualifies the delayMicroseconds() call in clockless_block_esp32.h as
fl::delayMicroseconds() explicitly rather than relying on unqualified
lookup finding the fl:: facade.

Part of #3715. Closes #3716.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@zackees, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d55e1a1f-7949-480f-ab0a-36a307b0181c

📥 Commits

Reviewing files that changed from the base of the PR and between bbdc3f1 and 809fe41.

📒 Files selected for processing (1)
  • CMakeLists.txt
📝 Walkthrough

Walkthrough

ESP32 platform timing now uses ESP-IDF APIs without requiring Arduino, including version-specific microsecond delays and esp_timer_get_time(). Clockless ESP32 pixel output calls the namespaced FastLED delay function.

Changes

ESP32 timing support

Layer / File(s) Summary
ESP-IDF platform timing implementation
src/platforms/esp/32/platform_time_esp32.cpp.hpp, CMakeLists.txt
Removes the Arduino requirement, uses ESP-IDF and FreeRTOS headers, selects compatible microsecond delay primitives, derives millis() and micros() from esp_timer_get_time(), and adds the required ESP-IDF components.
Clockless delay API wiring
src/platforms/esp/32/clockless_block_esp32.h
Includes the FastLED delay API and qualifies the microsecond delay call with fl::.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • Issue 3715: The timing migration removes Arduino timing dependencies from ESP32 platform code.
  • Issue 3721: The platform timing changes directly implement the ESP32 Arduino-dependency removal described by this issue.

Possibly related PRs

  • FastLED/FastLED#3731: Applies the same namespaced delay qualification to the ESP8266 clockless block path.

Suggested reviewers: swoboda1337

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main ESP32 bare-IDF timing implementation change.
Linked Issues check ✅ Passed The changes remove Arduino-only gating, switch to ESP-IDF timing APIs, preserve delay behavior, and fix the stray clockless delay call as required.
Out of Scope Changes check ✅ Passed No unrelated changes are evident; the CMake dependency update directly supports the new ESP-IDF timing APIs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/esp32-idf-native-time

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: 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 `@src/platforms/esp/32/platform_time_esp32.cpp.hpp`:
- Around line 13-28: Add the ESP-IDF components required by the includes in
platform_time_esp32.cpp.hpp to the existing CMakeLists.txt dependency
declaration: include the component providing esp_timer and the component
required by esp_rom_sys.h, while preserving the current Arduino, I2S, MCPWM, and
RMT dependencies.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 084f4ef8-750d-4266-8176-15b237884ce9

📥 Commits

Reviewing files that changed from the base of the PR and between 1404736 and a2e15f4.

📒 Files selected for processing (2)
  • src/platforms/esp/32/clockless_block_esp32.h
  • src/platforms/esp/32/platform_time_esp32.cpp.hpp

platform_time_esp32.cpp.hpp now includes esp_timer.h (esp_timer_get_time)
and esp_rom_sys.h/rom/ets_sys.h (esp_rom_delay_us/ets_delay_us) — declare
the owning ESP-IDF components so the idf_component_register() dependency
graph is accurate for component-based (bare-IDF) builds.

Addresses CodeRabbit review on #3726.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@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 `@CMakeLists.txt`:
- Line 17: Update the component requirements near app_update to preserve ESP-IDF
3.x resolution: remove unconditional esp_timer and esp_rom dependencies, or
conditionally require them only for IDF 4 and newer. Keep legacy IDF 3.3 builds
using rom/ets_sys.h resolvable.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d210d5f6-edbb-41a8-9e9e-b4001cedaef6

📥 Commits

Reviewing files that changed from the base of the PR and between a2e15f4 and bbdc3f1.

📒 Files selected for processing (1)
  • CMakeLists.txt

Comment thread CMakeLists.txt Resolved
esp_rom is a standalone ESP-IDF component only from 4.x onward
(esp_rom_sys.h / esp_rom_delay_us). Requiring it unconditionally would
break component resolution on IDF 3.x, where platform_time_esp32.cpp.hpp
uses rom/ets_sys.h (ets_delay_us) instead — no separate component needed
there.

Addresses CodeRabbit re-review on #3726.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@zackees
zackees merged commit eabb9b4 into master Jul 22, 2026
11 checks passed
@zackees
zackees deleted the feat/esp32-idf-native-time branch July 22, 2026 19:21
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 22, 2026
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.

esp32: bare-IDF fl::platforms time impl — drop Arduino millis()/micros()/delayMicroseconds() (blocks all framework=espidf builds)

1 participant