Exemple #1
0
void createCircle(int xcenter, int ycenter)
{
	unsigned short circle[N][N] = {BG};
	unsigned short bmp[N];
	int x0, y0, f, dFx, dFy, x, y, radius;
	
	x0 = N/2;
	y0 = N/2;
	radius = N/2;
	f = 1 - radius;
	dFx = 0;
	dFy = -2 * radius;
	x = 0;
	y = radius-1;
	
// 	line(x0, y - radius, x0, y0 + radius, circle);
// 	line(x0 - radius, y0, x0 + radius, y0, circle);

	bmp[(y - radius)*(N-1) + x0] = FG;
	bmp[(y0 + radius)*(N-1) + x0] = FG;
	bmp[y0*(N-1) + (x - radius)] = FG;
	bmp[y0*(N-1) + (x0 - radius)] = FG;

	while(x < y)
	{
		if(f >= 0)
		{
			y--;
			dFy += 2;
			f += dFy;
		}
		x++;
		dFx += 2;
		f += dFx + 1;
		
		bmp[(y0 + y)*(N-1) + (x0 - x)] = FG;
		bmp[(y0 + y)*(N-1) + (x0 + x)] = FG;
		bmp[(y0 - y)*(N-1) + (x0 - x)] = FG;
		bmp[(y0 - y)*(N-1) + (x0 + x)] = FG;
		bmp[(y0 + x)*(N-1) + (x0 - y)] = FG;
		bmp[(y0 + x)*(N-1) + (x0 + y)] = FG;
		bmp[(y0 - x)*(N-1) + (x0 - y)] = FG;
		bmp[(y0 - x)*(N-1) + (x0 + y)] = FG;
		
// 		line(x0 - x, y0 + y, x0 + x, y0 + y, circle);
// 		line(x0 - x, y0 - y, x0 + x, y0 - y, circle);
// 		line(x0 - y, y0 + x, x0 + y, y0 + x, circle);
// 		line(x0 - y, y0 - x, x0 + y, y0 - x, circle);
	}
//	convToBitmap(circle, circleBitmap);
	GLCD_Bitmap (xcenter - N/2, ycenter - N/2, N, N, (unsigned char*)bmp);
}
void show_bitmap()
{
	
	
	int ax_Phys[2],ay_Phys[2],i;
	unsigned char *images[] = { gImage_terminator_large,
					gImage_britney
					};
	//clear_buttons_and_frames();
	
	GUIDEMO_ShowIntro("Photographic Bitmap",
                    "Showing"
                    "\nTerminator Sarah Connor Chronicles"
                    "\nBy Siddharth Kaul");
	GLCD_Init ();
  	GLCD_Clear (White);
	i = 0;
	do
	{
		GUI_PID_STATE State;
		GUI_TOUCH_GetState(&State);
		if (State.Pressed) 
		{
			GLCD_Clear(White);
		    GLCD_Bitmap(0, 0, 320, 240, images[i]);
			i++;
			if(i > 1)
			{
				i = 0;	
			}
			
			//break;
		}
	}while(1);//end of do while	
	//delete pointer to free up memory
	free(images);
	/*
	GUI_SetFont(&GUI_Font24B_1);
	GUI_SetColor(GUI_YELLOW);
	GUI_DispStringAt("Terminator", 0,0);*/
}
Exemple #3
0
// This is the actual task that is run
static portTASK_FUNCTION( vLCDUpdateTask, pvParameters )
{
	#if LCD_EXAMPLE_OP==0
	unsigned short screenColor = 0;
	unsigned short tscr;
	unsigned char curLine;
	unsigned timerCount = 0;
	int xoffset = 0, yoffset = 0;
	unsigned int xmin=0, xmax=0, ymin=0, ymax=0;
	unsigned int x, y;
	int i, j;
	float hue=0, sat=0.2, light=0.2;
	#elif LCD_EXAMPLE_OP==1
	unsigned char picIndex = 0;
	#else
	Bad definition
	#endif
	vtLCDMsg msgBuffer;
	vtLCDStruct *lcdPtr = (vtLCDStruct *) pvParameters;

	#ifdef INSPECT_STACK
	// This is meant as an example that you can re-use in your own tasks
	// Inspect to the stack remaining to see how much room is remaining
	// 1. I'll check it here before anything really gets started
	// 2. I'll check during the run to see if it drops below 10%
	// 3. You could use break points or logging to check on this, but
	//    you really don't want to print it out because printf() can
	//    result in significant stack usage.
	// 4. Note that this checking is not perfect -- in fact, it will not
	//    be able to tell how much the stack grows on a printf() call and
	//    that growth can be *large* if version 1 of printf() is used.   
	unsigned portBASE_TYPE InitialStackLeft = uxTaskGetStackHighWaterMark(NULL);
	unsigned portBASE_TYPE CurrentStackLeft;
	float remainingStack = InitialStackLeft;
	remainingStack /= lcdSTACK_SIZE;
	if (remainingStack < 0.10) {
		// If the stack is really low, stop everything because we don't want it to run out
		// The 0.10 is just leaving a cushion, in theory, you could use exactly all of it
		VT_HANDLE_FATAL_ERROR(0);
	}
	#endif

	/* Initialize the LCD and set the initial colors */
	GLCD_Init();
	tscr = Red; // may be reset in the LCDMsgTypeTimer code below
	screenColor = White; // may be reset in the LCDMsgTypeTimer code below
	GLCD_SetTextColor(tscr);
	GLCD_SetBackColor(screenColor);
	GLCD_Clear(screenColor);

	// Added by Matthew Ibarra 2/2/2013
	int xPos = 0;

	// Note that srand() & rand() require the use of malloc() and should not be used unless you are using
	//   MALLOC_VERSION==1
	#if MALLOC_VERSION==1
	srand((unsigned) 55); // initialize the random number generator to the same seed for repeatability
	#endif

	curLine = 5;
	// This task should never exit
	for(;;)
	{	
		#ifdef INSPECT_STACK   
		CurrentStackLeft = uxTaskGetStackHighWaterMark(NULL);
		float remainingStack = CurrentStackLeft;
		remainingStack /= lcdSTACK_SIZE;
		if (remainingStack < 0.10) {
			// If the stack is really low, stop everything because we don't want it to run out
			VT_HANDLE_FATAL_ERROR(0);
		}
		#endif

		#if LCD_EXAMPLE_OP==0
		// Wait for a message
		if (xQueueReceive(lcdPtr->inQ,(void *) &msgBuffer,portMAX_DELAY) != pdTRUE) {
			VT_HANDLE_FATAL_ERROR(0);
		}
		

		#if EXAMPLE_COLOR_CHANGE==1
		//Log that we are processing a message -- more explanation of logging is given later on
		vtITMu8(vtITMPortLCDMsg,getMsgType(&msgBuffer));
		vtITMu8(vtITMPortLCDMsg,getMsgLength(&msgBuffer));

		// Take a different action depending on the type of the message that we received
		switch(getMsgType(&msgBuffer)) {
		case LCDMsgTypePrint: {
			// This will result in the text printing in the last five lines of the screen
			char   lineBuffer[lcdCHAR_IN_LINE+1];
			copyMsgString(lineBuffer,&msgBuffer,lcdCHAR_IN_LINE);
			// clear the line
			GLCD_ClearLn(curLine,1);
			// show the text
			GLCD_DisplayString(curLine,0,1,(unsigned char *)lineBuffer);
			curLine++;
			if (curLine == lcdNUM_LINES) {
				curLine = 5;
			}
			break;
		}
		case LCDMsgTypeTimer: {
			// Note: if I cared how long the timer update was I would call my routine
			//    unpackTimerMsg() which would unpack the message and get that value
			// Each timer update will cause a circle to be drawn on the top half of the screen
			//   as explained below
			if (timerCount == 0) {
				/* ************************************************** */
				// Find a new color for the screen by randomly (within limits) selecting HSL values
				// This can be ignored unless you care about the color map
				#if MALLOC_VERSION==1
				hue = rand() % 360;
				sat = (rand() % 1024) / 1023.0; sat = sat * 0.5; sat += 0.5;
				light = (rand() % 1024) / 1023.0;	light = light * 0.8; light += 0.10;
				#else
				hue = (hue + 1); if (hue >= 360) hue = 0;
				sat+=0.01; if (sat > 1.0) sat = 0.20;	
				light+=0.03; if (light > 1.0) light = 0.20;
				#endif
				screenColor = hsl2rgb(hue,sat,light);
				// Now choose a complementary value for the text color
				hue += 180;
				if (hue >= 360) hue -= 360;
				tscr = hsl2rgb(hue,sat,light);
				GLCD_SetTextColor(tscr);
				GLCD_SetBackColor(screenColor);
				// End of playing around with figuring out a random color
				/* ************************************************** */

				// clear the top half of the screen
				GLCD_ClearWindow(0,0,320,120,screenColor); 

				// Now we are going to draw a circle in the upper left corner of the screen
				int	count = 200;
				float radius;
				float inc, val, offset = MAX_RADIUS;
				unsigned short circleColor;
				inc = 2*M_PI/count;
				xmax = 0;
				ymax = 0;
				xmin = 50000;
				ymin = 50000;
				val = 0.0;
				for (i=0;i<count;i++) {
					// Make the circle a little thicker
					// by actually drawing three circles w/ different radii
					float cv = cos(val), sv=sin(val);
					circleColor = (val*0xFFFF)/(2*M_PI);
					GLCD_SetTextColor(circleColor);
					for (radius=MAX_RADIUS-2.0;radius<=MAX_RADIUS;radius+=1.0) {
						x = round(cv*radius+offset);
						y = round(sv*radius+offset);
						if (x > xmax) xmax = x;
						if (y > ymax) ymax = y;
						if (x < xmin) xmin = x;
						if (y < ymin) ymin = y;
						GLCD_PutPixel(x,y);	
					}
					val += inc;
				}
				// Now we are going to read the upper left square of the LCD's
				// memory (see its data sheet for details on that) and save
				// that into a buffer for fast re-drawing later
				if (((xmax+1-xmin)*(ymax+1-ymin)) > BUF_LEN) {
					// Make sure we have room for the data
					VT_HANDLE_FATAL_ERROR(0);
				}
				unsigned short int *tbuffer = buffer;
				unsigned int width = (xmax+1-xmin);
				for (j=ymin;j<=ymax;j++) {
					GLCD_GetPixelRow (xmin,j,width,tbuffer);
					tbuffer += width;
				}
				// end of reading in the buffer
				xoffset = xmin;
				yoffset = ymin;
			} else {
				// We are going to write out the data read into the buffer
				//   back onto the screen at a new location
				// This is *very* fast

				// First, clear out where we were
				GLCD_ClearWindow(xoffset,yoffset,xmax+1-xmin,ymax+1-ymin,screenColor);
				// Pick the new location
				#if MALLOC_VERSION==1
				xoffset = rand() % (320-(xmax+1-xmin));
				yoffset = rand() % (120-(ymax+1-ymin));
				#else
				xoffset = (xoffset + 10) % (320-(xmax+1-xmin));
				yoffset = (yoffset + 10) % (120-(ymax+1-ymin));
				#endif
				// Draw the bitmap
				GLCD_Bitmap(xoffset,yoffset,xmax+1-xmin,ymax-1-ymin,(unsigned char *)buffer);
			}
			timerCount++;
			if (timerCount >= 40) {	  
				// every so often, we reset timer count and start again
				// This isn't for any important reason, it is just to for this example code to do "stuff"
				timerCount = 0;
			}
			break;
		}
		default: {
			// In this configuration, we are only expecting to receive timer messages
			VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer));
			break;
		}
		} // end of switch()
		#endif
		#if MILESTONE_1==1
		// Added by Matthew Ibarra 2/2/2013
			if(timerCount==0) {
				GLCD_Clear(screenColor);
				
				// Draw the vertical gridlines onto the LCD
				int i;
				for(i = 320/6; i < 315; i = i + 320/6) {
					GLCD_ClearWindow(i, 0, 1, 240, Red);
				}
				
				// Draw the vertical gridlines onto the LCD
				for(i = 240/4; i < 235; i = i + 240/4) {
					GLCD_ClearWindow(0, i, 320, 1, Red);
				}
				
				//Output Scale on LCD
				GLCD_DisplayString(29, 0, 0, (unsigned char*) "V/div=2.5 s/div=3");
				timerCount++;
			}
			int adcValue;
			getMsgValue(&adcValue, &msgBuffer);
			int displayValue;
			displayValue = 120 - (adcValue * 120)/(0x100);
			GLCD_ClearWindow(xPos, displayValue, 2, 2, Black);
			xPos += 2;
			if(xPos > 320) {
				timerCount = 0;
				xPos = 0;
			}
		#endif

		// Here is a way to do debugging output via the built-in hardware -- it requires the ULINK cable and the
		//   debugger in the Keil tools to be connected.  You can view PORT0 output in the "Debug(printf) Viewer"
		//   under "View->Serial Windows".  You have to enable "Trace" and "Port0" in the Debug setup options.  This
		//   should not be used if you are using Port0 for printf()
		// There are 31 other ports and their output (and port 0's) can be seen in the "View->Trace->Records"
		//   windows.  You have to enable the prots in the Debug setup options.  Note that unlike ITM_SendChar()
		//   this "raw" port write is not blocking.  That means it can overrun the capability of the system to record
		//   the trace events if you go too quickly; that won't hurt anything or change the program execution and
		//   you can tell if it happens because the "View->Trace->Records" window will show there was an overrun.
		//vtITMu16(vtITMPortLCD,screenColor);

		#elif 	LCD_EXAMPLE_OP==1
		// In this alternate version, we just keep redrawing a series of bitmaps as
		//   we receive timer messages
		// Wait for a message
		if (xQueueReceive(lcdPtr->inQ,(void *) &msgBuffer,portMAX_DELAY) != pdTRUE) {
			VT_HANDLE_FATAL_ERROR(0);
		}
		if (getMsgType(&msgBuffer) != LCDMsgTypeTimer) {
			// In this configuration, we are only expecting to receive timer messages
			VT_HANDLE_FATAL_ERROR(getMsgType(&msgBuffer));
		}
  		/* go through a  bitmap that is really a series of bitmaps */
		picIndex = (picIndex + 1) % 9;
		GLCD_Bmp(99,99,120,45,(unsigned char *) &ARM_Ani_16bpp[picIndex*(120*45*2)]);
		#else
		Bad setting
		#endif	
	}
}
Exemple #4
0
//////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                          //
//                                        Main function                                     //
//                                                                                          //
//////////////////////////////////////////////////////////////////////////////////////////////
int main(void)
{	//Test
	int last_nombre = 4;
	char str[64] = "Test de String...";
	unsigned char distanceActuel = 0;
	
	//Variables protocole de liaison de donnée
	char trame_a_envoye = 0, trame_complete = 0, trameRX[NBROCTET], trameTX[NBROCTET];
	
	//Initial configuration
	setup_oscillator();
	config();
	
	//Init fifo
	fifo_init();
	radio_dir(TRM_RX);		//Module en réception

	//Display welcome screen:	ToDo
	#ifdef USE_GLCD
	GLCD_Bitmap((char*)Base1, 0, 0, 128, 64);
	#endif
	

	
	//Test
//	index = 0;
//	while(1)
//	{
//	//	result = get_offset(dirty_buf[index], dirty_buf[index + 1], flag);
//		result = get_flag(flag);
//		Nop();
//		clean_buffer(result, 16);
//		Nop();
//	}
	
	//Main loop
	while (1)
	{

		#ifdef AUTO
		routine_auto(&trame_a_envoye, &trame_complete, trameTX, trameRX);
		#endif

		#ifdef BORNE
		routine_borne(&trame_a_envoye, &trame_complete, trameTX, trameRX);
		#endif
	
		
		//Test: encodeur et GLCD
		if((last_nombre != nombre) || buttonPress)	//Si une transition a eu lieu
		{
			#ifdef USE_GLCD
			
			GLCD_ClearScreen();
			GLCD_Bitmap((char*)Base1, 0, 0, 128, 64);
			if(buttonPress && !toEcran1)
			{
				BORNERESERVE = nombre;
				GLCD_GoTo(0,5);
				GLCD_WriteString(RESERVE);
				toEcran1 = 1;
			}
			else if(buttonPress && toEcran1)
			{
				toEcran1 = 0;
				BORNERESERVE = 3;
				confirm=2;
			}
			sprintf(str,"%d",SERIALBATTERIE);
			GLCD_GoTo(107,0);
			GLCD_WriteString(str);

			#endif
				switch(nombre)
				{
					case 0:
						#ifdef USE_GLCD
						DISTANCE = D1;
						GLCD_GoTo(0,2);
						GLCD_WriteString(ADR1A);
					if(!toEcran1)
					{
						GLCD_GoTo(0,3);
						GLCD_WriteString(ADR2);
						GLCD_GoTo(0,4);
						GLCD_WriteString(ADR3);
					}
						#endif
						break;
					case 1:
						#ifdef USE_GLCD
						DISTANCE = D2;
						GLCD_GoTo(0,3);
						GLCD_WriteString(ADR2A);
					if(!toEcran1)
					{
						GLCD_GoTo(0,2);
						GLCD_WriteString(ADR1);
						GLCD_GoTo(0,4);
						GLCD_WriteString(ADR3);
					}
						#endif
						break;
					case 2:
						#ifdef USE_GLCD
						DISTANCE = D3;
					if(!toEcran1)
					{
						GLCD_GoTo(0,2);
						GLCD_WriteString(ADR1);
						GLCD_GoTo(0,3);
						GLCD_WriteString(ADR2);
					}
						GLCD_GoTo(0,4);
						GLCD_WriteString(ADR3A);
						#endif
						break;
					default:
						#ifdef USE_GLCD
						GLCD_ClearScreen();
						GLCD_Bitmap((char*)Base1, 0, 0, 128, 64);
						#endif
						break;
				}
			#ifdef USE_GLCD
			
			GLCD_GoTo(90,7);
			GLCD_WriteString(METER);
			distanceActuel = DISTANCE;	
			buttonPress = 0;		
			last_nombre = nombre;
			if(confirm==2)
			{
				if(D1<DISTANCEPROCHE){
					borneProche(0);	
				}
				else if(D2<DISTANCEPROCHE){
					borneProche(1);
				}
				else if(D3<DISTANCEPROCHE){
					borneProche(2);
				}
				if(confirm==1)
				{
					buttonPress=1;
					toEcran1=0;
				}
				else if(confirm==0)
				{
					buttonPress=0;
					toEcran1=0;
					last_nombre=4;	
				}
			}
			#endif
		}	
		
		//Données sortantes
		if(trame_a_envoye == 1)
		{
			envoie = rf_envoie(trameTX, (char *)clean_buf);
			
			if(envoie == 1)
				trame_a_envoye = 0;
		}
		
		//Flags - Données entrantes	
		if(rf_flag == 1)//&& trame_complete == 0)
		{
			//Actualise la batterie
			#ifdef USE_GLCD
			getBatt();
			sprintf(str,"%03i",BATTERIE);			
			GLCD_GoTo(80,0);
			if(nombre==0)
			{DISTANCE = D1;}
			else if(nombre==1)
			{DISTANCE = D2;}
			else if(nombre==2)
			{DISTANCE = D3;}
			
			GLCD_WriteString(str);
			sprintf(str,"%i",DISTANCE);
			GLCD_GoTo(40,7);
			GLCD_WriteString(str);
			#endif

			result = get_flag(flag);
			if(result != 10)
			{
				clean_buffer(result, 32);

				//Extraction des octets vers la couche application
				trame_complete = rf_gerer_RX((char *)clean_buf, trameRX);			
			}
			
			//Remise à zéro de la détection
			rf_flag = 0;
			result = 10;
		}
		
		//
		
		#ifdef GPS_FEEDTHROUGH
		//TestGPS
		#ifdef DEBUG_MPSIM
			gps_flag =1;  //REMOVE
		#endif
		
		if(gps_flag)
		{
			gps_flag = 0;
			//Filtre les données quand le buffer est plein
			
			#ifdef DEBUG_MPSIM
				(gpsstr[3]='R'); //REMOVE
			#endif
			
			if((gpsstr[3]=='R'))
			{
				for(a =0;a<47;a++)
				{
					gps[a] = gpsstr[a]; //Buffer de travail
				}
			//	puts_usart1(gpsstr);
				//gps[] = "$GPRMC,174254.000,V,4522.75800,N,07155.43400,W";
				#ifdef DEBUG_MPSIM
					gps[20]='4';
					gps[21]='5';
					gps[22]='2';
					gps[23]='2';
					gps[25]='7';
					gps[26]='5';
					gps[27]='8';
					
					gps[33]='0';
					gps[34]='7';
					gps[35]='1';
					gps[36]='5';
					gps[37]='5';
					gps[39]='4';
					gps[40]='3';
					gps[41]='4';
					gps[45]='W';
				#endif
				convStr();
				
				//LaA = 45.3793;
				//LoA= -71.9239;
				
				assignDist(LaA,LoA);				
			}
		}
		#endif
/*
		#ifdef USE_GLCD

		if(buttonPress)
		{
			switchScreen(last_nombre);
			buttonPress = 0;
		}
		
		if(distanceActuel < DISTANCEBATT && BATTERIE < 50 && ecran ==2)
		{
			switchBatt();
		}
		#endif
*/
		
		if(buttonPress)
		{
			#ifdef BORNE
			buttonPress = 0;
			char donnee_test[NBROCTET] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37};
			envoie = rf_envoie(donnee_test, (char *)clean_buf);
			#endif
			#ifdef AUTO
			puts_usart1(gps);
			#endif
		}
		
		
		
		if(rssi_flag)
		{
			rssi_flag = 0;
			//Filtre les données quand le buffer est plein
			rssi = get_rssi();
		}
		
	}
    return 0;
}
Exemple #5
0
void main()
{
	unsigned char i2cdata = 0, usartdata = 0;
	unsigned char data = 0;
	unsigned char str[] = "nom de la toune";
	unsigned char AUTO[] = "Auto";
	unsigned char NORMAL[] = "Normal";
	unsigned char CUTOM1[] = "Custom 1";
	unsigned char CUTOM2[] = "Custom 2";
	unsigned char CUTOM3[] = "Custom 3";
	// Config position
	short xposMMODE = 40;
	short yposMMODE = 2; //(tranche de 8)


	initialisation();	//Initialise tout


LED1=0;
LED2=1;
LED3=1;
		while(debut)
		{
			//chech dsp pour signal autocorrélation puis debut à 1
			if (read1==0xFF)
				debut=0;
			LED1 = 0;
		}
		LED1 = 1;	
		//Boucle infinie
	while(1)
	{
		//Affichage de l'écran initial
		if(!debut)
		{
			GLCD_Bitmap(logo, 0, 0, 128, 64);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			GLCD_ClearScreen();
			GLCD_Bitmap(PAUSE, 47, 2, 35, 24);
			debut=1;
		}

		if(last_nombre != nombre)	//Si une transition a eu lieu, gérer les menus d'affichage
		{
			switch(nombre)
			{
				case 0:
					
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(MODEselec, 1, 6, 68, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,1);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,1);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,1);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,1);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,1);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 1:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(SPOTselec, 70, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 2:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(STROBselec, 90, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);							
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 3:
					//GLCD_ClearScreen();
					GLCD_Bitmap(ICONES, 0, 6, 128, 16);
					GLCD_Bitmap(BARRselec, 110, 6, 18, 16);
					GLCD_GoTo(5,7);
					if(modeselect == 0)
						GLCD_WriteString(AUTO,0);
					else if(modeselect == 1)
						GLCD_WriteString(NORMAL,0);	
					else if(modeselect == 2)
						GLCD_WriteString(CUTOM1,0);							
					else if(modeselect == 3)
						GLCD_WriteString(CUTOM2,0);
					else if(modeselect == 4)
						GLCD_WriteString(CUTOM3,0);								
					if(proj)
						GLCD_Bitmap(flecheICO, 75, 5, 8, 8); //SPOT
					else
						GLCD_Bitmap(flecheNULL, 75, 5, 8, 8); //SPOT
					if(strob)
						GLCD_Bitmap(flecheICO, 95, 5, 8, 8); //STROB
					else
						GLCD_Bitmap(flecheNULL, 95, 5, 8, 8); //STROB	
					if(vu)
						GLCD_Bitmap(flecheICO, 115, 5, 8, 8); //BARR
					else
						GLCD_Bitmap(flecheNULL, 115, 5, 8, 8); //BARR
					break;
				case 4:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,1);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;	
				case 5:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,1);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 6:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,1);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 7:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,1);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,0);
					break;
				case 8:
					GLCD_ClearScreen();
					GLCD_Bitmap(titreMODE, 0, 0, 128, 16);
					GLCD_GoTo(xposMMODE,yposMMODE);
					GLCD_WriteString(AUTO,0);
					GLCD_GoTo(xposMMODE,yposMMODE+1);
					GLCD_WriteString(NORMAL,0);
					GLCD_GoTo(xposMMODE,yposMMODE+2);
					GLCD_WriteString(CUTOM1,0);
					GLCD_GoTo(xposMMODE,yposMMODE+3);
					GLCD_WriteString(CUTOM2,0);
					GLCD_GoTo(xposMMODE,yposMMODE+4);
					GLCD_WriteString(CUTOM3,1);
					break;					
			}
			last_nombre = nombre;
			}
			//Si on appuit sur le bouton, activer l'actuateur en question ou changer de menu
			if(!ENC_SW)
			{
				while(!ENC_SW);
				Delay10KTCYx(125);
				switch(nombre)
					{
						case 0:
							emplacement=2;
							nombre=modeselect+4;
							last_nombre=0;
						break;
						case 1:
						if(proj)
							proj=0;
						else
							proj=1;
						last_nombre=0;
						break;
						case 2:
						if(strob)
							strob=0;
						else
							strob=1;
						last_nombre=0;
						break;
						case 3:
						if(vu)
							vu=0;
						else
							vu=1;
						last_nombre=0;
						break;
						case 4:
							modeselect=0;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 5:
							modeselect=1;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 6:
							modeselect=2;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 7:
							modeselect=3;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
						case 8:
							modeselect=4;
							emplacement=1;
							nombre=0;
							GLCD_ClearScreen();
						break;
					}	
			}
		
		//Si la pédale est appuyée, changer de on-off
		if(!PORTBbits.RB3)
		{
			while(!PORTBbits.RB3);		//Attente que la pédale soit relâché
			if(etatplay==0)
			{
				play=1;
				pause=0;
				etatplay=1;
			}
			else
			{
				pause=1;
				last_nombre=9;
				etatplay=0;
			}
		}
