Example #1
0
void Display_sensors(void)
{
	while(BUTTON1 != 0)
	{
		if (BUTTON4 == 0)
		{
			_delay_ms(500);
			CalibrateAcc();
			CalibrateGyros();
		}

		if (BUTTON3 == 0)
		{
			_delay_ms(500);
			CalibrateInvAcc();
		}

		ReadGyros();
		ReadAcc();

		LCD_Display_Text(26,(prog_uchar*)Verdana8,0,0); 	// Gyro
		LCD_Display_Text(30,(prog_uchar*)Verdana8,70,0); 	// Acc
		LCD_Display_Text(27,(prog_uchar*)Verdana8,10,15);	// X
		LCD_Display_Text(28,(prog_uchar*)Verdana8,10,25);	// Y
		LCD_Display_Text(29,(prog_uchar*)Verdana8,10,35);	// Z

		mugui_lcd_puts(itoa(gyroADC[PITCH],pBuffer,10),(prog_uchar*)Verdana8,30,15);
		mugui_lcd_puts(itoa(gyroADC[ROLL],pBuffer,10),(prog_uchar*)Verdana8,30,25);
		mugui_lcd_puts(itoa(gyroADC[YAW],pBuffer,10),(prog_uchar*)Verdana8,30,35);
		mugui_lcd_puts(itoa(accADC[PITCH],pBuffer,10),(prog_uchar*)Verdana8,80,15);
		mugui_lcd_puts(itoa(accADC[ROLL],pBuffer,10),(prog_uchar*)Verdana8,80,25);
		mugui_lcd_puts(itoa(accADC[YAW],pBuffer,10),(prog_uchar*)Verdana8,80,35);

		// Print bottom markers
		LCD_Display_Text(12, (prog_uchar*)Wingdings, 0, 57); 	// Left
		LCD_Display_Text(157, (prog_uchar*)Verdana8, 75, 55); 	// Inverted Calibrate
		LCD_Display_Text(60, (prog_uchar*)Verdana8, 108, 55); 	// Calibrate

		// Update buffer
		write_buffer(buffer,1);
		clear_buffer(buffer);
		_delay_ms(100);
	}
}
Example #2
0
void Display_sensors(void)
{
	bool	first_time = true;
		
	clear_buffer(buffer);
		
	// While BACK not pressed
	while(BUTTON1 != 0)
	{
		ReadGyros();
		ReadAcc();

		LCD_Display_Text(26,(const unsigned char*)Verdana8,37,0); 	// Gyro
		LCD_Display_Text(30,(const unsigned char*)Verdana8,77,0); 	// Acc
		//
		LCD_Display_Text(27,(const unsigned char*)Verdana8,5,13);	// Roll
		LCD_Display_Text(28,(const unsigned char*)Verdana8,5,23);	// Pitch
		LCD_Display_Text(29,(const unsigned char*)Verdana8,5,33);	// Yaw/Z
		//
		mugui_lcd_puts(itoa(gyroADC[ROLL],pBuffer,10),(const unsigned char*)Verdana8,40,13);
		mugui_lcd_puts(itoa(gyroADC[PITCH],pBuffer,10),(const unsigned char*)Verdana8,40,23);
		mugui_lcd_puts(itoa(gyroADC[YAW],pBuffer,10),(const unsigned char*)Verdana8,40,33);
		mugui_lcd_puts(itoa(accADC[ROLL],pBuffer,10),(const unsigned char*)Verdana8,80,13);
		mugui_lcd_puts(itoa(accADC[PITCH],pBuffer,10),(const unsigned char*)Verdana8,80,23);
		mugui_lcd_puts(itoa(accADC[YAW],pBuffer,10),(const unsigned char*)Verdana8,80,33);

		// Print bottom markers
		LCD_Display_Text(12, (const unsigned char*)Wingdings, 0, 57); 	// Left
		LCD_Display_Text(37, (const unsigned char*)Verdana8, 75, 55); 	// Inverted Calibrate
		LCD_Display_Text(60, (const unsigned char*)Verdana8, 108, 55); 	// Calibrate

		// Update buffer
		write_buffer(buffer);
		clear_buffer(buffer);

		if (first_time)
		{
			// Wait until finger off button
			Wait_BUTTON4();
			
			first_time = false;
		}
		
		// Normal calibrate button pressed
		if (BUTTON4 == 0)
		{
			// Wait until finger off button
			Wait_BUTTON4();
			
			// Pause until steady
			_delay_ms(250);
			
			// Calibrate sensors
			CalibrateGyrosFast();
			CalibrateAcc(NORMAL);
		}

		// Inverted calibrate button pressed
		if (BUTTON3 == 0)
		{
			// Wait until button snap dissipated
			_delay_ms(250);
			CalibrateAcc(REVERSED);
		}
	}
}
Example #3
0
void DemoIntroduction(void)
{
	unsigned char i ;
	unsigned int w1, w2;
	unsigned char touchedNow;
	SCROLL_WHEEL_DIRECTION scrollDir;
	
    switch(DemoIntroState)
    {
        case 0:
            ResetDevice();  
        
            FillDisplay(0x00);
            oledPutROMString((ROM_STRING)" Labyrinth Demo v1.0 ",0,0);
            oledPutROMString((ROM_STRING)"   by Daniel Szot    ",1,0);
			oledPutROMString((ROM_STRING)"                     ",2,0);
			oledPutROMString((ROM_STRING)"  MB Turnkey Design  ",3,0);
			oledPutROMString((ROM_STRING)" mbturnkeydesign.com ",4,0);
            oledPutROMString((ROM_STRING)"Press Menu to proceed",6,0);

            DemoIntroState = 1;
            break;

        case 1:
            if(CheckButtonPressed() == TRUE)
            {
                DemoIntroState=4;
            }
            break;

        case 4:
            oledPutROMString((ROM_STRING)" 1. Use scroll to    ",0,0);
            oledPutROMString((ROM_STRING)" select menu items.  ",1,0);
            oledPutROMString((ROM_STRING)" 2. Tilt the board   ",2,0);
            oledPutROMString((ROM_STRING)" to move the ball.   ",3,0);
            oledPutROMString((ROM_STRING)" 3. Have a good time.",4,0);
            oledPutROMString((ROM_STRING)"                     ",5,0);
            oledPutROMString((ROM_STRING)"Press Menu to proceed",6,0);
            DemoIntroState = 5;
            break;

        case 5:
            if(CheckButtonPressed() == TRUE)
            {
                DemoIntroState++;
            }
            break;

        case 6:
			scrollDir = GetScrollDirection();

			if (scrollDir == SCROLL_UP)
			{
				if (g_menuSelected > 0)
					g_menuSelected --;
			}
			else if (scrollDir == SCROLL_DOWN)
			{
				if (g_menuSelected < 3)
					g_menuSelected ++;
			}		

            oledPutROMString((ROM_STRING)"   LABIRYNTH  MENU   ",0,0);
            oledPutROMString(empty_line,1,0);

			if (g_menuSelected == 0)
				oledPutROMNegString((ROM_STRING)"      NEW  GAME      ",2,0);	
			else
            	oledPutROMString((ROM_STRING)"      NEW  GAME      ",2,0);

            if (g_menuSelected == 1)
				oledPutROMNegString((ROM_STRING)"     SELECT LEVEL    ",3,0);
			else
				oledPutROMString((ROM_STRING)"     SELECT LEVEL    ",3,0);
		    
			if (g_menuSelected == 2)
            	oledPutROMNegString((ROM_STRING)"      CALIBRATE      ",4,0);
			else
				oledPutROMString((ROM_STRING)"      CALIBRATE      ",4,0);
			
			if (g_menuSelected == 3)
            	oledPutROMNegString((ROM_STRING)"      QUIT GAME      ",5,0);
			else
				oledPutROMString((ROM_STRING)"      QUIT GAME      ",5,0);

            oledPutROMString(empty_line,6,0);

			w1 = mTouchReadButton(0);
			if (w1 < 600)
			{
				switch(g_menuSelected)
				{
					case 0: DemoIntroState = 0xFF; g_level=0; loadLevel(g_level); break;
					case 1: DemoIntroState = 9; DelayMs(100); FillDisplay(0x00); g_menuSelected = 0; firstLevel = 0; break;
					case 2: DemoIntroState = 7; DelayMs(100); FillDisplay(0x00);  break;
					case 3: 
						_asm
						RESET
						_endasm
						 break;
				}
			}
            break;

        case 7:
			CalibrateAcc();
            break;

		case 8:
			FillDisplay(0xFF);
			oledPutROMNegString((ROM_STRING)"  CORNGRATULATIONS!  ",0,0);
			oledPutROMNegString((ROM_STRING)"   You won nothing   ",2,0);
			oledPutROMNegString((ROM_STRING)" You just waste your ",3,0);
			oledPutROMNegString((ROM_STRING)"   PRECIOUS time :)  ",4,0);
			DelayMs(2000);
			DemoIntroState = 6;
			FillDisplay(0x00);
			g_level = 0;
			g_ballGtt = 0;
			break;

		case 9:
			SelectLevel();
			break;

        default:
            break;
    }
}