ok

Dependencies:   mbed

Fork of 00_01LAB_matrix8x8_fig_tetris1 by Andres Cano

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