예제 #1
0
void InitializeAppPong()
{			
    joy  = -1;
    adc  = -1;
    btn  = -1;
	
		BackgroundColor = GLCD_COLOR_BLACK;
	  ForegroundColor = GLCD_COLOR_WHITE;
		BallForegroundColor = GLCD_COLOR_RED;
	  LeftPaddleForegroundColor = GLCD_COLOR_BLUE;
		RightPaddleForegroundColor = GLCD_COLOR_GREEN;
	
    GLCD_SetBackgroundColor (BackgroundColor);
    GLCD_SetForegroundColor (ForegroundColor);
    GLCD_SetFont            (&GLCD_Font_16x24);
		GLCD_ClearScreen();
	
		// Paddle 0 (left) position coordinates
		new_paddle0_Y = (GLCD_HEIGHT / 2) - (paddleH / 2);
		new_paddle0_X = borderWidth + paddleW;
		// Paddle 1 (right) position coordinates
		new_paddle1_Y = (GLCD_HEIGHT / 2) - (paddleH / 2);
		new_paddle1_X = GLCD_WIDTH - (borderWidth + (2*paddleW));

		// Ball position coordinates
		new_ball_X = GLCD_WIDTH/2;
				
		new_ball_Y = new_paddle0_Y + ball_rad;
				
				
		// We don't want to have the ball running towards the left whenever a new game start !
		ballVelocityX = abs(ballVelocityX);
		
		appPongState = Normal;		
}
예제 #2
0
void initialisation(void)
{
	//ADC Off
	ADCON0bits.ADON = 0;
	ADCON1 = 0b00001111;
	
	//Définition des IO
	define_i_o();
	
	//Périphériques		
//	init_timer_0();
	config_port_b();
	init_i2c();	
	init_eusart();
	//config_euart();
	
	//Init GLCD
	GLCD_Initalize();
	Delay10KTCYx(0);		//Modifier?
	GLCD_ClearScreen();		
	
	// On autorise toutes les interruptions
	RCONbits.IPEN = 0;	//1 niveau
	INTCONbits.GIE = 1;
	INTCONbits.PEIE = 1;
}
예제 #3
0
void main (void)
    {
    CMCON |= 7;
    ADCON1=0x0F;
    GLCD_Initialize();
    GLCD_ClearScreen();
while(1)
    {
    GLCD_WriteString("ETIQ TECHNOLOGIES");
    Delay_s(2);
    GLCD_Circle(64, 32, 28);
    Delay_s(2);
    GLCD_ClearScreen();
    GLCD_Rectangle(30, 12, 70,40);
    Delay_s(2);
    GLCD_ClearScreen();
    }
}
예제 #4
0
void InitializeAppMenu()
{
	selection = 0;
	BackgroundColor = GLCD_COLOR_WHITE;
	ForegroundColor = GLCD_COLOR_BLACK;
	GLCD_SetBackgroundColor (BackgroundColor);
  GLCD_SetForegroundColor (ForegroundColor);
	GLCD_ClearScreen();
	
}
int main(void)
{
  hours_tens = 1;
  hours_ones = 3;
  minutes_tens = 3;
  minutes_ones = 6;
  seconds_tens = 4;
  seconds_ones = 9;
	
  GLCD_Initalize();
  GLCD_ClearScreen();

/*//Draw the Hackaday Logo:
  GLCD_GoTo(0,0);
  for (unsigned char j=0; j<8; j++)
  {
    GLCD_GoTo(0,j);
    for (unsigned char i=0; i<64; i++)
    {
      GLCD_WriteData(skull[i+(j*64)]);
    }
  }
*/

  while(1)
  {
    //FIXME: Optimize so we don't redraw the entire screen every second.
    ShowBigTime(hours_tens, hours_ones, minutes_tens, minutes_ones);
    GLCD_GoTo(0,7);

    //Easter Egg:
    if ((hours_tens == 1) && (hours_ones == 3) && (minutes_tens == 3) && (minutes_ones == 7))
    {
      //Display Hackaday URL when time is 13:37
      GLCD_WriteString(" http://hackaday.com ");
      
    }
    else
    {
      //Display Day, Date, and Seconds
      GLCD_WriteString("Tuesday 12/3/2013  ");
      GLCD_WriteChar(seconds_tens+48); //ASCII offset
      GLCD_WriteChar(seconds_ones+48); //ASCII offset
    }
    IncSecond();

    //FIXME: This should be a hardware timer for accuracy
    //FIXME: This should use an RTC for accuracy
    Delay_ms(1000);
    
    
  }
}
예제 #6
0
파일: LCD.c 프로젝트: sonnle/srdesign
void LCD_Initiate(void)
{
	//Initialize the LCD
	GLCD_Initialize();
	
	// Set font size
	GLCD_SetFont(&GLCD_Font_16x24);
	
	// Set background and foreground colors
	GLCD_SetBackgroundColor(GLCD_COLOR_WHITE);
	GLCD_SetForegroundColor(GLCD_COLOR_BLACK);
	
	// Clear the screen for first use
	GLCD_ClearScreen();
}
예제 #7
0
int main (void){
			
		ADC_Initialize          ();           // Initialize A/D Converter      
    GLCD_Initialize         ();           // Initialize Graphical LCD           
    Joystick_Initialize     ();           // Initialize joystick                

    GLCD_SetBackgroundColor (BackgroundColor);
    GLCD_SetForegroundColor (ForegroundColor);
    GLCD_SetFont            (&GLCD_Font_16x24);
		GLCD_ClearScreen();		
		
		// Select P0.16 as output 
		LPC_GPIO0->FIODIR |= 0x00010000;
			
		menuChoice = InitMenu;
		while (1)
			{
					switch(menuChoice)
					{
						case InitMenu:
							InitializeAppMenu();
							menuChoice = Menu;
							break;
						case Menu:
							AppMenu();
							break;
						case InitPong:
							initDMA();
							InitializeAppPong();
							menuChoice = Pong;
							break;
						case Pong:
							AppPong();
							break;
						case InitShooter:
							InitializeAppShooter();
							menuChoice = Shooter;
							break;
						case Shooter:
							AppShooter();
							menuChoice = InitMenu;
							break;
					}	
			

			}			
}
예제 #8
0
파일: LCD.c 프로젝트: sonnle/srdesign
void LCD_InsulinOverDosePrevention(STATUS current)
{
	GLCD_ClearScreen();
	GLCD_SetFont(&GLCD_Font_16x24);
	if(current == Bolus_Status)
	{
		sprintf(LCD_StringInsulinOD, "Bolus: %d units", Profile_CurrentOptions.BolusSteps);
	}
	else if(current == Basal_Status)
	{
		sprintf(LCD_StringInsulinOD, "Basal: %d units", Profile_CurrentOptions.BasalStepsPerDose);
	}
	GLCD_DrawString(20, 60, LCD_StringInsulinOD);
	GLCD_SetFont(&GLCD_Font_6x8);
	GLCD_DrawString(20, 100, "Please wait to administer insulin\0");
	GLCD_DrawString(20, 120, "Press down on joystick to advance\0");
}
예제 #9
0
파일: main.c 프로젝트: maxk9/etro_new
void vLCDTask( void *pvParameters )
{
	xLCDMessage xMessage;
	
	/* Initialise the LCD and display a startup message. */
	GLCD_Initialize();

	taskENTER_CRITICAL();
	GLCD_ClearScreen();
	taskEXIT_CRITICAL();
	
	for( ;; )
	{
		/* Wait for a message to arrive that requires displaying. */
		while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );

		/* Display the message.  Print each message to a different position. */
		GLCD_PutString(xMessage);
	}
}
예제 #10
0
파일: main.c 프로젝트: martinien/s6eep06
void config(void)
{	
	//Define inputs/outputs
	define_io();		
	
	//Assignation des périphériques
	peripheral_pin_select();
	
	//Config peripherals:
 	setup_usart1(); 		//PC/GPS
	setup_usart2(); 		//Radio
	setup_timer1();			//10ms timebase
	setup_adc();			//ADC
	
	//Encoder interrupts:
	_INT0IF = 0;
	_INT1IF = 0;
	_INT0IE = 1;
	_INT1IE = 1;
	
	//Disable unwanted interrupts:
	_U1TXIE = 0;
	_U2TXIE = 0;
	_SPI1IE = 0;
	_SPI1IF = 0;
	_T3IE = 0;
	_T2IE = 0;
	_OC2IE = 0;
	_IC1IE = 0;
	_OC1IE = 0;
	_IC1IE = 0;
	_U1ERIE = 0;
	_U2ERIE = 0;
	_PMPIE = 0;
	
	#ifdef USE_GLCD
	//Init GLCD
	GLCD_Initalize();
	GLCD_ClearScreen();
	#endif		
}
예제 #11
0
void InitializeAppShooter()
{
  TimerId = osTimerCreate (osTimer(PeriodicTimer), osTimerPeriodic, NULL);
  if (TimerId) {
    osTimerStart (TimerId, 8);
  }
	
  /* Prepare display */
	GLCD_SetBackgroundColor (GLCD_COLOR_BLACK);
  GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
  GLCD_ClearScreen();
	
	// Variables initialization
	timerTick_01 = 0;										// Timer counter for Main
	timerTick_02 = 0;										// Timer counter for drawing the Objects
	plane_x = 0;												// Plane X position
	plane_y = 110;											// Plane Y position
	actualBallNumber = 0;
	newBall = false;										// Tells to the routine S_MoveBall to create a new ball
	objectNumb = 0;
	objectColor = 1;
	stopThreads = false;
	ballTimer = 0;
	stopShooter = false;
	playerScore = 0;
	machineScore = 0;
	
	S_IncPlayerScore();
	S_IncMachineScore();
	
	if(S_firstTime){
		glcd_semaph_id = osSemaphoreCreate(osSemaphore(glcd_semaph), 1); // Semaphore binaire, only one thread at the same time
		planeVar_mutex_id = osMutexCreate(osMutex(planeVar_mutex));
		objectVar_mutex_id = osMutexCreate(osMutex(objectVar_mutex));
		S_firstTime = false;
	}
	
	idThreadPlane = osThreadCreate (osThread (S_Thread_MovePlane), NULL);   // create the thread

}
예제 #12
0
파일: main.c 프로젝트: martinien/s6eep06
//////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                          //
//                                        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;
}
예제 #13
0
파일: LCD.c 프로젝트: sonnle/srdesign
void LCD_ClearScreen(void)
{
	GLCD_ClearScreen();
}
예제 #14
0
// Main function
int main (void) 
{  
// Local variable definations
emxArray_uint8_T *xaxis;
emxArray_uint8_T *yaxis;
emxArray_uint8_T *norm_xaxis_filt;
emxArray_uint8_T *norm_yaxis_filt;

uint16_T count;
uint8_T xaxis2,yaxis2;

long j = 0;

int again = 1;

char letter;
char letterstr[10];
int i=0;
letterstr[i] = '\0';

// Variable Initialisation
	for(j=0;j<MAX_VALUE;j++)
	{
		xdata[j] = 0;
		ydata[j] = 0;
	}

	
// Function Initialisation
	PINSEL2 &= ~((1<<2)|(1<<3));
	GLCD_Initalize();				  //Initialize the LCD
	Init_UART();
	InitADC();

// Welcome message
	GLCD_ClearScreen();
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Intelligent e-book");
//	for(j=0;j<999999;j++);
	delay_ms(2000);

// Calibration
	//Left bottom
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(0,7);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();


	x1 = xaxis1;
	y1 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);

	//Right top
	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Calibration");
	GLCD_GoTo(10,4);	
	GLCD_WriteString("Touch the point");
	GLCD_GoTo(120,0);	
	GLCD_WriteString("o");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;
	}while(xaxis1==0 && yaxis1==0);
	for(j=0;j<25;j++)
	capture();

	x2 = xaxis1;
	y2 = yaxis1;

	GLCD_GoTo(10,5);	
	GLCD_WriteString("Stored");
	delay_ms(1000);


