ok

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris1 by Andres Cano

Committer:
acastiblancoc
Date:
Thu Sep 13 20:05:40 2018 +0000
Revision:
9:f6536806c250
Parent:
8:0ddb5ffca870
Child:
10:ae8cf84c82ca
nuevo;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
fabeltranm 0:61199d9d0aed 1
fabeltranm 0:61199d9d0aed 2 #include "mbed.h"
fabeltranm 4:2bc5dfe058ef 3 #include "figuras.h"
fabeltranm 0:61199d9d0aed 4
fabeltranm 0:61199d9d0aed 5 SPI deviceM(PB_15, PB_14, PB_13);
fabeltranm 0:61199d9d0aed 6 DigitalOut ssel (PB_12);
fabeltranm 4:2bc5dfe058ef 7 Serial command(USBTX, USBRX);
fabeltranm 0:61199d9d0aed 8
fabeltranm 4:2bc5dfe058ef 9 #define DEBUG 1
acastiblancoc 5:819f043b99a5 10 #define VELOCITY 1000 // ms
fabeltranm 1:b732136485e0 11
acastiblancoc 5:819f043b99a5 12
fabeltranm 4:2bc5dfe058ef 13
fabeltranm 4:2bc5dfe058ef 14 uint8_t matrix_act[8]={0,0,0,0,0,0,0,0};
acastiblancoc 5:819f043b99a5 15 uint8_t matrix_tmp[11]={0b00000000,0b00000000,0b00000000,0,0,0,0,0,0,0};
acastiblancoc 9:f6536806c250 16 uint8_t array[3]={0,0,0};
acastiblancoc 9:f6536806c250 17
acastiblancoc 9:f6536806c250 18 void debug_m(char *s , ... ){
acastiblancoc 9:f6536806c250 19 #if DEBUG
acastiblancoc 9:f6536806c250 20 command.printf(s);
acastiblancoc 9:f6536806c250 21 #endif
acastiblancoc 9:f6536806c250 22 }
acastiblancoc 9:f6536806c250 23
acastiblancoc 9:f6536806c250 24 void clr_arr()
acastiblancoc 9:f6536806c250 25 { for(int i=0;i<5;i++)
acastiblancoc 9:f6536806c250 26 {
acastiblancoc 9:f6536806c250 27 array[i]=0;
acastiblancoc 9:f6536806c250 28 }}
acastiblancoc 9:f6536806c250 29
acastiblancoc 9:f6536806c250 30 int recibe (void)
acastiblancoc 9:f6536806c250 31 {
acastiblancoc 9:f6536806c250 32 char ini=command.getc();
acastiblancoc 9:f6536806c250 33 while(ini!='<')
acastiblancoc 9:f6536806c250 34 ini=command.getc();
acastiblancoc 9:f6536806c250 35
acastiblancoc 9:f6536806c250 36 for(int i=0;i<3;i++)
acastiblancoc 9:f6536806c250 37 {
acastiblancoc 9:f6536806c250 38 array[i]=command.getc();
acastiblancoc 9:f6536806c250 39 }
acastiblancoc 9:f6536806c250 40
acastiblancoc 9:f6536806c250 41 ini=command.getc();
acastiblancoc 9:f6536806c250 42 while(ini!='>')
acastiblancoc 9:f6536806c250 43 {
acastiblancoc 9:f6536806c250 44 debug_m("xx");
acastiblancoc 9:f6536806c250 45 return 0;
acastiblancoc 9:f6536806c250 46
acastiblancoc 9:f6536806c250 47 }
acastiblancoc 9:f6536806c250 48 debug_m("yy");
acastiblancoc 9:f6536806c250 49 return 1;
acastiblancoc 9:f6536806c250 50
acastiblancoc 9:f6536806c250 51 }
fabeltranm 0:61199d9d0aed 52
fabeltranm 0:61199d9d0aed 53 void sendSPI(uint8_t d1, uint8_t d2)
fabeltranm 0:61199d9d0aed 54 {
fabeltranm 0:61199d9d0aed 55 deviceM.unlock();
fabeltranm 0:61199d9d0aed 56 ssel=0;
fabeltranm 0:61199d9d0aed 57 deviceM.write(d1);
fabeltranm 0:61199d9d0aed 58 deviceM.write(d2);
fabeltranm 0:61199d9d0aed 59 ssel=1;
fabeltranm 0:61199d9d0aed 60 deviceM.lock();
fabeltranm 0:61199d9d0aed 61 };
fabeltranm 0:61199d9d0aed 62
acastiblancoc 8:0ddb5ffca870 63 void imp_fig(){
acastiblancoc 8:0ddb5ffca870 64 int i=0;
acastiblancoc 8:0ddb5ffca870 65 for(i=0;i<=8;i++){
acastiblancoc 8:0ddb5ffca870 66 sendSPI(i-2,0);
acastiblancoc 8:0ddb5ffca870 67 sendSPI(i-1,matrix_tmp[0]);
acastiblancoc 8:0ddb5ffca870 68 sendSPI(i,matrix_tmp[1]);
acastiblancoc 8:0ddb5ffca870 69 sendSPI(i+1,matrix_tmp[2]);
acastiblancoc 8:0ddb5ffca870 70 wait_ms(VELOCITY);
acastiblancoc 8:0ddb5ffca870 71 }
acastiblancoc 8:0ddb5ffca870 72 }
acastiblancoc 5:819f043b99a5 73
acastiblancoc 5:819f043b99a5 74
fabeltranm 0:61199d9d0aed 75 void printMatrix(uint8_t* vC)
fabeltranm 0:61199d9d0aed 76
fabeltranm 0:61199d9d0aed 77 {
fabeltranm 0:61199d9d0aed 78 uint8_t i =0;
fabeltranm 0:61199d9d0aed 79 for (i=1;i<9;i++){
fabeltranm 4:2bc5dfe058ef 80 sendSPI(i,*(vC+i-1));
fabeltranm 0:61199d9d0aed 81 }
fabeltranm 0:61199d9d0aed 82
acastiblancoc 5:819f043b99a5 83 }
fabeltranm 2:414129d953dd 84
fabeltranm 4:2bc5dfe058ef 85
acastiblancoc 5:819f043b99a5 86 void init_display(){
fabeltranm 4:2bc5dfe058ef 87 sendSPI(0x0c,1);
fabeltranm 4:2bc5dfe058ef 88 sendSPI(0x0b,7);
fabeltranm 4:2bc5dfe058ef 89 sendSPI(0x09,0);
acastiblancoc 5:819f043b99a5 90 sendSPI(0x0A,0x0E);
fabeltranm 4:2bc5dfe058ef 91 printMatrix(matrix_act);
fabeltranm 4:2bc5dfe058ef 92 int i;
acastiblancoc 5:819f043b99a5 93 for (i=0;i<4;i++){
fabeltranm 4:2bc5dfe058ef 94 sendSPI(0x0F,1);
acastiblancoc 5:819f043b99a5 95 wait (0.2);
fabeltranm 4:2bc5dfe058ef 96 sendSPI(0x0f,0);
acastiblancoc 5:819f043b99a5 97 wait (0.2);
fabeltranm 4:2bc5dfe058ef 98 }
acastiblancoc 5:819f043b99a5 99 }
acastiblancoc 5:819f043b99a5 100
acastiblancoc 5:819f043b99a5 101
acastiblancoc 5:819f043b99a5 102
fabeltranm 4:2bc5dfe058ef 103
fabeltranm 4:2bc5dfe058ef 104 void act_matrix(uint8_t* mascara){
fabeltranm 4:2bc5dfe058ef 105 for (int i=0; i<8;i++)
fabeltranm 4:2bc5dfe058ef 106 matrix_act[i]= ( *(mascara+i));
fabeltranm 4:2bc5dfe058ef 107
fabeltranm 4:2bc5dfe058ef 108 }
acastiblancoc 5:819f043b99a5 109 void copy_matrix(uint8_t* m2, char col){
fabeltranm 4:2bc5dfe058ef 110
fabeltranm 4:2bc5dfe058ef 111 for (int i=0; i<11;i++){
acastiblancoc 6:2f42f0b53611 112 matrix_tmp[i]= (*(m2+i)>>(col-1));
fabeltranm 4:2bc5dfe058ef 113 }
fabeltranm 4:2bc5dfe058ef 114 }
acastiblancoc 7:0a94835bc6e4 115
acastiblancoc 7:0a94835bc6e4 116
acastiblancoc 5:819f043b99a5 117
fabeltranm 4:2bc5dfe058ef 118 void new_read(){
acastiblancoc 9:f6536806c250 119 switch (array[0]) {
fabeltranm 4:2bc5dfe058ef 120 case L_TYPE:
acastiblancoc 9:f6536806c250 121 switch (array[1])
acastiblancoc 5:819f043b99a5 122 { case NOVEN:
acastiblancoc 9:f6536806c250 123 switch(array[2])
acastiblancoc 6:2f42f0b53611 124 {case 1:
acastiblancoc 6:2f42f0b53611 125 copy_matrix(FIG_L1,1);
acastiblancoc 6:2f42f0b53611 126 break;
acastiblancoc 6:2f42f0b53611 127 case 2:
acastiblancoc 6:2f42f0b53611 128 copy_matrix(FIG_L1,2);
acastiblancoc 6:2f42f0b53611 129 break;
acastiblancoc 6:2f42f0b53611 130 case 3:
acastiblancoc 6:2f42f0b53611 131 copy_matrix(FIG_L1,3);
acastiblancoc 6:2f42f0b53611 132 break;
acastiblancoc 6:2f42f0b53611 133 case 4:
acastiblancoc 6:2f42f0b53611 134 copy_matrix(FIG_L1,4);
acastiblancoc 6:2f42f0b53611 135 break;
acastiblancoc 6:2f42f0b53611 136 case 5:
acastiblancoc 6:2f42f0b53611 137 copy_matrix(FIG_L1,5);
acastiblancoc 6:2f42f0b53611 138 break;
acastiblancoc 6:2f42f0b53611 139 case 6:
acastiblancoc 6:2f42f0b53611 140 copy_matrix(FIG_L1,6);
acastiblancoc 6:2f42f0b53611 141 break;
acastiblancoc 6:2f42f0b53611 142 case 7:
acastiblancoc 6:2f42f0b53611 143 copy_matrix(FIG_L1,7);
acastiblancoc 6:2f42f0b53611 144 break;
acastiblancoc 6:2f42f0b53611 145 case 8:
acastiblancoc 6:2f42f0b53611 146 copy_matrix(FIG_L1,8);
acastiblancoc 6:2f42f0b53611 147 break;
acastiblancoc 6:2f42f0b53611 148 }
acastiblancoc 5:819f043b99a5 149 break;
acastiblancoc 5:819f043b99a5 150 case ZERO:
acastiblancoc 9:f6536806c250 151 switch(array[2])
acastiblancoc 8:0ddb5ffca870 152 {case 1:
acastiblancoc 8:0ddb5ffca870 153 copy_matrix(FIG_L,1);
acastiblancoc 8:0ddb5ffca870 154 break;
acastiblancoc 8:0ddb5ffca870 155 case 2:
acastiblancoc 8:0ddb5ffca870 156 copy_matrix(FIG_L,2);
acastiblancoc 8:0ddb5ffca870 157 break;
acastiblancoc 8:0ddb5ffca870 158 case 3:
acastiblancoc 8:0ddb5ffca870 159 copy_matrix(FIG_L,3);
acastiblancoc 8:0ddb5ffca870 160 break;
acastiblancoc 8:0ddb5ffca870 161 case 4:
acastiblancoc 8:0ddb5ffca870 162 copy_matrix(FIG_L,4);
acastiblancoc 8:0ddb5ffca870 163 break;
acastiblancoc 8:0ddb5ffca870 164 case 5:
acastiblancoc 8:0ddb5ffca870 165 copy_matrix(FIG_L,5);
acastiblancoc 8:0ddb5ffca870 166 break;
acastiblancoc 8:0ddb5ffca870 167 case 6:
acastiblancoc 8:0ddb5ffca870 168 copy_matrix(FIG_L,6);
acastiblancoc 8:0ddb5ffca870 169 break;
acastiblancoc 8:0ddb5ffca870 170 case 7:
acastiblancoc 8:0ddb5ffca870 171 copy_matrix(FIG_L,7);
acastiblancoc 8:0ddb5ffca870 172 break;
acastiblancoc 8:0ddb5ffca870 173 case 8:
acastiblancoc 8:0ddb5ffca870 174 copy_matrix(FIG_L,8);
acastiblancoc 8:0ddb5ffca870 175 break;
acastiblancoc 8:0ddb5ffca870 176 }
acastiblancoc 8:0ddb5ffca870 177
acastiblancoc 5:819f043b99a5 178 break ;
acastiblancoc 5:819f043b99a5 179 case PII:
acastiblancoc 8:0ddb5ffca870 180
acastiblancoc 9:f6536806c250 181 switch(array[2])
acastiblancoc 8:0ddb5ffca870 182 {case 1:
acastiblancoc 8:0ddb5ffca870 183 copy_matrix(FIG_L2,1);
acastiblancoc 8:0ddb5ffca870 184 break;
acastiblancoc 8:0ddb5ffca870 185 case 2:
acastiblancoc 8:0ddb5ffca870 186 copy_matrix(FIG_L2,2);
acastiblancoc 8:0ddb5ffca870 187 break;
acastiblancoc 8:0ddb5ffca870 188 case 3:
acastiblancoc 8:0ddb5ffca870 189 copy_matrix(FIG_L2,3);
acastiblancoc 8:0ddb5ffca870 190 break;
acastiblancoc 8:0ddb5ffca870 191 case 4:
acastiblancoc 8:0ddb5ffca870 192 copy_matrix(FIG_L2,4);
acastiblancoc 8:0ddb5ffca870 193 break;
acastiblancoc 8:0ddb5ffca870 194 case 5:
acastiblancoc 8:0ddb5ffca870 195 copy_matrix(FIG_L2,5);
acastiblancoc 8:0ddb5ffca870 196 break;
acastiblancoc 8:0ddb5ffca870 197 case 6:
acastiblancoc 8:0ddb5ffca870 198 copy_matrix(FIG_L2,6);
acastiblancoc 8:0ddb5ffca870 199 break;
acastiblancoc 8:0ddb5ffca870 200 case 7:
acastiblancoc 8:0ddb5ffca870 201 copy_matrix(FIG_L2,7);
acastiblancoc 8:0ddb5ffca870 202 break;
acastiblancoc 8:0ddb5ffca870 203 case 8:
acastiblancoc 8:0ddb5ffca870 204 copy_matrix(FIG_L2,8);
acastiblancoc 8:0ddb5ffca870 205 break;
acastiblancoc 8:0ddb5ffca870 206 }
acastiblancoc 5:819f043b99a5 207 break;
acastiblancoc 5:819f043b99a5 208 case DOSSE:
acastiblancoc 9:f6536806c250 209 switch(array[2])
acastiblancoc 8:0ddb5ffca870 210 {case 1:
acastiblancoc 8:0ddb5ffca870 211 copy_matrix(FIG_L3,1);
acastiblancoc 8:0ddb5ffca870 212 break;
acastiblancoc 8:0ddb5ffca870 213 case 2:
acastiblancoc 8:0ddb5ffca870 214 copy_matrix(FIG_L3,2);
acastiblancoc 8:0ddb5ffca870 215 break;
acastiblancoc 8:0ddb5ffca870 216 case 3:
acastiblancoc 8:0ddb5ffca870 217 copy_matrix(FIG_L3,3);
acastiblancoc 8:0ddb5ffca870 218 break;
acastiblancoc 8:0ddb5ffca870 219 case 4:
acastiblancoc 8:0ddb5ffca870 220 copy_matrix(FIG_L3,4);
acastiblancoc 8:0ddb5ffca870 221 break;
acastiblancoc 8:0ddb5ffca870 222 case 5:
acastiblancoc 8:0ddb5ffca870 223 copy_matrix(FIG_L3,5);
acastiblancoc 8:0ddb5ffca870 224 break;
acastiblancoc 8:0ddb5ffca870 225 case 6:
acastiblancoc 8:0ddb5ffca870 226 copy_matrix(FIG_L3,6);
acastiblancoc 8:0ddb5ffca870 227 break;
acastiblancoc 8:0ddb5ffca870 228 case 7:
acastiblancoc 8:0ddb5ffca870 229 copy_matrix(FIG_L3,7);
acastiblancoc 8:0ddb5ffca870 230 break;
acastiblancoc 8:0ddb5ffca870 231 case 8:
acastiblancoc 8:0ddb5ffca870 232 copy_matrix(FIG_L3,8);
acastiblancoc 8:0ddb5ffca870 233 break;
acastiblancoc 8:0ddb5ffca870 234 }
acastiblancoc 5:819f043b99a5 235 break;
acastiblancoc 5:819f043b99a5 236 }
acastiblancoc 6:2f42f0b53611 237 break ;
fabeltranm 4:2bc5dfe058ef 238 case S_TYPE:
acastiblancoc 9:f6536806c250 239 switch (array[1])
acastiblancoc 5:819f043b99a5 240 { case NOVEN:
acastiblancoc 9:f6536806c250 241 switch(array[2])
acastiblancoc 8:0ddb5ffca870 242 {case 1:
acastiblancoc 8:0ddb5ffca870 243 copy_matrix(FIG_S1,1);
acastiblancoc 8:0ddb5ffca870 244 break;
acastiblancoc 8:0ddb5ffca870 245 case 2:
acastiblancoc 8:0ddb5ffca870 246 copy_matrix(FIG_S1,2);
acastiblancoc 8:0ddb5ffca870 247 break;
acastiblancoc 8:0ddb5ffca870 248 case 3:
acastiblancoc 8:0ddb5ffca870 249 copy_matrix(FIG_S1,3);
acastiblancoc 8:0ddb5ffca870 250 break;
acastiblancoc 8:0ddb5ffca870 251 case 4:
acastiblancoc 8:0ddb5ffca870 252 copy_matrix(FIG_S1,4);
acastiblancoc 8:0ddb5ffca870 253 break;
acastiblancoc 8:0ddb5ffca870 254 case 5:
acastiblancoc 8:0ddb5ffca870 255 copy_matrix(FIG_S1,5);
acastiblancoc 8:0ddb5ffca870 256 break;
acastiblancoc 8:0ddb5ffca870 257 case 6:
acastiblancoc 8:0ddb5ffca870 258 copy_matrix(FIG_S1,6);
acastiblancoc 8:0ddb5ffca870 259 break;
acastiblancoc 8:0ddb5ffca870 260 case 7:
acastiblancoc 8:0ddb5ffca870 261 copy_matrix(FIG_S1,7);
acastiblancoc 8:0ddb5ffca870 262 break;
acastiblancoc 8:0ddb5ffca870 263 case 8:
acastiblancoc 8:0ddb5ffca870 264 copy_matrix(FIG_S1,8);
acastiblancoc 8:0ddb5ffca870 265 break;
acastiblancoc 8:0ddb5ffca870 266 }
acastiblancoc 5:819f043b99a5 267 break;
acastiblancoc 5:819f043b99a5 268 case ZERO:
acastiblancoc 9:f6536806c250 269 switch(array[2])
acastiblancoc 8:0ddb5ffca870 270 {case 1:
acastiblancoc 8:0ddb5ffca870 271 copy_matrix(FIG_S,1);
acastiblancoc 8:0ddb5ffca870 272 break;
acastiblancoc 8:0ddb5ffca870 273 case 2:
acastiblancoc 8:0ddb5ffca870 274 copy_matrix(FIG_S,2);
acastiblancoc 8:0ddb5ffca870 275 break;
acastiblancoc 8:0ddb5ffca870 276 case 3:
acastiblancoc 8:0ddb5ffca870 277 copy_matrix(FIG_S,3);
acastiblancoc 8:0ddb5ffca870 278 break;
acastiblancoc 8:0ddb5ffca870 279 case 4:
acastiblancoc 8:0ddb5ffca870 280 copy_matrix(FIG_S,4);
acastiblancoc 8:0ddb5ffca870 281 break;
acastiblancoc 8:0ddb5ffca870 282 case 5:
acastiblancoc 8:0ddb5ffca870 283 copy_matrix(FIG_S,5);
acastiblancoc 8:0ddb5ffca870 284 break;
acastiblancoc 8:0ddb5ffca870 285 case 6:
acastiblancoc 8:0ddb5ffca870 286 copy_matrix(FIG_S,6);
acastiblancoc 8:0ddb5ffca870 287 break;
acastiblancoc 8:0ddb5ffca870 288 case 7:
acastiblancoc 8:0ddb5ffca870 289 copy_matrix(FIG_S,7);
acastiblancoc 8:0ddb5ffca870 290 break;
acastiblancoc 8:0ddb5ffca870 291 case 8:
acastiblancoc 8:0ddb5ffca870 292 copy_matrix(FIG_S,8);
acastiblancoc 8:0ddb5ffca870 293 break;
acastiblancoc 8:0ddb5ffca870 294 }
acastiblancoc 5:819f043b99a5 295 break ;
acastiblancoc 5:819f043b99a5 296 case PII:
acastiblancoc 9:f6536806c250 297 switch(array[2])
acastiblancoc 8:0ddb5ffca870 298 {case 1:
acastiblancoc 8:0ddb5ffca870 299 copy_matrix(FIG_S2,1);
acastiblancoc 8:0ddb5ffca870 300 break;
acastiblancoc 8:0ddb5ffca870 301 case 2:
acastiblancoc 8:0ddb5ffca870 302 copy_matrix(FIG_S2,2);
acastiblancoc 8:0ddb5ffca870 303 break;
acastiblancoc 8:0ddb5ffca870 304 case 3:
acastiblancoc 8:0ddb5ffca870 305 copy_matrix(FIG_S2,3);
acastiblancoc 8:0ddb5ffca870 306 break;
acastiblancoc 8:0ddb5ffca870 307 case 4:
acastiblancoc 8:0ddb5ffca870 308 copy_matrix(FIG_S2,4);
acastiblancoc 8:0ddb5ffca870 309 break;
acastiblancoc 8:0ddb5ffca870 310 case 5:
acastiblancoc 8:0ddb5ffca870 311 copy_matrix(FIG_S2,5);
acastiblancoc 8:0ddb5ffca870 312 break;
acastiblancoc 8:0ddb5ffca870 313 case 6:
acastiblancoc 8:0ddb5ffca870 314 copy_matrix(FIG_S2,6);
acastiblancoc 8:0ddb5ffca870 315 break;
acastiblancoc 8:0ddb5ffca870 316 case 7:
acastiblancoc 8:0ddb5ffca870 317 copy_matrix(FIG_S2,7);
acastiblancoc 8:0ddb5ffca870 318 break;
acastiblancoc 8:0ddb5ffca870 319 case 8:
acastiblancoc 8:0ddb5ffca870 320 copy_matrix(FIG_S2,8);
acastiblancoc 8:0ddb5ffca870 321 break;
acastiblancoc 8:0ddb5ffca870 322 }
acastiblancoc 5:819f043b99a5 323 break;
acastiblancoc 5:819f043b99a5 324 case DOSSE:
acastiblancoc 9:f6536806c250 325 switch(array[2])
acastiblancoc 8:0ddb5ffca870 326 {case 1:
acastiblancoc 8:0ddb5ffca870 327 copy_matrix(FIG_S3,1);
acastiblancoc 8:0ddb5ffca870 328 break;
acastiblancoc 8:0ddb5ffca870 329 case 2:
acastiblancoc 8:0ddb5ffca870 330 copy_matrix(FIG_S3,2);
acastiblancoc 8:0ddb5ffca870 331 break;
acastiblancoc 8:0ddb5ffca870 332 case 3:
acastiblancoc 8:0ddb5ffca870 333 copy_matrix(FIG_S3,3);
acastiblancoc 8:0ddb5ffca870 334 break;
acastiblancoc 8:0ddb5ffca870 335 case 4:
acastiblancoc 8:0ddb5ffca870 336 copy_matrix(FIG_S3,4);
acastiblancoc 8:0ddb5ffca870 337 break;
acastiblancoc 8:0ddb5ffca870 338 case 5:
acastiblancoc 8:0ddb5ffca870 339 copy_matrix(FIG_S3,5);
acastiblancoc 8:0ddb5ffca870 340 break;
acastiblancoc 8:0ddb5ffca870 341 case 6:
acastiblancoc 8:0ddb5ffca870 342 copy_matrix(FIG_S3,6);
acastiblancoc 8:0ddb5ffca870 343 break;
acastiblancoc 8:0ddb5ffca870 344 case 7:
acastiblancoc 8:0ddb5ffca870 345 copy_matrix(FIG_S3,7);
acastiblancoc 8:0ddb5ffca870 346 break;
acastiblancoc 8:0ddb5ffca870 347 case 8:
acastiblancoc 8:0ddb5ffca870 348 copy_matrix(FIG_S3,8);
acastiblancoc 8:0ddb5ffca870 349 break;
acastiblancoc 8:0ddb5ffca870 350 }
acastiblancoc 5:819f043b99a5 351 break;
acastiblancoc 5:819f043b99a5 352 }
fabeltranm 4:2bc5dfe058ef 353 break ;
fabeltranm 4:2bc5dfe058ef 354 case I_TYPE:
acastiblancoc 9:f6536806c250 355 switch (array[1])
acastiblancoc 8:0ddb5ffca870 356 {
acastiblancoc 8:0ddb5ffca870 357 case NOVEN:
acastiblancoc 9:f6536806c250 358 switch(array[2])
acastiblancoc 8:0ddb5ffca870 359 {case 1:
acastiblancoc 8:0ddb5ffca870 360 copy_matrix(FIG_I1,1);
acastiblancoc 8:0ddb5ffca870 361 break;
acastiblancoc 8:0ddb5ffca870 362 case 2:
acastiblancoc 8:0ddb5ffca870 363 copy_matrix(FIG_I1,2);
acastiblancoc 8:0ddb5ffca870 364 break;
acastiblancoc 8:0ddb5ffca870 365 case 3:
acastiblancoc 8:0ddb5ffca870 366 copy_matrix(FIG_I1,3);
acastiblancoc 8:0ddb5ffca870 367 break;
acastiblancoc 8:0ddb5ffca870 368 case 4:
acastiblancoc 8:0ddb5ffca870 369 copy_matrix(FIG_I1,4);
acastiblancoc 8:0ddb5ffca870 370 break;
acastiblancoc 8:0ddb5ffca870 371 case 5:
acastiblancoc 8:0ddb5ffca870 372 copy_matrix(FIG_I1,5);
acastiblancoc 8:0ddb5ffca870 373 break;
acastiblancoc 8:0ddb5ffca870 374 case 6:
acastiblancoc 8:0ddb5ffca870 375 copy_matrix(FIG_I1,6);
acastiblancoc 8:0ddb5ffca870 376 break;
acastiblancoc 8:0ddb5ffca870 377 case 7:
acastiblancoc 8:0ddb5ffca870 378 copy_matrix(FIG_I1,7);
acastiblancoc 8:0ddb5ffca870 379 break;
acastiblancoc 8:0ddb5ffca870 380 case 8:
acastiblancoc 8:0ddb5ffca870 381 copy_matrix(FIG_I1,8);
acastiblancoc 8:0ddb5ffca870 382 break;
acastiblancoc 8:0ddb5ffca870 383 }
acastiblancoc 5:819f043b99a5 384 break;
acastiblancoc 5:819f043b99a5 385 case ZERO:
acastiblancoc 9:f6536806c250 386 switch(array[2])
acastiblancoc 8:0ddb5ffca870 387 {case 1:
acastiblancoc 8:0ddb5ffca870 388 copy_matrix(FIG_I,1);
acastiblancoc 8:0ddb5ffca870 389 break;
acastiblancoc 8:0ddb5ffca870 390 case 2:
acastiblancoc 8:0ddb5ffca870 391 copy_matrix(FIG_I,2);
acastiblancoc 8:0ddb5ffca870 392 break;
acastiblancoc 8:0ddb5ffca870 393 case 3:
acastiblancoc 8:0ddb5ffca870 394 copy_matrix(FIG_I,3);
acastiblancoc 8:0ddb5ffca870 395 break;
acastiblancoc 8:0ddb5ffca870 396 case 4:
acastiblancoc 8:0ddb5ffca870 397 copy_matrix(FIG_I,4);
acastiblancoc 8:0ddb5ffca870 398 break;
acastiblancoc 8:0ddb5ffca870 399 case 5:
acastiblancoc 8:0ddb5ffca870 400 copy_matrix(FIG_I,5);
acastiblancoc 8:0ddb5ffca870 401 break;
acastiblancoc 8:0ddb5ffca870 402 case 6:
acastiblancoc 8:0ddb5ffca870 403 copy_matrix(FIG_I,6);
acastiblancoc 8:0ddb5ffca870 404 break;
acastiblancoc 8:0ddb5ffca870 405 case 7:
acastiblancoc 8:0ddb5ffca870 406 copy_matrix(FIG_I,7);
acastiblancoc 8:0ddb5ffca870 407 break;
acastiblancoc 8:0ddb5ffca870 408 case 8:
acastiblancoc 8:0ddb5ffca870 409 copy_matrix(FIG_I,8);
acastiblancoc 8:0ddb5ffca870 410 break;
acastiblancoc 8:0ddb5ffca870 411 }
acastiblancoc 5:819f043b99a5 412 break ;
acastiblancoc 5:819f043b99a5 413 case PII:
acastiblancoc 9:f6536806c250 414 switch(array[2])
acastiblancoc 8:0ddb5ffca870 415 {case 1:
acastiblancoc 8:0ddb5ffca870 416 copy_matrix(FIG_I2,1);
acastiblancoc 8:0ddb5ffca870 417 break;
acastiblancoc 8:0ddb5ffca870 418 case 2:
acastiblancoc 8:0ddb5ffca870 419 copy_matrix(FIG_I2,2);
acastiblancoc 8:0ddb5ffca870 420 break;
acastiblancoc 8:0ddb5ffca870 421 case 3:
acastiblancoc 8:0ddb5ffca870 422 copy_matrix(FIG_I2,3);
acastiblancoc 8:0ddb5ffca870 423 break;
acastiblancoc 8:0ddb5ffca870 424 case 4:
acastiblancoc 8:0ddb5ffca870 425 copy_matrix(FIG_I2,4);
acastiblancoc 8:0ddb5ffca870 426 break;
acastiblancoc 8:0ddb5ffca870 427 case 5:
acastiblancoc 8:0ddb5ffca870 428 copy_matrix(FIG_I2,5);
acastiblancoc 8:0ddb5ffca870 429 break;
acastiblancoc 8:0ddb5ffca870 430 case 6:
acastiblancoc 8:0ddb5ffca870 431 copy_matrix(FIG_I2,6);
acastiblancoc 8:0ddb5ffca870 432 break;
acastiblancoc 8:0ddb5ffca870 433 case 7:
acastiblancoc 8:0ddb5ffca870 434 copy_matrix(FIG_I2,7);
acastiblancoc 8:0ddb5ffca870 435 break;
acastiblancoc 8:0ddb5ffca870 436 case 8:
acastiblancoc 8:0ddb5ffca870 437 copy_matrix(FIG_I2,8);
acastiblancoc 8:0ddb5ffca870 438 break;
acastiblancoc 8:0ddb5ffca870 439 }
acastiblancoc 5:819f043b99a5 440 break;
acastiblancoc 5:819f043b99a5 441 case DOSSE:
acastiblancoc 9:f6536806c250 442 switch(array[2])
acastiblancoc 8:0ddb5ffca870 443 {case 1:
acastiblancoc 8:0ddb5ffca870 444 copy_matrix(FIG_I3,1);
acastiblancoc 8:0ddb5ffca870 445 break;
acastiblancoc 8:0ddb5ffca870 446 case 2:
acastiblancoc 8:0ddb5ffca870 447 copy_matrix(FIG_I3,2);
acastiblancoc 8:0ddb5ffca870 448 break;
acastiblancoc 8:0ddb5ffca870 449 case 3:
acastiblancoc 8:0ddb5ffca870 450 copy_matrix(FIG_I3,3);
acastiblancoc 8:0ddb5ffca870 451 break;
acastiblancoc 8:0ddb5ffca870 452 case 4:
acastiblancoc 8:0ddb5ffca870 453 copy_matrix(FIG_I3,4);
acastiblancoc 8:0ddb5ffca870 454 break;
acastiblancoc 8:0ddb5ffca870 455 case 5:
acastiblancoc 8:0ddb5ffca870 456 copy_matrix(FIG_I3,5);
acastiblancoc 8:0ddb5ffca870 457 break;
acastiblancoc 8:0ddb5ffca870 458 case 6:
acastiblancoc 8:0ddb5ffca870 459 copy_matrix(FIG_I3,6);
acastiblancoc 8:0ddb5ffca870 460 break;
acastiblancoc 8:0ddb5ffca870 461 case 7:
acastiblancoc 8:0ddb5ffca870 462 copy_matrix(FIG_I3,7);
acastiblancoc 8:0ddb5ffca870 463 break;
acastiblancoc 8:0ddb5ffca870 464 case 8:
acastiblancoc 8:0ddb5ffca870 465 copy_matrix(FIG_I3,8);
acastiblancoc 8:0ddb5ffca870 466 break;
acastiblancoc 8:0ddb5ffca870 467 }
acastiblancoc 8:0ddb5ffca870 468 break;
acastiblancoc 5:819f043b99a5 469 }
fabeltranm 4:2bc5dfe058ef 470 break ;
acastiblancoc 5:819f043b99a5 471 case C_TYPE:
acastiblancoc 9:f6536806c250 472 switch(array[2])
acastiblancoc 8:0ddb5ffca870 473 {case 1:
acastiblancoc 8:0ddb5ffca870 474 copy_matrix(FIG_C,1);
acastiblancoc 8:0ddb5ffca870 475 break;
acastiblancoc 8:0ddb5ffca870 476 case 2:
acastiblancoc 8:0ddb5ffca870 477 copy_matrix(FIG_C,2);
acastiblancoc 8:0ddb5ffca870 478 break;
acastiblancoc 8:0ddb5ffca870 479 case 3:
acastiblancoc 8:0ddb5ffca870 480 copy_matrix(FIG_C,3);
acastiblancoc 8:0ddb5ffca870 481 break;
acastiblancoc 8:0ddb5ffca870 482 case 4:
acastiblancoc 8:0ddb5ffca870 483 copy_matrix(FIG_C,4);
acastiblancoc 8:0ddb5ffca870 484 break;
acastiblancoc 8:0ddb5ffca870 485 case 5:
acastiblancoc 8:0ddb5ffca870 486 copy_matrix(FIG_C,5);
acastiblancoc 8:0ddb5ffca870 487 break;
acastiblancoc 8:0ddb5ffca870 488 case 6:
acastiblancoc 8:0ddb5ffca870 489 copy_matrix(FIG_C,6);
acastiblancoc 8:0ddb5ffca870 490 break;
acastiblancoc 8:0ddb5ffca870 491 case 7:
acastiblancoc 8:0ddb5ffca870 492 copy_matrix(FIG_C,7);
acastiblancoc 8:0ddb5ffca870 493 break;
acastiblancoc 8:0ddb5ffca870 494 case 8:
acastiblancoc 8:0ddb5ffca870 495 copy_matrix(FIG_C,8);
acastiblancoc 8:0ddb5ffca870 496 break;
acastiblancoc 8:0ddb5ffca870 497 }
acastiblancoc 5:819f043b99a5 498 break ;
acastiblancoc 5:819f043b99a5 499 case T_TYPE:
acastiblancoc 9:f6536806c250 500 switch (array[1])
acastiblancoc 5:819f043b99a5 501 { case NOVEN:
acastiblancoc 9:f6536806c250 502 switch(array[2])
acastiblancoc 8:0ddb5ffca870 503 {case 1:
acastiblancoc 8:0ddb5ffca870 504 copy_matrix(FIG_T1,1);
acastiblancoc 8:0ddb5ffca870 505 break;
acastiblancoc 8:0ddb5ffca870 506 case 2:
acastiblancoc 8:0ddb5ffca870 507 copy_matrix(FIG_T1,2);
acastiblancoc 8:0ddb5ffca870 508 break;
acastiblancoc 8:0ddb5ffca870 509 case 3:
acastiblancoc 8:0ddb5ffca870 510 copy_matrix(FIG_T1,3);
acastiblancoc 8:0ddb5ffca870 511 break;
acastiblancoc 8:0ddb5ffca870 512 case 4:
acastiblancoc 8:0ddb5ffca870 513 copy_matrix(FIG_T1,4);
acastiblancoc 8:0ddb5ffca870 514 break;
acastiblancoc 8:0ddb5ffca870 515 case 5:
acastiblancoc 8:0ddb5ffca870 516 copy_matrix(FIG_T1,5);
acastiblancoc 8:0ddb5ffca870 517 break;
acastiblancoc 8:0ddb5ffca870 518 case 6:
acastiblancoc 8:0ddb5ffca870 519 copy_matrix(FIG_T1,6);
acastiblancoc 8:0ddb5ffca870 520 break;
acastiblancoc 8:0ddb5ffca870 521 case 7:
acastiblancoc 8:0ddb5ffca870 522 copy_matrix(FIG_T1,7);
acastiblancoc 8:0ddb5ffca870 523 break;
acastiblancoc 8:0ddb5ffca870 524 case 8:
acastiblancoc 8:0ddb5ffca870 525 copy_matrix(FIG_T1,8);
acastiblancoc 8:0ddb5ffca870 526 break;
acastiblancoc 8:0ddb5ffca870 527 }
acastiblancoc 5:819f043b99a5 528 break;
acastiblancoc 5:819f043b99a5 529 case ZERO:
acastiblancoc 9:f6536806c250 530 switch(array[2])
acastiblancoc 8:0ddb5ffca870 531 {case 1:
acastiblancoc 8:0ddb5ffca870 532 copy_matrix(FIG_T,1);
acastiblancoc 8:0ddb5ffca870 533 break;
acastiblancoc 8:0ddb5ffca870 534 case 2:
acastiblancoc 8:0ddb5ffca870 535 copy_matrix(FIG_T,2);
acastiblancoc 8:0ddb5ffca870 536 break;
acastiblancoc 8:0ddb5ffca870 537 case 3:
acastiblancoc 8:0ddb5ffca870 538 copy_matrix(FIG_T,3);
acastiblancoc 8:0ddb5ffca870 539 break;
acastiblancoc 8:0ddb5ffca870 540 case 4:
acastiblancoc 8:0ddb5ffca870 541 copy_matrix(FIG_T,4);
acastiblancoc 8:0ddb5ffca870 542 break;
acastiblancoc 8:0ddb5ffca870 543 case 5:
acastiblancoc 8:0ddb5ffca870 544 copy_matrix(FIG_T,5);
acastiblancoc 8:0ddb5ffca870 545 break;
acastiblancoc 8:0ddb5ffca870 546 case 6:
acastiblancoc 8:0ddb5ffca870 547 copy_matrix(FIG_T,6);
acastiblancoc 8:0ddb5ffca870 548 break;
acastiblancoc 8:0ddb5ffca870 549 case 7:
acastiblancoc 8:0ddb5ffca870 550 copy_matrix(FIG_T,7);
acastiblancoc 8:0ddb5ffca870 551 break;
acastiblancoc 8:0ddb5ffca870 552 case 8:
acastiblancoc 8:0ddb5ffca870 553 copy_matrix(FIG_T,8);
acastiblancoc 8:0ddb5ffca870 554 break;
acastiblancoc 8:0ddb5ffca870 555 }
acastiblancoc 5:819f043b99a5 556 break ;
acastiblancoc 5:819f043b99a5 557 case PII:
acastiblancoc 9:f6536806c250 558 switch(array[2])
acastiblancoc 8:0ddb5ffca870 559 {case 1:
acastiblancoc 8:0ddb5ffca870 560 copy_matrix(FIG_T2,1);
acastiblancoc 8:0ddb5ffca870 561 break;
acastiblancoc 8:0ddb5ffca870 562 case 2:
acastiblancoc 8:0ddb5ffca870 563 copy_matrix(FIG_T2,2);
acastiblancoc 8:0ddb5ffca870 564 break;
acastiblancoc 8:0ddb5ffca870 565 case 3:
acastiblancoc 8:0ddb5ffca870 566 copy_matrix(FIG_T2,3);
acastiblancoc 8:0ddb5ffca870 567 break;
acastiblancoc 8:0ddb5ffca870 568 case 4:
acastiblancoc 8:0ddb5ffca870 569 copy_matrix(FIG_T2,4);
acastiblancoc 8:0ddb5ffca870 570 break;
acastiblancoc 8:0ddb5ffca870 571 case 5:
acastiblancoc 8:0ddb5ffca870 572 copy_matrix(FIG_T2,5);
acastiblancoc 8:0ddb5ffca870 573 break;
acastiblancoc 8:0ddb5ffca870 574 case 6:
acastiblancoc 8:0ddb5ffca870 575 copy_matrix(FIG_T2,6);
acastiblancoc 8:0ddb5ffca870 576 break;
acastiblancoc 8:0ddb5ffca870 577 case 7:
acastiblancoc 8:0ddb5ffca870 578 copy_matrix(FIG_T2,7);
acastiblancoc 8:0ddb5ffca870 579 break;
acastiblancoc 8:0ddb5ffca870 580 case 8:
acastiblancoc 8:0ddb5ffca870 581 copy_matrix(FIG_T2,8);
acastiblancoc 8:0ddb5ffca870 582 break;
acastiblancoc 8:0ddb5ffca870 583 }
acastiblancoc 5:819f043b99a5 584 break;
acastiblancoc 5:819f043b99a5 585 case DOSSE:
acastiblancoc 9:f6536806c250 586 switch(array[2])
acastiblancoc 8:0ddb5ffca870 587 {case 1:
acastiblancoc 8:0ddb5ffca870 588 copy_matrix(FIG_T3,1);
acastiblancoc 8:0ddb5ffca870 589 break;
acastiblancoc 8:0ddb5ffca870 590 case 2:
acastiblancoc 8:0ddb5ffca870 591 copy_matrix(FIG_T3,2);
acastiblancoc 8:0ddb5ffca870 592 break;
acastiblancoc 8:0ddb5ffca870 593 case 3:
acastiblancoc 8:0ddb5ffca870 594 copy_matrix(FIG_T3,3);
acastiblancoc 8:0ddb5ffca870 595 break;
acastiblancoc 8:0ddb5ffca870 596 case 4:
acastiblancoc 8:0ddb5ffca870 597 copy_matrix(FIG_T3,4);
acastiblancoc 8:0ddb5ffca870 598 break;
acastiblancoc 8:0ddb5ffca870 599 case 5:
acastiblancoc 8:0ddb5ffca870 600 copy_matrix(FIG_T3,5);
acastiblancoc 8:0ddb5ffca870 601 break;
acastiblancoc 8:0ddb5ffca870 602 case 6:
acastiblancoc 8:0ddb5ffca870 603 copy_matrix(FIG_T3,6);
acastiblancoc 8:0ddb5ffca870 604 break;
acastiblancoc 8:0ddb5ffca870 605 case 7:
acastiblancoc 8:0ddb5ffca870 606 copy_matrix(FIG_T3,7);
acastiblancoc 8:0ddb5ffca870 607 break;
acastiblancoc 8:0ddb5ffca870 608 case 8:
acastiblancoc 8:0ddb5ffca870 609 copy_matrix(FIG_T3,8);
acastiblancoc 8:0ddb5ffca870 610 break;
acastiblancoc 8:0ddb5ffca870 611 }
acastiblancoc 5:819f043b99a5 612 break;
acastiblancoc 5:819f043b99a5 613 }
acastiblancoc 5:819f043b99a5 614 break;
fabeltranm 4:2bc5dfe058ef 615 default:
acastiblancoc 6:2f42f0b53611 616 copy_matrix(FIG_NULL,1);
acastiblancoc 5:819f043b99a5 617 break;
acastiblancoc 5:819f043b99a5 618 }
acastiblancoc 9:f6536806c250 619
fabeltranm 4:2bc5dfe058ef 620 }
acastiblancoc 5:819f043b99a5 621 //desplazamiento horizontal
fabeltranm 4:2bc5dfe058ef 622 void desplazar_fila(){
acastiblancoc 5:819f043b99a5 623 for (int i=0; i<8;i++)
fabeltranm 4:2bc5dfe058ef 624 matrix_tmp[i]= matrix_tmp[i]>>1;
fabeltranm 3:4a8de2f71ed0 625
acastiblancoc 5:819f043b99a5 626 }
acastiblancoc 5:819f043b99a5 627
fabeltranm 4:2bc5dfe058ef 628 int main() {
fabeltranm 4:2bc5dfe058ef 629 init_display();
fabeltranm 4:2bc5dfe058ef 630 while(1){
acastiblancoc 9:f6536806c250 631 while(recibe()==0);
fabeltranm 4:2bc5dfe058ef 632 new_read();
acastiblancoc 5:819f043b99a5 633 for(int i=0;i<8;i++){
fabeltranm 4:2bc5dfe058ef 634 act_matrix(matrix_tmp);
acastiblancoc 8:0ddb5ffca870 635 imp_fig();
acastiblancoc 8:0ddb5ffca870 636 //printMatrix(matrix_act);
acastiblancoc 6:2f42f0b53611 637 //desplazar_fila();
acastiblancoc 8:0ddb5ffca870 638
acastiblancoc 9:f6536806c250 639 }
acastiblancoc 5:819f043b99a5 640 }
fabeltranm 4:2bc5dfe058ef 641 }