Пример #1
0
void ticTacToeDisplay_runTest()
{
    while(1) //until button 1 is pressed
    {
        while(buttons_read() != (TICTACTOEDISPLAY_BTN0_ON))//until button 0 is pressed
        {
            if(buttons_read() == (TICTACTOEDISPLAY_BTN1_ON))//button has been pressed
            {
                display_setTextSize(TICTACTOEDISPLAY_TEXT_SIZE);  // this sets the text size
                display_setCursor(TICTACTOEDISPLAY_HALF_WIDTH-TICTACTOEDISPLAY_ONE_THIRD_WIDTH, //position x coordinate of cursor
                        TICTACTOEDISPLAY_HALF_HEIGHT - TICTACTOEDISPLAY_ONE_SIXTH_HEIGHT);//position y coordinate of cursor
                display_println("Game Over!");//print to the lcd
                return;//return out of both loops immediately
            }

            if(display_isTouched())
            {
                display_clearOldTouchData(); // Throws away all previous touch data.
                uint8_t row, column;
                ticTacToeDisplay_touchScreenComputeBoardRowColumn(&row, &column);//compute location of square
                if(switches_read() == TICTACTOEDISPLAY_SWITCH0_ON)//SW0 is up
                {
                    ticTacToeDisplay_drawO(row, column);//draw O character
                }
                if(switches_read() == TICTACTOEDISPLAY_SWITCH0_OFF)//SW0 is down
                {
                    ticTacToeDisplay_drawX(row, column);//draw X character
                }
            }
        }
        ticTacToeDisplay_init();//clear the screen
    }
}
Пример #2
0
void TicTacToeDisplay_runTest()
{
	display_init();
		TicTacToeDisplay_init();

	char number = buttons_read();
	char read = number & HEX_F;
	char s_read = switches_read();
	display_clearOldTouchData();

	bool go = true;
	while(go)
	{
		s_read = switches_read();
		number = buttons_read();
		read = number & HEX_F;
		utils_msDelay(50);


	if(display_isTouched())
	{
		utils_msDelay(50);
		display_clearOldTouchData();

		if(display_isTouched())
			TicTacToeDisplay_touchScreenComputeBoardRowColumn(&row, &column);

		if(s_read == 0x1)
		{
		TicTacToeDisplay_drawO(row, column);display_clearOldTouchData();
		}

		else
		{
		TicTacToeDisplay_drawX(row, column);display_clearOldTouchData();
		}


		display_clearOldTouchData();


	}
	if((read & 0x1) == HEX_ONE)
	{
		TicTacToeDisplay_init();
	}

	 if((read & 0x2) == 0x02)
	{
		TicTacToeDisplay_complete();
		go = false;
	}



	display_clearOldTouchData();


	}
}
Пример #3
0
//Runs a test of the switches
//switches_read() will run until all switches are in the UP position.
//Masking is used to determine which switches are in the UP position.
//When all switches are on the on position, the LED's are turned off.
void switches_runTest()
{
    switches_init();
    u32 read = switches_read();
    while(read  != HEX_F)
    {
        read = switches_read();
        char result = read & HEX_F;
        leds_write(result);
    }
    leds_write(0);

}
Пример #4
0
static ssize_t switches_dev_read(struct file *filp,
                                 char *buffer,
                                 size_t length,
                                 loff_t * offset)
{
    for (int i = 0 ; i < length; ++i)
        *buffer++ = switches_read();
    return length;
}
Пример #5
0
void switches_runTest()
{
    //initialize the LEDS
    leds_init(0);

    //initalize the switches, aka turn off tristate
    switches_init();


    int32_t switchValue = 0;

    //while not all the swtiches are up, continue to test
    //we mask the switchValue with all switches so we just see those bits
    while ((switchValue & SWITCHES_ALL_SWITCHES_ON) != SWITCHES_ALL_SWITCHES_ON)
    {
        switchValue = switches_read();
        //if switch0, led 0 on
        if ((switchValue & SWITCHES_SW0) == SWITCHES_SW0)
        {
            leds_write(SWITCHES_SW0); // this might cause problem, because it specifically turns off the other LEDS
        }
        //if switch1, led 1 on
        if ((switchValue & SWITCHES_SW1) == SWITCHES_SW1)
        {
            leds_write(SWITCHES_SW1); // this might cause problem, because it specifically turns off the other LEDS
        }
            //if switch2, led 2 on
        if ((switchValue & SWITCHES_SW2) == SWITCHES_SW2)
        {
            leds_write(SWITCHES_SW2); // this might cause problem, because it specifically turns off the other LEDS
        }
            //if switch3, led 3 on
        if ((switchValue & SWITCHES_SW3) == SWITCHES_SW3)
        {
            leds_write(SWITCHES_SW3); // this might cause problem, because it specifically turns off the other LEDS
        }
        else //no LEDS on
        {
            //when we put a switch down, turn off that LED
            leds_write(0);
        }
    }
    //turn off all LEDS, test is over
    leds_write(0);
}
// Tells if SW0 is up or down; returns true if high
uint8_t ticTacToeDisplay_SW () {
	return switches_read()& 0x1;
}