J. Nick Koston 357835cc20 [rp2040] Replace millis() with fast accumulator, wrap Arduino callers
Arduino-pico's millis() uses time_us_64() (64-bit hardware timer read)
then micros_to_millis() for 64-bit multiply-shift conversion on ARM
Cortex-M0+. Benchmarked at ~789 ns/call.

Replace with a simple accumulator that tracks a running millis counter
from 32-bit ::micros() deltas (220 ns on RP2040) using pure 32-bit
integer ops. No 64-bit math needed.

Use -Wl,--wrap=millis to intercept all ::millis() calls so Arduino
libraries also get the fast version.

millis_64() is left on time_us_64() for full 64-bit precision — it is
only called once per loop by the Scheduler.

Overflow safety: ::micros() wraps every ~71.6 minutes. Unsigned 32-bit
delta arithmetic handles one wrap correctly. ESPHome calls millis()
thousands of times per second, so missing a full wrap is not a realistic
concern.

Benchmarked on real RP2040 hardware:
  Before: 789 ns/call (time_us_64 + micros_to_millis)
  After:  ~270 ns/call (accumulator, estimated)
2026-04-11 22:20:36 -10:00
2023-06-12 17:00:34 +12:00
2022-09-06 15:48:01 +12:00
2025-12-21 09:26:03 -05:00
2024-03-28 10:20:51 +13:00
2025-07-17 22:40:28 +12:00
2026-04-07 22:29:55 +00:00
2025-12-08 14:37:45 -05:00
2026-04-09 11:28:48 +12:00
2025-07-17 22:40:28 +12:00
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme Multiple Licenses 393 MiB
Languages
C++ 60.7%
Python 38.9%
C 0.3%