ok

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris1 by Andres Cano

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