From 26e0151fee24fee795a25b2f84c47b701beeea41 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 3 Sep 2025 16:36:49 -0500 Subject: [PATCH] Update esphome/core/scheduler.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- esphome/core/scheduler.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/esphome/core/scheduler.h b/esphome/core/scheduler.h index 7ca0bc1064..6ae6d9af57 100644 --- a/esphome/core/scheduler.h +++ b/esphome/core/scheduler.h @@ -95,9 +95,10 @@ class Scheduler { } name_; uint32_t interval; // Split time to handle millis() rollover. The scheduler combines the 32-bit millis() - // with a 16-bit rollover counter to create a 48-bit time space (stored as 64-bit - // for compatibility). With 49.7 days per 32-bit rollover, the 16-bit counter - // supports 49.7 days × 65536 = ~8900 years. This ensures correct scheduling + // with a 16-bit rollover counter to create a 48-bit time space (using 32+16 bits). + // This is intentionally limited to 48 bits, not stored as a full 64-bit value. + // With 49.7 days per 32-bit rollover, the 16-bit counter supports + // 49.7 days × 65536 = ~8900 years. This ensures correct scheduling // even when devices run for months. Split into two fields for better memory // alignment on 32-bit systems. uint32_t next_execution_low_; // Lower 32 bits of execution time (millis value)