Skip to content

Commit 944f3d9

Browse files
committed
ok its a hack to make esp8266 happier but it works! swap() already exists in the tensilica codebase
1 parent 0acee33 commit 944f3d9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

Adafruit_GFX.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
172172
uint16_t color) {
173173
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
174174
if (steep) {
175-
swap(x0, y0);
176-
swap(x1, y1);
175+
adagfxswap(x0, y0);
176+
adagfxswap(x1, y1);
177177
}
178178

179179
if (x0 > x1) {
180-
swap(x0, x1);
181-
swap(y0, y1);
180+
adagfxswap(x0, x1);
181+
adagfxswap(y0, y1);
182182
}
183183

184184
int16_t dx, dy;
@@ -286,13 +286,13 @@ void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
286286

287287
// Sort coordinates by Y order (y2 >= y1 >= y0)
288288
if (y0 > y1) {
289-
swap(y0, y1); swap(x0, x1);
289+
adagfxswap(y0, y1); adagfxswap(x0, x1);
290290
}
291291
if (y1 > y2) {
292-
swap(y2, y1); swap(x2, x1);
292+
adagfxswap(y2, y1); adagfxswap(x2, x1);
293293
}
294294
if (y0 > y1) {
295-
swap(y0, y1); swap(x0, x1);
295+
adagfxswap(y0, y1); adagfxswap(x0, x1);
296296
}
297297

298298
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
@@ -334,7 +334,7 @@ void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
334334
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
335335
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
336336
*/
337-
if(a > b) swap(a,b);
337+
if(a > b) adagfxswap(a,b);
338338
drawFastHLine(a, y, b-a+1, color);
339339
}
340340

@@ -351,7 +351,7 @@ void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
351351
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
352352
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
353353
*/
354-
if(a > b) swap(a,b);
354+
if(a > b) adagfxswap(a,b);
355355
drawFastHLine(a, y, b-a+1, color);
356356
}
357357
}

Adafruit_GFX.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88
#include "WProgram.h"
99
#endif
1010

11-
#define swap(a, b) { int16_t t = a; a = b; b = t; }
11+
12+
#define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }
13+
14+
#if !defined(ESP8266)
15+
#define swap(a, b) adagfxswap(a, b)
16+
#endif
1217

1318
class Adafruit_GFX : public Print {
1419

0 commit comments

Comments
 (0)