// ---------------------------------------------------------------------------------------
// PLAY
		if(play)
		{
			//Affiche play à l'écran
			GLCD_Bitmap(PLAY, 47, 2, 35, 24);
			
			//Envoie le mode vers le dsp
			euart_out=modeselect;
			while(BusyUSART());
			putcUSART(euart_out);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			Delay10KTCYx(0);
			GLCD_ClearScreen();
			last_nombre=9;	
			play=1;
		}
// ---------------------------------------------------------------------------------------
// PAUSE
		if(emplacement == 1)
		{
			//Si non-pause, afficher les barres graphiques
			if(pause==0)
			{
				graphVU(chan_L,chan_R);
			}
			//Si pause, afficher l'image du pause
			else if(pause==1 && last_nombre!=nombre)
			{
				GLCD_ClearScreen();			
				GLCD_Bitmap(PAUSE, 47, 2, 35, 24);
				last_nombre=9;
			}
			//Affiche le nom de la chanson en cours
			GLCD_GoTo(2,0);
			if(toune==1)
				GLCD_WriteString(music_1,0);						
			else if(toune==2)
				GLCD_WriteString(music_2,0);
			else if(toune==3)
				GLCD_WriteString(music_3,0);			
		}

// I2C,  actualiser la FFT et envoyer les données vers le contrôleur principal
		if(flag_i2c)
		{
			flag_i2c=0;
			//Si trame FFT initiale détecté, commence à mettre à jour la FFT
			if((read3&0b00010000)==0x10)
			{
				compteur_fft=1; 
			}
			//Met à jour chaque trame de la FFT
			switch(compteur_fft)
					{
						case 1:
							fft1=(read3&0b00001111);
						break;
						case 2:
							fft2=(read3&0b00001111);
						break;
						case 3:
							fft3=(read3&0b00001111);
						break;
						case 4:
							fft4=(read3&0b00001111);
						break;
						case 5:
							fft5=(read3&0b00001111);
						break;
						case 6:
							fft6=(read3&0b00001111);
						break;
						case 7:
							fft7=(read3&0b00001111);
						break;
						case 8:
							fft8=(read3&0b00001111);
						break;
						case 9:
							fft9=(read3&0b00001111);
						break;
						case 10:
							fft10=(read3&0b00001111);
						break;
						case 11:
							fft11=(read3&0b00001111);
						break;
						case 12:
							fft12=(read3&0b00001111);
						break;
						case 13:
							fft13=(read3&0b00001111);
						break;
						case 14:
							fft14=(read3&0b00001111);
						break;
						case 15:
							fft15=(read3&0b00001111);
						break;
						case 16:
							fft16=(read3&0b00001111);
							compteur_fft=0;
						break;
						default:
							LED2=1;
						break;
					}	
			//Lorsque la FFT est actualiser, la faire afficher à l'écran
			if(compteur_fft==1 && (emplacement ==1)  && (etatplay==1))
				graphFFT(2*fft1,2*fft2,2*fft3,2*fft4,2*fft5,2*fft6,2*fft7,2*fft8,2*fft9,2*fft10,2*fft11,2*fft12,2*fft13,2*fft14,2*fft15,2*fft16);	
			compteur_fft++;
			//Choix de la chanson selon les données reçu
			if((read4&0b00001111)==0b00000001)
				toune=1;
			else if((read4&0b00001111)==0b00000010)
				toune=2;
			else if((read4&0b00001111)==0b00000011)
				toune=3;
			//Masques pour savoir les actuateurs à activer
			i2c_actuateur=0b00001000;
			if(vu && !pause)
				i2c_actuateur |= 0b00000001;			
			if(proj && !pause)
				i2c_actuateur |= 0b00000010;
			if(strob && !pause)
				i2c_actuateur |= 0b00000100;
			
			//Émet I2C uniquement sur nouvelles données
			if((last_i2c_1 != read2) || (last_i2c_2 != i2c_actuateur))
			{
				tst_str[1] = read2;
				tst_str[2] = i2c_actuateur;
				send_str_I2C(0x40, tst_str);
			}
			last_i2c_1 = read2;		
			last_i2c_2 = i2c_actuateur;	
		}
		if(play)
		{
			while(BusyUSART());
			putcUSART(euart_out);
			play=0;
		}
	}
}