aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTectu <joel@unormal.org>2012-06-14 12:21:58 +0200
committerTectu <joel@unormal.org>2012-06-14 12:21:58 +0200
commitcd7682c2c3d174ccd7e2b3acfec048917ec102dc (patch)
tree36fb88452ab687cdb5df5dd92f943a908f19412f
parent76fafb7dbbd8d1c45682fa3a84dcd2232ebb615c (diff)
downloaduGFX-cd7682c2c3d174ccd7e2b3acfec048917ec102dc.tar.gz
uGFX-cd7682c2c3d174ccd7e2b3acfec048917ec102dc.tar.bz2
uGFX-cd7682c2c3d174ccd7e2b3acfec048917ec102dc.zip
cleanup
-rw-r--r--glcd.c105
1 files changed, 46 insertions, 59 deletions
diff --git a/glcd.c b/glcd.c
index b7b27c34..2aca18f9 100644
--- a/glcd.c
+++ b/glcd.c
@@ -56,65 +56,52 @@ void lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) {
}
void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) {
- int16_t dy, dx;
- int16_t addx=1, addy=1;
- int16_t P, diff;
-
- int16_t i=0;
- dx = abs((int16_t)(x2 - x1));
- dy = abs((int16_t)(y2 - y1));
-
- if(x1 > x2)
- addx = -1;
- if(y1 > y2)
- addy = -1;
-
- if(dx >= dy)
- {
- dy *= 2;
- P = dy - dx;
- diff = P - dx;
-
- for(; i<=dx; ++i)
- {
- lcdDrawPixel(x1, y1, color);
-
- if(P < 0)
- {
- P += dy;
- x1 += addx;
- }
- else
- {
- P += diff;
- x1 += addx;
- y1 += addy;
- }
- }
- }
- else
- {
- dx *= 2;
- P = dx - dy;
- diff = P - dy;
-
- for(; i<=dy; ++i)
- {
- lcdDrawPixel(x1, y1, color);
-
- if(P < 0)
- {
- P += dx;
- y1 += addy;
- }
- else
- {
- P += diff;
- x1 += addx;
- y1 += addy;
- }
- }
- }
+ int16_t dy, dx;
+ int16_t addx=1, addy=1;
+ int16_t P, diff;
+
+ int16_t i=0;
+ dx = abs((int16_t)(x2 - x1));
+ dy = abs((int16_t)(y2 - y1));
+
+ if(x1 > x2)
+ addx = -1;
+ if(y1 > y2)
+ addy = -1;
+
+ if(dx >= dy) {
+ dy *= 2;
+ P = dy - dx;
+ diff = P - dx;
+
+ for(; i<=dx; ++i) {
+ lcdDrawPixel(x1, y1, color);
+ if(P < 0) {
+ P += dy;
+ x1 += addx;
+ } else {
+ P += diff;
+ x1 += addx;
+ y1 += addy;
+ }
+ }
+ } else {
+ dx *= 2;
+ P = dx - dy;
+ diff = P - dy;
+
+ for(; i<=dy; ++i) {
+ lcdDrawPixel(x1, y1, color);
+ if(P < 0) {
+ P += dx;
+ y1 += addy;
+ } else {
+ P += diff;
+ x1 += addx;
+ y1 += addy;
+ }
+ }
+ }
}
void lcdSetFont(const uint8_t *newFont) {