This is THE 447 FINAL PROJECT this is the frame work put your code in the spot where the it suppose to go and. Make sure you import this into your complier and work on your section, once you done just commit the changes and fork to a new folder
Dependencies: mbed-rtos mbed draw_test EALib SWSPI
Diff: main.cpp
- Revision:
- 9:e6f3edc7f775
- Parent:
- 8:1dc719b54bbc
- Child:
- 10:1d1834c6715d
--- a/main.cpp Mon Dec 07 09:34:29 2015 +0000 +++ b/main.cpp Mon Dec 07 09:54:52 2015 +0000 @@ -56,6 +56,7 @@ int A_x_old = 0,A_y_old = 0,A_z_old = 0; int send_check = 0; int update_game_look = 0; +int turns = 0; //X_coor is x coordinate from 0 to 6 //Y_coor is y coordinate form A to F // @@ -208,17 +209,17 @@ } //my_LEDs = my_X_coor; else if (Center.read() == 0) { - pc.printf ("got middle\n\r"); + //pc.printf ("got middle\n\r"); SPI_X_send = my_X_coor; SPI_Y_send = my_Y_coor; - pc.printf ("spi x = %d\n\r",SPI_X_send); - pc.printf ("spi y = %d\n\r",SPI_Y_send); + //pc.printf ("spi x = %d\n\r",SPI_X_send); + //pc.printf ("spi y = %d\n\r",SPI_Y_send); send_check = 1; } else { my_X_coor = my_X_coor; my_Y_coor = my_Y_coor; } - my_LEDs = (my_X_coor << 4)|(0x0A+(my_Y_coor-1)); + my_LEDs = (my_X_coor << 5)|(0x0F-(my_Y_coor-1)); LEDsoutput (my_LEDs); osDelay (170); } @@ -266,9 +267,10 @@ // Tunr 5 = We sink an enemy battle ship at 4B while (true) { if (update_game_look == 1) { + turns = turns + 1; update_game_look = 0; int i; - pc.printf ("\f\n\r"); + pc.printf ("\fTurn :%d\n\r",turns); for (i = 1; i < 9; i++) { string a; a = battle.get1row(i); @@ -333,13 +335,9 @@ if(! accSensor.read(Ax,Ay,Az)) {}; if (abs(Ax-A_x_old) > 20) { winner = 0; + turns = 0; pc.printf ("\fNew Game: Battle Ship Θ\n\r"); battle.new_game_board(); - // for (i = 1; i < 9; i++) { - // string a; - // a = battle.get1row(i); - // pc.printf ("%s", a); - // } //randomize ship position 6 ship total for (i = 0; i < 7; i++) { x = (rand()%6 +1); @@ -377,20 +375,11 @@ osThreadDef(checkreset, osPriorityNormal, DEFAULT_STACK_SIZE); //check for reset define thread int main() { - osThreadCreate(osThread(SPI_communication), NULL); + osThreadCreate(osThread(SPI_communication), NULL);//done but now is uart osThreadCreate(osThread(joy_stick_read), NULL); //done - osThreadCreate(osThread(game_view_update), NULL); - osThreadCreate(osThread(winnercheck), NULL); + osThreadCreate(osThread(game_view_update), NULL);//done + osThreadCreate(osThread(winnercheck), NULL);//buggy osThreadCreate(osThread(checkreset), NULL);//done - // initialize all peripheral here - // - // - // - // create a initialize thread with the key - // if key is 0 run the initialize the change key to 1 - // if key is 1 then get do nothing and get out - - //note game initialize and setup upon shake the board if (initlize == 0) { @@ -448,7 +437,5 @@ //Main Thread while (true) { osDelay (30); - //pc.printf ("in main"); - //check status and update status } }