ESP8266: use optimistic_yield in line, circle, ellipse and soft SPI fills

yield() panics when drawing from a timer or Ticker callback (#285).
optimistic_yield(10000) still yields on long draws so the watchdog
stays fed, and does nothing where yielding is not allowed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikey SklarandClaude Opus 5.5 committed 2026-10-16 16:42:02 -07:00
1 parent 9b7f8ef181
commit d9e22fb62e
2 files changed
+5 -5

No files matched your search

+4 -4
View File
@@ -132,7 +132,7 @@ Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h) : WIDTH(w), HEIGHT(h) {
void Adafruit_GFX::writeLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
uint16_t color) {
#if defined(ESP8266)
yield();
optimistic_yield(10000);
#endif
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
if (steep) {
@@ -358,7 +358,7 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
void Adafruit_GFX::drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
uint16_t color) {
#if defined(ESP8266)
yield();
optimistic_yield(10000);
#endif
// Bresenham's ellipse algorithm
int16_t x = 0, y = rh;
@@ -417,7 +417,7 @@ void Adafruit_GFX::drawEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
void Adafruit_GFX::fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
uint16_t color) {
#if defined(ESP8266)
yield();
optimistic_yield(10000);
#endif
// Bresenham's ellipse algorithm
int16_t x = 0, y = rh;
@@ -472,7 +472,7 @@ void Adafruit_GFX::fillEllipse(int16_t x0, int16_t y0, int16_t rw, int16_t rh,
void Adafruit_GFX::drawCircle(int16_t x0, int16_t y0, int16_t r,
uint16_t color) {
#if defined(ESP8266)
yield();
optimistic_yield(10000);
#endif
int16_t f = 1 - r;
int16_t ddF_x = 1;
+1 -1
View File
@@ -1436,7 +1436,7 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) {
if (pixelsThisPass > 20000)
pixelsThisPass = 20000;
len -= pixelsThisPass;
yield(); // Periodic yield() on long fills
optimistic_yield(10000); // Yield if 10 ms since last yield
while (pixelsThisPass--) {
for (uint16_t bit = 0, x = color; bit < 16; bit++) {
if (x & 0x8000)