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
main.cpp
- Committer:
- AndyTran
- Date:
- 2015-12-01
- Revision:
- 2:b14759e704c7
- Parent:
- 1:3f7aa28da00d
- Child:
- 3:84d9362dffeb
File content as of revision 2:b14759e704c7:
#include <iostream> #include "mbed.h" #include "cmsis_os.h" using namespace std; //declare your input pin and output pin here: //DigitalOut led1(p25); //DigitalOut led2(p26); //DigitalOut led3(p28); // // declare you globle variable here: unsigned char my_X_coor = 0, my_Y_coor = 0; unsigned char my_LEDs = ((X_coor << 8)|Y_coor); unsigned char other_X_coor = 0, other_Y_coor = 0; int friendly [6][6]; // array to determine friendly location //X_coor is x coordinate from 0 to 6 //Y_coor is y coordinate form A to F // // // // this thread is your SPI communication between 2 board void SPI_communication(void const *args) { //send my_X_coor and my_Y_coor if the center button is hit //receive other board x_coor and y_coor //spi code here } // joystick update x_coor and y_coor here void joy_stick_read(void const *args) { //might be an interrupt thread here for interrupt read of joystick // joy stick to update global val of x_coor and y_coor; // convert y coor to hex offset // update the 8 LEDs here } // this thread use to update the game board void game_view_update (void const *args) { // board of this game will be a class this update and get info to and from the class // update the by led game update // Uart runing at 921600 max speed; hopefully print 1 line and out; // x = hit // o = miss // > = your ship ship // 1) check for a hit // 2) update the game board // BLANK game Board // F _ _ _ _ _ _ F _ _ _ _ _ _ // E _ _ _ _ _ _ E _ _ _ _ _ _ // D _ _ _ _ _ _ D _ _ _ _ _ _ // C _ _ _ _ _ _ C _ _ _ _ _ _ // B _ _ _ _ _ _ B _ _ _ _ _ _ // A _ _ _ _ _ _ A _ _ _ _ _ _ // 1 2 3 4 5 6 1 2 3 4 5 6 // Friendly Enemy // Example of running game // F _ O _ > _ _ F _ O _ _ _ _ // E > _ O _ > _ E _ _ X _ _ _ // D _ _ > _ _ _ D _ _ _ O _ _ // C O _ _ _ _ _ C _ O _ _ _ _ // B _ X _ O _ _ B _ _ _ X _ _ //X on friendly mean your ship got destroy // A _ _ _ > _ _ A _ _ _ _ _ _ // 1 2 3 4 5 6 1 2 3 4 5 6 // Friendly Enemy // Turn 1 = miss at 2F // Turn 2 = We sink an enemy battle ship at 3E // Turn 3 = miss at 4D // Turn 4 = miss at 2C // Tunr 5 = We sink an enemy battle ship at 4B } // code here to check for winer and turn on the RGB void winnercheck (void const *args) { //check for winner by some condition } //read the accele void checkreset (void const *args) { //read the acceleron meter and compare against the previous value to //determine if the board have been shake the reset the game board; } osThreadDef(SPI_communication, osPriorityNormal, DEFAULT_STACK_SIZE); //comm between 2 board define thread osThreadDef(joy_stick_read, osPriorityNormal, DEFAULT_STACK_SIZE);//might be an interrupt define thread osThreadDef(game_view_update, osPriorityNormal, DEFAULT_STACK_SIZE);//update game view write to the fifo uart buffer define thread osThreadDef(winnercheck, osPriorityNormal, DEFAULT_STACK_SIZE); //check for winner define thread osThreadDef(checkreset, osPriorityNormal, DEFAULT_STACK_SIZE); //check for reset define thread int main() { osThreadCreate(osThread(SPI_communication), NULL); osThreadCreate(osThread(joy_stick_read), NULL); osThreadCreate(osThread(game_view_update), NULL); osThreadCreate(osThread(winnercheck), NULL); osThreadCreate(osThread(checkreset), NULL); // initialize all peripheral here // // // //note game initialize and setup upon shake the board //Main Thread while (true) { //check status and update status } }