while(again==1)
{
again = 0;

// Capturing xaxis and yaxis

GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(12,4);		
GLCD_WriteString("Waiting for input");
do
{
xaxis1 = Read_xaxis();
yaxis1 = Read_yaxis();

if(xaxis1<10)
	xaxis1 = 0;
if(yaxis1<10)
	yaxis1 = 0;

}while(xaxis1==0 && yaxis1==0);

xyelem = 0;
count = 0;
GLCD_ClearScreen();
GLCD_GoTo(0,0);		

// Eliminate first 25 samples
	for(j=0;j<25;j++)
	capture();

while(count!=250)
{
	capture();

	if(xaxis1!=0 && yaxis1!=0 && count==0)
	{
		
//	xaxis2 = (uint8_T)(((xaxis1-80)*255)/730);
//	yaxis2 = (uint8_T)(((yaxis1-100)*255)/650);
	xaxis2 = (uint8_T)(((xaxis1-x1)*255)/(x2-x1));
	yaxis2 = (uint8_T)(((yaxis1-y1)*255)/(y2-y1));

		count = 0;
	  	xdata[xyelem] = xaxis2;
		ydata[xyelem] = yaxis2;
		xyelem = xyelem + 1;
		GLCD_SetPixel(xaxis2/2,255-(yaxis2/4),1);

		if(xyelem>MAX_VALUE - 1)
		{
			GLCD_ClearScreen();
			GLCD_GoTo(10,0);	
			GLCD_WriteString("Intelligent e-book");
			GLCD_GoTo(10,4);		
			GLCD_WriteString("Overflow!!!");
			while(1);
		}
	}
	else if(xaxis1!=0 && yaxis1!=0)
	{
		xyelem = xyelem - 2;
		// Eliminate first 25 samples
		for(j=0;j<25;j++)
		capture();
		count = 0;
	}
	else
	{
	 	count = count + 1;
	}

//	delay(1000);
}
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(0,1);	
GLCD_WriteString(letterstr);

//GLCD_GoTo(10,4);		
//GLCD_WriteString("Scanning ended");
//delay_ms(500);


// Transmitting data to PC
//	transmit();

// Remove noise
	remove_noise();

// Allocating space for pointers  
	xaxis = emxCreateWrapper_uint8_T(xdata,1,xyelem);	//xdata1
	yaxis = emxCreateWrapper_uint8_T(ydata,1,xyelem);	//ydata1
	emxInit_uint8_T(&norm_xaxis_filt, 2);
	emxInit_uint8_T(&norm_yaxis_filt, 2);

/*	GLCD_ClearScreen();
	GLCD_GoTo(10,0);	
	GLCD_WriteString("Intelligent e-book");
	GLCD_GoTo(0,2);		
	GLCD_WriteString("Step1");
	GLCD_GoTo(37,2);		
	GLCD_WriteString("In");
*/
//	for(j=0;j<999999;j++);

	step1(xaxis, yaxis, norm_xaxis_filt, norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,2);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);

	emxDestroyArray_uint8_T(xaxis);
	emxDestroyArray_uint8_T(yaxis);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,3);	
//	GLCD_WriteString("Step2");
//	GLCD_GoTo(37,3);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

// char_bin is stored in column first fashion... each column vector are concatenated	
	step2(norm_xaxis_filt, norm_yaxis_filt, char_bin);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,3);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
	
	emxFree_uint8_T(&norm_xaxis_filt);
	emxFree_uint8_T(&norm_yaxis_filt);

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,4);	
//	GLCD_WriteString("Step3");
//	GLCD_GoTo(37,4);		
//	GLCD_WriteString("In");
//	for(j=0;j<999999;j++);

	for(j=0;j<10;j++)
	char_vec[j] = 1;
	
	step3(char_bin, char_vec);
	
//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(54,4);	
//	GLCD_WriteString("Out");
//	for(j=0;j<999999;j++);
  

	for(j=0;j<26;j++)
	char_vec1[j] = char_vec[j];
	
	// Feeding char_vec to trained neural network
	char_recog_nn(char_vec1,Y);

	letter = character();

	letterstr[i] = letter;
	letterstr[i+1] = '\0';

//	GLCD_ClearScreen();
//	GLCD_GoTo(10,0);	
//	GLCD_WriteString("Intelligent e-book");
//	GLCD_GoTo(0,6);	
//	GLCD_WriteString("Letter is: ");
	GLCD_GoTo(0,1);	
	GLCD_WriteString(letterstr);
	GLCD_GoTo(0,7);	
	GLCD_WriteString("Continue");

	do
	{
	xaxis1 = Read_xaxis();
	yaxis1 = Read_yaxis();

	if(xaxis1<10)
		xaxis1 = 0;
	if(yaxis1<10)
		yaxis1 = 0;

	}while(xaxis1==0 && yaxis1==0);

