From 3be667c90e2ef8f1de5f85b16a7b78d6e910e2f7 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 16:17:22 +0530 Subject: Critical Bug fix in Text Rendering function --- glcd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'glcd.c') diff --git a/glcd.c b/glcd.c index f50c696d..42685439 100644 --- a/glcd.c +++ b/glcd.c @@ -5,9 +5,9 @@ uint16_t lcd_width, lcd_height; uint16_t bgcolor=White, fgcolor=Black; -uint16_t cx, cy; +uint16_t cx=0, cy=0; static uint8_t tpText=0; -uint8_t* font; +const uint8_t* font; void lcdInit(void) { lld_lcdInit(); @@ -117,7 +117,7 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co } } -void lcdSetFont(uint8_t *fnt) { +void lcdSetFont(const uint8_t *fnt) { font = fnt; } @@ -164,7 +164,7 @@ void lcdDrawChar(char c) { cx += fontWidth; if(sps != 0) { if(!tpText) - lcdFillArea(cx, cy, sps, fontHeight, fgcolor); + lcdFillArea(cx, cy, cx+sps, cy+fontHeight, bgcolor); cx += sps; } } -- cgit v1.2.3 From 452bfcc059918e1b10c64ad81d224f9684540ce6 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 14 Jun 2012 12:16:34 +0200 Subject: cleanups --- glcd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'glcd.c') diff --git a/glcd.c b/glcd.c index 42685439..e8498961 100644 --- a/glcd.c +++ b/glcd.c @@ -117,8 +117,13 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co } } +<<<<<<< HEAD void lcdSetFont(const uint8_t *fnt) { font = fnt; +======= +void lcdSetFont(const uint8_t *newFont) { + font = newFont; +>>>>>>> cleanups } void lcdSetFontTransparency(uint8_t transparency) { -- cgit v1.2.3 From da7493da8b6fde878b675a4a1090b7bd99d4bf48 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 14 Jun 2012 12:21:58 +0200 Subject: cleanup --- glcd.c | 105 +++++++++++++++++++++++++++++------------------------------------ 1 file changed, 46 insertions(+), 59 deletions(-) (limited to 'glcd.c') diff --git a/glcd.c b/glcd.c index e8498961..34ff53d0 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; + } + } + } } <<<<<<< HEAD -- cgit v1.2.3 From 01179bb945790e349f8c872991074fe52da40772 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 17:14:05 +0530 Subject: Sync repo --- glcd.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'glcd.c') diff --git a/glcd.c b/glcd.c index 34ff53d0..8c86c8cf 100644 --- a/glcd.c +++ b/glcd.c @@ -104,13 +104,8 @@ void lcdDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t co } } -<<<<<<< HEAD -void lcdSetFont(const uint8_t *fnt) { - font = fnt; -======= void lcdSetFont(const uint8_t *newFont) { font = newFont; ->>>>>>> cleanups } void lcdSetFontTransparency(uint8_t transparency) { -- cgit v1.2.3