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

Commita09726d

Browse files
committed
Fix millis/micros mismatch.
1 parenteaf05e9 commita09726d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

‎cores/esp8266/Schedule.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
120120
item->alarm = alarm;
121121

122122
// prevent new item overwriting an already expired rTarget.
123-
constint32_t rRemaining = rTarget -millis();
123+
constint32_t rRemaining = rTarget -micros();
124124
if (!rFirst || (rRemaining >0 &&static_cast<uint32_t>(rRemaining) > item->callNow.remaining()))
125125
{
126-
rTarget =millis() + item->callNow.remaining();
126+
rTarget =micros() + item->callNow.remaining();
127127
}
128128

129129
esp8266::InterruptLock lockAllInterruptsInThisScope;
@@ -141,11 +141,11 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
141141
returntrue;
142142
}
143143

144-
uint32_tget_scheduled_recurrent_delay()
144+
uint32_tget_scheduled_recurrent_delay_us()
145145
{
146146
if (!rFirst)return ~static_cast<uint32_t>(0);
147147
// handle already expired rTarget.
148-
constint32_t rRemaining = rTarget -millis();
148+
constint32_t rRemaining = rTarget -micros();
149149
return (rRemaining >0) ?static_cast<uint32_t>(rRemaining) :0;
150150
}
151151

@@ -209,7 +209,7 @@ void run_scheduled_recurrent_functions()
209209
fence =true;
210210
}
211211

212-
rTarget =millis() + current->callNow.remaining();
212+
rTarget =micros() + current->callNow.remaining();
213213
recurrent_fn_t* prev =nullptr;
214214
// prevent scheduling of new functions during this run
215215
auto stop = rLast;
@@ -249,10 +249,10 @@ void run_scheduled_recurrent_functions()
249249
prev = current;
250250
current = current->mNext;
251251
// prevent current item overwriting an already expired rTarget.
252-
constint32_t rRemaining = rTarget -millis();
252+
constint32_t rRemaining = rTarget -micros();
253253
if (rRemaining >0 &&static_cast<uint32_t>(rRemaining) > current->callNow.remaining())
254254
{
255-
rTarget =millis() + current->callNow.remaining();
255+
rTarget =micros() + current->callNow.remaining();
256256
}
257257
}
258258

‎cores/esp8266/Schedule.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
// scheduled function happen more often: every yield() (vs every loop()),
4040
// and time resolution is microsecond (vs millisecond). Details are below.
4141

42-
//get_scheduled_recurrent_delay() is used by delay() to give a chance to
42+
//get_scheduled_recurrent_delay_us() is used by delay() to give a chance to
4343
// all recurrent functions to run per their timing requirement.
4444

45-
uint32_tget_scheduled_recurrent_delay();
45+
uint32_tget_scheduled_recurrent_delay_us();
4646

4747
// scheduled functions called once:
4848
//

‎cores/esp8266/core_esp8266_main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uin
174174
}
175175

176176
// compute greatest delay interval with respect to scheduled recurrent functions
177-
constuint32_t max_delay_ms =std::min(intvl_ms,get_scheduled_recurrent_delay());
177+
constuint32_t max_delay_ms =std::min(intvl_ms,get_scheduled_recurrent_delay_us() /1000);
178178

179179
// recurrent scheduled functions will be called from esp_delay()->esp_suspend()
180180
esp_delay(std::min((timeout_ms - expired), max_delay_ms));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp