Plymouth ELEC351 Group T
/
ELEC351_Group_T
FINAL PROJECT isn't it
Fork of ELEC351 by
COLOURS.cpp@56:bc5345bc6650, 2018-07-16 (annotated)
- Committer:
- thomasmorris
- Date:
- Mon Jul 16 10:51:47 2018 +0000
- Revision:
- 56:bc5345bc6650
- Child:
- 57:aba1296e51b1
Moves added to serial;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thomasmorris | 56:bc5345bc6650 | 1 | #include "COLOURS.hpp" |
thomasmorris | 56:bc5345bc6650 | 2 | |
thomasmorris | 56:bc5345bc6650 | 3 | |
thomasmorris | 56:bc5345bc6650 | 4 | int temp_colour_data_1 = 0; |
thomasmorris | 56:bc5345bc6650 | 5 | int temp_colour_data_2 = 0; |
thomasmorris | 56:bc5345bc6650 | 6 | int temp_colour_data_3 = 0; |
thomasmorris | 56:bc5345bc6650 | 7 | int temp_colour_data_4 = 0; |
thomasmorris | 56:bc5345bc6650 | 8 | int temp_colour_data_5 = 0; |
thomasmorris | 56:bc5345bc6650 | 9 | int temp_colour_data_6 = 0; |
thomasmorris | 56:bc5345bc6650 | 10 | int temp_colour_data_7 = 0; |
thomasmorris | 56:bc5345bc6650 | 11 | int temp_colour_data_8 = 0; |
thomasmorris | 56:bc5345bc6650 | 12 | int temp_colour_data_9 = 0; |
thomasmorris | 56:bc5345bc6650 | 13 | |
thomasmorris | 56:bc5345bc6650 | 14 | int Cubelet_Colours[9] = {0,0,0,0,0,0,0,0,0};//9 cubelets store colours here |
thomasmorris | 56:bc5345bc6650 | 15 | |
thomasmorris | 56:bc5345bc6650 | 16 | |
thomasmorris | 56:bc5345bc6650 | 17 | Colours convert (int Colour) |
thomasmorris | 56:bc5345bc6650 | 18 | { |
thomasmorris | 56:bc5345bc6650 | 19 | Colours colours_return_value; |
thomasmorris | 56:bc5345bc6650 | 20 | if(Colour == 1) |
thomasmorris | 56:bc5345bc6650 | 21 | { |
thomasmorris | 56:bc5345bc6650 | 22 | colours_return_value = White; |
thomasmorris | 56:bc5345bc6650 | 23 | } |
thomasmorris | 56:bc5345bc6650 | 24 | else if(Colour == 2) |
thomasmorris | 56:bc5345bc6650 | 25 | { |
thomasmorris | 56:bc5345bc6650 | 26 | colours_return_value = Orange; |
thomasmorris | 56:bc5345bc6650 | 27 | } |
thomasmorris | 56:bc5345bc6650 | 28 | else if(Colour == 3) |
thomasmorris | 56:bc5345bc6650 | 29 | { |
thomasmorris | 56:bc5345bc6650 | 30 | colours_return_value = Blue; |
thomasmorris | 56:bc5345bc6650 | 31 | } |
thomasmorris | 56:bc5345bc6650 | 32 | else if(Colour == 4) |
thomasmorris | 56:bc5345bc6650 | 33 | { |
thomasmorris | 56:bc5345bc6650 | 34 | colours_return_value = Red; |
thomasmorris | 56:bc5345bc6650 | 35 | } |
thomasmorris | 56:bc5345bc6650 | 36 | else if(Colour == 5) |
thomasmorris | 56:bc5345bc6650 | 37 | { |
thomasmorris | 56:bc5345bc6650 | 38 | colours_return_value = Green; |
thomasmorris | 56:bc5345bc6650 | 39 | } |
thomasmorris | 56:bc5345bc6650 | 40 | else if(Colour == 6) |
thomasmorris | 56:bc5345bc6650 | 41 | { |
thomasmorris | 56:bc5345bc6650 | 42 | colours_return_value = Yellow; |
thomasmorris | 56:bc5345bc6650 | 43 | } |
thomasmorris | 56:bc5345bc6650 | 44 | return colours_return_value; |
thomasmorris | 56:bc5345bc6650 | 45 | } |
thomasmorris | 56:bc5345bc6650 | 46 | void Store_Cubelet_data() |
thomasmorris | 56:bc5345bc6650 | 47 | { |
thomasmorris | 56:bc5345bc6650 | 48 | if((8 >= colour_data) && (colour_data <= 15)) |
thomasmorris | 56:bc5345bc6650 | 49 | { |
thomasmorris | 56:bc5345bc6650 | 50 | temp_colour_data_1 = colour_data - 8;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 51 | Cubelet_Colours[0] = temp_colour_data_1;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 52 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 53 | } |
thomasmorris | 56:bc5345bc6650 | 54 | |
thomasmorris | 56:bc5345bc6650 | 55 | if((16 >= colour_data) && (colour_data <= 23)) |
thomasmorris | 56:bc5345bc6650 | 56 | { |
thomasmorris | 56:bc5345bc6650 | 57 | temp_colour_data_2 = colour_data - 16;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 58 | Cubelet_Colours[1] = temp_colour_data_2;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 59 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 60 | } |
thomasmorris | 56:bc5345bc6650 | 61 | if((24 >= colour_data) && (colour_data <= 31)) |
thomasmorris | 56:bc5345bc6650 | 62 | { |
thomasmorris | 56:bc5345bc6650 | 63 | temp_colour_data_3 = colour_data - 24;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 64 | Cubelet_Colours[2] = temp_colour_data_3;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 65 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 66 | } |
thomasmorris | 56:bc5345bc6650 | 67 | if((32 >= colour_data) && (colour_data <= 39)) |
thomasmorris | 56:bc5345bc6650 | 68 | { |
thomasmorris | 56:bc5345bc6650 | 69 | temp_colour_data_4 = colour_data - 32;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 70 | Cubelet_Colours[3] = temp_colour_data_4;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 71 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 72 | } |
thomasmorris | 56:bc5345bc6650 | 73 | if((40 >= colour_data) && (colour_data <= 47)) |
thomasmorris | 56:bc5345bc6650 | 74 | { |
thomasmorris | 56:bc5345bc6650 | 75 | temp_colour_data_5 = colour_data - 40;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 76 | Cubelet_Colours[4] = temp_colour_data_5;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 77 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 78 | } |
thomasmorris | 56:bc5345bc6650 | 79 | if((48 >= colour_data) && (colour_data <= 55)) |
thomasmorris | 56:bc5345bc6650 | 80 | { |
thomasmorris | 56:bc5345bc6650 | 81 | temp_colour_data_6 = colour_data - 48;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 82 | Cubelet_Colours[5] = temp_colour_data_6;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 83 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 84 | } |
thomasmorris | 56:bc5345bc6650 | 85 | if((56 >= colour_data) && (colour_data <= 63)) |
thomasmorris | 56:bc5345bc6650 | 86 | { |
thomasmorris | 56:bc5345bc6650 | 87 | temp_colour_data_7 = colour_data - 56;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 88 | Cubelet_Colours[6] = temp_colour_data_7;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 89 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 90 | } |
thomasmorris | 56:bc5345bc6650 | 91 | if((64 >= colour_data) && (colour_data <= 71)) |
thomasmorris | 56:bc5345bc6650 | 92 | { |
thomasmorris | 56:bc5345bc6650 | 93 | temp_colour_data_8 = colour_data - 64;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 94 | Cubelet_Colours[7] = temp_colour_data_8;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 95 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 96 | } |
thomasmorris | 56:bc5345bc6650 | 97 | if((72 >= colour_data) && (colour_data <= 79)) |
thomasmorris | 56:bc5345bc6650 | 98 | { |
thomasmorris | 56:bc5345bc6650 | 99 | temp_colour_data_9 = colour_data - 72;//Result shall be the colour |
thomasmorris | 56:bc5345bc6650 | 100 | Cubelet_Colours[8] = temp_colour_data_9;//Stores the colour value to the mememory map |
thomasmorris | 56:bc5345bc6650 | 101 | //take colour_data postion value and subtract it and you will be left with just the colour |
thomasmorris | 56:bc5345bc6650 | 102 | } |
thomasmorris | 56:bc5345bc6650 | 103 | |
thomasmorris | 56:bc5345bc6650 | 104 | |
thomasmorris | 56:bc5345bc6650 | 105 | if(Cubelet_Colours[5] == 1)//Store data to the white side |
thomasmorris | 56:bc5345bc6650 | 106 | { |
thomasmorris | 56:bc5345bc6650 | 107 | CubeMap[0][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 108 | CubeMap[0][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 109 | CubeMap[0][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 110 | CubeMap[0][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 111 | CubeMap[0][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 112 | CubeMap[0][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 113 | CubeMap[0][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 114 | CubeMap[0][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 115 | CubeMap[0][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 116 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 117 | } |
thomasmorris | 56:bc5345bc6650 | 118 | if(Cubelet_Colours[5] == 2)//Store data to the orange side |
thomasmorris | 56:bc5345bc6650 | 119 | { |
thomasmorris | 56:bc5345bc6650 | 120 | CubeMap[1][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 121 | CubeMap[1][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 122 | CubeMap[1][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 123 | CubeMap[1][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 124 | CubeMap[1][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 125 | CubeMap[1][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 126 | CubeMap[1][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 127 | CubeMap[1][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 128 | CubeMap[1][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 129 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 130 | } |
thomasmorris | 56:bc5345bc6650 | 131 | if(Cubelet_Colours[5] == 3)//Store data to the blue side |
thomasmorris | 56:bc5345bc6650 | 132 | { |
thomasmorris | 56:bc5345bc6650 | 133 | CubeMap[2][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 134 | CubeMap[2][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 135 | CubeMap[2][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 136 | CubeMap[2][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 137 | CubeMap[2][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 138 | CubeMap[2][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 139 | CubeMap[2][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 140 | CubeMap[2][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 141 | CubeMap[2][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 142 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 143 | } |
thomasmorris | 56:bc5345bc6650 | 144 | if(Cubelet_Colours[5] == 4)//Store data to the red side |
thomasmorris | 56:bc5345bc6650 | 145 | { |
thomasmorris | 56:bc5345bc6650 | 146 | CubeMap[3][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 147 | CubeMap[3][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 148 | CubeMap[3][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 149 | CubeMap[3][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 150 | CubeMap[3][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 151 | CubeMap[3][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 152 | CubeMap[3][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 153 | CubeMap[3][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 154 | CubeMap[3][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 155 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 156 | } |
thomasmorris | 56:bc5345bc6650 | 157 | if(Cubelet_Colours[5] == 5)//Store data to the green side |
thomasmorris | 56:bc5345bc6650 | 158 | { |
thomasmorris | 56:bc5345bc6650 | 159 | CubeMap[4][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 160 | CubeMap[4][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 161 | CubeMap[4][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 162 | CubeMap[4][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 163 | CubeMap[4][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 164 | CubeMap[4][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 165 | CubeMap[4][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 166 | CubeMap[4][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 167 | CubeMap[4][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 168 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 169 | } |
thomasmorris | 56:bc5345bc6650 | 170 | if(Cubelet_Colours[5] == 6)//Store data to the yellow side |
thomasmorris | 56:bc5345bc6650 | 171 | { |
thomasmorris | 56:bc5345bc6650 | 172 | CubeMap[5][0][0] = convert(Cubelet_Colours[0]); |
thomasmorris | 56:bc5345bc6650 | 173 | CubeMap[5][0][1] = convert(Cubelet_Colours[1]); |
thomasmorris | 56:bc5345bc6650 | 174 | CubeMap[5][0][2] = convert(Cubelet_Colours[2]); |
thomasmorris | 56:bc5345bc6650 | 175 | CubeMap[5][1][0] = convert(Cubelet_Colours[3]); |
thomasmorris | 56:bc5345bc6650 | 176 | CubeMap[5][1][1] = convert(Cubelet_Colours[4]); |
thomasmorris | 56:bc5345bc6650 | 177 | CubeMap[5][1][2] = convert(Cubelet_Colours[5]); |
thomasmorris | 56:bc5345bc6650 | 178 | CubeMap[5][2][0] = convert(Cubelet_Colours[6]); |
thomasmorris | 56:bc5345bc6650 | 179 | CubeMap[5][2][1] = convert(Cubelet_Colours[7]); |
thomasmorris | 56:bc5345bc6650 | 180 | CubeMap[5][2][2] = convert(Cubelet_Colours[8]); |
thomasmorris | 56:bc5345bc6650 | 181 | //Store this to the white face |
thomasmorris | 56:bc5345bc6650 | 182 | } |
thomasmorris | 56:bc5345bc6650 | 183 | } |