Behrooz Abdi
/
Tiger_LCD
Landtiger (LPC1768) graphics LCD demo.
Diff: GLCD_LPC1700.cpp
- Revision:
- 2:43ede88fb5a3
- Parent:
- 1:ea0f7b1c5daf
- Child:
- 3:2dccfa0121de
--- a/GLCD_LPC1700.cpp Sun Nov 04 18:13:01 2012 +0000 +++ b/GLCD_LPC1700.cpp Tue Nov 06 21:39:33 2012 +0000 @@ -1,5 +1,5 @@ /******************************************************************************/ -/* GLCD_LPC1700 low-level Graphic LCD (320x240 pixels) for LandTiger */ +/* GLCD::LPC1700 low-level Graphic LCD (320x240 pixels) for LandTiger */ /* */ /******************************************************************************/ /* This file is modified from the uVision/ARM development tools. */ @@ -11,6 +11,7 @@ #include "mbed.h" #include "GLCD.h" +#include "GLCD_Config.h" #include "Font_24x16.h" /*********************** Hardware specific configuration **********************/ @@ -66,48 +67,57 @@ /* Pin RD setting to 0 or 1 */ #define LCD_RD(x) ((x) ? (LPC_GPIO0->FIOSET = PIN_RD) : (LPC_GPIO0->FIOCLR = PIN_RD)); - -#define swap(type, i, j) {type t = i; i = j; j = t;} - /*---------------------------- Global variables ------------------------------*/ /******************************************************************************/ -static volatile unsigned short TextColor = Black, BackColor = White; -static unsigned short driverCode; +//static volatile unsigned short ____textColor = Black, _______backColor = White; +//static unsigned short ___driverCode; /************************ Local auxiliary functions ***************************/ +#define swap(type, i, j) {type t = i; i = j; j = t;} + +// rrrrrggggggbbbbb +#define RGB24toRGB16(r,g,b) ((r & 0xF8)<<8) | ((g & 0xFC)<<3) | ((b & 0xF8)>>3) + + /******************************************************************************* * Delay in while loop cycles * * Parameter: cnt: number of while cycles to delay * * Return: * *******************************************************************************/ -static void delay (int cnt) { +static __inline void delay (int cnt) { cnt <<= DELAY_2N; while (cnt--); } -__asm void wait() +static __inline __asm void wait() { nop BX lr } -void wait_delay(int count) +static __inline void wait_delay(int count) { while(count--); } + +GLCD::GLCD() { + Init(); +} + + /******************************************************************************* * Send 1 short to LCD * * Parameter: data: data to be sent * * Return: * *******************************************************************************/ -static __inline unsigned char lcd_send (unsigned short data) { +unsigned char GLCD::lcd_send (unsigned short data) { LPC_GPIO2->FIODIR |= 0x000000ff; //P2.0...P2.7 Output LCD_DIR(1) //Interface A->B @@ -126,7 +136,7 @@ * Return: short data from LCD * *******************************************************************************/ -static __inline unsigned short lcd_read (void) { +unsigned short GLCD::lcd_read (void) { unsigned short id; LPC_GPIO2->FIODIR &= 0xffffff00; //P2.0...P2.7 Input LCD_DIR(0) //Interface B->A @@ -146,7 +156,7 @@ * Return: * *******************************************************************************/ -static __inline void wr_cmd (unsigned char c) { +void GLCD::wr_cmd (unsigned char c) { LCD_RS(0) LCD_RD(1) @@ -163,7 +173,7 @@ * Return: * *******************************************************************************/ -static __inline void wr_dat (unsigned short c) { +void GLCD::wr_dat (unsigned short c) { LCD_RS(1) LCD_RD(1) @@ -179,7 +189,7 @@ * Return: read data * *******************************************************************************/ -static __inline unsigned short rd_dat (void) { +unsigned short GLCD::rd_dat (void) { unsigned short val = 0; LCD_RS(1) @@ -196,7 +206,7 @@ * Return: * *******************************************************************************/ -static __inline void wr_dat_start (void) { +void GLCD::wr_dat_start (void) { LCD_CS(0) LCD_RS(1) @@ -209,7 +219,7 @@ * Return: * *******************************************************************************/ -static __inline void wr_dat_stop (void) { +void GLCD::wr_dat_stop (void) { LCD_CS(1) } @@ -221,7 +231,7 @@ * Return: * *******************************************************************************/ -static __inline void wr_dat_only (unsigned short c) { +void GLCD::wr_dat_only (unsigned short c) { lcd_send(c); LCD_WR(0) @@ -236,7 +246,7 @@ * val: value to write to register * *******************************************************************************/ -static __inline void wr_reg (unsigned char reg, unsigned short val) { +void GLCD::wr_reg (unsigned char reg, unsigned short val) { LCD_CS(0) wr_cmd(reg); @@ -251,7 +261,7 @@ * Return: value read from register * *******************************************************************************/ -static unsigned short rd_reg (unsigned short reg) { +unsigned short GLCD::rd_reg (unsigned short reg) { unsigned short val = 0; LCD_CS(0) @@ -270,7 +280,7 @@ * Return: * *******************************************************************************/ -void GLCD_Init (void) { +void GLCD::Init (void) { /* Configure the LCD Control pins */ LPC_GPIO0->FIODIR |= 0x03f80000; @@ -278,12 +288,13 @@ delay(5); /* Delay 50 ms */ - driverCode = rd_reg(0x00); + _driverCode = rd_reg(0x00); - switch (driverCode) { + switch (_driverCode) { case LGDP4531_ID: { //2.8" TFT LCD Module, DriverIC is LGDP4531 +#ifndef DISABLE_LGDP4531 wr_reg(0x00,0x0001); wr_reg(0x10,0x0628); wr_reg(0x12,0x0006); @@ -323,13 +334,14 @@ delay(15); wr_reg(0xA0,0x0000); delay(20); - +#endif break; } case ILI9328_ID: case ILI9325_ID: { //2.8" TFT LCD Module, DriverIC is ILI9325 +#ifndef DISABLE_ILI9325 wr_reg(0x00e7,0x0010); wr_reg(0x0000,0x0001); //start internal osc wr_reg(0x0001,0x0100); @@ -396,11 +408,13 @@ wr_reg(0x0007,0x0133); wr_reg(0x0020,0x0000); wr_reg(0x0021,0x0000); - +#endif break; } case ILI9320_ID: { //3.2" TFT LCD Module,DriverIC is ILI9320 + +#ifndef DISABLE_ILI9320 /* Start Initial Sequence --------------------------------------------------*/ wr_reg(0xE5, 0x8000); /* Set the internal vcore voltage */ wr_reg(0x00, 0x0001); /* Start internal OSC */ @@ -468,11 +482,14 @@ wr_reg(0x95, 0x0110); wr_reg(0x97, 0x0000); wr_reg(0x98, 0x0000); +#endif break; } case ILI9331_ID: { + +#ifndef DISABLE_ILI9331 wr_reg(0x00E7, 0x1014); wr_reg(0x0001, 0x0100); /* set SS and SM bit */ wr_reg(0x0002, 0x0200); /* set 1 line inversion */ @@ -534,11 +551,13 @@ wr_reg(0x0007,0x0061); delay(50); /* delay 50 ms */ wr_reg(0x0007,0x0133); /* 262K color and display ON */ +#endif break; } case SSD1289_ID: { //3.2" TFT LCD Module,DriverIC is SSD1289 - + +#ifndef DISABLE_SSD1289_ID wr_reg(0x0007,0x0233); delay(5); //0x0233 Set this first or init fails ! wr_reg(0x0000,0x0001); delay(5); // osc en @@ -600,12 +619,14 @@ wr_reg(0x0025,0x8000); delay(5); // Frame freq 65 Hz wr_reg(0x004e,0); // Start x wr_reg(0x004f,0); // Start y - +#endif break; } case SSD1298_ID: { + +#ifndef DISABLE_SSD1298_ID wr_reg(0x0028,0x0006); wr_reg(0x0000,0x0001); wr_reg(0x0003,0xaea4); /* power control 1---line frequency and VHG,VGL voltage */ @@ -654,10 +675,13 @@ wr_reg(0x0026,0x7000); wr_reg(0x0020,0xb0eb); wr_reg(0x0027,0x007c); +#endif break; } case SSD2119_ID: { + +#ifndef DISABLE_SSD2119_ID /* POWER ON & RESET DISPLAY OFF */ wr_reg(0x28,0x0006); wr_reg(0x00,0x0001); @@ -690,6 +714,7 @@ wr_reg(0x3a,0x1200); wr_reg(0x3b,0x0800); wr_reg(0x07,0x0033); +#endif break; } @@ -701,6 +726,7 @@ case R61505U_ID1: case R61505U_ID2: { +#ifndef DISABLE_R61505U /* second release on 3/5 ,luminance is acceptable,water wave appear during camera preview */ wr_reg(0x0007,0x0000); delay(50); /* delay 50 ms */ @@ -773,11 +799,13 @@ wr_reg(0x0007,0x0061); delay(200); /* delay 200 ms */ wr_reg(0x0007,0x0173); +#endif break; } case SPFD5408B_ID: { - + +#ifndef DISABLE_SPFD5408B wr_reg(0x0001,0x0100); /* Driver Output Contral Register */ wr_reg(0x0002,0x0700); /* LCD Driving Waveform Contral */ wr_reg(0x0003,0x1030); /* Entry ModeÉèÖÃ */ @@ -821,10 +849,13 @@ wr_reg(0x0093,0x0003); /* Panel Interface control 3 */ wr_reg(0x0095,0x0110); /* Frame Cycle Control */ wr_reg(0x0007,0x0173); +#endif break; } case LGDP4531_ID: { + +#ifndef DISABLE_LGDP4531 /* Setup display */ wr_reg(0x00,0x0001); wr_reg(0x10,0x0628); @@ -864,10 +895,13 @@ wr_reg(0x07,0x0133); delay(50); wr_reg(0xA0,0x0000); +#endif break; } case LGDP4535_ID: { + +#ifndef DISABLE_LGDP4535 wr_reg(0x15, 0x0030); /* Set the internal vcore voltage */ wr_reg(0x9A, 0x0010); /* Start internal OSC */ wr_reg(0x11, 0x0020); /* set SS and SM bit */ @@ -907,10 +941,13 @@ wr_reg(0x07, 0x0023); wr_reg(0x07, 0x0033); wr_reg(0x07, 0x0133); +#endif break; } case HX8347D_ID: { + + #ifndef DISABLE_HX8347D /* Start Initial Sequence */ wr_reg(0xEA,0x00); wr_reg(0xEB,0x20); @@ -970,11 +1007,14 @@ wr_reg(0x36,0x00); wr_reg(0x28,0x38); delay(50); - wr_reg(0x28,0x3C); + wr_reg(0x28,0x3C); +#endif break; } case ST7781_ID: { + +#ifndef DISABLE_ST7781 /* Start Initial Sequence */ wr_reg(0x00FF,0x0001); wr_reg(0x00F3,0x0008); @@ -1019,14 +1059,18 @@ wr_reg(0x0090,0x0033); wr_reg(0x002B,0x000B); wr_reg(0x0007,0x0133); +#endif break; } #endif default: { /* special ID */ - driverCode = rd_reg(0x67); - if (driverCode == HX8347A_ID) { + _driverCode = rd_reg(0x67); + + if (_driverCode == HX8347A_ID) { + +#ifndef DISABLE_HX8347A wr_reg(0x0042,0x0008); /* Gamma setting */ wr_reg(0x0046,0x00B4); @@ -1104,17 +1148,28 @@ wr_reg(0x0057,0x0002); wr_reg(0x0055,0x0000); wr_reg(0x0057,0x0000); +#endif } // if + break; } // default case } // end switch - + _textColor = Black; + _backColor = White; } +int GLCD::getDisplayXSize() +{ + return HEIGHT; +} +int GLCD::getDisplayYSize() +{ + return WIDTH; +} /******************************************************************************* @@ -1122,9 +1177,9 @@ * Parameter: * * Return: short Controller ID * *******************************************************************************/ -unsigned short GLCD_DriverCode () { +unsigned short GLCD::getDriverCode () { - return (driverCode); + return (_driverCode); } @@ -1134,9 +1189,9 @@ * Return: * *******************************************************************************/ -void GLCD_WindowMax (void) { +void GLCD::WindowMax (void) { - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { wr_reg(0x44, 0); /* Horizontal GRAM Start Address */ wr_reg(0x44, 0 |((HEIGHT-1)<<8)); /* Horizontal GRAM End Address (-1) */ @@ -1158,14 +1213,14 @@ * Return: * *******************************************************************************/ -void GLCD_Window (int x1, int y1, int x2, int y2) { +void GLCD::Window (int x1, int y1, int x2, int y2) { - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { // wr_reg(0x44, x1); /* Horizontal GRAM Start Address */ // wr_reg(0x44, 0 | (x2<<8)); /* Horizontal GRAM End Address */ -//Note x,y flipped +//Note x,y flipped for landscape wr_reg(0x44, ((y2 & 0xFF) <<8) | (y1 & 0xFF)); /* Horizontal GRAM End Address | Start Address */ wr_reg(0x45, x1); /* Vertical GRAM Start Address */ wr_reg(0x46, x2); /* Vertical GRAM End Address */ @@ -1189,9 +1244,30 @@ * Return: * *******************************************************************************/ -void GLCD_PutPixel (unsigned int x, unsigned int y) { +void GLCD::drawPixel (unsigned int x, unsigned int y) { // Set Cursor - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) + { + wr_reg(0x4e, y); +// wr_reg(0x4f, WIDTH-1-x); + wr_reg(0x4f, x); + } + else + { + wr_reg(0x20, y); +// wr_reg(0x21, WIDTH-1-x); + wr_reg(0x21, x); + } + LCD_CS(0) + wr_cmd(0x22); + wr_dat(_textColor); + LCD_CS(1) +} + +void GLCD::drawPixel (unsigned int x, unsigned int y, unsigned short color) +{ + // Set Cursor + if(_driverCode==SSD1289_ID) { wr_reg(0x4e, y); wr_reg(0x4f, WIDTH-1-x); @@ -1203,32 +1279,76 @@ } LCD_CS(0) wr_cmd(0x22); - wr_dat(TextColor); + wr_dat(color); LCD_CS(1) } +void GLCD::drawPixel (unsigned int x, unsigned int y, uint8_t r, uint8_t g, uint8_t b) +{ +// unsigned short color = ((r & 0xF8)<<8) | ((g & 0xFC)<<3) | ((b & 0xF8)>>3); // rrrrrggggggbbbbb + unsigned short color = RGB24toRGB16(r,g,b); + + + // Set Cursor + if(_driverCode==SSD1289_ID) + { + wr_reg(0x4e, y); +// wr_reg(0x4f, WIDTH-1-x); + wr_reg(0x4f, x); + } + else + { + wr_reg(0x20, y); +// wr_reg(0x21, WIDTH-1-x); + wr_reg(0x21, x); + } + LCD_CS(0) + wr_cmd(0x22); + wr_dat(color); + LCD_CS(1) +} + + + + /******************************************************************************* * Set foreground color * * Parameter: color: foreground color * * Return: * *******************************************************************************/ -void GLCD_SetTextColor (unsigned short color) { +void GLCD::setColor (unsigned short color) { + + _textColor = color; +} - TextColor = color; +void GLCD::setColor (uint8_t r, uint8_t g, uint8_t b) { + unsigned short color = RGB24toRGB16(r,g,b); + + _textColor = color; } + + + /******************************************************************************* * Set background color * * Parameter: color: background color * * Return: * *******************************************************************************/ -void GLCD_SetBackColor (unsigned short color) { +void GLCD::setBackColor (unsigned short color) { + + _backColor = color; +} - BackColor = color; + +void GLCD::setBackColor (uint8_t r, uint8_t g, uint8_t b) { + unsigned short color = RGB24toRGB16(r,g,b); + + _backColor = color; } @@ -1238,13 +1358,13 @@ * Return: * *******************************************************************************/ -void GLCD_Clear (unsigned short color) { +void GLCD::clearScreen (unsigned short color) { unsigned int i; - GLCD_WindowMax(); + WindowMax(); // Set Cursor - if(driverCode==0x8989) + if (_driverCode==SSD1289_ID) { wr_reg(0x4e, 0); wr_reg(0x4f, 0); @@ -1271,12 +1391,12 @@ * Return: * *******************************************************************************/ -void GLCD_DrawChar (unsigned int x, unsigned int y, unsigned short *c) { +void GLCD::DrawChar (unsigned int x, unsigned int y, unsigned short *c) { int idx = 0, i, j; //wh x = WIDTH-x-CHAR_W; - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { //wh wr_reg(0x44, y); /* Horizontal GRAM Start Address */ wr_reg(0x44, y |((y+CHAR_H-1)<<8)); /* Horizontal GRAM End Address (-1) */ @@ -1303,9 +1423,9 @@ //wh for (i = CHAR_W-1; i >= 0; i--) { for (i = 0; i < CHAR_W; i++) { if((c[idx] & (1 << i)) == 0x00) { - wr_dat_only(BackColor); + wr_dat_only(_backColor); } else { - wr_dat_only(TextColor); + wr_dat_only(_textColor); } } c++; @@ -1322,11 +1442,11 @@ * Return: * *******************************************************************************/ -void GLCD_DisplayChar (unsigned int ln, unsigned int col, unsigned char c) { +void GLCD::DisplayChar (unsigned int ln, unsigned int col, unsigned char c) { c -= 32; // x = column, y = line - GLCD_DrawChar(col * CHAR_W, ln * CHAR_H, (unsigned short *)&Font_24x16[c * CHAR_H]); + DrawChar(col * CHAR_W, ln * CHAR_H, (unsigned short *)&Font_24x16[c * CHAR_H]); } @@ -1339,11 +1459,11 @@ * Return: * *******************************************************************************/ -void GLCD_DisplayString (unsigned int ln, unsigned int col, unsigned char *s) { +void GLCD::DisplayString (unsigned int ln, unsigned int col, unsigned char *s) { - GLCD_WindowMax(); + WindowMax(); while (*s) { - GLCD_DisplayChar(ln, col++, *s++); + DisplayChar(ln, col++, *s++); } } @@ -1354,10 +1474,10 @@ * Return: * *******************************************************************************/ -void GLCD_ClearLn (unsigned int ln) { +void GLCD::ClearLn (unsigned int ln) { - GLCD_WindowMax(); - GLCD_DisplayString(ln, 0, (unsigned char*) " "); + WindowMax(); + DisplayString(ln, 0, (unsigned char*) " "); } //SSD1289 @@ -1368,7 +1488,7 @@ //} -void GLCD_drawHLine(int x, int y, int l) +void GLCD::drawHLine(int x, int y, int l) { // char ch, cl; @@ -1377,7 +1497,7 @@ // cbi(P_CS, B_CS); - GLCD_Window (x, y, x+l, y); + Window (x, y, x+l, y); // for (int i=0; i<l+1; i++) // { @@ -1389,15 +1509,15 @@ wr_dat_start(); for (int i=0; i<l; i++) - wr_dat_only(TextColor); + wr_dat_only(_textColor); wr_dat_stop(); // sbi(P_CS, B_CS); // clrXY(); - GLCD_WindowMax(); + WindowMax(); } -void GLCD_drawVLine(int x, int y, int l) +void GLCD::drawVLine(int x, int y, int l) { // char ch, cl; @@ -1405,29 +1525,29 @@ // cl=((fcolorg&28)<<3|fcolorb>>3); // cbi(P_CS, B_CS); - GLCD_Window(x, y, x, y+l); + Window(x, y, x, y+l); // for (int i=0; i<l; i++) // { -// GLCD_wr_dat(ch, cl); +// GLCD::wr_dat(ch, cl); // } LCD_CS(0) wr_cmd(0x22); wr_dat_start(); for (int i=0; i<l; i++) - wr_dat_only(TextColor); + wr_dat_only(_textColor); wr_dat_stop(); // sbi(P_CS, B_CS); // clrXY(); - GLCD_WindowMax(); + WindowMax(); } -void GLCD_drawRect(int x1, int y1, int x2, int y2) +void GLCD::drawRect(int x1, int y1, int x2, int y2) { - int tmp; + //int tmp; if (x1>x2) { @@ -1438,12 +1558,269 @@ swap(int, y1, y2); } - GLCD_drawHLine(x1, y1, x2-x1); - GLCD_drawHLine(x1, y2, x2-x1); - GLCD_drawVLine(x1, y1, y2-y1); - GLCD_drawVLine(x2, y1, y2-y1); + drawHLine(x1, y1, x2-x1); + drawHLine(x1, y2, x2-x1); + drawVLine(x1, y1, y2-y1); + drawVLine(x2, y1, y2-y1); +} + + +/// Replace by faster Bresenham int +void GLCD::drawLine(int x1, int y1, int x2, int y2) +{ +// int tmp; + double delta, tx, ty; +// double m, b, dx, dy; +// char ch, cl; + + if (((x2-x1)<0)) + { + swap(int, x1, x2); + swap(int, y1, y2); + } + if (((y2-y1)<0)) + { + swap(int, x1, x2); + swap(int, y1, y2); + } + + if (y1==y2) + { + if (x1>x2) + { + swap(int, x1, x2); + } + drawHLine(x1, y1, x2-x1); + } + else if (x1==x2) + { + if (y1>y2) + { + swap(int, y1, y2); + } + drawVLine(x1, y1, y2-y1); + } + else if (abs(x2-x1)>abs(y2-y1)) + { + delta=(double(y2-y1)/double(x2-x1)); + ty=double(y1); + if (x1>x2) + { + for (int i=x1; i>=x2; i--) + { + drawPixel(i, int(ty+0.5)); + ty=ty-delta; + } + } + else + { + for (int i=x1; i<=x2; i++) + { + drawPixel(i, int(ty+0.5)); + ty=ty+delta; + } + } + + } + else + { + delta=(float(x2-x1)/float(y2-y1)); + tx=float(x1); + if (y1>y2) + { + for (int i=y2+1; i>y1; i--) + { + drawPixel(int(tx+0.5), i); + tx=tx+delta; + } + } + else + { + for (int i=y1; i<y2+1; i++) + { + drawPixel(int(tx+0.5), i); + tx=tx+delta; + } + } + } + + WindowMax(); +} + +void GLCD::drawRoundRect(int x1, int y1, int x2, int y2) +{ +// int tmp; + + if (x1>x2) + { + swap(int, x1, x2); + } + if (y1>y2) + { + swap(int, y1, y2); + } + if ((x2-x1)>4 && (y2-y1)>4) + { + drawPixel(x1+1,y1+1); + drawPixel(x2-1,y1+1); + drawPixel(x1+1,y2-1); + drawPixel(x2-1,y2-1); + drawHLine(x1+2, y1, x2-x1-4); + drawHLine(x1+2, y2, x2-x1-4); + drawVLine(x1, y1+2, y2-y1-4); + drawVLine(x2, y1+2, y2-y1-4); + } } +void GLCD::fillRect(int x1, int y1, int x2, int y2) +{ +// int tmp; + + if (x1>x2) + { + swap(int, x1, x2); + } + if (y1>y2) + { + swap(int, y1, y2); + } + +// if (orient==PORTRAIT) +// { +// for (int i=0; i<((y2-y1)/2)+1; i++) +// { +// drawHLine(x1, y1+i, x2-x1); +// drawHLine(x1, y2-i, x2-x1); +// } +// } +// else +// { + for (int i=0; i<((x2-x1)/2)+1; i++) + { + drawVLine(x1+i, y1, y2-y1); + drawVLine(x2-i, y1, y2-y1); + } +// } +} + +void GLCD::fillRoundRect(int x1, int y1, int x2, int y2) +{ +// int tmp; + + if (x1>x2) + { + swap(int, x1, x2); + } + if (y1>y2) + { + swap(int, y1, y2); + } + + if ((x2-x1)>4 && (y2-y1)>4) + { + for (int i=0; i<((y2-y1)/2)+1; i++) + { + switch(i) + { + case 0: + drawHLine(x1+2, y1+i, x2-x1-4); + drawHLine(x1+2, y2-i, x2-x1-4); + break; + case 1: + drawHLine(x1+1, y1+i, x2-x1-2); + drawHLine(x1+1, y2-i, x2-x1-2); + break; + default: + drawHLine(x1, y1+i, x2-x1); + drawHLine(x1, y2-i, x2-x1); + } + } + } +} + +void GLCD::drawCircle(int x, int y, int radius) +{ + int f = 1 - radius; + int ddF_x = 1; + int ddF_y = -2 * radius; + int x1 = 0; + int y1 = radius; +// char ch, cl; + +// ch=((fcolorr&248)|fcolorg>>5); +// cl=((fcolorg&28)<<3|fcolorb>>3); + +// cbi(P_CS, B_CS); + drawPixel(x, y + radius); + + drawPixel(x, y - radius); + + drawPixel(x + radius, y); + + drawPixel(x - radius, y); + + + while(x1 < y1) + { + if(f >= 0) + { + y1--; + ddF_y += 2; + f += ddF_y; + } + x1++; + ddF_x += 2; + f += ddF_x; + drawPixel(x + x1, y + y1); + + drawPixel(x - x1, y + y1); + + drawPixel(x + x1, y - y1); + + drawPixel(x - x1, y - y1); + + drawPixel(x + y1, y + x1); + + drawPixel(x - y1, y + x1); + + drawPixel(x + y1, y - x1); + + drawPixel(x - y1, y - x1); + + } +// sbi(P_CS, B_CS); +// clrXY(); +} + +void GLCD::fillCircle(int x, int y, int radius) +{ +// cbi(P_CS, B_CS); + for(int y1=-radius; y1<=radius; y1++) + for(int x1=-radius; x1<=radius; x1++) + if(x1*x1+y1*y1 <= radius*radius) + { + drawPixel(x+x1, y+y1); + } +// sbi(P_CS, B_CS); +// clrXY(); +} + + + + +void GLCD::lcdOff() +{ +} + +void GLCD::lcdOn() +{ +} + +void GLCD::setContrast(char c) +{ +} + + @@ -1456,11 +1833,11 @@ * Return: * *******************************************************************************/ -void GLCD_Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) { +void GLCD::Bargraph (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int val) { int i,j; x = WIDTH-x-w; - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { wr_reg(0x44, y); /* Horizontal GRAM Start Address */ wr_reg(0x44, y |((y+CHAR_H-1)<<8)); /* Horizontal GRAM End Address (-1) */ @@ -1476,7 +1853,7 @@ } val = (val * w) >> 10; /* Scale value for 24x12 characters */ - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { wr_reg(0x4e, y); wr_reg(0x4f, x); @@ -1492,9 +1869,9 @@ for (i = 0; i < h; i++) { for (j = w-1; j >= 0; j--) { if(j >= val) { - wr_dat_only(BackColor); + wr_dat_only(_backColor); } else { - wr_dat_only(TextColor); + wr_dat_only(_textColor); } } } @@ -1514,12 +1891,12 @@ * Return: * *******************************************************************************/ -void GLCD_Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) { +void GLCD::Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) { unsigned int i, j; unsigned short *bitmap_ptr = (unsigned short *)bitmap; x = WIDTH-x-w; - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { wr_reg(0x44, y); /* Horizontal GRAM Start Address */ wr_reg(0x44, y |((y+h-1)<<8)); /* Horizontal GRAM End Address (-1) */ @@ -1563,13 +1940,13 @@ * Return: * *******************************************************************************/ -void GLCD_Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp) { +void GLCD::Bmp (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bmp) { unsigned int i, j; unsigned short *bitmap_ptr = (unsigned short *)bmp; //wh x = WIDTH-x-w; - if(driverCode==0x8989) + if(_driverCode==SSD1289_ID) { //wh wr_reg(0x44, y); /* Horizontal GRAM Start Address */ wr_reg(0x44, y |((y+h-1)<<8)); /* Horizontal GRAM End Address (-1) */