NUEVO

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris by Alyson Castiblanco

Committer:
acastiblancoc
Date:
Thu Sep 13 13:02:21 2018 +0000
Revision:
8:0ddb5ffca870
Parent:
7:0a94835bc6e4
Child:
9:f6536806c250
ok

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