From 5f9705d1b702bc5aef353fa8e063f73bb8236d59 Mon Sep 17 00:00:00 2001 From: Neil McKechnie Date: Fri, 10 Feb 2023 15:30:35 +0000 Subject: [PATCH] Improve IODevice::reset function Ensure that the _loop() function is able to run after a device is reset. --- IODevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/IODevice.cpp b/IODevice.cpp index 32e6445..e907c23 100644 --- a/IODevice.cpp +++ b/IODevice.cpp @@ -76,7 +76,12 @@ void IODevice::begin() { // reset() function to reinitialise all devices void IODevice::reset() { + unsigned long currentMicros = micros(); for (IODevice *dev = _firstDevice; dev != NULL; dev = dev->_nextDevice) { + dev->_deviceState = DEVSTATE_DORMANT; + // First ensure that _loop isn't delaying + dev->delayUntil(currentMicros); + // Then invoke _begin to restart driver dev->_begin(); } }