Example #1
0
int main(void){
	char i = 0;
	char temp;
	lcd_init();
	init_serial();
	char buf[16]={0};
	while(1){
		while((UCSR0A&(1<<RXC0)) == 0); // Wait for character input
		temp = UDR0;
		while((UCSR0A&(1<<UDRE0)) == 0); // Wait for release of input
		
		if(temp == ','){
			buf[15] = '\0';			
			my_send_string(buf);
			printLCD(buf);
			for(i=0; i<16; i++){
				buf[i] = 0;
			}
			i = 0;		//Reset indexer
		}	
		else{
			buf[i] = temp;
			i++;
		}
	}
}
void init_music(){
	int clusterLength, secCount;
	search_for_filetype("WAV", &returnData,0,1);
	printLCD(returnData.Name, "Buffering...");
	clusterLength = 1+ ceil( (float) returnData.FileSize / bytePerCluster);
	build_cluster_chain(cc, clusterLength, &returnData);
	play_type = IORD(SWITCH_PIO_BASE, 0) & 0x07;
	LCD_Display(returnData.Name, play_type);
}
Example #3
0
File: main.c Project: sndae/b3r1
int main (void)
{
    Initialization();

    show_mhz();				// Display CPU speed
    TimerWait(1000);		// Wait 1 second

    while(1)
    {
        printLCD("Show ADC");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, just skip over it.
        {
            TimerWait(500);				// debounce joystick button
            showADC();
            printLCD("Back ADCs");
            TimerWait(2000);
        }

        printLCD("Balance");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            balance();
            printLCD("Back Balance");
            TimerWait(2000);
        }

        printLCD("rprintf");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            rprintf_test();
            printLCD("Back rprintf");
            TimerWait(2000);
        }

        printLCD("PWM Test");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            PWM_Test();
            printLCD("Back PWM Test");
            TimerWait(3000);
        }
    }
}
Example #4
0
void printTripHystory(signed int point)
{
	int temp;

	LCD_clear();
	temp = point + '0';

	strcpy(st, "TRIP [0]");
	st[6] = point + '0';
	PrintLCD(0,0,st);

 	delay_sec();

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.000e+1");	// rq trip code
	gSciTxBuf[8] = temp;

	SendSciString( gSciTxBuf );
	delay_sec();
	if( getSciMsg(st)) printLCD(0,10,st); // disp code
	else DisplayChar( 0 , 10, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.500e+1");   // trip time
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(2,0,st); // time
	else DisplayChar( 2 , 1, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.600e+1");   // rq trip message
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(1,0,st); // disp message
	else DisplayChar( 1 , 1, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.400e+1");   // trip VDC
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(3,0,st); // debug
	else{
		strcpy(st," -    ");   
		printLCD(3,0,st);
	}

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.100e+1");   // trip data
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(3,10,st); // debug
	else DisplayChar( 3 , 10, '-');
}
Example #5
0
/*--------------------------------------------------------------------------------------------------------------------
        Function:         Main

        Description:      Main routine

        Revisions:

--------------------------------------------------------------------------------------------------------------------*/
void main(void)
{

	General_Init();
	Oscillator_Init();
	Timer_Init();
	Voltage_Reference_Init();
	DAC_Init();
	Interrupts_Init();




	initLCD();
	
	


	P2 = 0x0;
	
	while(1)
	{	
			//Allow user to change current gamestate. i.e. menu or playing
		Check_State_Change();																											//STILL NEEDED AS OF 5:41PM 4/5/15
			
			//Execute the current state chosen
			switch (gameState)
			{
				case 0: /* Volume Menu */
					//Clear any previous visuals
					printLCD("Volume Levels");
					blink();
					Change_Volume();
					Display_Volume();
					Change_Octave();
					break;
				case 1: /* Play Menu */
					PORT1_TO_PLAY_TONE();
					break;
			}
		}
		
		//This is a debug counter that should never, EVER execute. So, delete it when you have no issues at the end.
//		while(1)
//		{	
//			debugcounter +=1;
//		}

}
Example #6
0
int main (void)
{
    // Inicializamos la placa
    initBoard();
    
    // Inicializamos el LCD 
    configLCD(&databusLCD, &enPinLCD, &rwPinLCD, &rsPinLCD);
    
    // Escribimos texto en el LCD
    printLCD("Wake up Neo");
    
    // Bucle infinito
    while(1)
    {
        // Parpadeamos el led
        togglePin(&LED[0]);
        delay_ms(500);
    }
    
    return 0;
}
Example #7
0
int Platform_Get_ID_by_card(char *buf, int timeoutseconds) {
	char magbuf[384];	
	int retries=6;
	int ticks = timeoutseconds * 20;
	long eventreceived;	



	// clear out events.  but if EVT_KBD was flipped, then there is probably key input.
	// This is important, because a call to this was probably preceded by a hit on the
	// fingerprint reader, which would have exited upon detecting a key event.
	
	eventreceived = read_evt(EVT_KBD);
	
	if (eventreceived) return 0;

	while (1) {
		int rv;
		int TempY = CurrentYPixelPosition;
		char *s;
		char *track1,*track2,*track3;


		while (1) {
			// this while loop will peek for events, but keep calling Platform_yield_ms while waiting.			
			eventreceived = peek_event();

			if (eventreceived & EVT_KBD) return 0;
			if (eventreceived & EVT_MAG) break;
			if (--ticks <= 0) return -2;
			Platform_yield_ms(50);
		}

		// Clear mag event
		read_evt(EVT_MAG);
		
		// point tracks at valid pointer
		track1=track2=track3="";

		// Attempt to read the mag
		rv = read(hMagReader,magbuf,384);

		// If swiped, then the card data is going to need parsing.
		// We are only interested in tracks that contain valid data, and 5, 12, or 14 digits.
		// note that key_card_entry adds 2 bytes to each track.
		if (rv > 10) {
			
			// Turn these into null-terminated strings where the 1st byte is the status byte.
			// Note, format is C1 S1 ... C2 S2 ... C3 S3 ...
			// where Cn is the length of all track n data (including the count byte)
			// and Sn is the status byte, and ... is any data read.
			track1=magbuf;
			track2=&magbuf[magbuf[0]];
			track3=&magbuf[magbuf[0]+magbuf[magbuf[0]]];
			track3[*track3]=0; // null for track3
			track3[0]=0; // null for track2
			track2[0]=0; // null for track1
			track1++,track2++,track3++; // now these all point at the status byte preceding the null-termed string.
			// THE STATUS BYTES NEED TO BE 0 TO INDICATE GOOD DATA.
			// IF DATA IS GOOD, ADJUST POINTER TO POINT AT GOOD DATA.  IF NOT, SET POINTER TO EMPTY STRING
			if (*track1==0) track1++; else track1="";
			if (*track2==0) track2++; else track2="";
			if (*track3==0) track3++; else track3="";

			// Find a track beginning with 9622 and length 12 or 14, in order of tracks 1,2,3
			if (strncmp(track1,"9622",4)==0 && (strlen(track1)==12 || strlen(track1)==14)) {
				strcpy(buf,track1+4);
				return 1;
			} else if (strncmp(track2,"9622",4)==0 && (strlen(track2)==12 || strlen(track2)==14)) {
				strcpy(buf,track2+4);
				return 1;
			} else if (strncmp(track3,"9622",4)==0 && (strlen(track3)==12 || strlen(track3)==14)) {
				strcpy(buf,track3+4);
				return 1;
			} else if (strlen(track1)==5) {
				strcpy(buf,track1);
				return 1;
			} else if (strlen(track2)==5) {
				strcpy(buf,track2);
				return 1;
			} else if (strlen(track3)==5) {
				strcpy(buf,track3);
				return 1;
			}
		}
		
		if (--retries==0) return -1;

		CurrentXPixelPosition=0;

		// flush mag
		while (read(hMagReader,magbuf,384) > 0);
					
		s="\v    \bPlease try again";
		// If tracks 1 and 2 were SOMETHING, then this is probably a Visa/Mastercard
		if (track1[0] != 0 && track2[0] != 0) {
			s="\v    Not a valid time card";
		}
		printLCD(s);				
		CurrentYPixelPosition = TempY;
		Platform_error_tone();
		Platform_yield_ms(800);
	
		

		
	}

}
Example #8
0
void TimeDataSetProc()			// 시간 설정
{
	BUTTON KeyIn;
	char ChangeCode = 0;
	int loopCtrl = 1;
	signed int point=0;
	int i;

	machine_state = STATE_TIME_MODE;
	LCD_Clear();
	strcpy(st, "DATE & TIME SETTING ");
	PrintLCD(0,0,st);

	strcpy(gSciTxBuf,"9:4:906:0.000e-0");
	SendSciString( gSciTxBuf );
	sci_rx_msg_start = sci_rx_msg_end = 0;
	delay_ms(100); 
	delay_ms(100); 
	getSciMsg(st); printLCD(1,0,st);
	printLCD(3,0,st);

	for( i = 0; i< 12 ; i++ ) Code[i] = st[ DATE_POS[i]];
	Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
	
	while(loopCtrl){

		ChangeCode = 1;

		KeyIn = GetKey();

		if		( KeyIn == BTN_UP  ) (Code[point])++;
		else if ( KeyIn == BTN_DOWN) (Code[point])--;
		else if ( KeyIn == BTN_ESC)		point--;
		else if	(KeyIn == BTN_RIGHT) 	point ++;
		else if ( KeyIn == BTN_STOP){
			machine_state = STATE_SET_MODE;
			return;
		}
		else if ( KeyIn == BTN_SAVE){

			strcpy(gSciTxBuf,"9:4:904:0.");
			strcpy(&(gSciTxBuf[10]),Code);
			SendSciString( gSciTxBuf );
			delay_ms(50);

			strcpy(gSciTxBuf,"9:4:904:1.");
			strcpy(&(gSciTxBuf[10]),&Code[6]);
			SendSciString( gSciTxBuf );
			strcpy(gSciTxBuf,"9:4:906:0.000e-0");
			SendSciString( gSciTxBuf );

			sci_rx_msg_start = sci_rx_msg_end = 0;
			delay_ms(50); getSciMsg(st); printLCD(1,0,st);
		}
		else if ( KeyIn == BTN_SET){
			strcpy(gSciTxBuf,"9:4:906:0.000e-0");
			SendSciString( gSciTxBuf );
			sci_rx_msg_start = sci_rx_msg_end = 0;
			delay_ms(100); 
			delay_ms(100); 
			getSciMsg(st); printLCD(1,0,st);
			printLCD(3,0,st);
		
			for( i = 0; i< 12 ; i++ ) Code[i] = st[ DATE_POS[i]];
			Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
		}
		else ChangeCode = 0;

		if		(point > 11) 	point = 0;
		else if (point < 0 )	point = 11;
	
		if		(Code[point] > '9') Code[point] = '0';
		else if	(Code[point] < '0') Code[point] = '9';
	
		if(ChangeCode == 1)
		{
			DisplayChar(3,DATE_POS[point],Code[point]);
			Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
		}
	}
}
Example #9
0
void EditCodeDataProc()
{
	BUTTON KeyIn;

	int i;
	int loopCtrl = 1;
	int changeCode;

	LCD_Clear();

	strcpy(st,msgEditAddr); PrintLCD(0,0,st); 

	SerialPortSetup();	
	for ( i = 0; i< 9;i++) Code[i] = '0';
	Code[7] = '+';

	CodeID = 0;
	Cursor(CODE_POS[CodeId][0],CODE_POS[CodeId][1],CURSOR_BLINK);					

	while( loopCtrl)
	{

		KeyIn = GetKey();
	
		changeCode = 1;
		Cursor(CODE_POS[CodeID][0],CODE_POS[CodeID][1],DISPLAY_CURSE_BLINK_ON);//CURSOR_OFF);

		if ( KeyIn == BTN_ESC){
			if(CodeId == 0) CodeID = 8 ;
			else			CodeID -- ;
		}	
		else if ( KeyIn == BTN_SET){
			for( i = 1 ; i< 4; i++ ) clear_line(i);
			CopyCode2TxMsg(SCI_CMD_READ_DATA);

		//--- write data
			gSciTxBuf[9]  ='.';	gSciTxBuf[10] ='0'; gSciTxBuf[11] ='0';	gSciTxBuf[12] ='0'; 
		//--- exponent part
			gSciTxBuf[13] ='e'; gSciTxBuf[14] ='+'; gSciTxBuf[15] ='0'; 

		//--- print code discription
			gSciTxBuf[8]  ='1';
			sci_rx_msg_start = sci_rx_msg_end = 0;
			SendSciString( gSciTxBuf );
			delay_ms(100);
			i = getSciMsg(st); 
			if(i) printLCD(2,0,st);
			else {
				strcpy(st,"NO Received Data");				
				printLCD(1,0,st);
			}

			gSciTxBuf[8]  ='2';
			sci_rx_msg_start = sci_rx_msg_end = 0;
			// for(clearcnt = 0; clearcnt <40; clearcnt++) sci_rx_msg_box[clearcnt] = 0;
			SendSciString( gSciTxBuf ); 
			delay_ms(100); 
			i = getSciMsg(st); 
			if(i) printLCD(3,0,st);
			else {
				strcpy(st,"NO Received Data");				
				printLCD(3,0,st);
			}
		}
		else if ( KeyIn == BTN_SAVE ){	
			lcd_x_posi=0; lcd_y_posi=1;
			CopyCode2TxMsg(SCI_CMD_WRITE_ROM); 
			SendSciString( gSciTxBuf );
			delay_ms(50); getSciMsg(st); printLCD(1,0,st); // debug
		}
		else if ( KeyIn == BTN_DOWN){
			if(CodeID == 7 ){
				if( Code[CodeID] == '+') Code[CodeID] = '-';
				else                     Code[CodeID] = '+';
			}
			else {
				if      ( Code[CodeID] > '9') Code[CodeID] = '9';
				else if ( Code[CodeID] <= '0') Code[CodeID] = '9';
				else 						  Code[CodeID]--;
			}
		}
		else if ( KeyIn == BTN_UP ){
			if(CodeID == 7 ){
				if( Code[CodeID] == '+') Code[CodeID] = '-'; 
				else					 Code[CodeID] = '+';	 
			}
			else {
				if     ( Code[CodeID] <  '0') 	 	Code[CodeID] = '0';
				else if( Code[CodeID] >= '9') 	 	Code[CodeID] = '0';
				else 								Code[CodeID]++;
			}
		}
		else if ( KeyIn == BTN_RIGHT){		
			if(CodeId == 8) CodeID = 0 ;
			else			CodeID ++ ;	 
		}
		else if ( KeyIn ==  BTN_STOP){
			machine_state = STATE_SET_MODE;
			loopCtrl = 0;
			return;
		}
		else changeCode = 0;
		if(changeCode == 1 ){
			DisplayChar(CODE_POS[CodeID][0],CODE_POS[CodeID][1],Code[CodeID]);
			Cursor(CODE_POS[CodeID][0],CODE_POS[CodeID][1],CURSOR_BLINK);				
		}
	}
}
Example #10
0
void monitor_converter()
{
	BUTTON KeyIn;
	unsigned int disp_count=0;
	int loopCtrl =1;
	int debug;

	LCD_Clear();
	LCD_Cmd(CURSOR_OFF);

	while( loopCtrl)
	{ 
		KeyIn = GetKey();
		lcd_y_posi = 1; lcd_x_posi = 0;

		debug =getSciMsg(st); 		
		if( debug ) {
			if(debug > 19 ); st[19] = 0;
			printLCD(lcd_y_posi,lcd_y_posi,st);
		}

		if		( KeyIn == BTN_SET 	){	machine_state = STATE_SET_MODE; loopCtrl = 0;	return;}
		else if	(KeyIn == BTN_RUN	){	strcpy(gSciTxBuf,"9:4:905:0.000e-0"); SendSciString( gSciTxBuf );}
		else if	(KeyIn == BTN_STOP	){	strcpy(gSciTxBuf,"9:4:905:1.000e-0"); SendSciString( gSciTxBuf );}
		else if	(KeyIn == BTN_UP	){ 	strcpy(gSciTxBuf,"9:4:905:2.000e-0"); SendSciString( gSciTxBuf );}
		else if	(KeyIn == BTN_DOWN	){	strcpy(gSciTxBuf,"9:4:905:3.000e-0"); SendSciString( gSciTxBuf );}
		else{
			if( disp_count == 0){ 
				lcd_y_posi = 0; lcd_x_posi = 0;
				strcpy(gSciTxBuf,"9:4:901:0.000e-0");
			}
			else if( disp_count == 1){
				lcd_y_posi = 0; lcd_x_posi = 10;
				strcpy(gSciTxBuf,"9:4:902:0.000e-0");	// Power Input
			}	
			else if( disp_count == 2){
				lcd_y_posi = 2; lcd_x_posi = 0;
				strcpy(gSciTxBuf,"9:4:902:1.000e-0");	// Vdc
			}
			else if( disp_count == 3){
				lcd_y_posi = 2; lcd_x_posi = 10;
				strcpy(gSciTxBuf,"9:4:902:2.000e-0");	// I RMS Source 
			}
			else if( disp_count == 4){
				lcd_y_posi = 3; lcd_x_posi = 0;
				strcpy(gSciTxBuf,"9:4:902:3.000e-0");	// I alpa
			}
			else {
				lcd_y_posi = 3; lcd_x_posi = 10;
				strcpy(gSciTxBuf,"9:4:902:4.000e-0");	// I beta
			}
			sci_rx_msg_start = sci_rx_msg_end = 0;
			SendSciString( gSciTxBuf );
			delay_ms(50);
			debug = getSciMsg(st);
			if( debug ) {
				if( debug> 9);
				st[10] = 0;
				printLCD(lcd_y_posi,lcd_x_posi,st);
			}
			else {
				strcpy(st,"  ---   ");	
				st[0] = disp_count + '0';
				printLCD(lcd_y_posi,lcd_x_posi,st);
			}
			if(disp_count >= 5 ) disp_count = 0; 
			else disp_count ++;
		}
		delay_ms(100);
	} // while loop
}