Boyu Fang
/
Ovation_Controller
TFT
Fork of Ovation_Controller_1 by
Diff: Graphic.h
- Revision:
- 2:67e16df2c89a
- Parent:
- 1:ecf8078bf531
--- a/Graphic.h Mon Apr 04 05:32:25 2011 +0000 +++ b/Graphic.h Thu Jun 09 05:13:10 2011 +0000 @@ -50,10 +50,10 @@ #define DISINV 0x21 #define DISNOR 0x20 #define NOP 0x00 -#define XMAX 640 -#define YMAX 480 +#define XMAX 640 // x axis max pixels +#define YMAX 480 // y axis max pixels #define TRUE 1 -#define SPAN 460 +#define SPAN 460 //this is for the slider bar #define ZERO 100 #define PI 3.14159265 @@ -71,7 +71,7 @@ //unsigned char FONT8x8[97][8]; //unsigned char FONT8x16[97][8]; /************ here the XY reference locations for the buttons ************/ -int righttbutinc=76; +int righttbutinc=80; int xref2=590; //right hand side button x reference int xref1=16; //left hand side button x reference int leftbutinc=76; //y axis increment for the left hand side buttons @@ -87,6 +87,8 @@ unsigned int fill; unsigned int radius; int z; +int color1; +int color2; //float slider; //float vol; @@ -101,8 +103,9 @@ void LCDPutString (char *lcd_string, const char *font_style, unsigned char x, unsigned char y, unsigned char fcolor, unsigned char bcolor); void trigcircle (int xtc, int ytc, int radius, int color); -void show_screen( int xs, int width, int ys, int height ); +void show_screen( int xs, int width, int ys, int height ); void volume_slider (int volume); +void mute (unsigned int onoff); //************************************************************************************ void Write_Command(unsigned char command) { @@ -305,7 +308,7 @@ /*******************************************************************************/ /************** draw a rectangle, filled or not filled *************************/ void LCDSetRect(int x0, int y0, int x1,int y1, int fill, int color) { - int xmin, xmax, ymin, ymax; + int xmin, xmax, ymin, ymax; int i; // check if the rectangle is to be filled if (fill == TRUE) { @@ -464,12 +467,7 @@ SendData(color); } } else { - //LCDSetLine(x0, y0, x1, y0, color); - //LCDSetLine(x0, y1, x1, y1, color); - //LCDSetLine(x0, y0, x0, y1, color); - // LCDSetLine(x1, y0, x1, y1, color); - /***************************/ LCDSetLine(x0, y0, (x0 + xbutsize1), y0, color); LCDSetLine(x0, (y0+ybutsize1), (x0 + xbutsize1), (y0+ybutsize1), color); LCDSetLine(x0, y0, x0, (y0+ybutsize1), color); @@ -481,23 +479,11 @@ void volume_slider(int volume) { //was float int slider; int pos; - //volume=255-volume; - //printf("%u\n\r",volume); - //LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),73,1,BLACK); //erase the previous slider button position - pos = (volume*451)/255; - //pos = volume*(1/254); + pos = (volume*450)/222; slider = ZERO+pos; //((volume/255)*SPAN); - //printf("%u %u\n\r",volume, slider); LCDSetRect((ZERO-10),37,(SPAN+ZERO+10),60,1,BLACK); //erase the previous slider button position -// here we change the colour of the slider bar depending upn the level - if (slider<237) - LCDSetRect(slider,40,(slider+10),60,1,BLUE); - else if (slider<420) - LCDSetRect(slider,40,(slider+10),60,1,WHITE); - else if (slider<470) - LCDSetRect(slider,40,(slider+10),60,1,YELLOW); - else if (slider<580) - LCDSetRect(slider,40,(slider+10),60,1,RED); + LCDSetRect(slider,40,(slider+10),60,1,WHITE); + } /*************************************************************************************************/ /***************************** this is the main central button ******************************/ @@ -518,7 +504,7 @@ void slider_bar(void) { LCDSetRect(100, 20,560,30,0,WHITE);//slider scale volume bar - LCDPutStr("Mute -80 -60 -40 -20 0 +6 +12 +20 +30",10,100,MEDIUM, WHITE,BLACK);//slider scale + LCDPutStr("0ff -82 -65 -48 -30 -12 -6 0 +7 +16",10,100,MEDIUM, WHITE,BLACK);//slider scale } /*************************************************************************************************/ @@ -527,20 +513,19 @@ } /*************************************************************************************************/ void input_buttons(void) { - // int righttbutinc=76; - // int xref2=590; + LCDSetCircle(xref2,(1*righttbutinc),25,WHITE); FontDrawString("CD",(xref2-75),(righttbutinc-20),WHITE,BLACK,&Calibri28); - + LCDSetCircle(xref2,(2*righttbutinc),25,WHITE); FontDrawString("Aux2",(xref2-108),((2*righttbutinc)-20),WHITE,BLACK,&Calibri28); - + LCDSetCircle(xref2,(3*righttbutinc),25,WHITE); FontDrawString("Aux1",(xref2-108),((3*righttbutinc)-20),WHITE,BLACK,&Calibri28); - + LCDSetCircle(xref2,(4*righttbutinc),25,WHITE); FontDrawString("Recdr",(xref2-122),((4*righttbutinc)-20),WHITE,BLACK,&Calibri28); - + LCDSetCircle(xref2,(5*righttbutinc),25,WHITE); FontDrawString("Phono",(xref2-132),((5*righttbutinc)-20),WHITE,BLACK,&Calibri28); } @@ -633,19 +618,19 @@ /*************************************************************************************************/ void Control_buttons(void) { - - sqbutton1(xref1,50,0,WHITE); //mute - FontDrawString("Mute",82,57,WHITE,BLACK,&Calibri28); - - sqbutton1(xref1, 126,0,WHITE); //Rec - FontDrawString("Rec",82,128,WHITE,BLACK,&Calibri28); //gap is 66 - - sqbutton1(xref1,202,0,WHITE); //stdby - FontDrawString("Stdby",82,203,WHITE,BLACK,&Calibri28); - - sqbutton1(xref1, 278,0,WHITE);//power amp - FontDrawString("Amp",82,280,WHITE,BLACK,&Calibri28); - + + sqbutton1(xref1,80,0,WHITE); //mute + FontDrawString("Mute",82,87,WHITE,BLACK,&Calibri28); + + sqbutton1(xref1, 196,0,WHITE); //Rec + FontDrawString("Rec",82,197,WHITE,BLACK,&Calibri28); //gap is 66 + + //sqbutton1(xref1,202,0,WHITE); //stdby + //FontDrawString("Stdby",82,203,WHITE,BLACK,&Calibri28); + + sqbutton1(xref1, 312,0,WHITE);//power amp + FontDrawString("Amp",82,313,WHITE,BLACK,&Calibri28); + //sqbutton1(xref1,400,0,RED); //this is the IR indicator //FontDrawString("IR",82,400,WHITE,BLACK,&Calibri28); @@ -653,30 +638,27 @@ /*************************************************************************************************/ void mute(unsigned int onoff) { //this is the bottom button if (onoff==0) { - sqbutton1(xref1,50,1,BLACK); //first erase the button - wait_ms(800); - sqbutton1(xref1,50,0,WHITE); + sqbutton1(xref1,80,1,BLACK); //first erase the button + sqbutton1(xref1,80,0,WHITE); } //now redraw it else { - sqbutton1(16,50,1,WHITE); + sqbutton1(16,80,1,WHITE); } } /*************************************************************************************************/ void record(unsigned int onoff) { //this is the second from bottom button if (onoff==0) { - sqbutton1(xref1,126,1,BLACK); //first erase the button - wait_ms(800); - sqbutton1(16, 126,0,WHITE); + sqbutton1(xref1,196,1,BLACK); //first erase the button + sqbutton1(16, 196,0,WHITE); } //now redraw it else { - sqbutton1(16,126,1,WHITE); + sqbutton1(16,196,1,WHITE); } } /*************************************************************************************************/ void stdby(unsigned int onoff) { //this is the 3rd from bottom button if (onoff==0) { sqbutton1(xref1,202,1,BLACK); //first erase the button - wait_ms(800); sqbutton1(xref1, 202,0,WHITE); } //now redraw it else { @@ -686,19 +668,17 @@ /*************************************************************************************************/ void pwramp(unsigned int onoff) { //this is the top lefthand side button if (onoff==0) { - sqbutton1(xref1, 278,1,BLACK); //first erase the button - wait_ms(800); - sqbutton1(xref1,278,0,WHITE); + sqbutton1(xref1, 312,1,BLACK); //first erase the button + sqbutton1(xref1,312,0,WHITE); } //now redraw it else { - sqbutton1(xref1, 278,1,WHITE); + sqbutton1(xref1, 312,1,WHITE); } } /*************************************************************************************************/ void infra(unsigned int onoff) { //this is the top lefthand side button if (onoff==0) { sqbutton1(xref1, 400,1,BLACK); //first erase the button - wait_ms(800); sqbutton1(xref1,400,0,RED); } //now redraw it else { @@ -707,31 +687,28 @@ } /*************************************************************************************************/ void trigcircle (int xtc, int ytc, int radius, int color) { - + double circ; double cosnum; double sinum; - - // trigcircle (230, 230, 100, WHITE); - for (circ=0;circ<=360;(circ++)) { + for (circ=0;circ<=volume;circ++) { sinum=sin(circ)*radius; - cosnum=cos(circ)*radius; - LCDSetLine(xtc,ytc,(sinum+xtc),(cosnum+ytc),WHITE); - } - + cosnum=cos(circ)*radius; + LCDSetLine(xtc,ytc,(sinum+xtc),(cosnum+ytc),color); + } } /**************************************************************************************/ -void clear_input_select(void){ +void clear_input_select(void) { -int circinc; - for (circinc=1;circinc<24;circinc++) { + int circinc; + for (circinc=1;circinc<24;circinc++) { -LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK); //phono -LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK); //aux1 -LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK); //aux2 -LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK); //CD -LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK); //recorder - } - } \ No newline at end of file + LCDSetCircle(xref2,(5*righttbutinc),circinc,BLACK); //phono + LCDSetCircle(xref2,(3*righttbutinc),circinc,BLACK); //aux1 + LCDSetCircle(xref2,(2*righttbutinc),circinc,BLACK); //aux2 + LCDSetCircle(xref2,(1*righttbutinc),circinc,BLACK); //CD + LCDSetCircle(xref2,(4*righttbutinc),circinc,BLACK); //recorder + } +} \ No newline at end of file