Skip to content

Commit

Permalink
Basic fix for issue adafruit#23
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
digidigital authored May 25, 2017
1 parent cef439b commit 7cf7fbf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Adafruit_Thermal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down

0 comments on commit 7cf7fbf

Please sign in to comment.