From 3be667c90e2ef8f1de5f85b16a7b78d6e910e2f7 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 16:17:22 +0530 Subject: [PATCH 1/6] Critical Bug fix in Text Rendering function --- glcd.c | 8 ++++---- glcd.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) 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; } } diff --git a/glcd.h b/glcd.h index 65c5ef3f..69d5c6ed 100644 --- a/glcd.h +++ b/glcd.h @@ -35,7 +35,7 @@ enum transparency {solid, transparent}; // For text rendering only extern uint16_t bgcolor, fgcolor; extern uint16_t cx, cy; -extern uint8_t* font; +extern const uint8_t* font; // A few macros #define lcdGotoXY(x,y) { cx=x; cy=y; } @@ -55,7 +55,7 @@ void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color); void lcdSetFontTransparency(uint8_t transparency); -void lcdSetFont(uint8_t *fnt); +void lcdSetFont(const uint8_t *fnt); void lcdDrawChar(char c); void lcdPutString(const char *str); void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor); From 452bfcc059918e1b10c64ad81d224f9684540ce6 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 14 Jun 2012 12:16:34 +0200 Subject: [PATCH 2/6] cleanups --- glcd.c | 5 +++++ glcd.h | 4 ++++ 2 files changed, 9 insertions(+) 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) { diff --git a/glcd.h b/glcd.h index 69d5c6ed..c67541c9 100644 --- a/glcd.h +++ b/glcd.h @@ -55,7 +55,11 @@ void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color); void lcdSetFontTransparency(uint8_t transparency); +<<<<<<< HEAD void lcdSetFont(const uint8_t *fnt); +======= +void lcdSetFont(const uint8_t *newFont); +>>>>>>> cleanups void lcdDrawChar(char c); void lcdPutString(const char *str); void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor); From da7493da8b6fde878b675a4a1090b7bd99d4bf48 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 14 Jun 2012 12:21:58 +0200 Subject: [PATCH 3/6] cleanup --- glcd.c | 95 +++++++++++++++++++++++++--------------------------------- 1 file changed, 41 insertions(+), 54 deletions(-) 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 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)); + 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(x1 > x2) + addx = -1; + if(y1 > y2) + addy = -1; - if(dx >= dy) - { - dy *= 2; - P = dy - dx; - diff = P - dx; + if(dx >= dy) { + dy *= 2; + P = dy - dx; + diff = P - dx; - for(; i<=dx; ++i) - { - lcdDrawPixel(x1, y1, color); + 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; - 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; - } - } - } + for(; i<=dy; ++i) { + lcdDrawPixel(x1, y1, color); + if(P < 0) { + P += dx; + y1 += addy; + } else { + P += diff; + x1 += addx; + y1 += addy; + } + } + } } <<<<<<< HEAD From be23213164d2373631328e13e4aa8d5c02512158 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 17:11:23 +0530 Subject: [PATCH 4/6] Critical Bug fixed in text rendering function Still only portrait Orientation is supported byS6D1121. Added stubs --- drivers/s6d1121_lld.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/s6d1121_lld.c b/drivers/s6d1121_lld.c index aa13169e..dfadc19d 100644 --- a/drivers/s6d1121_lld.c +++ b/drivers/s6d1121_lld.c @@ -96,13 +96,9 @@ void lcdWriteData(uint16_t lcdData) { void lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { LCD_CS_LOW; - LCD_RS_LOW; - lld_lcdwrite(lcdReg); - - LCD_RS_HIGH; - - lld_lcdwrite(lcdRegValue); + lcdWriteIndex(lcdReg); + lcdWriteData(lcdRegValue); LCD_CS_HIGH; } @@ -215,26 +211,22 @@ void lld_lcdSetOrientation(uint8_t newOrientation) { switch(orientation) { case portrait: - lcdWriteReg(0x0001, 0x2B3F); - lcdWriteReg(0x0011, 0x6070); + lcdWriteReg(0x03, 0x03); lcd_height = SCREEN_HEIGHT; lcd_width = SCREEN_WIDTH; break; case landscape: - lcdWriteReg(0x0001, 0x293F); - lcdWriteReg(0x0011, 0x6078); + // Not implemented yet lcd_height = SCREEN_WIDTH; lcd_width = SCREEN_HEIGHT; break; case portraitInv: - lcdWriteReg(0x0001, 0x693F); - lcdWriteReg(0x0011, 0x6040); + // Not implemented yet lcd_height = SCREEN_HEIGHT; lcd_width = SCREEN_WIDTH; break; case landscapeInv: - lcdWriteReg(0x0001, 0x6B3F); - lcdWriteReg(0x0011, 0x6048); + // Not implemented yet lcd_height = SCREEN_WIDTH; lcd_width = SCREEN_HEIGHT; break; From 01179bb945790e349f8c872991074fe52da40772 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 17:14:05 +0530 Subject: [PATCH 5/6] Sync repo --- glcd.c | 5 ----- 1 file changed, 5 deletions(-) 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) { From 04fdc1a2563342b142cf3d1fe7808fae286e27e0 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 14 Jun 2012 17:16:32 +0530 Subject: [PATCH 6/6] Sync repo again --- glcd.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/glcd.h b/glcd.h index c67541c9..75c47457 100644 --- a/glcd.h +++ b/glcd.h @@ -55,11 +55,7 @@ void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color); void lcdSetFontTransparency(uint8_t transparency); -<<<<<<< HEAD -void lcdSetFont(const uint8_t *fnt); -======= void lcdSetFont(const uint8_t *newFont); ->>>>>>> cleanups void lcdDrawChar(char c); void lcdPutString(const char *str); void lcdDrawString(uint16_t x, uint16_t y, const char *str, uint16_t color, uint16_t bkcolor);