TFT

Dependencies:   mbed

Fork of Ovation_Controller_1 by Andrew R

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Graphic.h Source File

Graphic.h

00001 /***********************************************************************************/
00002 /***** Newhaven NHD-5.7-640480WF-CTXL# Display Driver **********/
00003 /***** for mbed (www.mbed,org) NXP LPC1768 32 bit ARM MCU ******/
00004 /********* Adapted by Andrew C. Russell,  March 2011 ***********/
00005 
00006 /************I hereby acknowledge and thank the following ******/
00007 /***software authors whose code I have adapted and/or adopted***/
00008 /*******************to create these drivers:- ******************/
00009 
00010 //Curt Lagerstam - Newhaven Display International, LLC for the dispay initialization.
00011 //James P Lynch - code adapted from his Nokia LCD display tutorial at
00012 //http://www.sparkfun.com/tutorial/Nokia%206100%20LCD%20Display%20Driver.pdf
00013 //Akifumi 'Tedd' Okano for assistance and adapting the .bmp display driver and writing
00014 //the driver for the font display
00015 /***********************************************************************************/
00016 
00017 //#include "mbed.h"
00018 //#include "font_1.h"
00019 //#include "stdlib.h"
00020 //#include "string.h"
00021 //#include "math.h"
00022 #include "font_new.h"
00023 //#include "system_defines.h"
00024 
00025 /***********************************************************************************/
00026 /********************************** Colors *****************************************/
00027 /********* taken directly from http://web.njit.edu/~kevin/rgb.txt.html**************/
00028 #define BLACK       0x000000
00029 #define WHITE       0xFFFFFF
00030 #define BLACK       0x000000
00031 #define RED         0xFF0000
00032 #define GREEN       0x00FF00
00033 #define LGREEN      0xCCFF00    //light green
00034 #define BLUE        0x0000FF
00035 #define GREY        0xBEBEBE
00036 #define DEEPINK     0xFF1493
00037 #define YELLOW      0xFFFF00
00038 #define LORANGE     0xFFFF00    //light orange
00039 #define DORANGE     0xFF9900    //dark orange
00040 #define OLIVE       0x999900
00041 
00042 #define PASET       0x2B
00043 #define CASET       0x2A
00044 #define DISON       0x29
00045 #define DISOFF      0x28
00046 #define DEEPSLEEP   0xE5
00047 #define RAMWR       0x2C
00048 #define RAMCT       0x3C
00049 #define RESET       0x01
00050 #define DISINV      0x21
00051 #define DISNOR      0x20
00052 #define NOP         0x00
00053 #define XMAX        640         // x axis max pixels
00054 #define YMAX        480         // y axis max pixels
00055 #define TRUE        1
00056 #define SPAN        460         //this is for the slider bar
00057 #define ZERO        100
00058 #define PI          3.14159265
00059 
00060 // Font sizes
00061 #define SMALL 0
00062 #define MEDIUM 1
00063 #define LARGE 2
00064 #define LARGE1 3
00065 /********************************************************************/
00066 #ifdef   TEST
00067 extern unsigned char    screen[ SC_WIDTH * SC_HEIGHT ]    = { '.' };
00068 #endif
00069 /********************************************************************/
00070 //unsigned char FONT6x8[97][8];
00071 //unsigned char FONT8x8[97][8];
00072 //unsigned char FONT8x16[97][8];
00073 /************ here the XY reference locations for the buttons ************/
00074 int righttbutinc=80;
00075 int xref2=590;  //right hand side button x reference
00076 int xref1=16;   //left hand side button x reference
00077 int leftbutinc=76;  //y axis increment for the left hand side buttons
00078 int yref1=70;
00079 int xbutsize1=60;  // x size of button
00080 int ybutsize1=50;  // y size of button
00081 /************************************************************************/
00082 unsigned char command;
00083 unsigned char data1;
00084 int DOWN;
00085 int RIGHT;
00086 int color;
00087 unsigned int fill;
00088 unsigned int radius;
00089 int z;
00090 int color1;
00091 int color2;
00092 //float slider;
00093 //float vol;
00094 
00095 /**************************** forward references *******************************/
00096 void LCDSetXY(int x, int y);
00097 void LCDClearScreen(void);
00098 void LCDSetPixel(int x, int y, int color);
00099 void LCDSetLine(int x1, int y1, int x2, int y2, int color);
00100 void LCDSetRect(int x0, int y0, int x1, int y1, int fill, int color);
00101 void LCDSetCircle(int x0, int y0, int radius, int color);
00102 void LCDPutChar(char c, int x, int y, int size, int fcolor, int bcolor);
00103 void LCDPutString (char *lcd_string, const char *font_style, unsigned char x, unsigned char y,
00104                    unsigned char fcolor, unsigned char bcolor);
00105 void trigcircle (int xtc, int ytc, int radius, int color);
00106 void show_screen( int xs, int width, int ys, int height );
00107 void volume_slider (int volume);
00108 void mute (unsigned int onoff);
00109 //************************************************************************************
00110 
00111 void Write_Command(unsigned char command) {
00112     CS=1; /* just to make sure */
00113     nRD = 1; /* make sure the RD is HIGH just to be sure */
00114     DC=0;
00115     nWR = 0;
00116     CS=0;
00117     //data_bus_write(command);
00118     DB=command;
00119     CS = 1;
00120     nWR = 1;
00121 }
00122 //;******************************************************************************
00123 //void Write_Data(unsigned char data1) {
00124 void Write_Data(int data1) {
00125     CS=1; /* just to make sure */
00126     nRD = 1;
00127     DC=1;
00128     nWR = 0;
00129     CS=0;
00130     //data_bus_write(data1);
00131     DB=data1;//write(data1);
00132     CS = 1;
00133     nWR = 1;
00134 }
00135 //====================================================
00136 void Command_Write(unsigned char REG,unsigned char VALUE) {
00137     Write_Command(REG);
00138     Write_Data(VALUE);
00139 }
00140 //======================================================
00141 void SendData(unsigned long color) {
00142     Write_Data((color)>>16);        //red
00143     Write_Data((color)>>8);         //green
00144     Write_Data(color);              //blue
00145 }
00146 /********************************************************************************/
00147 // initialize the SSD1963 controller
00148 void Init_SSD1963 (void) {
00149     Write_Command(0x01);            //Software Reset
00150     wait_ms(10);
00151     Write_Command(0x01);            //Software Reset
00152     wait_ms(10);
00153     Write_Command(0x01);            //Software Reset
00154     wait_ms(10);
00155     Command_Write(0xe0,0x01);       //START PLL
00156     wait_us(1);
00157     Command_Write(0xe0,0x03);    //LOCK PLL
00158     Write_Command(0xb0);         //SET LCD MODE  SET TFT 18Bits MODE
00159     Write_Data(0x0c);            //SET TFT MODE & hsync+Vsync+DEN MODE
00160     Write_Data(0x80);            //SET TFT MODE & hsync+Vsync+DEN MODE
00161     Write_Data(0x02);            //SET horizontal size=640-1 HightByte
00162     Write_Data(0x7f);            //SET horizontal size=640-1 LowByte
00163     Write_Data(0x01);            //SET vertical size=480-1 HightByte
00164     Write_Data(0xdf);            //SET vertical size=480-1 LowByte
00165     Write_Data(0x00);            //SET even/odd line RGB seq.=RGB
00166     Command_Write(0xf0,0x00);    //SET pixel data I/F format=8bit
00167     Command_Write(0x3a,0x60);    // SET R G B format = 6 6 6
00168     Write_Command(0xe6);         //SET PCLK freq=4.94MHz  ; pixel clock frequency
00169     Write_Data(0x02);
00170     Write_Data(0xff);
00171     Write_Data(0xff);
00172     Write_Command(0xb4);         //SET HBP,
00173     Write_Data(0x02);            //SET HSYNC Total=760
00174     Write_Data(0xf8);
00175     Write_Data(0x00);            //SET HBP 68
00176     Write_Data(0x44);
00177     Write_Data(0x0f);            //SET VBP 16=15+1
00178     Write_Data(0x00);            //SET Hsync pulse start position
00179     Write_Data(0x00);
00180     Write_Data(0x00);            //SET Hsync pulse subpixel start position
00181     Write_Command(0xb6);         //SET VBP,
00182     Write_Data(0x01);            //SET Vsync total
00183     Write_Data(0xf8);
00184     Write_Data(0x00);            //SET VBP=19
00185     Write_Data(0x13);
00186     Write_Data(0x07);            //SET Vsync pulse 8=7+1
00187     Write_Data(0x00);            //SET Vsync pulse start position
00188     Write_Data(0x00);
00189     Write_Command(0x2a);         //SET column address
00190     Write_Data(0x00);            //SET start column address=0
00191     Write_Data(0x00);
00192     Write_Data(0x02);            //SET end column address=639
00193     Write_Data(0x7f);
00194     Write_Command(0x2b);         //SET page address
00195     Write_Data(0x00);            //SET start page address=0
00196     Write_Data(0x00);
00197     Write_Data(0x01);            //SET end page address=479
00198     Write_Data(0xdf);
00199     Write_Command(0x29);         //SET display on
00200 }
00201 
00202 
00203 /********************************************************************************/
00204 void WindowSet( int s_x,int e_x,int s_y,int e_y) {
00205     Write_Command(CASET);           //SET page address
00206     Write_Data((s_x)>>8);           //SET start page address=0
00207     Write_Data(s_x);
00208     Write_Data((e_x)>>8);           //SET end page address=639
00209     Write_Data(e_x);
00210     Write_Command(PASET);           //SET column address
00211     Write_Data((s_y)>>8);           //SET start column address=0
00212     Write_Data(s_y);
00213     Write_Data((e_y)>>8);           //SET end column address=479
00214     Write_Data(e_y);
00215 }
00216 /***************************************************************************/
00217 /* this routine locates the screen pointer at position XY in the frame buffer */
00218 void LCDSetXY(int x, int y) {
00219     Write_Command(CASET);           //SET page address
00220     Write_Data((x)>>8);             //SET start page address=0
00221     Write_Data(x);
00222     Write_Data((XMAX)>>8);          //SET end page address=XMAX
00223     Write_Data(XMAX);
00224     Write_Command(PASET);           //SET column address
00225     Write_Data((y)>>8);             //SET start column address=0
00226     Write_Data(y);
00227     Write_Data((YMAX)>>8);          //SET end column address=YMAX
00228     Write_Data(YMAX);
00229     Write_Command(RAMWR);           //ready to now start writing the data
00230     //when returnung to the caller
00231 }
00232 
00233 
00234 /********************************************************************************/
00235 void clear_to_color(int color) {
00236     int m,n;
00237     WindowSet(0,640,0,480); // 0-640 wide by 0-480 high
00238     Write_Command(RAMWR);
00239     for (m=0;m<481;m++) {
00240         for (n=0;n<641;n++) {
00241             SendData(color);
00242         }
00243     }
00244 }
00245 /**********************************************************************************/
00246 /********** this routine lights up a single pixel to a specific colour ***********/
00247 void LCDSetPixel(int x,int y, int color) {
00248     Write_Command(CASET);           //SET page address
00249     Write_Data((x)>>8);             //SET start page address=0
00250     Write_Data(x);
00251     Write_Data((XMAX)>>8);          //SET end page address=XMAX
00252     Write_Data(XMAX);
00253     Write_Command(PASET);           //SET column address
00254     Write_Data((y)>>8);             //SET start column address=0
00255     Write_Data(y);
00256     Write_Data((YMAX)>>8);          //SET end column address=YMAX
00257     Write_Data(YMAX);
00258     Write_Command(RAMWR);           //ready to now start writing the data
00259     //when returnung to the caller
00260     SendData(color);
00261     Write_Command(NOP);
00262 }
00263 /*********************************************************************************/
00264 /************ This routine draws a line between 2 points on the screen ***********/
00265 void LCDSetLine(int x0, int y0, int x1,int y1, int color) {
00266     int dy = y1 - y0;
00267     int dx = x1 - x0;
00268     int stepx, stepy;
00269     if (dy < 0) {
00270         dy = -dy;
00271         stepy = -1;
00272     } else {
00273         stepy = 1;
00274     }
00275     if (dx < 0) {
00276         dx = -dx;
00277         stepx = -1;
00278     } else {
00279         stepx = 1;
00280     }
00281     dy <<= 1; // dy is now 2*dy
00282     dx <<= 1; // dx is now 2*dx
00283     LCDSetPixel(x0, y0, color);
00284     if (dx > dy) {
00285         int fraction = dy - (dx >> 1); // same as 2*dy - dx
00286         while (x0 != x1) {
00287             if (fraction >= 0) {
00288                 y0 += stepy;
00289                 fraction -= dx; // same as fraction -= 2*dx
00290             }
00291             x0 += stepx;
00292             fraction += dy; // same as fraction -= 2*dy
00293             LCDSetPixel(x0, y0, color);
00294         }
00295     } else {
00296         int fraction = dx - (dy >> 1);
00297         while (y0 != y1) {
00298             if (fraction >= 0) {
00299                 x0 += stepx;
00300                 fraction -= dy;
00301             }
00302             y0 += stepy;
00303             fraction += dx;
00304             LCDSetPixel(x0, y0, color);
00305         }
00306     }
00307 }
00308 /*******************************************************************************/
00309 /************** draw a rectangle, filled or not filled *************************/
00310 void LCDSetRect(int x0, int y0, int x1,int y1, int fill,  int color) {
00311     int xmin, xmax, ymin, ymax;
00312     int i;
00313 // check if the rectangle is to be filled
00314     if (fill == TRUE) {
00315 // calculate the min and max for x and y directions
00316         xmin = (x0 <= x1) ? x0 : x1;
00317         xmax = (x0 > x1) ? x0 : x1;
00318         ymin = (y0 <= y1) ? y0 : y1;
00319         ymax = (y0 > y1) ? y0 : y1;
00320         Write_Command(CASET);           //SET page address
00321         Write_Data((x0)>>8);            //SET start page address=0
00322         Write_Data(x0);
00323         Write_Data((x1)>>8);            //SET end page address=XMAX
00324         Write_Data(x1);
00325         Write_Command(PASET);           //SET column address
00326         Write_Data((y0)>>8);            //SET start column address=0
00327         Write_Data(y0);
00328         Write_Data((y1)>>8);            //SET end column address=YMAX
00329         Write_Data(y1);
00330         Write_Command(RAMWR);           //ready to now start writing the data
00331         for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
00332             SendData(color);
00333         }
00334     } else {
00335         LCDSetLine(x0, y0, x1, y0, color);
00336         LCDSetLine(x0, y1, x1, y1, color);
00337         LCDSetLine(x0, y0, x0, y1, color);
00338         LCDSetLine(x1, y0, x1, y1, color);
00339     }
00340 }
00341 /***************************************************************************/
00342 void LCDSetCircle(int x0, int y0, int radius, int color) {
00343     int f = 1 - radius;
00344     int ddF_x = 0;
00345     int ddF_y = -2 * radius;
00346     int x = 0;
00347     int y = radius;
00348     LCDSetPixel(x0, y0 + radius, color);
00349     LCDSetPixel(x0, y0 - radius, color);
00350     LCDSetPixel(x0 + radius, y0, color);
00351     LCDSetPixel(x0 - radius, y0, color);
00352     while (x < y) {
00353         if (f >= 0) {
00354             y--;
00355             ddF_y += 2;
00356             f += ddF_y;
00357         }
00358         x++;
00359         ddF_x += 2;
00360         f += ddF_x + 1;
00361         LCDSetPixel(x0 + x, y0 + y, color);
00362         LCDSetPixel(x0 - x, y0 + y, color);
00363         LCDSetPixel(x0 + x, y0 - y, color);
00364         LCDSetPixel(x0 - x, y0 - y, color);
00365         LCDSetPixel(x0 + y, y0 + x, color);
00366         LCDSetPixel(x0 - y, y0 + x, color);
00367         LCDSetPixel(x0 + y, y0 - x, color);
00368         LCDSetPixel(x0 - y, y0 - x, color);
00369     }
00370 }
00371 /***************************************************************************/
00372 /***************** this is the mini-font version ***************************/
00373 void LCDPutChar(char c, int x, int y, int size, int fColor, int bColor) {
00374     extern const unsigned char FONT6x8[97][8];
00375     extern const unsigned char FONT8x8[97][8];
00376     extern const unsigned char FONT8x16[97][16];
00377     extern const unsigned char FONT24x59[1][177];
00378 
00379     int i,j;
00380     unsigned int nCols;
00381     unsigned int nRows;
00382     unsigned int nBytes;
00383     unsigned char PixelRow;
00384     unsigned char Mask;
00385     unsigned int Word0;
00386     unsigned char *pFont;
00387     unsigned char *pChar;
00388     unsigned char *FontTable[] = {
00389         (unsigned char *)FONT6x8,
00390         (unsigned char *)FONT8x8,
00391         (unsigned char *)FONT8x16,
00392         (unsigned char *)FONT24x59  // I added this - it is just for the zero
00393     };
00394     // get pointer to the beginning of the selected font table
00395     pFont = (unsigned char *)FontTable[size];
00396     // get the nColumns, nRows and nBytes in the font table
00397     nCols = *pFont;
00398     nRows = *(pFont + 1);
00399     nBytes = *(pFont + 2);
00400     // get pointer to the last byte of the desired character - i.e. last byte in the row
00401     pChar = pFont + (nBytes * (c - 0x1F)) + nBytes - 1;
00402 
00403     WindowSet( x, (x + nRows - 1), y, (y + nCols - 1) ); // set window (drawing rectangle) to font size
00404     Write_Command(RAMWR);
00405 
00406     for ( i = (nRows - 1); i >= 0; i-- ) {
00407         PixelRow = *pChar--;
00408         Mask = 0x80;
00409 
00410         for ( j = 0; j < nCols; j++ ) {
00411 
00412             Word0    = (PixelRow & Mask) ? fColor : bColor;
00413             Mask    = Mask >> 1;
00414 
00415             Write_Data( (Word0 >> 16) & 0xFF );
00416             Write_Data( (Word0 >>  8) & 0xFF );
00417             Write_Data( (Word0      ) & 0xFF );
00418         }
00419     }
00420     Write_Command(NOP);// this terminates the Write Memory command
00421 }
00422 /*****************************************************************************/
00423 /***************** this is the mini-font version ***************************/
00424 void LCDPutStr(char *pString, int x, int y, int Size, int fColor, int bColor) {
00425 // loop until null-terminator is seen
00426     while (*pString != 0x00) {
00427 // draw the character
00428         LCDPutChar(*pString++, y, x, Size, fColor, bColor);
00429 // advance the y position
00430         if (Size == 0)// small
00431             y = y + 6;
00432         else if (Size == 1)  //medium
00433             y = y + 8;
00434         else if (Size == 2) //large
00435             y = y + 16;
00436         else if (Size == 3)
00437             y = y + 24;  //large1
00438         if (y > 640) break; //bail out if it exceeds screen width
00439     }
00440 }
00441 /******************************** square button ***********************/
00442 void sqbutton1(unsigned int x0, unsigned int y0, unsigned int fill, unsigned int color) {
00443     unsigned int xmin, xmax, ymin, ymax;
00444     int i;
00445 
00446 // check if the rectangle is to be filled
00447     if (fill == TRUE) {
00448 // best way to create a filled rectangle is to define a drawing box
00449 // and loop two pixels at a time
00450 // calculate the min and max for x and y directions
00451         xmin = (x0 <= (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
00452         xmax = (x0 > (x0 + xbutsize1)) ? x0 : (x0 + xbutsize1);
00453         ymin = (y0 <= (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
00454         ymax = (y0 > (y0+ybutsize1)) ? y0 : (y0+ybutsize1);
00455         Write_Command(CASET);           //SET page address
00456         Write_Data((x0)>>8);             //SET start page address=0
00457         Write_Data(x0);
00458         Write_Data((x0 + xbutsize1)>>8);          //SET end page address=XMAX
00459         Write_Data (x0 + xbutsize1);
00460         Write_Command(PASET);           //SET column address
00461         Write_Data((y0)>>8);             //SET start column address=0
00462         Write_Data(y0);
00463         Write_Data((y0+ybutsize1)>>8);          //SET end column address=YMAX
00464         Write_Data (y0+ybutsize1);
00465         Write_Command(RAMWR);           //ready to now start writing the data
00466         for (i = 0; i < ((((xmax - xmin + 1) * (ymax - ymin + 1))) + 1); i++) {
00467             SendData(color);
00468         }
00469     } else {
00470 
00471         LCDSetLine(x0, y0, (x0 + xbutsize1), y0, color);
00472         LCDSetLine(x0, (y0+ybutsize1), (x0 + xbutsize1), (y0+ybutsize1), color);
00473         LCDSetLine(x0, y0, x0, (y0+ybutsize1), color);
00474         LCDSetLine((x0 + xbutsize1), y0, (x0 + xbutsize1), (y0+ybutsize1), color);
00475     }
00476 }
00477 
00478 /**************************************** volume slider ******************************************/
00479 void volume_slider(int volume) {  //was float
00480     int slider;
00481     int pos;
00482     pos = (volume*450)/222;
00483     slider = ZERO+pos; //((volume/255)*SPAN);
00484     LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),60,1,BLACK); //erase the previous slider button position
00485     LCDSetRect(slider,40,(slider+10),60,1,WHITE);
00486 
00487 }
00488 /*************************************************************************************************/
00489 /***************************** this is the main central button ******************************/
00490 void big_button(void) {
00491     int z;
00492     for (z=117;z<122;z++) {
00493         LCDSetCircle(320,240,z,WHITE);
00494     }
00495     for (z=130;z<133;z++) {
00496         LCDSetCircle(320,240,z,WHITE);
00497     }
00498 }
00499 /*************************************************************************************************/
00500 void volume_display_window(void) {
00501     LCDSetRect(223,198,418,283,0,WHITE);
00502 }
00503 /*************************************************************************************************/
00504 void slider_bar(void) {
00505 
00506     LCDSetRect(100, 20,560,30,0,WHITE);//slider scale volume bar
00507     LCDPutStr("0ff   -82     -65      -48      -30      -12 -6  0  +7  +16",10,100,MEDIUM, WHITE,BLACK);//slider scale
00508 
00509 }
00510 /*************************************************************************************************/
00511 void input_sel_window(void) {
00512     LCDSetRect(180,380,460,460,0,WHITE);// input select window
00513 }
00514 /*************************************************************************************************/
00515 void input_buttons(void) {
00516    
00517     LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
00518     FontDrawString("CD",(xref2-75),(righttbutinc-20),WHITE,BLACK,&Calibri28);
00519 
00520     LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
00521     FontDrawString("Aux2",(xref2-108),((2*righttbutinc)-20),WHITE,BLACK,&Calibri28);
00522 
00523     LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
00524     FontDrawString("Aux1",(xref2-108),((3*righttbutinc)-20),WHITE,BLACK,&Calibri28);
00525 
00526     LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
00527     FontDrawString("Recdr",(xref2-122),((4*righttbutinc)-20),WHITE,BLACK,&Calibri28);
00528 
00529     LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
00530     FontDrawString("Phono",(xref2-132),((5*righttbutinc)-20),WHITE,BLACK,&Calibri28);
00531 }
00532 
00533 /*************************************************************************************************/
00534 void phono_d(int onoff) {
00535     int circinc;
00536     if (onoff==0) {
00537         for (circinc=1;circinc<27;circinc++) {
00538             LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK);
00539         } //first erase the button
00540 
00541         LCDSetCircle(xref2,(5*righttbutinc),25,WHITE);
00542     } //now draw it in outline = OFF
00543 
00544     else {
00545         for (circinc=1;circinc<26;circinc++) {     //so onoff must have been TRUE
00546             LCDSetCircle(xref2,(5*righttbutinc),circinc,GREEN);    //it on so draw it in GREEN
00547         }
00548     }
00549 }
00550 /*************************************************************************************************/
00551 void AUX1(int onoff) {
00552     int circinc;
00553     if (onoff==0) {
00554         for (circinc=1;circinc<27;circinc++) {
00555             LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK);
00556         } //first erase the button
00557 
00558         LCDSetCircle(xref2,(3*righttbutinc),25,WHITE);
00559     } //now draw it in outline = OFF
00560 
00561     else {
00562         for (circinc=1;circinc<26;circinc++) {     //so onoff must have been TRUE
00563             LCDSetCircle(xref2,(3*righttbutinc),circinc,GREEN);    //it on so draw it in GREEN
00564         }
00565     }
00566 }
00567 /*************************************************************************************************/
00568 void AUX2(int onoff) {
00569     int circinc;
00570     if (onoff==0) {
00571         for (circinc=1;circinc<27;circinc++) {
00572             LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK);
00573         } //first erase the button
00574 
00575         LCDSetCircle(xref2,(2*righttbutinc),25,WHITE);
00576     } //now draw it in outline = OFF
00577 
00578     else {
00579         for (circinc=1;circinc<26;circinc++) {     //so onoff must have been TRUE
00580             LCDSetCircle(xref2,(2*righttbutinc),circinc,GREEN);    //it on so draw it in GREEN
00581         }
00582     }
00583 }
00584 /*************************************************************************************************/
00585 void CD_d(int onoff) {
00586     int circinc;
00587     if (onoff==0) {
00588         for (circinc=1;circinc<27;circinc++) {
00589             LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK);
00590         } //first erase the button
00591 
00592         LCDSetCircle(xref2,(1*righttbutinc),25,WHITE);
00593     } //now draw it in outline = OFF
00594 
00595     else {
00596         for (circinc=1;circinc<26;circinc++) {     //so onoff must have been TRUE
00597             LCDSetCircle(xref2,(1*righttbutinc),circinc,GREEN);    //it on so draw it in GREEN
00598         }
00599     }
00600 }
00601 /*************************************************************************************************/
00602 void Recorder_d(int onoff) {
00603     int circinc;
00604     if (onoff==0) {
00605         for (circinc=1;circinc<27;circinc++) {
00606             LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK);
00607         } //first erase the button
00608 
00609         LCDSetCircle(xref2,(4*righttbutinc),25,WHITE);
00610     } //now draw it in outline = OFF
00611 
00612     else {
00613         for (circinc=1;circinc<26;circinc++) {     //so onoff must have been TRUE
00614             LCDSetCircle(xref2,(4*righttbutinc),circinc,GREEN);    //it on so draw it in GREEN
00615         }
00616     }
00617 }
00618 
00619 /*************************************************************************************************/
00620 void Control_buttons(void) {
00621 
00622     sqbutton1(xref1,80,0,WHITE); //mute
00623     FontDrawString("Mute",82,87,WHITE,BLACK,&Calibri28);
00624 
00625     sqbutton1(xref1, 196,0,WHITE); //Rec
00626     FontDrawString("Rec",82,197,WHITE,BLACK,&Calibri28); //gap is 66
00627 
00628     //sqbutton1(xref1,202,0,WHITE); //stdby
00629     //FontDrawString("Stdby",82,203,WHITE,BLACK,&Calibri28);
00630 
00631     sqbutton1(xref1, 312,0,WHITE);//power amp
00632     FontDrawString("Amp",82,313,WHITE,BLACK,&Calibri28);
00633 
00634     //sqbutton1(xref1,400,0,RED);  //this is the IR indicator
00635     //FontDrawString("IR",82,400,WHITE,BLACK,&Calibri28);
00636 
00637 }
00638 /*************************************************************************************************/
00639 void mute(unsigned int onoff) {     //this is the bottom button
00640     if (onoff==0) {
00641         sqbutton1(xref1,80,1,BLACK); //first erase the button
00642         sqbutton1(xref1,80,0,WHITE);
00643     } //now redraw it
00644     else {
00645         sqbutton1(16,80,1,WHITE);
00646     }
00647 }
00648 /*************************************************************************************************/
00649 void record(unsigned int onoff) { //this is the second from bottom button
00650     if (onoff==0) {
00651         sqbutton1(xref1,196,1,BLACK); //first erase the button
00652         sqbutton1(16, 196,0,WHITE);
00653     } //now redraw it
00654     else {
00655         sqbutton1(16,196,1,WHITE);
00656     }
00657 }
00658 /*************************************************************************************************/
00659 void stdby(unsigned int onoff) { //this is the 3rd from bottom button
00660     if (onoff==0) {
00661         sqbutton1(xref1,202,1,BLACK); //first erase the button
00662         sqbutton1(xref1, 202,0,WHITE);
00663     } //now redraw it
00664     else {
00665         sqbutton1(xref1,202,1,WHITE);
00666     }
00667 }
00668 /*************************************************************************************************/
00669 void pwramp(unsigned int onoff) { //this is the top  lefthand side button
00670     if (onoff==0) {
00671         sqbutton1(xref1, 312,1,BLACK); //first erase the button
00672         sqbutton1(xref1,312,0,WHITE);
00673     } //now redraw it
00674     else {
00675         sqbutton1(xref1, 312,1,WHITE);
00676     }
00677 }
00678 /*************************************************************************************************/
00679 void infra(unsigned int onoff) { //this is the top  lefthand side button
00680     if (onoff==0) {
00681         sqbutton1(xref1, 400,1,BLACK); //first erase the button
00682         sqbutton1(xref1,400,0,RED);
00683     } //now redraw it
00684     else {
00685         sqbutton1(xref1, 400,1,RED);
00686     }
00687 }
00688 /*************************************************************************************************/
00689 void trigcircle (int xtc, int ytc, int radius, int color) {
00690 
00691     double circ;
00692     double cosnum;
00693     double sinum;
00694     for (circ=0;circ<=volume;circ++) {
00695         sinum=sin(circ)*radius;
00696         cosnum=cos(circ)*radius;
00697         LCDSetLine(xtc,ytc,(sinum+xtc),(cosnum+ytc),color);
00698     }
00699 }
00700 
00701 /**************************************************************************************/
00702 
00703 void clear_input_select(void) {
00704 
00705     int circinc;
00706     for (circinc=1;circinc<24;circinc++) {
00707 
00708         LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK); //phono
00709         LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK); //aux1
00710         LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK); //aux2
00711         LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK); //CD
00712         LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK); //recorder
00713     }
00714 }