From 7cf7fbfe3bab89c3e396011130e348e2fe31d402 Mon Sep 17 00:00:00 2001 From: digidigital Date: Thu, 25 May 2017 22:56:59 +0200 Subject: [PATCH] Basic fix for issue #23 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding yield() enables the ESP8266 to do other things while waiting and prevents reboots due to watchdog timer timeouts.. I had a hard tme to find out that the while-loop was the cause for the reboots.... That´s exactly what yield() is for -> Passes control to other tasks when called. Ideally yield() should be used in functions that will take awhile to complete. --- Adafruit_Thermal.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Adafruit_Thermal.cpp b/Adafruit_Thermal.cpp index cd84653..fb908f2 100644 --- a/Adafruit_Thermal.cpp +++ b/Adafruit_Thermal.cpp @@ -66,9 +66,9 @@ void Adafruit_Thermal::timeoutSet(unsigned long x) { // This function waits (if necessary) for the prior task to complete. void Adafruit_Thermal::timeoutWait() { if(dtrEnabled) { - while(digitalRead(dtrPin) == HIGH); + while(digitalRead(dtrPin) == HIGH){yield();}; } else { - while((long)(micros() - resumeTime) < 0L); // (syntax is rollover-proof) + while((long)(micros() - resumeTime) < 0L){yield();}; // (syntax is rollover-proof) } }