Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit538025a

Browse files
committed
Simplified roll-over logic
1 parent717f4ad commit538025a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

‎cores/esp8266/Schedule.cpp‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
126126
// prevent new item overwriting an already expired rTarget.
127127
constauto now =micros();
128128
constauto itemRemaining = item->callNow.remaining();
129-
constint32_t remaining = rTarget - now;
130-
if (!rFirst || (remaining>0 &&static_cast<decltype(micros())>(remaining) > itemRemaining))
129+
constauto remaining = rTarget - now;
130+
if (!rFirst || (remaining<= HALF_MAX_MICROS && remaining > itemRemaining))
131131
{
132132
rTarget = now + itemRemaining;
133133
}
@@ -149,8 +149,9 @@ decltype(micros()) get_scheduled_recurrent_delay_us()
149149
{
150150
if (!rFirst)return HALF_MAX_MICROS;
151151
// handle already expired rTarget.
152-
constint32_t remaining = rTarget -micros();
153-
return (remaining >0) ?static_cast<decltype(micros())>(remaining) :0;
152+
constauto now =micros();
153+
constauto remaining = rTarget - now;
154+
return (remaining <= HALF_MAX_MICROS) ? remaining :0;
154155
}
155156

156157
decltype(micros()) get_scheduled_delay_us()
@@ -262,8 +263,8 @@ void run_scheduled_recurrent_functions()
262263
// prevent current item overwriting an already expired rTarget.
263264
constauto now =micros();
264265
constauto currentRemaining = current->callNow.remaining();
265-
constint32_t remaining = rTarget - now;
266-
if (remaining>0 &&static_cast<decltype(micros())>(remaining) > currentRemaining)
266+
constauto remaining = rTarget - now;
267+
if (remaining<= HALF_MAX_MICROS && remaining > currentRemaining)
267268
{
268269
rTarget = now + currentRemaining;
269270
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp