Skip to content

Commit 7e429cc

Browse files
committed
Reset() was wrecked by resetting _timeout. Reverted.
1 parent 36241a9 commit 7e429cc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

cores/esp8266/PolledTimeout.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class timeoutTemplate
176176

177177
bool canWait () const
178178
{
179-
return _timeout != alwaysExpired;
179+
return _timeout != alwaysExpired && !_oneShotExpired;
180180
}
181181

182182
// Resets, will trigger after this new timeout.
@@ -193,6 +193,7 @@ class timeoutTemplate
193193
void reset()
194194
{
195195
_start = TimePolicyT::time();
196+
_oneShotExpired = false;
196197
}
197198

198199
// Resets to just expired so that on next poll the check will immediately trigger for the user,
@@ -245,8 +246,8 @@ class timeoutTemplate
245246
bool checkExpired(const timeType internalUnit) const
246247
{
247248
// canWait() is not checked here
248-
// returns "can expire" and "time expired"
249-
return (!_neverExpires) && ((internalUnit - _start) >= _timeout);
249+
// returns "can expire" and "oneshot not expired" and "time expired"
250+
return (_oneShotExpired) || ((!_neverExpires) && ((internalUnit - _start) >= _timeout));
250251
}
251252

252253
protected:
@@ -274,7 +275,7 @@ class timeoutTemplate
274275
if (!canWait()) return true;
275276
if (checkExpired(TimePolicyT::time()))
276277
{
277-
_timeout = alwaysExpired;
278+
_oneShotExpired = true;
278279
return true;
279280
}
280281
return false;
@@ -283,6 +284,7 @@ class timeoutTemplate
283284
timeType _timeout;
284285
timeType _start;
285286
bool _neverExpires;
287+
bool _oneShotExpired;
286288
};
287289

288290
// legacy type names, deprecated (unit is milliseconds)

0 commit comments

Comments
 (0)