Skip to content

Commit f5ec45e

Browse files
adagfxswap() renamed and localized to .cpp file to avoid collisions
1 parent 93dde8b commit f5ec45e

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Adafruit_GFX.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ POSSIBILITY OF SUCH DAMAGE.
4949
#define min(a,b) (((a) < (b)) ? (a) : (b))
5050
#endif
5151

52+
#ifndef _swap_int16_t
53+
#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
54+
#endif
55+
5256
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
5357
WIDTH(w), HEIGHT(h)
5458
{
@@ -176,13 +180,13 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
176180
uint16_t color) {
177181
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
178182
if (steep) {
179-
adagfxswap(x0, y0);
180-
adagfxswap(x1, y1);
183+
_swap_int16_t(x0, y0);
184+
_swap_int16_t(x1, y1);
181185
}
182186

183187
if (x0 > x1) {
184-
adagfxswap(x0, x1);
185-
adagfxswap(y0, y1);
188+
_swap_int16_t(x0, x1);
189+
_swap_int16_t(y0, y1);
186190
}
187191

188192
int16_t dx, dy;
@@ -287,13 +291,13 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
287291

288292
// Sort coordinates by Y order (y2 >= y1 >= y0)
289293
if (y0 > y1) {
290-
adagfxswap(y0, y1); adagfxswap(x0, x1);
294+
_swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
291295
}
292296
if (y1 > y2) {
293-
adagfxswap(y2, y1); adagfxswap(x2, x1);
297+
_swap_int16_t(y2, y1); _swap_int16_t(x2, x1);
294298
}
295299
if (y0 > y1) {
296-
adagfxswap(y0, y1); adagfxswap(x0, x1);
300+
_swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
297301
}
298302

299303
if(y0 == y2) { // Handle awkward all-on-same-line case as its own thing
@@ -335,7 +339,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
335339
a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
336340
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
337341
*/
338-
if(a > b) adagfxswap(a,b);
342+
if(a > b) _swap_int16_t(a,b);
339343
drawFastHLine(a, y, b-a+1, color);
340344
}
341345

@@ -352,7 +356,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
352356
a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
353357
b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
354358
*/
355-
if(a > b) adagfxswap(a,b);
359+
if(a > b) _swap_int16_t(a,b);
356360
drawFastHLine(a, y, b-a+1, color);
357361
}
358362
}

Adafruit_GFX.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
#include "gfxfont.h"
1212

13-
#define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }
14-
15-
#if !defined(ESP8266)
16-
#define swap(a, b) adagfxswap(a, b)
17-
#endif
18-
1913
class Adafruit_GFX : public Print {
2014

2115
public:

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit GFX Library
2-
version=1.1.3
2+
version=1.1.4
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.

0 commit comments

Comments
 (0)