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 } }
// Runs a test of the display. Does the following. // Draws the board. Each time you touch one of the screen areas, the screen will paint // an X or an O, depending on whether switch 0 (SW0) is slid up (O) or down (X). // When BTN0 is pushed, the screen is cleared. The test terminates when BTN1 is pushed. void ticTacToeDisplay_runTest() { uint8_t* row = 0; uint8_t* column = 0; ticTacToeDisplay_init(); while(1){ ticTacToeDisplay_touchScreenComputeBoardRowColumn(row , column ); if ((buttons_read() & BUTTON_ISOLATE_BITS) & BUTTONS_ISOLATE_BIT_B0) { ticTacToeDisplay_clear(); } if ((buttons_read() & BUTTON_ISOLATE_BITS) & BUTTONS_ISOLATE_BIT_B1) { ticTacToeDisplay_gameOver(); break; } } }
void ticTacToeDisplay_clear() { ticTacToeDisplay_init(); }