Skip to content

Commit 33d4d7f

Browse files
committed
Use µs resolution in Ticker from Schedule
1 parent 139acbe commit 33d4d7f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

cores/esp32/Schedule.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
typedef std::function<bool(void)> mFuncT;
1313

14-
constexpr uint32_t TICKER_MIN_US = 5000;
15-
1614
struct scheduled_fn_t
1715
{
1816
mFuncT mFunc = nullptr;
@@ -58,8 +56,7 @@ namespace {
5856

5957
void ticker_scheduled(SchedulerTicker* ticker, const std::function<bool(void)>& fn, uint32_t repeat_us, schedule_e policy)
6058
{
61-
auto repeat_ms = (repeat_us + 500) / 1000;
62-
ticker->once_ms(repeat_ms, [ticker, fn, repeat_us, policy]()
59+
ticker->once_us(repeat_us, [ticker, fn, repeat_us, policy]()
6360
{
6461
if (!schedule_function([ticker, fn, repeat_us, policy]()
6562
{
@@ -72,6 +69,12 @@ namespace {
7269
}
7370
});
7471
}
72+
73+
#ifdef ESP8266
74+
constexpr uint32_t TICKER_MIN_US = 5000;
75+
#else
76+
constexpr uint32_t TICKER_MIN_US = 5000;
77+
#endif
7578
};
7679

7780
bool IRAM_ATTR schedule_function_us(std::function<bool(void)>&& fn, uint32_t repeat_us, schedule_e policy)

0 commit comments

Comments
 (0)