Quellcode durchsuchen

ok its a hack to make esp8266 happier but it works! swap() already exists in the tensilica codebase

ladyada vor 10 Jahren
Ursprung
Commit
944f3d9d9f
2 geänderte Dateien mit 15 neuen und 10 gelöschten Zeilen
  1. 9 9
      Adafruit_GFX.cpp
  2. 6 1
      Adafruit_GFX.h

+ 9 - 9
Adafruit_GFX.cpp

@@ -172,13 +172,13 @@ void Adafruit_GFX::drawLine(int16_t x0, int16_t y0,
 			    uint16_t color) {
   int16_t steep = abs(y1 - y0) > abs(x1 - x0);
   if (steep) {
-    swap(x0, y0);
-    swap(x1, y1);
+    adagfxswap(x0, y0);
+    adagfxswap(x1, y1);
   }
 
   if (x0 > x1) {
-    swap(x0, x1);
-    swap(y0, y1);
+    adagfxswap(x0, x1);
+    adagfxswap(y0, y1);
   }
 
   int16_t dx, dy;
@@ -286,13 +286,13 @@ void Adafruit_GFX::fillTriangle ( int16_t x0, int16_t y0,
 
   // Sort coordinates by Y order (y2 >= y1 >= y0)
   if (y0 > y1) {
-    swap(y0, y1); swap(x0, x1);
+    adagfxswap(y0, y1); adagfxswap(x0, x1);
   }
   if (y1 > y2) {
-    swap(y2, y1); swap(x2, x1);
+    adagfxswap(y2, y1); adagfxswap(x2, x1);
   }
   if (y0 > y1) {
-    swap(y0, y1); swap(x0, x1);
+    adagfxswap(y0, y1); adagfxswap(x0, x1);
   }
 
   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,
     a = x0 + (x1 - x0) * (y - y0) / (y1 - y0);
     b = x0 + (x2 - x0) * (y - y0) / (y2 - y0);
     */
-    if(a > b) swap(a,b);
+    if(a > b) adagfxswap(a,b);
     drawFastHLine(a, y, b-a+1, color);
   }
 
@@ -351,7 +351,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) swap(a,b);
+    if(a > b) adagfxswap(a,b);
     drawFastHLine(a, y, b-a+1, color);
   }
 }

+ 6 - 1
Adafruit_GFX.h

@@ -8,7 +8,12 @@
  #include "WProgram.h"
 #endif
 
-#define swap(a, b) { int16_t t = a; a = b; b = t; }
+
+#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 {