From 2a101832ca5e03d4296a1000282e6e70a401e47c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 26 Feb 2026 22:59:29 -1000 Subject: [PATCH] Address review feedback - Remove unnecessary uint64_t cast on esp_timer_get_time() (already returns int64_t, always non-negative after boot) - Fix next_schedule_in @param comment: now is only unused on ESP32, used for rollover tracking on other platforms - Use fully-qualified friend declaration (::esphome::millis_64()) --- esphome/components/esp32/core.cpp | 2 +- esphome/core/scheduler.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/esp32/core.cpp b/esphome/components/esp32/core.cpp index b9ae871abf..501dd7d2ea 100644 --- a/esphome/components/esp32/core.cpp +++ b/esphome/components/esp32/core.cpp @@ -23,7 +23,7 @@ namespace esphome { void HOT yield() { vPortYield(); } uint32_t IRAM_ATTR HOT millis() { return (uint32_t) (esp_timer_get_time() / 1000ULL); } -uint64_t HOT millis_64() { return static_cast(esp_timer_get_time()) / 1000ULL; } +uint64_t HOT millis_64() { return esp_timer_get_time() / 1000; } void HOT delay(uint32_t ms) { vTaskDelay(ms / portTICK_PERIOD_MS); } uint32_t IRAM_ATTR HOT micros() { return (uint32_t) esp_timer_get_time(); } void IRAM_ATTR HOT delayMicroseconds(uint32_t us) { delay_microseconds_safe(us); } diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index fa95484e7f..c61bd40f7c 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -121,7 +121,7 @@ class Scheduler { uint64_t millis_64() { return esphome::millis_64(); } // Calculate when the next scheduled item should run - // @param now Unused, kept for API compatibility + // @param now On ESP32, unused (native 64-bit); on other platforms, extended to 64-bit via rollover tracking // Returns the time in milliseconds until the next scheduled item, or nullopt if no items // This method performs cleanup of removed items before checking the schedule // IMPORTANT: This method should only be called from the main thread (loop task). @@ -299,7 +299,7 @@ class Scheduler { // On non-ESP32 platforms, millis_64() HAL function delegates to this method // which tracks 32-bit millis() rollover using millis_major_ and last_millis_. // On ESP32, millis_64() uses esp_timer_get_time() directly. - friend uint64_t millis_64(); + friend uint64_t ::esphome::millis_64(); uint64_t millis_64_impl_(uint32_t now); #endif // Cleanup logically deleted items from the scheduler