remotes/origin_old/ugfx_release_2.6
Tectu 2012-06-17 04:29:35 +02:00
parent 096e6c4ed9
commit 07d992ea1d
1 changed files with 18 additions and 18 deletions

36
glcd.c
View File

@ -4,9 +4,9 @@
#include <math.h> #include <math.h>
uint16_t lcd_width, lcd_height; uint16_t lcd_width, lcd_height;
uint16_t bgcolor=White, fgcolor=Black; uint16_t bgcolor = White, fgcolor = Black;
uint16_t cx=0, cy=0; uint16_t cx = 0, cy = 0;
static uint8_t tpText=0; static uint8_t tpText = 0;
const uint8_t* font; const uint8_t* font;
void lcdInit(void) { void lcdInit(void) {
@ -71,18 +71,18 @@ static void lcdWriteStream(uint16_t *buffer, uint16_t size) {
lld_lcdWriteStream(buffer, size); lld_lcdWriteStream(buffer, size);
} }
void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) { void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) {
int16_t dy, dx; int16_t dy, dx;
int16_t addx=1, addy=1; int16_t addx = 1, addy = 1;
int16_t P, diff; int16_t P, diff;
int16_t i=0; int16_t i = 0;
dx = abs((int16_t)(x2 - x1)); dx = abs((int16_t)(x1 - x0));
dy = abs((int16_t)(y2 - y1)); dy = abs((int16_t)(y1 - y0));
if(x1 > x2) if(x0 > x1)
addx = -1; addx = -1;
if(y1 > y2) if(y0 > y1)
addy = -1; addy = -1;
if(dx >= dy) { if(dx >= dy) {
@ -91,14 +91,14 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co
diff = P - dx; diff = P - dx;
for(; i<=dx; ++i) { for(; i<=dx; ++i) {
lcdDrawPixel(x1, y1, color); lcdDrawPixel(x0, y0, color);
if(P < 0) { if(P < 0) {
P += dy; P += dy;
x1 += addx; x0 += addx;
} else { } else {
P += diff; P += diff;
x1 += addx; x0 += addx;
y1 += addy; y0 += addy;
} }
} }
} else { } else {
@ -107,14 +107,14 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co
diff = P - dy; diff = P - dy;
for(; i<=dy; ++i) { for(; i<=dy; ++i) {
lcdDrawPixel(x1, y1, color); lcdDrawPixel(x0, y0, color);
if(P < 0) { if(P < 0) {
P += dx; P += dx;
y1 += addy; y0 += addy;
} else { } else {
P += diff; P += diff;
x1 += addx; x0 += addx;
y1 += addy; y0 += addy;
} }
} }
} }