Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
Diff: main.cpp
- Revision:
- 54:a4c5949707ca
- Parent:
- 53:71f59e195f06
- Child:
- 55:e0e684531825
--- a/main.cpp Mon May 07 15:44:34 2018 +0000 +++ b/main.cpp Wed May 16 19:57:52 2018 +0000 @@ -1,6 +1,19 @@ #include "SETUP.hpp" +#define Cubelet_data_ready 1 +#define Not_Cubelet_data_ready 0 +/* +Colour lookup table +1 = White +2 = Red +3 = Orange +4 = Blue +5 = Green +6 = Yellow +*/ + +//Colours Cubelet_Colours_string[]; int SPI_RX_DATA = 0; int Cubelet_Colours[9] = {0,0,0,0,0,0,0,0,0};//9 cubelets store colours here int Received_data = 0; @@ -56,21 +69,92 @@ { //Do stuff cs= 0; - SPI_RX_DATA = spi.write(0xCB); + SPI_RX_DATA = spi.write(0xF0); wait_us(3); cs= 1; //SPI_RX_DATA = SPI_RX_DATA >> 7; //SPI_RX_DATA = SPI_RX_DATA << 1; - //pc.printf("Received data : %x\n",SPI_RX_DATA); - - std::bitset<16> bits(SPI_RX_DATA); - cout << bits << endl; + //std::bitset<16> bits(SPI_RX_DATA); + //cout << bits << endl; + + //if(bits != 0) + //{ + //find the location possition + //find the colour value + //Store these values in to the tempory array + //When all of the data is received all 9 cubelets set a global variable high / thread signal + + //} pc.printf("Received data = %d\n", SPI_RX_DATA); //wait_us(3); Thread::wait(1000); } } + +Colours convert (int Colour) +{ + Colours colours_return_value; + if(Colour == 1) + { + colours_return_value = White; + } + else if(Colour == 2) + { + colours_return_value = Red; + } + else if(Colour == 3) + { + colours_return_value = Orange; + } + else if(Colour == 4) + { + colours_return_value = Blue; + } + else if(Colour == 5) + { + colours_return_value = Green; + } + else if(Colour == 6) + { + colours_return_value = Yellow; + } + + return colours_return_value; +} +void Store_Cubelet_data() +{ + + /* + enum Colours//The posible colours of each point on the cube map +{ + White,//Front + Red,//Upper + Orange,//Down + Blue,//Left + Green,//Right + Yellow//Back +}; + + */ + + //signal::wait(Cubelet_data_ready); + if(Cubelet_Colours[5] == 1) + { + CubeMap[0][0][0] = convert(Cubelet_Colours[0]); + CubeMap[0][0][1] = convert(Cubelet_Colours[1]); + CubeMap[0][0][2] = convert(Cubelet_Colours[2]); + CubeMap[0][1][0] = convert(Cubelet_Colours[3]); + CubeMap[0][1][1] = convert(Cubelet_Colours[4]); + CubeMap[0][1][2] = convert(Cubelet_Colours[5]); + CubeMap[0][2][0] = convert(Cubelet_Colours[6]); + CubeMap[0][2][1] = convert(Cubelet_Colours[7]); + CubeMap[0][2][2] = convert(Cubelet_Colours[8]); + //CubeMap[6][3][3] + //Store this to the white face + } +} + void Motor_Control() { while(1)