From cebad901d8a0fae04bf2033d6240128699f5f87a Mon Sep 17 00:00:00 2001 From: "Dirk O. Kaar" Date: Sun, 2 Jul 2023 09:28:56 +0200 Subject: [PATCH] Add pseudo-get delay function for scheduled functions --- cores/esp8266/Schedule.cpp | 5 +++++ cores/esp8266/Schedule.h | 7 +++++++ libraries/SoftwareSerial | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/Schedule.cpp b/cores/esp8266/Schedule.cpp index 64d9767fd1..2652051a30 100644 --- a/cores/esp8266/Schedule.cpp +++ b/cores/esp8266/Schedule.cpp @@ -149,6 +149,11 @@ uint32_t get_scheduled_recurrent_delay_us() return (remaining > 0) ? static_cast(remaining) : 0; } +uint32_t get_scheduled_delay_us() +{ + return sFirst ? 0 : ~static_cast(0) >> 1; +} + void run_scheduled_functions() { // prevent scheduling of new functions during this run diff --git a/cores/esp8266/Schedule.h b/cores/esp8266/Schedule.h index 7105212bf3..56333d08e2 100644 --- a/cores/esp8266/Schedule.h +++ b/cores/esp8266/Schedule.h @@ -60,6 +60,13 @@ uint32_t get_scheduled_recurrent_delay_us(); // * Run the lambda only once next time. // * A scheduled function can schedule a function. +// get_scheduled_delay_us() is named for symmetry to get_scheduled_recurrent_delay_us, +// despite the lack of specific delay times. Therefore it can return only one of two +// values, viz. 0 in case of any pending scheduled functions, or a large delay time if +// there is no function in the queue. + +uint32_t get_scheduled_delay_us(); + bool schedule_function (const std::function& fn); // Run all scheduled functions. diff --git a/libraries/SoftwareSerial b/libraries/SoftwareSerial index 34c2803982..73fe38b788 160000 --- a/libraries/SoftwareSerial +++ b/libraries/SoftwareSerial @@ -1 +1 @@ -Subproject commit 34c28039821d7599818293f0e053737bcc6a1a89 +Subproject commit 73fe38b788a2ffc60ae44e5912ece3ee8ff3cc50