again = 1;
i = i + 1;
/*
GLCD_ClearScreen();
GLCD_GoTo(10,0);	
GLCD_WriteString("Intelligent e-book");
GLCD_GoTo(20,4);		
GLCD_WriteString("Restarting.");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
delay_ms(200);
GLCD_WriteString(".");
*/
delay_ms(400);
}

  while(1); 
}
예제 #15
0
int main (void) {
  int32_t max_num = LED_GetCount() - 1;
  int32_t num = 0;
  int32_t dir = 1;
  uint32_t keyMsk, adcVal;
  int32_t key  = -1;
  int32_t adc  = -1;

  SystemCoreClockUpdate();

  LED_Initialize();                         /* LED Initialization             */
  ADC_Initialize();                         /* A/D Converter Init             */
  Buttons_Initialize();                     /* Button initialization          */
  GLCD_Initialize();                        /* Initialize the GLCD            */

  SysTick_Config(SystemCoreClock/100);      /* Generate interrupt each 10 ms  */

  GLCD_SetBackgroundColor (GLCD_COLOR_WHITE);
  GLCD_ClearScreen ();

  GLCD_SetBackgroundColor (GLCD_COLOR_BLUE);
  GLCD_SetForegroundColor (GLCD_COLOR_WHITE);
  GLCD_SetFont            (&GLCD_Font_16x24);
  GLCD_DrawString (0*16, 0*24, " STM32303C-EVAL Demo");
  GLCD_DrawString (0*16, 1*24, "  Blinky Example    ");
  GLCD_DrawString (0*16, 2*24, "   www.keil.com     ");
  GLCD_SetBackgroundColor (GLCD_COLOR_WHITE);
  GLCD_SetForegroundColor (GLCD_COLOR_BLUE);

  GLCD_DrawString (0*16, 5*24, "LEDs:               ");
  GLCD_DrawString (0*16, 6*24, "AD value:           ");
  GLCD_DrawString (0*16, 7*24, "Buttons :           ");
  GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
  GLCD_DrawString (9*16, 5*24, "0123");

  while (1) {
    /* Force refresh */
    key = -1;
    adc = -1;

    if (LEDOn) {
      LEDOn = 0;
      LED_On (num);                         /* Turn specified LED on          */
      GLCD_SetForegroundColor (GLCD_COLOR_RED);
      GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]);
    }

    if (LEDOff) {
      LEDOff = 0;
      LED_Off (num);                        /* Turn specified LED off         */
      GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
      GLCD_DrawChar ((9+num)*16, 5*24, numStr[num]);

      num += dir;                           /* Change LED number              */
      if (dir == 1 && num == max_num) {
        dir = -1;                           /* Change direction to down       */
      }
      else if (num == 0) {
        dir =  1;                           /* Change direction to up         */
      }
    }

    keyMsk = Buttons_GetState();            /* Show buttons state             */
    if (key ^ keyMsk) {
      GLCD_SetForegroundColor (GLCD_COLOR_BLACK);
      if (keyMsk & KEY_USER  )    { GLCD_DrawString (9*16, 7*24, "Key");   }

      GLCD_SetForegroundColor (GLCD_COLOR_LIGHT_GREY);
      if (!(keyMsk & KEY_USER  )) { GLCD_DrawString (9*16, 7*24, "Key");   }
    }

    ADC_StartConversion();                  /* Show A/D conversion bargraph   */
    adcVal = ADC_GetValue();
    if (adc ^ adcVal) {
      adc = adcVal;
      GLCD_SetForegroundColor (GLCD_COLOR_GREEN);
      GLCD_DrawBargraph (9*16, 6*24, 160, 20, (adcVal * 100) / ((1 << ADC_GetResolution()) - 1));
    }
  }
}
예제 #16
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;
		}
	}
}