Ver código fonte

adagfxswap() renamed and localized to .cpp file to avoid collisions

Phillip Burgess 10 anos atrás
pai
commit
f5ec45e42b
3 arquivos alterados com 14 adições e 16 exclusões
  1. 13 9
      Adafruit_GFX.cpp
  2. 0 6
      Adafruit_GFX.h
  3. 1 1
      library.properties

+ 13 - 9
Adafruit_GFX.cpp

@@ -49,6 +49,10 @@ POSSIBILITY OF SUCH DAMAGE.
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #endif
 
+#ifndef _swap_int16_t
+#define _swap_int16_t(a, b) { int16_t t = a; a = b; b = t; }
+#endif
+
 Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
   WIDTH(w), HEIGHT(h)
 {
@@ -176,13 +180,13 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
  uint16_t color) {
   int16_t steep = abs(y1 - y0) > abs(x1 - x0);
   if (steep) {
-    adagfxswap(x0, y0);
-    adagfxswap(x1, y1);
+    _swap_int16_t(x0, y0);
+    _swap_int16_t(x1, y1);
   }
 
   if (x0 > x1) {
-    adagfxswap(x0, x1);
-    adagfxswap(y0, y1);
+    _swap_int16_t(x0, x1);
+    _swap_int16_t(y0, y1);
   }
 
   int16_t dx, dy;
@@ -287,13 +291,13 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
 
   // Sort coordinates by Y order (y2 >= y1 >= y0)
   if (y0 > y1) {
-    adagfxswap(y0, y1); adagfxswap(x0, x1);
+    _swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
   }
   if (y1 > y2) {
-    adagfxswap(y2, y1); adagfxswap(x2, x1);
+    _swap_int16_t(y2, y1); _swap_int16_t(x2, x1);
   }
   if (y0 > y1) {
-    adagfxswap(y0, y1); adagfxswap(x0, x1);
+    _swap_int16_t(y0, y1); _swap_int16_t(x0, x1);
   }
 
   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,
     a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
     b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
     */
-    if(a > b) adagfxswap(a,b);
+    if(a > b) _swap_int16_t(a,b);
     drawFastHLine(a, y, b-a+1, color);
   }
 
@@ -352,7 +356,7 @@ void Adafruit_GFX::fillTriangle(int16_t x0, int16_t y0,
     a = x1 + (x2 - x1) * (y - y1) / (y2 - y1);
     b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
     */
-    if(a > b) adagfxswap(a,b);
+    if(a > b) _swap_int16_t(a,b);
     drawFastHLine(a, y, b-a+1, color);
   }
 }

+ 0 - 6
Adafruit_GFX.h

@@ -10,12 +10,6 @@
 
 #include "gfxfont.h"
 
-#define adagfxswap(a, b) { int16_t t = a; a = b; b = t; }
-
-#if !defined(ESP8266)
-  #define swap(a, b) adagfxswap(a, b)
-#endif
-
 class Adafruit_GFX : public Print {
 
  public:

+ 1 - 1
library.properties

@@ -1,5 +1,5 @@
 name=Adafruit GFX Library
-version=1.1.3
+version=1.1.4
 author=Adafruit
 maintainer=Adafruit <info@adafruit.com>
 sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.