Repository navigation
Description
Part of #3715.
Problem
fl::platforms::{delay, delayMicroseconds, millis, micros} for ESP32 is implemented only in src/platforms/esp/32/platform_time_esp32.cpp.hpp, and the whole file is gated:
#if defined(FL_IS_ESP32) && defined(ARDUINO) && !defined(FASTLED_STUB_IMPL) // line 11Inside, it calls Arduino globals: ::delayMicroseconds() (line 39), ::millis() (line 44), ::micros() (line 48). The generic fallback src/platforms/arduino/platform_time.cpp.hpp is also gated on defined(ARDUINO) (and excludes FL_IS_ESP32 anyway).
Consequence: a bare ESP-IDF build has no time implementation at all — fl::platforms::millis etc. are undefined symbols at link time. This is the single hardest blocker for any framework=espidf build and must land before the CI sub-issue can go green.
Additional stray Arduino call: src/platforms/esp/32/clockless_block_esp32.h:90 calls unqualified delayMicroseconds(...).
Fix
Replace the Arduino calls with IDF-native equivalents so the impl compiles under both Arduino and bare IDF, and drop the defined(ARDUINO) term from the guard:
| Arduino | IDF-native |
|---|---|
::millis() |
esp_timer_get_time() / 1000 |
::micros() |
esp_timer_get_time() |
::delayMicroseconds(us) |
esp_rom_delay_us(us) (IDF 4+) / ets_delay_us(us) (IDF 3.x) |
::delay(ms) |
already vTaskDelay(pdMS_TO_TICKS(ms)) — keep (FreeRTOS, framework-agnostic) |
The existing ms/us split in delayMicroseconds (yield via vTaskDelay for whole ms, busy-wait the remainder) should be preserved.
clockless_block_esp32.h:90 → route through fl::platforms::delayMicroseconds (or esp_rom_delay_us directly).
IDF compat notes (3.x/4.x/5.x/6.x)
esp_timer_get_time()exists in IDF 3.x+ (esp_timer.h); on 3.x the header lives at the same include path — verify against theesp32dev_idf33CI leg.esp_rom_delay_uswas introduced with theesp_rom_*layer in IDF 4; useets_delay_us(declared inrom/ets_sys.hon 3.x/4.x,esp_rom_sys.hon 4.3+) behind theesp_version.hpredicates.- Follow the existing version-fork convention (
isr_esp32_idf{3,4,5}.hpp) if a clean single expression is not possible.
Acceptance criteria
-
platform_time_esp32.cpp.hppcompiles with noARDUINOrequirement and no Arduino globals;fl/system/arduino.hinclude (line 14) removed. - Existing Arduino CI legs (idf33 / idf44 / 5.x / idf6) stay green.
- A
-DFL_NO_ARDUINO-style compile of an ESP32 example links the time symbols (interim proof until the bare-IDF CI leg from the CI sub-issue exists). - Timing accuracy unaffected —
millis()/micros()monotonic and consistent with previous behavior (regression context: [Bug] Compounded timing inaccuracy on master compared to 3.10.3 #2420/[Bug] Compounded timing inaccuracy on master compared to 3.10.3 (Follow-up to #2420) #2994 make ESP32 timing changes sensitive; keep the change minimal).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
feat(esp8266): qualify delayMicroseconds as fl::delayMicroseconds (#3731
feat(esp32): bare-IDF fl::platforms time implementation (FastLED#3726)