10000 delay / esp_delay: transparently manage recurrent scheduled functions by d-a-v · Pull Request #8802 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

delay / esp_delay: transparently manage recurrent scheduled functions #8802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
rename global function
  • Loading branch information
d-a-v committed Jan 14, 2023
commit 4f5eb32ca0bedddf7c4d0da8f166178635b67a1d
2 changes: 1 addition & 1 deletion cores/esp8266/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ bool schedule_recurrent_function_us(const std::function<bool(void)>& fn,
return true;
}

uint32_t compute_recurrent_grain ()
uint32_t compute_scheduled_recurrent_grain ()
{
if (recurrent_max_grain_mS == 0)
{
Expand Down
6 changes: 3 additions & 3 deletions cores/esp8266/Schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
// scheduled function happen more often: every yield() (vs every loop()),
// and time resolution is microsecond (vs millisecond). Details are below.

// compute_recurrent_grain() is used by delay() to give a chance to all
// recurrent functions to run per their timing requirement.
// compute_scheduled_recurrent_grain() is used by delay() to give a chance to
// all recurrent functions to run per their timing requirement.

uint32_t compute_recurrent_grain ();
uint32_t compute_scheduled_recurrent_grain ();

// scheduled functions called once:
//
Expand Down
2 changes: 1 addition & 1 deletion cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ bool esp_try_delay(const uint32_t start_ms, const uint32_t timeout_ms, const uin
}

// compute greatest chunked delay with respect to scheduled recurrent functions
uint32_t grain_ms = std::gcd(intvl_ms, compute_recurrent_grain());
uint32_t grain_ms = std::gcd(intvl_ms, compute_scheduled_recurrent_grain());

// recurrent scheduled functions will be called from esp_delay()->esp_suspend()
esp_delay(grain_ms > 0 ?
Expand Down
0