mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 15:46:54 +00:00
357835cc20226bf5a01ccc72e6aa93e8cb8d049d
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)
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%
